From 252125d0f293da9531519165ebfd04b1cf687358 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Miro=20Mets=C3=A4nheimo?= Date: Sun, 24 Apr 2022 21:51:45 +0300 Subject: [PATCH] Version 1.4.1 * Fix for legacy wallet creation presented in 1.4.0 --- README.md | 2 +- lib/bip39-mnemonic.ts | 2 +- package-lock.json | 2 +- package.json | 2 +- test/test.js | 14 ++++++++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f0c0df3..98a65cd 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ npm install nanocurrency-web ### In web ```html - + diff --git a/lib/bip39-mnemonic.ts b/lib/bip39-mnemonic.ts index 2b291fb..0ec34dc 100644 --- a/lib/bip39-mnemonic.ts +++ b/lib/bip39-mnemonic.ts @@ -53,7 +53,7 @@ export default class Bip39Mnemonic { } if (!seed) { - seed = this.randomHex(64) + seed = this.randomHex(32) } const mnemonic = this.deriveMnemonic(seed) diff --git a/package-lock.json b/package-lock.json index bbe79d6..4b5408f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nanocurrency-web", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c2a6615..5b39c7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nanocurrency-web", - "version": "1.4.0", + "version": "1.4.1", "description": "Toolkit for Nano cryptocurrency client side offline integrations", "author": "Miro Metsänheimo ", "license": "MIT", diff --git a/test/test.js b/test/test.js index 9d94ad9..e7f3168 100644 --- a/test/test.js +++ b/test/test.js @@ -334,10 +334,10 @@ describe('Box tests', () => { before(() => { this.message = 'The quick brown fox jumps over the lazy dog' this.bob = wallet.generate() - this.alice = wallet.generate() + this.alice = wallet.generateLegacy() }) - it('should encrypt and decrypt a message', () => { + it('should encrypt and decrypt a message from bob to alice', () => { const encrypted = box.encrypt(this.message, this.alice.accounts[0].address, this.bob.accounts[0].privateKey) const encrypted2 = box.encrypt(this.message, this.alice.accounts[0].address, this.bob.accounts[0].privateKey) const encrypted3 = box.encrypt(this.message + 'asd', this.alice.accounts[0].address, this.bob.accounts[0].privateKey) @@ -351,9 +351,15 @@ describe('Box tests', () => { expect(this.message).to.equal(decrypted) }) + it('should encrypt and decrypt a message from alice to bob', () => { + const encrypted = box.encrypt(this.message, this.bob.accounts[0].address, this.alice.accounts[0].privateKey) + const decrypted = box.decrypt(encrypted, this.alice.accounts[0].address, this.bob.accounts[0].privateKey) + expect(this.message).to.equal(decrypted) + }) + it('should fail to decrypt with wrong public key in encryption', () => { // Encrypt with wrong public key - const aliceAccounts = wallet.accounts(this.alice.seed, 1, 2) + const aliceAccounts = wallet.legacyAccounts(this.alice.seed, 1, 2) const encrypted = box.encrypt(this.message, aliceAccounts[0].address, this.bob.accounts[0].privateKey) expect(() => box.decrypt(encrypted, this.bob.accounts[0].address, this.alice.accounts[0].privateKey)).to.throw() }) @@ -374,7 +380,7 @@ describe('Box tests', () => { it('should fail to decrypt with wrong private key in decryption', () => { // Encrypt with wrong public key - const aliceAccounts = wallet.accounts(this.alice.seed, 1, 2) + const aliceAccounts = wallet.legacyAccounts(this.alice.seed, 1, 2) const encrypted = box.encrypt(this.message, this.alice.accounts[0].address, this.bob.accounts[0].privateKey) expect(() => box.decrypt(encrypted, this.bob.accounts[0].address, aliceAccounts[0].privateKey)).to.throw() }) -- 2.34.1