@@ -144,13 +144,23 @@ impl EncryptionToolkit {
144
144
}
145
145
146
146
/// 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.
147
152
#[ wasm_bindgen( js_name = "generateTvk" ) ]
148
153
pub fn generate_tvk ( view_key : & ViewKey , tpk : & Group ) -> Field {
149
154
tpk. scalar_multiply ( & view_key. to_scalar ( ) ) . to_x_coordinate ( )
150
155
}
151
156
152
157
/// Creates a record view key from the view key. This can be later be used to decrypt a
153
158
// 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.
154
164
#[ wasm_bindgen( js_name = "generateRecordViewKey" ) ]
155
165
pub fn generate_record_view_key ( view_key : & ViewKey , record_ciphertext : & RecordCiphertext ) -> Result < Field , String > {
156
166
let record_nonce = record_ciphertext. nonce ( ) ;
@@ -159,6 +169,11 @@ impl EncryptionToolkit {
159
169
160
170
/// Decrypts a record ciphertext using the record view key. Decryption only succeeds
161
171
/// 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.
162
177
#[ wasm_bindgen( js_name = "decryptRecordWithRVk" ) ]
163
178
pub fn decrypt_record_symmetric_unchecked (
164
179
record_vk : & Field ,
@@ -176,6 +191,11 @@ impl EncryptionToolkit {
176
191
177
192
/// Decrypts a transition using the transition view key. The ciphertext inputs and outputs
178
193
/// 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.
179
199
#[ wasm_bindgen( js_name = "decryptTransitionWithVk" ) ]
180
200
pub fn decrypt_transition_with_vk ( transition : & Transition , transition_vk : & Field ) -> Result < Transition , String > {
181
201
transition. decrypt_transition ( transition_vk)
0 commit comments