Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Adds id() method to Secp256k1PrivateKey
Browse files Browse the repository at this point in the history
Feature parity with ed25519 and rsa
  • Loading branch information
AlbertoElias authored Feb 14, 2019
1 parent 3a8bab9 commit 2645f9a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ module.exports = (keysProtobuf, randomBytes, crypto) => {
ensure(callback)
multihashing(this.bytes, 'sha2-256', callback)
}

/**
* Gets the ID of the key.
*
* The key id is the base58 encoding of the SHA-256 multihash of its public key.
* The public key is a protobuf encoding containing a type and the DER encoding
* of the PKCS SubjectPublicKeyInfo.
*
* @param {function(Error, id)} callback
* @returns {undefined}
*/
id (callback) {
this.public.hash((err, hash) => {
if (err) {
return callback(err)
}
callback(null, bs58.encode(hash))
})
}
}

function unmarshalSecp256k1PrivateKey (bytes, callback) {
Expand Down

0 comments on commit 2645f9a

Please sign in to comment.