Skip to content

Commit

Permalink
Version 1.4.1
Browse files Browse the repository at this point in the history
* Fix for legacy wallet creation presented in 1.4.0
  • Loading branch information
numsu committed Apr 24, 2022
1 parent 6fefc48 commit 252125d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ npm install nanocurrency-web
### In web

```html
<script src="https://unpkg.com/[email protected].0" type="text/javascript"></script>
<script src="https://unpkg.com/[email protected].1" type="text/javascript"></script>
<script type="text/javascript">
NanocurrencyWeb.wallet.generate(...);
</script>
Expand Down
2 changes: 1 addition & 1 deletion lib/bip39-mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class Bip39Mnemonic {
}

if (!seed) {
seed = this.randomHex(64)
seed = this.randomHex(32)
}

const mnemonic = this.deriveMnemonic(seed)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"license": "MIT",
Expand Down
14 changes: 10 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
})
Expand All @@ -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()
})
Expand Down

0 comments on commit 252125d

Please sign in to comment.