]> zoso.dev Git - libnemo.git/commitdiff
Version 1.4.1
authorMiro Metsänheimo <miro@metsanheimo.fi>
Sun, 24 Apr 2022 18:51:45 +0000 (21:51 +0300)
committerMiro Metsänheimo <miro@metsanheimo.fi>
Sun, 24 Apr 2022 18:51:45 +0000 (21:51 +0300)
* Fix for legacy wallet creation presented in 1.4.0

README.md
lib/bip39-mnemonic.ts
package-lock.json
package.json
test/test.js

index f0c0df3ba3ecbf7f2dde193629688ff010bf598c..98a65cdaf2132069d53427c114f6f1df3a2634f5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ npm install nanocurrency-web
 ### In web
 
 ```html
-<script src="https://unpkg.com/nanocurrency-web@1.4.0" type="text/javascript"></script>
+<script src="https://unpkg.com/nanocurrency-web@1.4.1" type="text/javascript"></script>
 <script type="text/javascript">
     NanocurrencyWeb.wallet.generate(...);
 </script>
index 2b291fb65e3d658a352782889a532eba75656545..0ec34dca275c71d7d98fa749f02ef6248110a88e 100644 (file)
@@ -53,7 +53,7 @@ export default class Bip39Mnemonic {
                }
 
                if (!seed) {
-                       seed = this.randomHex(64)
+                       seed = this.randomHex(32)
                }
 
                const mnemonic = this.deriveMnemonic(seed)
index bbe79d620759cd4250b895d85105a8a062b2e748..4b5408f4f3cf11dcf9c8fee45a2e51cd5424eef5 100644 (file)
@@ -1,6 +1,6 @@
 {
        "name": "nanocurrency-web",
-       "version": "1.4.0",
+       "version": "1.4.1",
        "lockfileVersion": 1,
        "requires": true,
        "dependencies": {
index c2a66152babc6b29cd70d854e34c6a8e9af97c84..5b39c7e13a9904f70a8dec4035cc6a54da96f87f 100644 (file)
@@ -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 <miro@metsanheimo.fi>",
        "license": "MIT",
index 9d94ad9c9c0836cd5becfffb9a2a43221badc4a8..e7f3168f9a9e9a2dd6b34d3ff22aacc5951703e4 100644 (file)
@@ -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()
        })