From aac228011f9c8c75b17bc9d100bb67534172e366 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 26 Sep 2018 17:44:31 +1000 Subject: [PATCH] README: rm bad sha256 hash example --- README.md | 1 - test/integration/addresses.js | 11 ----------- 2 files changed, 12 deletions(-) diff --git a/README.md b/README.md index 23dce36..28c1b21 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,6 @@ Otherwise, pull requests are appreciated. Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP). - [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L22) -- [Generate an address from a SHA256 hash](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L29) - [Import an address via WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L40) - [Generate a 2-of-3 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L47) - [Generate a SegWit address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L60) diff --git a/test/integration/addresses.js b/test/integration/addresses.js index 4bd71c8..0024410 100644 --- a/test/integration/addresses.js +++ b/test/integration/addresses.js @@ -25,17 +25,6 @@ describe('bitcoinjs-lib (addresses)', function () { assert.strictEqual(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64') }) - it('can generate an address from a SHA256 hash', function () { - const hash = bitcoin.crypto.sha256(Buffer.from('correct horse battery staple')) - - const keyPair = bitcoin.ECPair.fromPrivateKey(hash) - const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey }) - - // Generating addresses from SHA256 hashes is not secure if the input to the hash function is predictable - // Do not use with predictable inputs - assert.strictEqual(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8') - }) - it('can import an address via WIF', function () { const keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct') const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey })