{"name":"@scure/bip32","version":"1.6.2","description":"Secure, audited & minimal implementation of BIP32 hierarchical deterministic (HD) wallets over secp256k1","main":"./lib/index.js","module":"./lib/esm/index.js","types":"./lib/index.d.ts","exports":{".":{"import":"./lib/esm/index.js","require":"./lib/index.js"}},"dependencies":{"@noble/curves":"~1.8.1","@noble/hashes":"~1.7.1","@scure/base":"~1.2.2"},"devDependencies":{"@paulmillr/jsbt":"0.3.1","micro-should":"0.5.1","prettier":"3.3.2","typescript":"5.5.2"},"sideEffects":false,"author":{"name":"Paul Miller","url":"https://paulmillr.com"},"homepage":"https://paulmillr.com/noble/#scure","repository":{"type":"git","url":"git+https://github.com/paulmillr/scure-bip32.git"},"contributors":[{"name":"Patricio Palladino","email":"patricio@nomiclabs.io"},{"name":"Paul Miller","url":"https://paulmillr.com"}],"license":"MIT","scripts":{"build":"tsc && tsc -p tsconfig.cjs.json","build:release":"npx jsbt esbuild test/build","lint":"prettier --check 'index.ts' 'test/*.test.ts'","format":"prettier --write 'index.ts' 'test/*.test.ts'","test":"node test/index.js","test:bun":"bun test/index.js","test:deno":"deno --allow-env --allow-read test/index.js"},"keywords":["bip32","hierarchical","deterministic","hd key","bip0032","bip-32","bip39","micro","scure","mnemonic","phrase","code"],"funding":"https://paulmillr.com/funding/","_id":"@scure/bip32@1.6.2","gitHead":"1d9017c6ba041e5de4aae2de2852a3a769a2cad1","bugs":{"url":"https://github.com/paulmillr/scure-bip32/issues"},"_nodeVersion":"22.13.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==","shasum":"093caa94961619927659ed0e711a6e4bf35bffd0","tarball":"http://registry-npm.ywwl.com/@scure/bip32/download/@scure/bip32-1.6.2.tgz","fileCount":13,"unpackedSize":65666,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@scure%2fbip32@1.6.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDP1KWBWdsAurENCk03jO8ll3D9T75DR6rrj7GcPfKL3AiA1vAkx3W6FSGjUcvSv9H4X/DbYYPRaDEbSyC7Ap7piTg=="}],"size":13002,"noattachment":false,"key":"/@scure/bip32/-/@scure/bip32-1.6.2.tgz"},"_npmUser":{"name":"paulmillr","email":"paul@paulmillr.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bip32_1.6.2_1737193723202_0.12203794851028715"},"_hasShrinkwrap":false,"readme":"# scure-bip32\n\nAudited & minimal implementation of BIP32 hierarchical deterministic (HD) wallets over secp256k1.\n\n- 🔒 [Audited](#security) by an independent security firm\n- 🔻 Tree-shakeable: unused code is excluded from your builds\n- 📦 ESM and common.js\n- ➰ Only 3 audited dependencies by the same author:\n  [noble-curves](https://github.com/paulmillr/noble-curves),\n  [noble-hashes](https://github.com/paulmillr/noble-hashes),\n  and [scure-base](https://github.com/paulmillr/scure-base)\n- 🪶 49KB with all dependencies bundled (300 lines)\n\nCheck out [scure-bip39](https://github.com/paulmillr/scure-bip39) if you need mnemonic phrases.\nSee [key-producer](https://github.com/paulmillr/micro-key-producer) if you need SLIP-0010/BIP32 ed25519 hdkey implementation.\n\n### This library belongs to *scure*\n\n> **scure** — audited micro-libraries.\n\n- Zero or minimal dependencies\n- Highly readable TypeScript / JS code\n- PGP-signed releases and transparent NPM builds\n- Check out [homepage](https://paulmillr.com/noble/#scure) & all libraries:\n  [base](https://github.com/paulmillr/scure-base),\n  [bip32](https://github.com/paulmillr/scure-bip32),\n  [bip39](https://github.com/paulmillr/scure-bip39),\n  [btc-signer](https://github.com/paulmillr/scure-btc-signer),\n  [starknet](https://github.com/paulmillr/scure-starknet)\n\n## Usage\n\n> `npm install @scure/bip32`\n\n> `deno add jsr:@scure/bip32`\n\n> `deno doc jsr:@scure/bip32`  # command-line documentation\n\nThis module exports a single class `HDKey`, which should be used like this:\n\n```ts\nimport { HDKey } from \"@scure/bip32\";\nconst hdkey1 = HDKey.fromMasterSeed(seed);\nconst hdkey2 = HDKey.fromExtendedKey(base58key);\nconst hdkey3 = HDKey.fromJSON({ xpriv: string });\n\n// props\n[hdkey1.depth, hdkey1.index, hdkey1.chainCode];\nconsole.log(hdkey2.privateKey, hdkey2.publicKey);\nconsole.log(hdkey3.derive(\"m/0/2147483647'/1\"));\nconst sig = hdkey3.sign(hash);\nhdkey3.verify(hash, sig);\n```\n\nNote: `chainCode` property is essentially a private part\nof a secret \"master\" key, it should be guarded from unauthorized access.\n\nThe full API is:\n\n```ts\nclass HDKey {\n  public static HARDENED_OFFSET: number;\n  public static fromMasterSeed(seed: Uint8Array, versions: Versions): HDKey;\n  public static fromExtendedKey(base58key: string, versions: Versions): HDKey;\n  public static fromJSON(json: { xpriv: string }): HDKey;\n\n  readonly versions: Versions;\n  readonly depth: number = 0;\n  readonly index: number = 0;\n  readonly chainCode: Uint8Array | null = null;\n  readonly parentFingerprint: number = 0;\n\n  get fingerprint(): number;\n  get identifier(): Uint8Array | undefined;\n  get pubKeyHash(): Uint8Array | undefined;\n  get privateKey(): Uint8Array | null;\n  get publicKey(): Uint8Array | null;\n  get privateExtendedKey(): string;\n  get publicExtendedKey(): string;\n\n  derive(path: string): HDKey;\n  deriveChild(index: number): HDKey;\n  sign(hash: Uint8Array): Uint8Array;\n  verify(hash: Uint8Array, signature: Uint8Array): boolean;\n  wipePrivateData(): this;\n}\n\ninterface Versions {\n  private: number;\n  public: number;\n}\n```\n\nThe module implements [bip32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) standard:\ncheck it out for additional documentation.\n\nThe implementation is loosely based on cryptocoinjs/hdkey, [which has MIT License](#LICENSE).\n\n## Security\n\nThe library has been independently audited:\n\n- at version 1.0.1, in Jan 2022, by [cure53](https://cure53.de)\n  - PDFs: [online](https://cure53.de/pentest-report_hashing-libs.pdf), [offline](./audit/2022-01-05-cure53-audit-nbl2.pdf)\n  - [Changes since audit](https://github.com/paulmillr/scure-bip32/compare/1.0.0..main).\n  - The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io)\n\nThe library was initially developed for [js-ethereum-cryptography](https://github.com/ethereum/js-ethereum-cryptography).\nAt commit [ae00e6d7](https://github.com/ethereum/js-ethereum-cryptography/commit/ae00e6d7d24fb3c76a1c7fe10039f6ecd120b77e),\nit was extracted to a separate package called `micro-bip32`.\nAfter the audit we've decided to use `@scure` NPM namespace for security.\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com)\n","publish_time":1737193723421,"maintainers":[{"name":"paulmillr","email":"paul@paulmillr.com"}],"_cnpm_publish_time":1737193723421,"dist-tags":{"beta":"2.0.0-beta.1","latest":"2.4.0"}}