[zk-sdk] Expose ElGamal and authenticated encryption ciphertext types for wasm target #4171
+104
−71
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 ElGamal and authenticated encryption types are not yet exported for wasm target build.
Summary of Changes
I exported the ElGamal and authenticated encryption types for wasm target in a sequence of steps.
fb298c9: I first added the
zeroed()
function for thePodElGamalPubkey
. Default values for types are useful when initializing types like mint or account in typescript. I first tried exportingdefault()
, but there did not seem to be a clean way to do it without manually implementing theDefault
trait.b6f4fff: The JS logic for
PodElGamalCiphertext
andPodAeCiphertext
are very similar to that ofPodElGamalPubkey
, so I made a macro for the JS logic.36adba2: I exported the
ElGamalCiphertext
related types for wasm. I am just exporting the types for now. I will deter exporting encryption or decryption in subsequent PRs as they are not needed to generate the instruction data for the majority of confidential transfer instructions.0ebd97e: I exported the
AeCiphertext
andAeKey
related types and functions for wasm. Here, I did include the encryption function since we will need the encryption of 0 to properly configure account data.bda4976: In TS, camelCase is standard while in rust snake_case is standard. Previously, I just exported out the
new_rand()
function as is, but I figured out a way to specifyjs_name
, so I updated the names tonewRand()
.Fixes #