{"name":"ethereum-cryptography","version":"0.0.1","keywords":["ethereum","cryptography"],"author":{"name":"Patricio Palladino","email":"patricio@nomiclabs.io"},"license":"MIT","_id":"ethereum-cryptography@0.0.1","maintainers":[{"name":"alcuadrado","email":"email@patriciopalladino.com"}],"homepage":"https://github.com/alcuadrado/ethereum-cryptography#readme","bugs":{"url":"https://github.com/alcuadrado/ethereum-cryptography/issues"},"dist":{"shasum":"4df4b6a8ea7276d3f7f548a1f8e6fdb18f6be9cd","tarball":"http://registry-npm.ywwl.com/ethereum-cryptography/download/ethereum-cryptography-0.0.1.tgz","fileCount":17,"integrity":"sha512-M6aawT9Xtvv2xnUSm+TYgIxwLH1Lo6Ujp6Xmwqv0uzBHUPxgvoAwnbTFIeRhWyCG+L1jWqB2QQy9RQ5mHzE8Sw==","signatures":[{"sig":"MEYCIQDwDscVUJvkZaJ6p2CcZdkGDwPefo8rqquuSgKCBITlmgIhAIzHjk1i+7mt7HjLVhy2Czvr/DbhFMCcY/QW2Qt0t4lg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7574,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdcCdCCRA9TVsSAnZWagAA0kgP/iuRQGYrcEgUNRiat4AJ\nbs4iY7tXdiQdaGzL+TFkTgLCsORzUuHBLe0DKn+RZRsXQg86LTB68hzQ+4i1\n4j910LOPS1tCs9C53UCX4FLGKasfxDzOSBzzRNdYZ14S1SPFMytuRK3V0+W6\nS7f+DUcKzKh8LWjtuzOcLlxLrER+lf5LDk81YEauE3qFDv/+OTmGFILVh1Cj\nlScUcxUk3DKGmicXM3BInUgkkDINoywaRKmChtwlNvLIlYrIrW6JFsWHvUUH\noUlEP1VGDIhfRdgNMCBhNiGn76E0QfYjq2TayY36D626zNqX0de2+rDz0dMZ\nNCe/oQxdPfuF2FxyGp5aZNz2DOXVgYjuJDPG67MjXUPKTNSukcPEZUNPR7bD\n7Uc85FCD+KmA5dows5V9tUs6GgKKu+uRCq2QG8QEjEafoS9OYbsxxENoPHIC\nQl4ME3UsMQx595exb4RrLfUGbTnFFzFVQOfuuPw89NAeBH99Lw7cyDN65APg\nipQtIHaM3rj1LAzQ2yUrJxmLjCA98QTvvLWT3tDK7wYrVI3peJc/sngE4g1g\n5AnGr4Lxqdyj/dcAM4TCjN8wlkVapWobFIAZhrxPnUa2xN1wjQAlJGRe+cVb\nXl84jb04i7pSG+BF/HHBobyLsw9TaUhtUdzH0QjJy+AutGECMsV96Hgpwk+s\nVuXA\r\n=0AKT\r\n-----END PGP SIGNATURE-----\r\n","size":2907,"noattachment":false,"key":"/ethereum-cryptography/-/ethereum-cryptography-0.0.1.tgz"},"main":"index.js","types":"index.d.ts","browser":{"./keccak.js":"./pure/keccak.js"},"scripts":{"lint":"tslint --project tsconfig.json","test":"mocha","build":"tsc --project tsconfig.prod.json","clean":"rimraf pure '*.js' '*.js.map' '*.d.ts' '*.d.ts.map'","prepare":"npm run build","lint:fix":"tslint --fix --project tsconfig.json"},"_npmUser":{"name":"alcuadrado","email":"email@patriciopalladino.com"},"repository":{"url":"git+https://github.com/alcuadrado/ethereum-cryptography.git","type":"git"},"_npmVersion":"6.11.2","description":"All the cryptographic primitives used in Ethereum","directories":{},"sideEffects":false,"_nodeVersion":"8.16.0","dependencies":{"js-sha3":"^0.8.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","mocha":"^6.2.0","rimraf":"^3.0.0","tslint":"^5.19.0","ts-node":"^8.3.0","prettier":"1.18.2","typescript":"~3.6.2","@types/chai":"^4.2.1","@types/node":"^8.10.52","@types/mocha":"^5.2.7","tslint-config-prettier":"^1.18.0","tslint-plugin-prettier":"^2.0.1"},"_npmOperationalInternal":{"tmp":"tmp/ethereum-cryptography_0.0.1_1567631170217_0.07610878550544609","host":"s3://npm-registry-packages"},"readme":"# ethereum-cryptography\n\n[![npm version][1]][2] [![license][3]][4]\n\n[Audited](#security) pure JS library containing all Ethereum-related cryptographic primitives.\n\nIncluded algorithms, implemented with just 5 [noble & scure](https://paulmillr.com/noble/) dependencies:\n\n* [Hashes: SHA256, keccak-256, RIPEMD160, BLAKE2b](#hashes-sha256-keccak-256-ripemd160-blake2b)\n* [KDFs: PBKDF2, Scrypt](#kdfs-pbkdf2-scrypt)\n* [CSPRNG (Cryptographically Secure Pseudorandom Number Generator)](#csprng-cryptographically-strong-pseudorandom-number-generator)\n* [secp256k1 elliptic curve](#secp256k1-curve)\n* [BIP32 HD Keygen](#bip32-hd-keygen)\n* [BIP39 Mnemonic phrases](#bip39-mnemonic-seed-phrase)\n* [AES Encryption](#aes-encryption)\n\n**April 2023 update:** v2.0 is out, switching\n[noble-secp256k1](https://github.com/paulmillr/noble-secp256k1) to\n[noble-curves](https://github.com/paulmillr/noble-curves),\nwhich changes re-exported api of `secp256k1` submodule.\nThere have been no other changes.\n\n**January 2022 update:** v1.0 has been released. We've rewritten the library from\nscratch and [audited](#security) it. It became **6x smaller:** ~5,000 lines of\ncode instead of ~24,000 (with all deps); 650KB instead of 10.2MB.\n5 dependencies by 1 author are now used, instead of 38 by 5 authors.\n\nCheck out [Upgrading](#upgrading) section and an article about the library:\n[A safer, smaller, and faster Ethereum cryptography stack](https://medium.com/nomic-labs-blog/a-safer-smaller-and-faster-ethereum-cryptography-stack-5eeb47f62d79).\n\n## Usage\n\nUse NPM / Yarn in node.js / browser:\n\n```bash\n# NPM\nnpm install ethereum-cryptography\n\n# Yarn\nyarn add ethereum-cryptography\n```\n\nSee [browser usage](#browser-usage) for information on using the package with major Javascript bundlers. It is\ntested with **Webpack, Rollup, Parcel and Browserify**.\n\nThis package has no single entry-point, but submodule for each cryptographic\nprimitive. Read each primitive's section of this document to learn how to use\nthem.\n\nThe reason for this is that importing everything from a single file will lead to\nhuge bundles when using this package for the web. This could be avoided through\ntree-shaking, but the possibility of it not working properly on one of\n[the supported bundlers](#browser-usage) is too high.\n\n```js\n// Hashes\nimport { sha256 } from \"ethereum-cryptography/sha256.js\";\nimport { keccak256 } from \"ethereum-cryptography/keccak.js\";\nimport { ripemd160 } from \"ethereum-cryptography/ripemd160.js\";\nimport { blake2b } from \"ethereum-cryptography/blake2b.js\";\n\n// KDFs\nimport { pbkdf2Sync } from \"ethereum-cryptography/pbkdf2.js\";\nimport { scryptSync } from \"ethereum-cryptography/scrypt.js\";\n\n// Random\nimport { getRandomBytesSync } from \"ethereum-cryptography/random.js\";\n\n// AES encryption\nimport { encrypt } from \"ethereum-cryptography/aes.js\";\n\n// secp256k1 elliptic curve operations\nimport { secp256k1 } from \"ethereum-cryptography/secp256k1.js\";\n\n// BIP32 HD Keygen, BIP39 Mnemonic Phrases\nimport { HDKey } from \"ethereum-cryptography/hdkey.js\";\nimport { generateMnemonic } from \"ethereum-cryptography/bip39/index.js\";\nimport { wordlist } from \"ethereum-cryptography/bip39/wordlists/english.js\";\n\n// utilities\nimport { hexToBytes, toHex, utf8ToBytes } from \"ethereum-cryptography/utils.js\";\n```\n\n## Hashes: SHA256, keccak-256, RIPEMD160, BLAKE2b\n```typescript\nfunction sha256(msg: Uint8Array): Uint8Array;\nfunction sha512(msg: Uint8Array): Uint8Array;\nfunction keccak256(msg: Uint8Array): Uint8Array;\nfunction ripemd160(msg: Uint8Array): Uint8Array;\nfunction blake2b(msg: Uint8Array, outputLength = 64): Uint8Array;\n```\n\nExposes following cryptographic hash functions:\n\n- SHA2 (SHA256, SHA512)\n- keccak-256 variant of SHA3 (also `keccak224`, `keccak384`,\nand `keccak512`)\n- RIPEMD160\n- BLAKE2b\n\n```js\nimport { sha256 } from \"ethereum-cryptography/sha256.js\";\nimport { sha512 } from \"ethereum-cryptography/sha512.js\";\nimport { keccak256, keccak224, keccak384, keccak512 } from \"ethereum-cryptography/keccak.js\";\nimport { ripemd160 } from \"ethereum-cryptography/ripemd160.js\";\nimport { blake2b } from \"ethereum-cryptography/blake2b.js\";\n\nsha256(Uint8Array.from([1, 2, 3]))\n\n// Can be used with strings\nimport { utf8ToBytes } from \"ethereum-cryptography/utils.js\";\nsha256(utf8ToBytes(\"abc\"))\n\n// If you need hex\nimport { bytesToHex as toHex } from \"ethereum-cryptography/utils.js\";\ntoHex(sha256(utf8ToBytes(\"abc\")))\n```\n\n## KDFs: PBKDF2, Scrypt\n\n```ts\nfunction pbkdf2(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, digest: string): Promise<Uint8Array>;\nfunction pbkdf2Sync(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, digest: string): Uint8Array;\nfunction scrypt(password: Uint8Array, salt: Uint8Array, N: number, p: number, r: number, dkLen: number, onProgress?: (progress: number) => void): Promise<Uint8Array>;\nfunction scryptSync(password: Uint8Array, salt: Uint8Array, N: number, p: number, r: number, dkLen: number, onProgress?: (progress: number) => void)): Uint8Array;\n```\n\nThe `pbkdf2` submodule has two functions implementing the PBKDF2 key\nderivation algorithm in synchronous and asynchronous ways. This algorithm is\nvery slow, and using the synchronous version in the browser is not recommended,\nas it will block its main thread and hang your UI. The KDF supports `sha256` and `sha512` digests.\n\nThe `scrypt` submodule has two functions implementing the Scrypt key\nderivation algorithm in synchronous and asynchronous ways. This algorithm is\nvery slow, and using the synchronous version in the browser is not recommended,\nas it will block its main thread and hang your UI.\n\nEncoding passwords is a frequent source of errors. Please read\n[these notes](https://github.com/ricmoo/scrypt-js/tree/0eb70873ddf3d24e34b53e0d9a99a0cef06a79c0#encoding-notes)\nbefore using these submodules.\n\n```js\nimport { pbkdf2 } from \"ethereum-cryptography/pbkdf2.js\";\nimport { utf8ToBytes } from \"ethereum-cryptography/utils.js\";\n// Pass Uint8Array, or convert strings to Uint8Array\nconsole.log(await pbkdf2(utf8ToBytes(\"password\"), utf8ToBytes(\"salt\"), 131072, 32, \"sha256\"));\n```\n\n```js\nimport { scrypt } from \"ethereum-cryptography/scrypt.js\";\nimport { utf8ToBytes } from \"ethereum-cryptography/utils.js\";\nconsole.log(await scrypt(utf8ToBytes(\"password\"), utf8ToBytes(\"salt\"), 262144, 8, 1, 32));\n```\n\n## CSPRNG (Cryptographically strong pseudorandom number generator)\n\n```ts\nfunction getRandomBytes(bytes: number): Promise<Uint8Array>;\nfunction getRandomBytesSync(bytes: number): Uint8Array;\n```\n\nThe `random` submodule has functions to generate cryptographically strong\npseudo-random data in synchronous and asynchronous ways.\n\nBacked by [`crypto.getRandomValues`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) in browser and by [`crypto.randomBytes`](https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback) in node.js. If backends are somehow not available, the module would throw an error and won't work, as keeping them working would be insecure.\n\n```js\nimport { getRandomBytesSync } from \"ethereum-cryptography/random.js\";\nconsole.log(getRandomBytesSync(32));\n```\n\n## secp256k1 curve\n\n```ts\nfunction getPublicKey(privateKey: Uint8Array, isCompressed = true): Uint8Array;\nfunction sign(msgHash: Uint8Array, privateKey: Uint8Array): { r: bigint; s: bigint; recovery: number };\nfunction verify(signature: Uint8Array, msgHash: Uint8Array, publicKey: Uint8Array): boolean\nfunction getSharedSecret(privateKeyA: Uint8Array, publicKeyB: Uint8Array): Uint8Array;\nfunction utils.randomPrivateKey(): Uint8Array;\n```\n\nThe `secp256k1` submodule provides a library for elliptic curve operations on\nthe curve secp256k1. For detailed documentation, follow [README of `noble-curves`](https://github.com/paulmillr/noble-curves), which the module uses as a backend.\n\nsecp256k1 private keys need to be cryptographically secure random numbers with\ncertain characteristics. If this is not the case, the security of secp256k1 is\ncompromised. We strongly recommend using `utils.randomPrivateKey()` to generate them.\n\n```js\nimport { secp256k1 } from \"ethereum-cryptography/secp256k1.js\";\n(async () => {\n  // You pass either a hex string, or Uint8Array\n  const privateKey = \"6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e\";\n  const messageHash = \"a33321f98e4ff1c283c76998f14f57447545d339b3db534c6d886decb4209f28\";\n  const publicKey = secp256k1.getPublicKey(privateKey);\n  const signature = secp256k1.sign(messageHash, privateKey);\n  const isSigned = secp256k1.verify(signature, messageHash, publicKey);\n})();\n```\n\nWe're also providing a compatibility layer for users who want to upgrade\nfrom `tiny-secp256k1` or `secp256k1` modules without hassle.\nCheck out [secp256k1 compatibility layer](#legacy-secp256k1-compatibility-layer).\n\n## BIP32 HD Keygen\n\nHierarchical deterministic (HD) wallets that conform to BIP32 standard.\nAlso available as standalone package [scure-bip32](https://github.com/paulmillr/scure-bip32).\n\nThis module exports a single class `HDKey`, which should be used like this:\n\n```ts\nimport { HDKey } from \"ethereum-cryptography/hdkey.js\";\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 `hdkey` submodule provides a library for keys derivation according to\n[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).\n\nIt has almost the exact same API than the version `1.x` of\n[`hdkey` from cryptocoinjs](https://github.com/cryptocoinjs/hdkey),\nbut it's backed by this package's primitives, and has built-in TypeScript types.\nIts only difference is that it has to be used with a named import.\nThe implementation is [loosely based on hdkey, which has MIT License](#LICENSE).\n\n## BIP39 Mnemonic Seed Phrase\n\n```ts\nfunction generateMnemonic(wordlist: string[], strength: number = 128): string;\nfunction mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array;\nfunction entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string;\nfunction validateMnemonic(mnemonic: string, wordlist: string[]): boolean;\nasync function mnemonicToSeed(mnemonic: string, passphrase: string = \"\"): Promise<Uint8Array>;\nfunction mnemonicToSeedSync(mnemonic: string, passphrase: string = \"\"): Uint8Array;\n```\n\nThe `bip39` submodule provides functions to generate, validate and use seed\nrecovery phrases according to [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).\n\nAlso available as standalone package [scure-bip39](https://github.com/paulmillr/scure-bip39).\n\n```js\nimport { generateMnemonic } from \"ethereum-cryptography/bip39/index.js\";\nimport { wordlist } from \"ethereum-cryptography/bip39/wordlists/english.js\";\nconsole.log(generateMnemonic(wordlist));\n```\n\nThis submodule also contains the word lists defined by BIP39 for Czech, English,\nFrench, Italian, Japanese, Korean, Simplified and Traditional Chinese, and\nSpanish. These are not imported by default, as that would increase bundle sizes\ntoo much. Instead, you should import and use them explicitly.\n\nThe word lists are exported as a `wordlist` variable in each of these submodules:\n\n* `ethereum-cryptography/bip39/wordlists/czech.js`\n* `ethereum-cryptography/bip39/wordlists/english.js`\n* `ethereum-cryptography/bip39/wordlists/french.js`\n* `ethereum-cryptography/bip39/wordlists/italian.js`\n* `ethereum-cryptography/bip39/wordlists/japanese.js`\n* `ethereum-cryptography/bip39/wordlists/korean.js`\n* `ethereum-cryptography/bip39/wordlists/portuguese.js`\n* `ethereum-cryptography/bip39/wordlists/simplified-chinese.js`\n* `ethereum-cryptography/bip39/wordlists/spanish.js`\n* `ethereum-cryptography/bip39/wordlists/traditional-chinese.js`\n\n## AES Encryption\n\n```ts\nfunction encrypt(msg: Uint8Array, key: Uint8Array, iv: Uint8Array, mode = \"aes-128-ctr\", pkcs7PaddingEnabled = true): Promise<Uint8Array>;\nfunction decrypt(cypherText: Uint8Array, key: Uint8Array, iv: Uint8Array, mode = \"aes-128-ctr\", pkcs7PaddingEnabled = true): Promise<Uint8Array>;\n```\n\nThe `aes` submodule contains encryption and decryption functions implementing\nthe [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\nalgorithm.\n\n### Encrypting with passwords\n\nAES is not supposed to be used directly with a password. Doing that will\ncompromise your users' security.\n\nThe `key` parameters in this submodule are meant to be strong cryptographic\nkeys. If you want to obtain such a key from a password, please use a\n[key derivation function](https://en.wikipedia.org/wiki/Key_derivation_function)\nlike [pbkdf2](#kdfs-pbkdf2-scrypt) or [scrypt](#kdfs-pbkdf2-scrypt).\n\n### Operation modes\n\nThis submodule works with different [block cipher modes of operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation). If you are using this module in a new\napplication, we recommend using the default.\n\nWhile this module may work with any mode supported by OpenSSL, we only test it\nwith `aes-128-ctr`, `aes-128-cbc`, and `aes-256-cbc`. If you use another module\na warning will be printed in the console.\n\nWe only recommend using `aes-128-cbc` and `aes-256-cbc` to decrypt already\nencrypted data.\n\n### Padding plaintext messages\n\nSome operation modes require the plaintext message to be a multiple of `16`. If\nthat isn't the case, your message has to be padded.\n\nBy default, this module automatically pads your messages according to [PKCS#7](https://tools.ietf.org/html/rfc2315).\nNote that this padding scheme always adds at least 1 byte of padding. If you\nare unsure what anything of this means, we **strongly** recommend you to use\nthe defaults.\n\nIf you need to encrypt without padding or want to use another padding scheme,\nyou can disable PKCS#7 padding by passing `false` as the last argument and\nhandling padding yourself. Note that if you do this and your operation mode\nrequires padding, `encrypt` will throw if your plaintext message isn't a\nmultiple of `16`.\n\nThis option is only present to enable the decryption of already encrypted data.\nTo encrypt new data, we recommend using the default.\n\n### How to use the IV parameter\n\nThe `iv` parameter of the `encrypt` function must be unique, or the security\nof the encryption algorithm can be compromised.\n\nYou can generate a new `iv` using the `random` module.\n\nNote that to decrypt a value, you have to provide the same `iv` used to encrypt\nit.\n\n### How to handle errors with this module\n\nSensitive information can be leaked via error messages when using this module.\nTo avoid this, you should make sure that the errors you return don't\ncontain the exact reason for the error. Instead, errors must report general\nencryption/decryption failures.\n\nNote that implementing this can mean catching all errors that can be thrown\nwhen calling on of this module's functions, and just throwing a new generic\nexception.\n\n### Example usage\n\n```js\nimport { encrypt } from \"ethereum-cryptography/aes.js\";\nimport { hexToBytes, utf8ToBytes } from \"ethereum-cryptography/utils.js\";\n\nconsole.log(\n  encrypt(\n    utf8ToBytes(\"message\"),\n    hexToBytes(\"2b7e151628aed2a6abf7158809cf4f3c\"),\n    hexToBytes(\"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff\")\n  )\n);\n```\n\n## Browser usage\n\n### Rollup setup\n\nUsing this library with Rollup requires the following plugins:\n\n* [`@rollup/plugin-commonjs`](https://www.npmjs.com/package/@rollup/plugin-commonjs)\n* [`@rollup/plugin-node-resolve`](https://www.npmjs.com/package/@rollup/plugin-node-resolve)\n\nThese can be used by setting your `plugins` array like this:\n\n```js\n  plugins: [\n    commonjs(),\n    resolve({\n      browser: true,\n      preferBuiltins: false,\n    }),\n  ]\n```\n\n## Legacy secp256k1 compatibility layer\n\n**Warning:** use `secp256k1` instead. This module is only for users who upgraded\nfrom ethereum-cryptography v0.1. It could be removed in the future.\n\nThe API of `secp256k1-compat` is the same as [secp256k1-node](https://github.com/cryptocoinjs/secp256k1-node):\n\n```js\nimport { createPrivateKeySync, ecdsaSign } from \"ethereum-cryptography/secp256k1-compat\";\nconst msgHash = Uint8Array.from(\n  \"82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28\",\n  \"hex\"\n);\nconst privateKey = createPrivateKeySync();\nconsole.log(Uint8Array.from(ecdsaSign(msgHash, privateKey).signature));\n```\n\n## Missing cryptographic primitives\n\nThis package intentionally excludes the cryptographic primitives necessary\nto implement the following EIPs:\n\n* [EIP 196: Precompiled contracts for addition and scalar multiplication on the elliptic curve alt_bn128](https://eips.ethereum.org/EIPS/eip-196)\n* [EIP 197: Precompiled contracts for optimal ate pairing check on the elliptic curve alt_bn128](https://eips.ethereum.org/EIPS/eip-197)\n* [EIP 198: Big integer modular exponentiation](https://eips.ethereum.org/EIPS/eip-198)\n* [EIP 152: Add Blake2 compression function `F` precompile](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md)\n\nFeel free to open an issue if you want this decision to be reconsidered, or if\nyou found another primitive that is missing.\n\n## Upgrading\n\nUpgrading from 1.0 to 2.0:\n\n1. `secp256k1` module was changed massively:\n  before, it was using [noble-secp256k1 1.7](https://github.com/paulmillr/noble-secp256k1);\n  now it uses safer [noble-curves](https://github.com/paulmillr/noble-curves). Please refer\n  to [upgrading section from curves README](https://github.com/paulmillr/noble-curves#upgrading).\n  Main changes to keep in mind: a) `sign` now returns `Signature` instance\n  b) `recoverPublicKey` got moved onto a `Signature` instance\n2. node.js 14 and older support was dropped. Upgrade to node.js 16 or later.\n\nUpgrading from 0.1 to 1.0: **Same functionality**, all old APIs remain the same except for the breaking changes:\n\n1. We return `Uint8Array` from all methods that worked with `Buffer` before.\n`Buffer` has never been supported in browsers, while `Uint8Array`s are supported natively in both\nbrowsers and node.js.\n2. We target runtimes with [bigint](https://caniuse.com/bigint) support,\nwhich is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support older runtimes, use `ethereum-cryptography@0.1`\n3. If you've used `secp256k1`, [rename it to `secp256k1-compat`](#legacy-secp256k1-compatibility-layer)\n\n```js\nimport { sha256 } from \"ethereum-cryptography/sha256.js\";\n\n// Old usage\nconst hasho = sha256(Buffer.from(\"string\", \"utf8\")).toString(\"hex\");\n\n// New usage\nimport { toHex } from \"ethereum-cryptography/utils.js\";\nconst hashn = toHex(sha256(\"string\"));\n\n// If you have `Buffer` module and want to preserve it:\nconst hashb = Buffer.from(sha256(\"string\"));\nconst hashbo = hashb.toString(\"hex\");\n```\n\n## Security\n\nAudited by Cure53 on Jan 5, 2022. Check out the audit [PDF](./audit/2022-01-05-cure53-audit-nbl2.pdf) & [URL](https://cure53.de/pentest-report_hashing-libs.pdf).\n\n## License\n\n`ethereum-cryptography` is released under The MIT License (MIT)\n\nCopyright (c) 2021 Patricio Palladino, Paul Miller, ethereum-cryptography contributors\n\nSee [LICENSE](./LICENSE) file.\n\n`hdkey` is loosely based on [hdkey](https://github.com/cryptocoinjs/hdkey),\nwhich had [MIT License](https://github.com/cryptocoinjs/hdkey/blob/3f3c0b5cedb98f971835b5116ebea05b3c09422a/LICENSE)\n\nCopyright (c) 2018 cryptocoinjs\n\n[1]: https://img.shields.io/npm/v/ethereum-cryptography.svg\n[2]: https://www.npmjs.com/package/ethereum-cryptography\n[3]: https://img.shields.io/npm/l/ethereum-cryptography\n[4]: https://github.com/ethereum/js-ethereum-cryptography/blob/master/packages/ethereum-cryptography/LICENSE\n","publish_time":1567631170324,"_cnpm_publish_time":1567631170324,"dist-tags":{"latest":"3.2.0"}}