Skip to content

Commit 57727db

Browse files
committed
added expanded docstrings for encrypt.rs methods
1 parent 1fec577 commit 57727db

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

wasm/src/utilities/encrypt.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,23 @@ impl EncryptionToolkit {
144144
}
145145

146146
/// Generates a transition view key from the view key and the transition public key.
147+
///
148+
/// @param {ViewKey} view_key The view key to use for generating the transition view key.
149+
/// @param {Group} tpk The transition public key to use for generating the transition view key.
150+
///
151+
/// @returns {Field} The generated transition view key.
147152
#[wasm_bindgen(js_name = "generateTvk")]
148153
pub fn generate_tvk(view_key: &ViewKey, tpk: &Group) -> Field {
149154
tpk.scalar_multiply(&view_key.to_scalar()).to_x_coordinate()
150155
}
151156

152157
/// Creates a record view key from the view key. This can be later be used to decrypt a
153158
// record without revealing an account's view key.
159+
///
160+
/// @param {ViewKey} view_key The view key to use for generating the record view key.
161+
/// @param {RecordCiphertext} record_ciphertext The record ciphertext to use for generating the record view key.
162+
///
163+
/// @returns {Field} The generated record view key.
154164
#[wasm_bindgen(js_name = "generateRecordViewKey")]
155165
pub fn generate_record_view_key(view_key: &ViewKey, record_ciphertext: &RecordCiphertext) -> Result<Field, String> {
156166
let record_nonce = record_ciphertext.nonce();
@@ -159,6 +169,11 @@ impl EncryptionToolkit {
159169

160170
/// Decrypts a record ciphertext using the record view key. Decryption only succeeds
161171
/// if the record view key was generated from the view key of the record owner.
172+
///
173+
/// @param {Field} record_vk The record view key to use for decryption.
174+
/// @param {RecordCiphertext} record_ciphertext The record ciphertext to decrypt.
175+
///
176+
/// @returns {RecordPlaintext} The decrypted record plaintext.
162177
#[wasm_bindgen(js_name = "decryptRecordWithRVk")]
163178
pub fn decrypt_record_symmetric_unchecked(
164179
record_vk: &Field,
@@ -176,6 +191,11 @@ impl EncryptionToolkit {
176191

177192
/// Decrypts a transition using the transition view key. The ciphertext inputs and outputs
178193
/// can only be decrypted if the transition view key was generated by the transaction signer.
194+
///
195+
/// @param {Transition} transition The transition to decrypt.
196+
/// @param {Field} transition_vk The transition view key to use for decryption.
197+
///
198+
/// @returns {Transition} The decrypted transition.
179199
#[wasm_bindgen(js_name = "decryptTransitionWithVk")]
180200
pub fn decrypt_transition_with_vk(transition: &Transition, transition_vk: &Field) -> Result<Transition, String> {
181201
transition.decrypt_transition(transition_vk)

0 commit comments

Comments
 (0)