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

Fixes #264. This wraps the given Uint8Array in a Buffer so that it doesn't cause a crash in base-x.

This commit is contained in:
David Edwards 2018-11-06 10:10:53 +01:00
parent 994c8ef163
commit e4d0efd967

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(new Buffer(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(new Buffer(keyPair.secretKey.slice(0, 32)))
}