Gathering detailed insights and metrics for @teamteanpm2024/vel-neque-necessitatibus
Gathering detailed insights and metrics for @teamteanpm2024/vel-neque-necessitatibus
Gathering detailed insights and metrics for @teamteanpm2024/vel-neque-necessitatibus
Gathering detailed insights and metrics for @teamteanpm2024/vel-neque-necessitatibus
npm install @teamteanpm2024/vel-neque-necessitatibus
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
37
A JavaScript component for BIP32(hierarchical deterministic keys).
npm i --save @teamteanpm2024/vel-neque-necessitatibus
example:
1var HDKey = require('@teamteanpm2024/vel-neque-necessitatibus') 2var seed = 'a0c42a9c3ac6abf2ba6a9946ae83af18f51bf1c9fa7dacc4c92513cc4dd015834341c775dcd4c0fac73547c5662d81a9e9361a0aac604a73a321bd9103bce8af' 3var hdkey = HDKey.fromMasterSeed(new Buffer(seed, 'hex')) 4console.log(hdkey.privateExtendedKey) 5// => 'xprv9s21ZrQH143K2SKJK9EYRW3Vsg8tWVHRS54hAJasj1eGsQXeWDHLeuu5hpLHRbeKedDJM4Wj9wHHMmuhPF8dQ3bzyup6R7qmMQ1i1FtzNEW' 6console.log(hdkey.publicExtendedKey) 7// => 'xpub661MyMwAqRbcEvPmRAmYndzERhyNux1GoHzHxgzVHMBFkCro3kbbCiDZZ5XabZDyXPj5mH3hktvkjhhUdCQxie5e1g4t2GuAWNbPmsSfDp2'
HDKey.fromMasterSeed(seedBuffer[, versions])
Creates an hdkey
object from a master seed buffer. Accepts an optional versions
object.
1var seed = 'a0c42a9c3ac6abf2ba6a9946ae83af18f51bf1c9fa7dacc4c92513cc4dd015834341c775dcd4c0fac73547c5662d81a9e9361a0aac604a73a321bd9103bce8af' 2var hdkey = HDKey.fromMasterSeed(new Buffer(seed, 'hex'))
HDKey.fromExtendedKey(extendedKey[, versions])
Creates an hdkey
object from a xprv
or xpub
extended key string. Accepts an optional versions
object.
1var key = 'xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7nadnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j' 2var hdkey = HDKey.fromExtendedKey(key)
or
1var key = 'xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbdpq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt' 2var hdkey = HDKey.fromExtendedKey(key)
HDKey.fromJSON(obj)
Creates an hdkey
object from an object created via hdkey.toJSON()
.
hdkey.derive(path)
Derives the hdkey
at path
from the current hdkey
.
1var seed = 'fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542' 2var hdkey = HDKey.fromMasterSeed(Buffer.from(seed, 'hex')) 3var childkey = hdkey.derive("m/0/2147483647'/1") 4 5console.log(childkey.privateExtendedKey) 6// -> "xprv9zFnWC6h2cLgpmSA46vutJzBcfJ8yaJGg8cX1e5StJh45BBciYTRXSd25UEPVuesF9yog62tGAQtHjXajPPdbRCHuWS6T8XA2ECKADdw4Ef" 7console.log(childkey.publicExtendedKey) 8// -> "xpub6DF8uhdarytz3FWdA8TvFSvvAh8dP3283MY7p2V4SeE2wyWmG5mg5EwVvmdMVCQcoNJxGoWaU9DCWh89LojfZ537wTfunKau47EL2dhHKon"
hdkey.sign(hash)
Signs the buffer hash
with the private key using secp256k1
and returns the signature as a buffer.
hdkey.verify(hash, signature)
Verifies that the signature
is valid for hash
and the hdkey
's public key using secp256k1
. Returns true
for valid, false
for invalid. Throws if the hash
or signature
is the wrong length.
hdkey.wipePrivateData()
Wipes all record of the private key from the hdkey
instance. After calling this method, the instance will behave as if it was created via HDKey.fromExtendedKey(xpub)
.
hdkey.toJSON()
Serializes the hdkey
to an object that can be JSON.stringify()
ed.
1var seed = 'fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542' 2var hdkey = HDKey.fromMasterSeed(Buffer.from(seed, 'hex')) 3 4console.log(hdkey.toJSON()) 5// -> { 6// xpriv: 'xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U', 7// xpub: 'xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB' 8// }
hdkey.privateKey
Getter/Setter of the hdkey
's private key, stored as a buffer.
hdkey.publicKey
Getter/Setter of the hdkey
's public key, stored as a buffer.
hdkey.privateExtendedKey
Getter/Setter of the hdkey
's xprv
, stored as a string.
hdkey.publicExtendedKey
Getter/Setter of the hdkey
's xpub
, stored as a string.
MIT
No vulnerabilities found.
No security vulnerabilities found.