-
Notifications
You must be signed in to change notification settings - Fork 269
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] Add ciphertext validity proof with 3 handles instruction #897
[zk-token-sdk] Add ciphertext validity proof with 3 handles instruction #897
Conversation
8d97bf7
to
85b7ee3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #897 +/- ##
========================================
Coverage 81.8% 81.9%
========================================
Files 853 855 +2
Lines 231812 231956 +144
========================================
+ Hits 189848 189989 +141
- Misses 41964 41967 +3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Just some tiny points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really great how simple these tests are, and a sign that the code is well factored!
let auditor_keypair = ElGamalKeypair::new_rand(); | ||
let auditor_pubkey = auditor_keypair.pubkey(); | ||
|
||
let amount: u64 = 55; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the benches, how important is the amount encrypted? As in, do large numbers make things take longer, or is it inconsequential compared to all the other calculations that need to be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep it is inconsequential since the proof only certifies that a ciphertext is well-formed. If it were, then the proof would leak information about the encrypted amount since anyone can try verifying the proof and measure the time!
/// Accounts expected by this instruction: | ||
/// | ||
/// * Creating a proof context account | ||
/// 0. `[writable]` The proof context account | ||
/// 1. `[]` The proof context account owner | ||
/// | ||
/// * Otherwise | ||
/// None | ||
/// | ||
/// Data expected by this instruction: | ||
/// `GroupedCiphertextValidityProofContext` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't mention that it's possible to read from account data, like the other instructions. Can you add that in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I totally missed that! Thanks!
/// * Creating a proof context account | ||
/// 0. `[writable]` The proof context account | ||
/// 1. `[]` The proof context account owner | ||
/// | ||
/// * Otherwise | ||
/// None | ||
/// | ||
/// Data expected by this instruction: | ||
/// `BatchedGroupedCiphertextValidityProofContext` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, can you point out that it's possible to use account data?
9f6ae10
to
e19bbda
Compare
Co-authored-by: Jon C <[email protected]>
e19bbda
to
61a2183
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry just one last little nit, then this is good to go
Co-authored-by: Jon C <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Problem
Currently, the zk-token-proof program only handles ciphertext validity proof for grouped ciphertext with 2 handles. A ciphertext validity proof for 3 handles is needed to simplify confidential transfers in spl as explained in #809.
Summary of Changes
Added ciphertext validity proof instructions to the zk-token-proof program. The zk-token-proof program is not activated yet and I will rekey the program feature gate once this PR is merged.
Fixes #