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

dashhd

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dashhd - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

70

dashhd.js

@@ -9,2 +9,4 @@ /**

* @prop {HDFromXKey} fromXKey
* @prop {HDToId} toId
* @prop {HDToIdBytes} toIdBytes
* @prop {HDToAddr} toAddr

@@ -18,2 +20,3 @@ * @prop {HDToWif} toWif

* @prop {HDWipePrivates} wipePrivateData - randomizes private key buffer in-place
* @prop {HDToPublic} toPublic - returns public key
* @prop {Number} HARDENED_OFFSET - 0x80000000

@@ -40,2 +43,3 @@ * @prop {HDVersions} MAINNET - 'xprv' & 'xpub'

* @prop {HDHasher} sha512hmac
* @prop {HDBase64Url} bytesToBase64Url
* @prop {HDKeyToKey} toPublicKey

@@ -224,2 +228,19 @@ */

/** @type {HDBase64Url} */
Utils.bytesToBase64Url = function (bytes) {
let bins = [];
for (let i = 0; i < bytes.length; i += 1) {
let b = bytes[i];
let s = String.fromCodePoint(b);
bins.push(s);
}
let str = bins.join("");
let b64 = btoa(str);
let b64url = b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
return b64url;
};
/** @type {HDSecureErase} */

@@ -255,2 +276,4 @@ Utils.secureErase = function (buf) {

DashHd._utils = Utils;
// Bitcoin defaults hard-coded by default.

@@ -659,2 +682,25 @@ // Use package `coininfo` for others.

DashHd.toId = async function (hdkey) {
let idBytes = await DashHd.toIdBytes(hdkey);
let id = Utils.bytesToBase64Url(idBytes);
return id;
};
DashHd.toIdBytes = async function (hdkey) {
let xpubBytes = await DashHd.toXPubBytes(hdkey);
let hashBuffer = await Crypto.subtle.digest("SHA-256", xpubBytes);
let idBuffer = hashBuffer.slice(0, 8);
let idBytes = new Uint8Array(idBuffer);
return idBytes;
};
DashHd.toPublic = function (_hdkey) {
let hdkey = Object.assign({}, _hdkey);
hdkey.privateKey = null;
return hdkey;
};
DashHd.wipePrivateData = function (hdkey) {

@@ -838,2 +884,14 @@ if (hdkey.privateKey) {

/**
* @callback HDToId
* @param {HDKey} hdkey
* @returns {Promise<String>}
*/
/**
* @callback HDToIdBytes
* @param {HDKey} hdkey
* @returns {Promise<Uint8Array>}
*/
/**
* @callback HDToXKeyBytes

@@ -882,2 +940,8 @@ * @param {HDKey} hdkey

/**
* @callback HDBase64Url
* @param {Uint8Array} bytes
* @returns {String} - URL-Safe Base64 Encoding
*/
/**
* @callback HDHasher

@@ -920,4 +984,10 @@ * @param {Uint8Array} bytes

/**
* @callback HDToPublic
* @param {HDKey} hdkey
* @returns {HDKey}
*/
/**
* @callback HDWipePrivates
* @param {HDKey} hdkey
*/

2

package.json
{
"name": "dashhd",
"version": "3.1.0",
"version": "3.2.0",
"description": "Manage HD Keys from HD Wallet Seed and Extended (xprv, xpub) Key Paths. Part of $DASH Tools.",

@@ -5,0 +5,0 @@ "main": "dashhd.js",

@@ -242,2 +242,4 @@ # [DashHD.js](https://github.com/dashhive/dashhd.js)

async fromXKey(xprv||xpub, opts) // depth-4 hdkey (XKey)
async toPublic(xKey)
async wipePrivateData(xKey)
async toWif(privBytes, opts)

@@ -419,2 +421,18 @@ async toAddr(pubBytes, opts)

### `toPublic(xkey)`
Creates a copy of the HD Key with `privateKey` set to `null`.
```js
let xpubKey = await DashHd.toPublic(xprvKey);
```
### `wipePrivateData(xkey)`
Performs an in-place secure erase of the private key memory.
```js
await DashHd.wipePrivateData(xprvKey);
```
### `toWif(privBytes, opts)`

@@ -421,0 +439,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