Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hdkey

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hdkey - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

29

lib/hdkey.js

@@ -5,2 +5,3 @@ var assert = require('assert')

var bs58check = require('bs58check')
var RIPEMD160 = require('ripemd160')
var secp256k1 = require('secp256k1')

@@ -45,2 +46,9 @@

function setPublicKey (hdkey, publicKey) {
hdkey._publicKey = Buffer.from(publicKey)
hdkey._identifier = hash160(publicKey)
hdkey._fingerprint = hdkey._identifier.slice(0, 4).readUInt32BE(0)
hdkey._privateKey = null
}
Object.defineProperty(HDKey.prototype, 'publicKey', {

@@ -53,7 +61,5 @@ get: function () {

assert(secp256k1.publicKeyVerify(value) === true, 'Invalid public key')
this._publicKey = Buffer.from(secp256k1.publicKeyConvert(value, true)) // force compressed point
this._identifier = hash160(this.publicKey)
this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0)
this._privateKey = null
// force compressed point (performs public key verification)
const publicKey = (value.length === 65) ? secp256k1.publicKeyConvert(value, true) : value
setPublicKey(this, publicKey)
}

@@ -159,3 +165,3 @@ })

HDKey.prototype.sign = function (hash) {
return Buffer.from(secp256k1.ecdsaSign(hash, this.privateKey).signature)
return Buffer.from(secp256k1.ecdsaSign(Uint8Array.from(hash), Uint8Array.from(this.privateKey)).signature)
}

@@ -196,5 +202,6 @@

HDKey.fromExtendedKey = function (base58key, versions) {
HDKey.fromExtendedKey = function (base58key, versions, skipVerification) {
// => version(4) || depth(1) || fingerprint(4) || index(4) || chain(32) || key(33)
versions = versions || BITCOIN_VERSIONS
skipVerification = skipVerification || false
var hdkey = new HDKey(versions)

@@ -218,3 +225,7 @@

assert(version === versions.public, 'Version mismatch: version does not match public')
hdkey.publicKey = key
if (skipVerification) {
setPublicKey(hdkey, key)
} else {
hdkey.publicKey = key
}
}

@@ -248,3 +259,3 @@

var sha = crypto.createHash('sha256').update(buf).digest()
return crypto.createHash('ripemd160').update(sha).digest()
return new RIPEMD160().update(sha).digest()
}

@@ -251,0 +262,0 @@

{
"name": "hdkey",
"version": "2.0.1",
"version": "2.1.0",
"description": "Bitcoin BIP32 hierarchical deterministic keys",

@@ -38,2 +38,3 @@ "main": "lib/hdkey.js",

"bs58check": "^2.1.2",
"ripemd160": "^2.0.2",
"safe-buffer": "^5.1.1",

@@ -40,0 +41,0 @@ "secp256k1": "^4.0.0"

@@ -14,3 +14,5 @@ hdkey

npm i --save hdkey
```bash
npm i --save hdkey
```

@@ -43,5 +45,5 @@

### `HDKey.fromExtendedKey(extendedKey[, versions])`
### `HDKey.fromExtendedKey(extendedKey[, versions, skipVerification])`
Creates an `hdkey` object from a `xprv` or `xpub` extended key string. Accepts an optional `versions` object.
Creates an `hdkey` object from a `xprv` or `xpub` extended key string. Accepts an optional `versions` object & an optional `skipVerification` boolean. If `skipVerification` is set to true, then the provided public key's x (and y if uncompressed) coordinate will not will be verified to be on the curve.

@@ -81,2 +83,9 @@ ```js

Newer, "hardened" derivation paths look like this:
```js
// as defined by BIP-44
var childkey = hdkey.derive("m/44'/0'/0'/0/0");
```
### `hdkey.sign(hash)`

@@ -83,0 +92,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc