Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zk-token-sdk] Re-organize error types #34034

Merged
merged 8 commits into from
Nov 16, 2023
Merged

[zk-token-sdk] Re-organize error types #34034

merged 8 commits into from
Nov 16, 2023

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented Nov 13, 2023

Problem

The error types in the zk-token-sdk are organized by ProofError, which does not allow fine-grained control of different ways that proof generation can produce error.

Summary of Changes

Re-organized error types in the zk-token-sdk.

  • cd164b1: Added deserialization error variant in AuthenticatedEncryptionError and ElGamalError types and replaced pod conversion to return these error types instead of ProofError.
  • 3070d2c: Added SigmaProofVerificationError type to deal with sigma proof errors. Previously, we used a universal ProofError to catch sigma proof error, which provided less flexibility.
  • 1c99510: Similar to the previous commit but for range proof. For the case of range proof, the proof generation can fail, so I added RangeProofGenerationError and RangeProofVerificationError. The RangeProofGenerationError variants are added in a follow-up PR ([zk-token-sdk] Add range proof generation error types #34065).
  • 4236779: I missed updating the convert module, so I updated it.
  • 609829d: Finally, I divided the ProofError into ProofGenerationError and ProofVerificationError and updated the instruction module accordingly. I also added InstructionError to catch errors that are not related to proof generation or verification (e.g. instruction decryption).

Fixes #

@samkim-crypto samkim-crypto added the work in progress This isn't quite right yet label Nov 13, 2023
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

Merging #34034 (0689a2f) into master (6a5b8e8) will decrease coverage by 0.1%.
Report is 3 commits behind head on master.
The diff coverage is 50.7%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34034     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         812      813      +1     
  Lines      219656   219651      -5     
=========================================
- Hits       179989   179984      -5     
  Misses      39667    39667             

ASTRONAU2023

This comment was marked as spam.

@samkim-crypto samkim-crypto removed the work in progress This isn't quite right yet label Nov 15, 2023
joncinque
joncinque previously approved these changes Nov 15, 2023
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small little micro-nits, looks great otherwise!

zk-token-sdk/src/errors.rs Outdated Show resolved Hide resolved
zk-token-sdk/src/errors.rs Outdated Show resolved Hide resolved
@samkim-crypto samkim-crypto added the v1.17 PRs that should be backported to v1.17 label Nov 15, 2023
@samkim-crypto samkim-crypto merged commit 0fd4762 into solana-labs:master Nov 16, 2023
32 checks passed
mergify bot pushed a commit that referenced this pull request Nov 16, 2023
* add deserialization error type for encryption

* re-organize sigma proof error types

* re-organize range proof error types

* update pod conversion module

* update instruction error types

* clippy

* fix `thiserror` visibility

* Apply suggestions from code review

Co-authored-by: Jon Cinque <me@jonc.dev>

---------

Co-authored-by: Jon Cinque <me@jonc.dev>
(cherry picked from commit 0fd4762)

# Conflicts:
#	zk-token-sdk/src/instruction/withdraw.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.17 PRs that should be backported to v1.17
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants