@@ -353,7 +353,7 @@ describe('WASM Objects', () => {
353
353
} ) ;
354
354
355
355
it ( 'can be decrypted with a valid record view key' , ( ) => {
356
- const recordViewKey = ciphertext . generateRecordViewKey ( viewKey ) ;
356
+ const recordViewKey = ciphertext . recordViewKey ( viewKey ) ;
357
357
const plaintext = ciphertext . decryptWithRecordViewKey ( recordViewKey ) ;
358
358
const isOwner = ciphertext . isOwner ( viewKey ) ;
359
359
@@ -363,7 +363,8 @@ describe('WASM Objects', () => {
363
363
} )
364
364
365
365
it ( 'cannot be decrypted with an invalid record view key' , ( ) => {
366
- const badRecordViewKey = ciphertext . generateRecordViewKey ( foreignViewKeyString ) ;
366
+ const foreignViewKey = ViewKey . from_string ( foreignViewKeyString ) ;
367
+ const badRecordViewKey = ciphertext . recordViewKey ( foreignViewKey ) ;
367
368
368
369
// Ensure the record ciphertext cannot be decrypted with an invalid record view key
369
370
expect ( ( ) => ciphertext . decryptWithRecordViewKey ( badRecordViewKey ) ) . throw ( ) ;
@@ -390,21 +391,22 @@ describe('WASM Objects', () => {
390
391
const invalidTransitionViewKeyString = "5089075468761042335883809641276568724119791331127957254389204093712358605127field"
391
392
const transitionViewKey = Field . fromString ( transitionViewKeyString ) ;
392
393
const invalidTransitionViewKey = Field . fromString ( invalidTransitionViewKeyString ) ;
393
- const viewKeyString = "AViewKey1ccEt8A2Ryva5rxnKcAbn7wgTaTsb79tzkKHFpeKsm9NX" ;
394
- const viewKey = ViewKey . from_string ( viewKeyString ) ;
394
+ const privateKey = PrivateKey . from_string ( "APrivateKey1zkp6rE5FSWGD3jxrsAT64aZutFs3w6xvF8uQzGZKJEKsN8j" ) ;
395
+ const viewKey = privateKey . to_view_key ( ) ;
396
+ const tvk = transition . tvk ( viewKey ) ;
395
397
396
398
it ( 'can be decrypted with a valid transition view key' , ( ) => {
397
- const transitionDecryptedWithTVK = transition . decryptWithTransitionViewKey ( transitionViewKey ) ;
399
+ const transitionDecryptedWithTVK = transition . decryptTransition ( tvk ) ;
398
400
// Ensure the transition is valid
399
- expect ( transitionDecryptedWithTVK ) . equal ( transitionDecrypted ) ;
401
+ expect ( transitionDecryptedWithTVK . toString ( ) ) . equal ( transitionDecrypted . toString ( ) ) ;
400
402
} ) ;
401
403
402
404
it ( 'cannot be decrypted with an invalid transition view key' , ( ) => {
403
- expect ( ( ) => transition . decryptWithTransitionViewKey ( invalidTransitionViewKey ) . toThrow ( ) ) ;
405
+ expect ( ( ) => transition . decryptTransition ( invalidTransitionViewKey ) . toThrow ( ) ) ;
404
406
} ) ;
405
407
406
408
it ( 'can generate a transition view key from a valid view key' , ( ) => {
407
- const generatedTransitionViewKey = transition . generateTransitionViewKey ( viewKey ) ;
409
+ const generatedTransitionViewKey = transition . tvk ( viewKey ) ;
408
410
// Ensure the generated transition view key is the same as the one used to decrypt
409
411
expect ( generatedTransitionViewKey . toString ( ) ) . equal ( transitionViewKeyString ) ;
410
412
} ) ;
@@ -425,16 +427,16 @@ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private,
425
427
const recordViewKey = Field . fromString ( recordViewKeyString ) ;
426
428
427
429
it ( 'can generate a record view key from a view key and a record ciphertext' , ( ) => {
428
- const generatedRecordViewKey = EncryptionToolkit . generateRecordViewKey ( viewKey , recordCiphertext ) ;
430
+ const generatedRecordViewKey = EncryptionToolkit . generateRecordViewkey ( viewKey , recordCiphertext ) ;
429
431
// Ensure the generated record view key is the same as the one used to decrypt
430
- expect ( generatedRecordViewKey ) . equal ( recordViewKey ) ;
432
+ expect ( generatedRecordViewKey . toString ( ) ) . equal ( recordViewKey . toString ( ) ) ;
431
433
} ) ;
432
434
it ( 'can decrypt a record ciphertext with the record view key' , ( ) => {
433
435
const decryptedRecord = EncryptionToolkit . decryptRecordWithRVk ( recordViewKey , recordCiphertext ) ;
434
436
// Ensure the decrypted record is the same as the plaintext
435
437
expect ( decryptedRecord ) . equal ( recordPlaintext ) ;
436
438
} ) ;
437
- it ( 'caanot decrypt a record ciphertext with an invalid record view key' , ( ) => {
439
+ it ( 'cannot decrypt a record ciphertext with an invalid record view key' , ( ) => {
438
440
const invalidRecordViewKey = Field . fromString ( "4445718830394614891114647247073357114867447866913203502139893824059966201724field" ) ;
439
441
expect ( ( ) => EncryptionToolkit . decryptRecordWithRVk ( invalidRecordViewKey , recordCiphertext ) ) . to . throw ( ) ;
440
442
} ) ;
0 commit comments