File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,15 @@ impl RecordCiphertext {
156
156
pub fn nonce ( & self ) -> Group {
157
157
Group :: from ( self . 0 . nonce ( ) )
158
158
}
159
+
160
+ /// Clone the record ciphertext.
161
+ ///
162
+ /// @returns {RecordCiphertext} A clone of the record ciphertext.
163
+ /// Clone the field element.
164
+ #[ allow( clippy:: should_implement_trait) ]
165
+ pub fn clone ( & self ) -> RecordCiphertext {
166
+ RecordCiphertext ( self . 0 . clone ( ) )
167
+ }
159
168
}
160
169
161
170
impl Deref for RecordCiphertext {
@@ -235,6 +244,13 @@ mod tests {
235
244
assert ! ( RecordCiphertext :: from_string( invalid_bech32) . is_err( ) ) ;
236
245
}
237
246
247
+ #[ wasm_bindgen_test]
248
+ fn test_clone ( ) {
249
+ let record = RecordCiphertext :: from_string ( OWNER_CIPHERTEXT ) . unwrap ( ) ;
250
+ let cloned_record = record. clone ( ) ;
251
+ assert_eq ! ( record. to_string( ) , cloned_record. to_string( ) ) ;
252
+ }
253
+
238
254
#[ wasm_bindgen_test]
239
255
fn test_decrypt_and_tag_computation ( ) {
240
256
let record = RecordCiphertext :: from_string ( OWNER_CIPHERTEXT ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -265,6 +265,15 @@ impl RecordPlaintext {
265
265
pub fn record_view_key ( & self , view_key : & ViewKey ) -> Field {
266
266
Group :: from_string ( & self . nonce ( ) ) . unwrap ( ) . scalar_multiply ( & view_key. to_scalar ( ) ) . to_x_coordinate ( )
267
267
}
268
+
269
+ /// Clone the record plaintext.
270
+ ///
271
+ /// @returns {RecordPlaintext} A clone of the record plaintext.
272
+ /// Clone the field element.
273
+ #[ allow( clippy:: should_implement_trait) ]
274
+ pub fn clone ( & self ) -> RecordPlaintext {
275
+ RecordPlaintext ( self . 0 . clone ( ) )
276
+ }
268
277
}
269
278
270
279
impl Deref for RecordPlaintext {
@@ -341,6 +350,13 @@ mod tests {
341
350
assert_eq ! ( record. to_string( ) , CREDITS_RECORD ) ;
342
351
}
343
352
353
+ #[ wasm_bindgen_test]
354
+ fn test_clone ( ) {
355
+ let record = RecordPlaintext :: from_string ( CREDITS_RECORD ) . unwrap ( ) ;
356
+ let cloned_record = record. clone ( ) ;
357
+ assert_eq ! ( record. to_string( ) , cloned_record. to_string( ) ) ;
358
+ }
359
+
344
360
#[ wasm_bindgen_test]
345
361
fn test_get_record_member ( ) {
346
362
// Get the record members.
You can’t perform that action at this time.
0 commit comments