Skip to content

Commit bb0a34a

Browse files
Fix unit tests
1 parent 267ff83 commit bb0a34a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

sdk/tests/wasm.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,8 @@ describe('WASM Objects', () => {
362362
expect(isOwner).equal(true);
363363
})
364364

365-
it ('cannot be decrypted with an invalid record view key', () => {
366-
const foreignViewKey = ViewKey.from_string(foreignViewKeyString);
367-
const badRecordViewKey = ciphertext.recordViewKey(foreignViewKey);
368-
365+
it('cannot be decrypted with an invalid record view key', () => {
366+
const badRecordViewKey = ciphertext.recordViewKey(ViewKey.from_string(foreignViewKeyString));
369367
// Ensure the record ciphertext cannot be decrypted with an invalid record view key
370368
expect(() => ciphertext.decryptWithRecordViewKey(badRecordViewKey)).throw();
371369
})
@@ -406,7 +404,7 @@ describe('WASM Objects', () => {
406404
it('can generate a transition view key from a valid view key', () => {
407405
const generatedTransitionViewKey = transition.tvk(viewKey);
408406

409-
const generatedTransitionViewKeyFromEncryptionToolkit = EncryptionToolkit.generateTransitionViewKey(viewKey, transition);
407+
const generatedTransitionViewKeyFromEncryptionToolkit = EncryptionToolkit.generateTvk(viewKey, transition.tpk());
410408
// Ensure the generated transition view key is the same as the one used to decrypt
411409
expect(generatedTransitionViewKey.toString()).equal(generatedTransitionViewKeyFromEncryptionToolkit.toString());
412410
});
@@ -427,14 +425,14 @@ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private,
427425
const recordViewKey = Field.fromString(recordViewKeyString);
428426

429427
it('can generate a record view key from a view key and a record ciphertext', () => {
430-
const generatedRecordViewKey = EncryptionToolkit.generateRecordViewkey(viewKey, recordCiphertext);
428+
const generatedRecordViewKey = EncryptionToolkit.generateRecordViewKey(viewKey, recordCiphertext);
431429
// Ensure the generated record view key is the same as the one used to decrypt
432430
expect(generatedRecordViewKey.toString()).equal(recordViewKey.toString());
433431
});
434432
it('can decrypt a record ciphertext with the record view key', () => {
435433
const decryptedRecord = EncryptionToolkit.decryptRecordWithRVk(recordViewKey, recordCiphertext);
436434
// Ensure the decrypted record is the same as the plaintext
437-
expect(decryptedRecord).equal(recordPlaintext);
435+
expect(decryptedRecord.toString()).equal(recordPlaintext.toString());
438436
});
439437
it('cannot decrypt a record ciphertext with an invalid record view key', () => {
440438
const invalidRecordViewKey = Field.fromString("4445718830394614891114647247073357114867447866913203502139893824059966201724field");

wasm/src/utilities/encrypt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl EncryptionToolkit {
151151

152152
/// Creates a record view key from the view key. This can be later be used to decrypt a
153153
// record without revealing an account's view key.
154-
#[wasm_bindgen(js_name = "generateRecordViewkey")]
154+
#[wasm_bindgen(js_name = "generateRecordViewKey")]
155155
pub fn generate_record_view_key(view_key: &ViewKey, record_ciphertext: &RecordCiphertext) -> Result<Field, String> {
156156
let record_nonce = record_ciphertext.nonce();
157157
Ok(record_nonce.scalar_multiply(&view_key.to_scalar()).to_x_coordinate())

0 commit comments

Comments
 (0)