Comparing version 3.1.0 to 4.0.0
{ | ||
"name": "bip32", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "A BIP32 compatible library", | ||
@@ -40,6 +40,4 @@ "keywords": [ | ||
"dependencies": { | ||
"bs58check": "^2.1.1", | ||
"create-hash": "^1.2.0", | ||
"create-hmac": "^1.1.7", | ||
"ripemd160": "^2.0.2", | ||
"@noble/hashes": "^1.2.0", | ||
"@scure/base": "^1.1.1", | ||
"typeforce": "^1.11.5", | ||
@@ -49,4 +47,3 @@ "wif": "^2.0.6" | ||
"devDependencies": { | ||
"@types/node": "10.12.18", | ||
"@types/ripemd160": "^2.0.0", | ||
"@types/node": "18.x", | ||
"nyc": "^15.0.0", | ||
@@ -57,3 +54,3 @@ "prettier": "1.16.4", | ||
"tslint": "^6.1.0", | ||
"typescript": "3.3.3333" | ||
"typescript": "4.7" | ||
}, | ||
@@ -60,0 +57,0 @@ "author": "Daniel Cousens", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BIP32Factory = void 0; | ||
const crypto = require("./crypto"); | ||
const testecc_1 = require("./testecc"); | ||
const bs58check = require('bs58check'); | ||
const base_1 = require("@scure/base"); | ||
const sha256_1 = require("@noble/hashes/sha256"); | ||
const typeforce = require('typeforce'); | ||
const wif = require('wif'); | ||
const _bs58check = (0, base_1.base58check)(sha256_1.sha256); | ||
const bs58check = { | ||
encode: (data) => _bs58check.encode(Uint8Array.from(data)), | ||
decode: (str) => Buffer.from(_bs58check.decode(str)), | ||
}; | ||
function BIP32Factory(ecc) { | ||
testecc_1.testEcc(ecc); | ||
(0, testecc_1.testEcc)(ecc); | ||
const UINT256_TYPE = typeforce.BufferN(32); | ||
@@ -244,2 +251,4 @@ const NETWORK_TYPE = typeforce.compile({ | ||
const xOnlyPubKey = toXOnly(this.publicKey); | ||
if (!ecc.xOnlyPointAddTweak) | ||
throw new Error('xOnlyPointAddTweak not supported by ecc library'); | ||
const tweakedPublicKey = ecc.xOnlyPointAddTweak(xOnlyPubKey, t); | ||
@@ -260,5 +269,10 @@ if (!tweakedPublicKey || tweakedPublicKey.xOnlyPubkey === null) | ||
(this.publicKey[0] === 4 && (this.publicKey[64] & 1) === 1); | ||
const privateKey = hasOddY | ||
? ecc.privateNegate(this.privateKey) | ||
: this.privateKey; | ||
const privateKey = (() => { | ||
if (!hasOddY) | ||
return this.privateKey; | ||
else if (!ecc.privateNegate) | ||
throw new Error('privateNegate not supported by ecc library'); | ||
else | ||
return ecc.privateNegate(this.privateKey); | ||
})(); | ||
const tweakedPrivateKey = ecc.privateAdd(privateKey, t); | ||
@@ -265,0 +279,0 @@ if (!tweakedPrivateKey) |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const RipeMd160 = require("ripemd160"); | ||
const createHash = require('create-hash'); | ||
const createHmac = require('create-hmac'); | ||
exports.hmacSHA512 = exports.hash160 = void 0; | ||
const hmac_1 = require("@noble/hashes/hmac"); | ||
const ripemd160_1 = require("@noble/hashes/ripemd160"); | ||
const sha256_1 = require("@noble/hashes/sha256"); | ||
const sha512_1 = require("@noble/hashes/sha512"); | ||
function hash160(buffer) { | ||
const sha256Hash = createHash('sha256') | ||
.update(buffer) | ||
.digest(); | ||
try { | ||
return createHash('rmd160') | ||
.update(sha256Hash) | ||
.digest(); | ||
} | ||
catch (err) { | ||
try { | ||
return createHash('ripemd160') | ||
.update(sha256Hash) | ||
.digest(); | ||
} | ||
catch (err2) { | ||
return new RipeMd160().update(sha256Hash).digest(); | ||
} | ||
} | ||
const sha256Hash = (0, sha256_1.sha256)(Uint8Array.from(buffer)); | ||
return Buffer.from((0, ripemd160_1.ripemd160)(sha256Hash)); | ||
} | ||
exports.hash160 = hash160; | ||
function hmacSHA512(key, data) { | ||
return createHmac('sha512', key) | ||
.update(data) | ||
.digest(); | ||
return Buffer.from((0, hmac_1.hmac)(sha512_1.sha512, key, data)); | ||
} | ||
exports.hmacSHA512 = hmacSHA512; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BIP32Factory = exports.default = void 0; | ||
var bip32_1 = require("./bip32"); | ||
exports.default = bip32_1.BIP32Factory; | ||
exports.BIP32Factory = bip32_1.BIP32Factory; | ||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return bip32_1.BIP32Factory; } }); | ||
Object.defineProperty(exports, "BIP32Factory", { enumerable: true, get: function () { return bip32_1.BIP32Factory; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.testEcc = void 0; | ||
const h = (hex) => Buffer.from(hex, 'hex'); | ||
@@ -17,11 +18,15 @@ function testEcc(ecc) { | ||
assert(Buffer.from(ecc.pointFromScalar(h('b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af'))).equals(h('02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99'))); | ||
assert(ecc.xOnlyPointAddTweak(h('79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'), h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140')) === null); | ||
let xOnlyRes = ecc.xOnlyPointAddTweak(h('1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b'), h('a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac')); | ||
assert(Buffer.from(xOnlyRes.xOnlyPubkey).equals(h('e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf')) && xOnlyRes.parity === 1); | ||
xOnlyRes = ecc.xOnlyPointAddTweak(h('2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991'), h('823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47')); | ||
if (ecc.xOnlyPointAddTweak) { | ||
assert(ecc.xOnlyPointAddTweak(h('79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'), h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140')) === null); | ||
let xOnlyRes = ecc.xOnlyPointAddTweak(h('1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b'), h('a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac')); | ||
assert(Buffer.from(xOnlyRes.xOnlyPubkey).equals(h('e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf')) && xOnlyRes.parity === 1); | ||
xOnlyRes = ecc.xOnlyPointAddTweak(h('2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991'), h('823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47')); | ||
} | ||
assert(Buffer.from(ecc.pointAddScalar(h('0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'), h('0000000000000000000000000000000000000000000000000000000000000003'))).equals(h('02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5'))); | ||
assert(Buffer.from(ecc.privateAdd(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e'), h('0000000000000000000000000000000000000000000000000000000000000002'))).equals(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140'))); | ||
assert(Buffer.from(ecc.privateNegate(h('0000000000000000000000000000000000000000000000000000000000000001'))).equals(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140'))); | ||
assert(Buffer.from(ecc.privateNegate(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e'))).equals(h('0000000000000000000000000000000000000000000000000000000000000003'))); | ||
assert(Buffer.from(ecc.privateNegate(h('b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af'))).equals(h('4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792'))); | ||
if (ecc.privateNegate) { | ||
assert(Buffer.from(ecc.privateNegate(h('0000000000000000000000000000000000000000000000000000000000000001'))).equals(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140'))); | ||
assert(Buffer.from(ecc.privateNegate(h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e'))).equals(h('0000000000000000000000000000000000000000000000000000000000000003'))); | ||
assert(Buffer.from(ecc.privateNegate(h('b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af'))).equals(h('4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792'))); | ||
} | ||
assert(Buffer.from(ecc.sign(h('5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed'), h('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140'))).equals(h('54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5'))); | ||
@@ -28,0 +33,0 @@ assert(ecc.verify(h('5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed'), h('0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'), h('54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5'))); |
@@ -59,6 +59,6 @@ /// <reference types="node" /> | ||
verifySchnorr?(h: Uint8Array, Q: Uint8Array, signature: Uint8Array): boolean; | ||
xOnlyPointAddTweak(p: Uint8Array, tweak: Uint8Array): XOnlyPointAddTweakResult | null; | ||
privateNegate(d: Uint8Array): Uint8Array; | ||
xOnlyPointAddTweak?(p: Uint8Array, tweak: Uint8Array): XOnlyPointAddTweakResult | null; | ||
privateNegate?(d: Uint8Array): Uint8Array; | ||
} | ||
export declare function BIP32Factory(ecc: TinySecp256k1Interface): BIP32API; | ||
export {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27970
4
7
507
+ Added@noble/hashes@^1.2.0
+ Added@scure/base@^1.1.1
+ Added@noble/hashes@1.5.0(transitive)
+ Added@scure/base@1.1.9(transitive)
- Removedbs58check@^2.1.1
- Removedcreate-hash@^1.2.0
- Removedcreate-hmac@^1.1.7
- Removedripemd160@^2.0.2
- Removedcreate-hmac@1.1.7(transitive)