1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-12-27 23:27:50 +01:00

Merge pull request #265 from DavidEdwards/fix-buffer-crash

Wrap Uint8Array in a Buffer
This commit is contained in:
Jernej Pregelj 2018-11-06 11:45:58 +01:00 committed by GitHub
commit 561a2960b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ import nacl from 'tweetnacl'
*/
export default function Ed25519Keypair(seed) {
const keyPair = seed ? nacl.sign.keyPair.fromSeed(seed) : nacl.sign.keyPair()
this.publicKey = base58.encode(keyPair.publicKey)
this.publicKey = base58.encode(Buffer.from(keyPair.publicKey))
// tweetnacl's generated secret key is the secret key + public key (resulting in a 64-byte buffer)
this.privateKey = base58.encode(keyPair.secretKey.slice(0, 32))
this.privateKey = base58.encode(Buffer.from(keyPair.secretKey.slice(0, 32)))
}