@@ -11,6 +11,13 @@ import {
11
11
recordPlaintextString ,
12
12
beaconPrivateKeyString
13
13
} from "./data/account-data.js" ;
14
+ import {
15
+ RECORD_CIPHERTEXT_STRING ,
16
+ RECORD_CIPHERTEXT_STRING_COPY ,
17
+ RECORD_CIPHERTEXT_STRING_NOT_OWNED ,
18
+ RECORD_CIPHERTEXT_STRING_NOT_OWNED2 ,
19
+ RECORD_PLAINTEXT_STRING ,
20
+ } from "./data/records.js" ;
14
21
15
22
16
23
describe ( 'WASM Objects' , ( ) => {
@@ -440,28 +447,18 @@ describe('WASM Objects', () => {
440
447
}
441
448
} ) ;
442
449
443
-
444
450
describe ( 'EncryptionToolkit' , ( ) => {
445
- const recordCiphertextString = "record1qyqsqpe2szk2wwwq56akkwx586hkndl3r8vzdwve32lm7elvphh37rsyqyxx66trwfhkxun9v35hguerqqpqzqrtjzeu6vah9x2me2exkgege824sd8x2379scspmrmtvczs0d93qttl7y92ga0k0rsexu409hu3vlehe3yxjhmey3frh2z5pxm5cmxsv4un97q" ;
446
- const recordCiphertextStringCopy = "record1qyqsqpe2szk2wwwq56akkwx586hkndl3r8vzdwve32lm7elvphh37rsyqyxx66trwfhkxun9v35hguerqqpqzqrtjzeu6vah9x2me2exkgege824sd8x2379scspmrmtvczs0d93qttl7y92ga0k0rsexu409hu3vlehe3yxjhmey3frh2z5pxm5cmxsv4un97q" ;
447
- const recordCiphertextStringNotOwned = "RECORD1QVQSQ5H8YT5682E73ZT7PYNJGPL29MWTSETRVS9VHCKFHJRNX9RX94CFQYXX66TRWFHKXUN9V35HGUERQQPQZQZ6KMY7S5HPKKF02L6R46QM8RQCW9X0K4RQ6GT234AMJ2UG3LMTQT5NY4UG8SXJY3U8D05K4Q3E9F54VX67ZMD3G6JYQQ7KXRWS0R0SWM6P833" ;
448
- const recordCiphertextStringNotOwned2 = "RECORD1QVQSP37HJE4CEU8EFZE8XMAHE5TDTXCZ0K534WQPKVN6C9R629X3C4Q8QYRXZMT0W4H8GGCQQGQSPVUJYCN0K7HYFHENXA40HXTFSX68092WMVJ4E3XSEXR2DY0FMCCXT0DS42W5MAASZFJV930QVQRKATQJ900AKU4K777UMH2K54ZHLUGQC2AFJD" ;
449
- const recordCiphertext = RecordCiphertext . fromString ( recordCiphertextString ) ;
450
- const recordCiphertextNotOwned = RecordCiphertext . fromString ( recordCiphertextStringNotOwned ) ;
451
- const recordCiphertextNotOwned2 = RecordCiphertext . fromString ( recordCiphertextStringNotOwned2 ) ;
451
+ const recordCiphertext = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING ) ;
452
+ const recordCiphertextNotOwned = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING_NOT_OWNED ) ;
453
+ const recordCiphertextNotOwned2 = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING_NOT_OWNED2 ) ;
452
454
const recordCiphertextArray = [ recordCiphertext , recordCiphertextNotOwned , recordCiphertextNotOwned2 ] ;
453
455
// Create copies of the record ciphertexts
454
- const recordCiphertextCopy1 = RecordCiphertext . fromString ( recordCiphertextString ) ;
455
- const recordCiphertextNotOwnedCopy1 = RecordCiphertext . fromString ( recordCiphertextStringNotOwned ) ;
456
- const recordCiphertextNotOwned2Copy1 = RecordCiphertext . fromString ( recordCiphertextStringNotOwned2 ) ;
456
+ const recordCiphertextCopy1 = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING_COPY ) ;
457
+ const recordCiphertextNotOwnedCopy1 = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING_NOT_OWNED ) ;
458
+ const recordCiphertextNotOwned2Copy1 = RecordCiphertext . fromString ( RECORD_CIPHERTEXT_STRING_NOT_OWNED2 ) ;
457
459
const recordCiphertextArrayCopy = [ recordCiphertextCopy1 , recordCiphertextNotOwnedCopy1 , recordCiphertextNotOwned2Copy1 ] ;
458
- const recordPlaintextString = `{
459
- owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private,
460
- microcredits: 1500000000000000u64.private,
461
- _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public
462
- }` ;
463
- const recordPlaintext = RecordPlaintext . fromString ( recordPlaintextString ) ;
464
- const recordPlaintextCopy = RecordPlaintext . fromString ( recordPlaintextString ) ;
460
+ const recordPlaintext = RecordPlaintext . fromString ( RECORD_PLAINTEXT_STRING ) ;
461
+ const recordPlaintextCopy = RecordPlaintext . fromString ( RECORD_PLAINTEXT_STRING ) ;
465
462
const viewKeyString = "AViewKey1ccEt8A2Ryva5rxnKcAbn7wgTaTsb79tzkKHFpeKsm9NX" ;
466
463
const viewKey = ViewKey . from_string ( viewKeyString ) ;
467
464
const recordViewKeyString = "4445718830394614891114647247073357094867447866913203502139893824059966201724field" ;
@@ -484,13 +481,12 @@ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private,
484
481
it ( 'can check if a record ciphertext from an array of record ciphertexts is owned by a view key' , ( ) => {
485
482
const ownedRecords = EncryptionToolkit . checkOwnedRecords ( viewKey , recordCiphertextArray ) ;
486
483
// Ensure the record ciphertext is owned by the view key
487
- expect ( ownedRecords [ 0 ] . toString ( ) ) . equal ( recordCiphertextStringCopy . toString ( ) ) ;
484
+ expect ( ownedRecords [ 0 ] . toString ( ) ) . equal ( RECORD_CIPHERTEXT_STRING_COPY . toString ( ) ) ;
488
485
} ) ;
489
486
it ( 'can decrypt a record ciphertext from an array of record ciphertexts' , ( ) => {
490
487
const decryptedRecords = EncryptionToolkit . decryptOwnedRecords ( viewKey , recordCiphertextArrayCopy ) ;
491
488
// Ensure the decrypted record is the same as the plaintext
492
489
expect ( decryptedRecords [ 0 ] . toString ( ) ) . equal ( recordPlaintextCopy . toString ( ) ) ;
493
490
} ) ;
494
-
495
491
} ) ;
496
492
} ) ;
0 commit comments