This repository was archived by the owner on Mar 11, 2025. It is now read-only.
[confidential-transfer] Add confidential transfer ciphertext arithmetic crate #7026
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The syscall ElGamal ciphertext arithmetic functions (the logic in
solana_zk_token_sdk::zk_elgamal::ops
) have been removed insolana-zk-sdk
as they are related specifically to the token program with plans to be moved into the spl repo.Summary of changes
Added the confidential transfer
ciphertext-arithmetic
crate that implements the syscall ElGamal ciphertext arithmetic functions.This is essentially a copy of the logic from
solana_zk_token_sdk::zk_elgamal::ops
except for the following functions:elgamal_ciphertext_to_ristretto(...)
: In thezk-token-sdk
,(
PodPedersenCommitment, PodDecryptHandle)implemented
TryFromfor
PodElGamalCiphertext. However, this was removed in
zk-sdkfor simplicity. The
elgamal_ciphertext_to_ristretto(...)was added as a function to directly convert from these two types. The return type is actually
(PodRistrettoPoint, PodRistrettoPoint)because
PodRistrettoPoint` is actually the type that is used in the syscall functions.ristretto_to_elgamal_ciphertext(...)
: This function is the opposite/complement of the function above. Unfortunately, there is one complication with this function. Insolana-zk-token-sdk
, thePodElGamalCiphertext
is defined asPodElGamalCiphertext(pub [u8; 64])
. However, insolana-zk-sdk
, we havePodElGamalCiphertext(pub(crate) [u8; 64])
and it does not expose a constructor that allows us to createPodElGamalCiphertext
from array bytes directly. As a workaround, I ended up converting array bytes into base64 strings and then converting it toPodElGamalCiphertext
, sincePodElGamalCiphertext
does implementFromStr
... I think we can use this workaround for now until the next major agave release where we add a proper constructor insolana-zk-sdk
.