@chainsafe/bls-hd-key
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,1 +1,7 @@ | ||
## 0.2.0 (2020-09-25) | ||
## BREAKING CHANGES | ||
- Update hdkfModR to latest EIP-2333 spec ([42fd6a](https://github.com/chainsafe/ssz/commit/42fd6a)) | ||
## 0.1.0 (2020-07-29) | ||
@@ -2,0 +8,0 @@ |
@@ -48,9 +48,19 @@ "use strict"; | ||
function hkdfModR(ikm, keyInfo = _buffer.Buffer.alloc(0)) { | ||
const prk = _hkdf.default.extract(_sha.default, _buffer.Buffer.concat([ikm, _buffer.Buffer.alloc(1)]), _buffer.Buffer.from("BLS-SIG-KEYGEN-SALT-", "ascii")); | ||
let salt = _buffer.Buffer.from("BLS-SIG-KEYGEN-SALT-", "ascii"); | ||
const okm = _hkdf.default.expand(_sha.default, prk, _buffer.Buffer.concat([keyInfo, _buffer.Buffer.from([0, 48])]), 48); | ||
let sk = new _bn.default(0); | ||
const okmBN = new _bn.default(okm, "hex", "be"); | ||
const r = new _bn.default("52435875175126190479447740508185965837690552500527637822603658699938581184513"); | ||
return _buffer.Buffer.from(okmBN.mod(r).toArray("be", 32)); | ||
while (sk.eqn(0)) { | ||
salt = _sha.default.digest(salt); | ||
const prk = _hkdf.default.extract(_sha.default, _buffer.Buffer.concat([ikm, _buffer.Buffer.alloc(1)]), salt); | ||
const okm = _hkdf.default.expand(_sha.default, prk, _buffer.Buffer.concat([keyInfo, _buffer.Buffer.from([0, 48])]), 48); | ||
const okmBN = new _bn.default(okm, "hex", "be"); | ||
const r = new _bn.default("52435875175126190479447740508185965837690552500527637822603658699938581184513"); | ||
sk = okmBN.mod(r); | ||
} | ||
return _buffer.Buffer.from(sk.toArray("be", 32)); | ||
} | ||
@@ -57,0 +67,0 @@ |
{ | ||
"name": "@chainsafe/bls-hd-key", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "BLS KDF and HD wallet utilities", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -24,11 +24,17 @@ import SHA256 from "bcrypto/lib/sha256"; | ||
function hkdfModR(ikm: Buffer, keyInfo: Buffer = Buffer.alloc(0)): Buffer { | ||
const prk = HKDF.extract( | ||
SHA256, | ||
Buffer.concat([ikm, Buffer.alloc(1)]), | ||
Buffer.from("BLS-SIG-KEYGEN-SALT-", "ascii") | ||
); | ||
const okm = HKDF.expand(SHA256, prk, Buffer.concat([keyInfo, Buffer.from([0, 48])]), 48); | ||
const okmBN = new BN(okm, "hex", "be"); | ||
const r = new BN("52435875175126190479447740508185965837690552500527637822603658699938581184513"); | ||
return Buffer.from(okmBN.mod(r).toArray("be", 32)); | ||
let salt = Buffer.from("BLS-SIG-KEYGEN-SALT-", "ascii"); | ||
let sk = new BN(0); | ||
while (sk.eqn(0)) { | ||
salt = SHA256.digest(salt); | ||
const prk = HKDF.extract( | ||
SHA256, | ||
Buffer.concat([ikm, Buffer.alloc(1)]), | ||
salt | ||
); | ||
const okm = HKDF.expand(SHA256, prk, Buffer.concat([keyInfo, Buffer.from([0, 48])]), 48); | ||
const okmBN = new BN(okm, "hex", "be"); | ||
const r = new BN("52435875175126190479447740508185965837690552500527637822603658699938581184513"); | ||
sk = okmBN.mod(r); | ||
} | ||
return Buffer.from(sk.toArray("be", 32)); | ||
} | ||
@@ -35,0 +41,0 @@ |
@@ -5,25 +5,25 @@ { | ||
"seed": "0xc55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04", | ||
"master_SK": "5399117110774477986698372024995405256382522670366369834617409486544348441851", | ||
"master_SK": "6083874454709270928345386274498605044986640685124978867557563392430687146096", | ||
"child_index": 0, | ||
"child_SK": "11812940737387919040225825939013910852517748782307378293770044673328955938106" | ||
"child_SK": "20397789859736650942317412262472558107875392172444076792671091975210932703118" | ||
}, | ||
{ | ||
"seed": "0x3141592653589793238462643383279502884197169399375105820974944592", | ||
"master_SK": "36167147331491996618072159372207345412841461318189449162487002442599770291484", | ||
"master_SK": "29757020647961307431480504535336562678282505419141012933316116377660817309383", | ||
"child_index": 3141592653, | ||
"child_SK": "41787458189896526028601807066547832426569899195138584349427756863968330588237" | ||
"child_SK": "25457201688850691947727629385191704516744796114925897962676248250929345014287" | ||
}, | ||
{ | ||
"seed": "0x0099FF991111002299DD7744EE3355BBDD8844115566CC55663355668888CC00", | ||
"master_SK": "13904094584487173309420026178174172335998687531503061311232927109397516192843", | ||
"master_SK": "27580842291869792442942448775674722299803720648445448686099262467207037398656", | ||
"child_index": 4294967295, | ||
"child_SK": "12482522899285304316694838079579801944734479969002030150864436005368716366140" | ||
"child_SK": "29358610794459428860402234341874281240803786294062035874021252734817515685787" | ||
}, | ||
{ | ||
"seed": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", | ||
"master_SK": "44010626067374404458092393860968061149521094673473131545188652121635313364506", | ||
"master_SK": "19022158461524446591288038168518313374041767046816487870552872741050760015818", | ||
"child_index": 42, | ||
"child_SK": "4011524214304750350566588165922015929937602165683407445189263506512578573606" | ||
"child_SK": "31372231650479070279774297061823572166496564838472787488249775572789064611981" | ||
} | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
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
49910
539