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

[token-2022] Update confidential transfer instruction to support split proof contexts #5001

Merged

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented Aug 12, 2023

Summary of changes

  • 779eaba: The verify proof helper function for Transfer is going to be a bit more involved, so I created a verify_proof submodule and refactored the existing verify_..._proof()` helper functions into this submodule.
  • 7ee73cb: Modified instruction.rs modules to support split proof context states. The most notable change here is the addition of SplitContextStateAccounts variant of ProofLocation argument type.
  • c26ec15: I updated the verify_..._proof() helper functions to take in the iterator of account_info's since functions like verify_transfer_proof need to take in variable number of context state accounts.
  • fee378f: I refactored ciphertext extraction related helper functions into a separate submodule. The code in the ciphertext_extraction module should really belong to the solana-zk-token-sdk, so they can be removed on a future Solana upgrade.
  • 4de36f4: This is commit adds the main logic that checks consistency between the split context state proofs. This is unfortunately a bit technical and lower-level in terms of zkp that should really belong to the solana-zk-token-sdk (and hence added to ciphertext_extraction submodule, which could be removed in the future).
  • f0049ce: So this commit relates to a really annoying mistake that I made. The split proof context accounts for equality, ciphertext validity, and range proofs do not contain all the information that is needed to reconstruct a full transfer proof context state due to some optimizations that I mistakenly made. So the "decryption handle" components under the source public key is missing from the three split proof instructions... I added these components directly as part of the transfer instruction data for now, but they should really be removed once this is fixed on the zk token sdk side.
  • 78ce6eb: Updated the token client to account for the above changes.
  • 684ca38: This is another unfortunately quite technical commit that should really belong to the zk token sdk. This adds logic that generates the individual split proof data from the token account info.
  • c3be8fa: Added tests for the split proof
  • 655bac5: Took me a while to figure out why the test was keep failing, but I realized that I had the conditional state flipped backwards...
  • 11c9c1f: Added two additional error variants to suitably describe common error when working with ciphertexts

@samkim-crypto samkim-crypto added the WIP Work in progress label Aug 12, 2023
@samkim-crypto samkim-crypto force-pushed the token22-divide-transfer branch 5 times, most recently from 0fca7ce to 5825be1 Compare August 14, 2023 23:18
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.

Thanks for breaking up all the commits and explaining each step. Even the really technical stuff was very digestible!

I added a commit to fix the serde tests, so this is good to go!

@samkim-crypto
Copy link
Contributor Author

Thanks for the help @joncinque!

@samkim-crypto samkim-crypto merged commit 6f30f86 into solana-labs:master Aug 18, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants