@@ -73,11 +73,21 @@ impl Plaintext {
73
73
}
74
74
75
75
/// Encrypt a plaintext with an address and randomizer.
76
+ ///
77
+ /// @param {Address} address The address to encrypt the plaintext for.
78
+ /// @param {Scalar} randomizer The randomizer to use for encryption.
79
+ ///
80
+ /// @returns {Ciphertext} The encrypted ciphertext.
81
+ #[ wasm_bindgen( js_name = encrypt) ]
76
82
pub fn encrypt ( & self , address : & Address , randomizer : & Scalar ) -> Result < Ciphertext , String > {
77
83
self . 0 . encrypt ( address, * * randomizer) . map_err ( |e| e. to_string ( ) ) . map ( Ciphertext :: from)
78
84
}
79
85
80
86
/// Encrypt a plaintext with a transition view key.
87
+ ///
88
+ /// @param {Field} transition_view_key The transition view key to use for encryption.
89
+ ///
90
+ /// @returns {Ciphertext} The encrypted ciphertext.
81
91
#[ wasm_bindgen( js_name = encryptSymmetric) ]
82
92
pub fn encrypt_symmetric ( & self , transition_view_key : & Field ) -> Result < Ciphertext , String > {
83
93
self . 0 . encrypt_symmetric ( * * transition_view_key) . map_err ( |e| e. to_string ( ) ) . map ( Ciphertext :: from)
@@ -106,6 +116,8 @@ impl Plaintext {
106
116
}
107
117
108
118
/// Get the left endian byte array representation of the plaintext.
119
+ ///
120
+ /// @returns {Uint8Array} The left endian byte array representation of the plaintext.
109
121
#[ wasm_bindgen( js_name = "toBytesLe" ) ]
110
122
pub fn to_bytes_le ( & self ) -> Result < Uint8Array , String > {
111
123
let rust_bytes = self . 0 . to_bytes_le ( ) . map_err ( |e| e. to_string ( ) ) ?;
@@ -125,6 +137,8 @@ impl Plaintext {
125
137
}
126
138
127
139
/// Get the left endian boolean array representation of the bits of the plaintext.
140
+ ///
141
+ /// @returns {Array} The left endian boolean array representation of the bits of the plaintext.
128
142
#[ wasm_bindgen( js_name = "toBitsLe" ) ]
129
143
pub fn to_bits_le ( & self ) -> Array {
130
144
to_bits_array_le ! ( self )
@@ -143,6 +157,8 @@ impl Plaintext {
143
157
}
144
158
145
159
/// Get the field array representation of the plaintext.
160
+ ///
161
+ /// @returns {Array} The field array representation of the plaintext.
146
162
#[ wasm_bindgen( js_name = "toFields" ) ]
147
163
pub fn to_fields ( & self ) -> Result < Array , String > {
148
164
let native = self . 0 . clone ( ) ;
0 commit comments