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] Refactor zk-token-elgamal conversion code for authenticated encryption, range proof, and sigma proof types #31855

Merged
merged 4 commits into from
May 30, 2023
Merged

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented May 29, 2023

Problem

This is a follow-up to #31846 on refactoring conversion logic in convert.rs (#31813).

Summary of Changes

  • Refactor Try and TryFrom implementation for authenticated encryption type to zk_token_elgamal::auth_encryption
  • Refactor Try and TryFrom implementation for range proof types to zk_token_elgamal::range_proof
  • Refactor Try and TryFrom implementation for sigma proof types to zk_token_elgamal::sigma_proofs

Fixes #

@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #31855 (9eb0678) into master (8203c6e) will decrease coverage by 0.1%.
The diff coverage is 85.1%.

❗ Current head 9eb0678 differs from pull request most recent head 8dbcec9. Consider uploading reports for the commit 8dbcec9 to get more accurate results

@@            Coverage Diff            @@
##           master   #31855     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         752      752             
  Lines      206799   206751     -48     
=========================================
- Hits       169480   169398     -82     
- Misses      37319    37353     +34     

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Couple comment nits


/// Serialization of range proofs for 64-bit numbers (for `Withdraw` instruction)
/// The `RangeProof` type as a `Pod` restricted to proofs on 64-bit numbers.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct RangeProof64(pub [u8; 672]);
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not too late, could we rename these to ...U64 to match the instructions and other types? (different PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was going to do that. I don't think SPL or any of the dependencies use range proof types directly, so I think it should be okay.

zk-token-sdk/src/zk_token_elgamal/pod/range_proof.rs Outdated Show resolved Hide resolved
zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs Outdated Show resolved Hide resolved
@mvines mvines added the v1.16 PRs that should be backported to v1.16 label May 30, 2023
@samkim-crypto samkim-crypto merged commit e4fe933 into solana-labs:master May 30, 2023
mergify bot pushed a commit that referenced this pull request May 30, 2023
…ticated encryption, range proof, and sigma proof types (#31855)

* refactor convert logic for `AeCiphertext`

* refactor convert logic for `RangeProof`

* refactor convert logic for sigma proof types

* Apply suggestions from code review

Co-authored-by: Tyera <[email protected]>

---------

Co-authored-by: Tyera <[email protected]>
(cherry picked from commit e4fe933)
samkim-crypto added a commit that referenced this pull request May 31, 2023
… authenticated encryption, range proof, and sigma proof types (backport of #31855) (#31887)

[zk-token-sdk] Refactor `zk-token-elgamal` conversion code for authenticated encryption, range proof, and sigma proof types (#31855)

* refactor convert logic for `AeCiphertext`

* refactor convert logic for `RangeProof`

* refactor convert logic for sigma proof types

* Apply suggestions from code review

Co-authored-by: Tyera <[email protected]>

---------

Co-authored-by: Tyera <[email protected]>
(cherry picked from commit e4fe933)

Co-authored-by: samkim-crypto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.16 PRs that should be backported to v1.16
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants