{"name":"ethereum-cryptography","version":"0.2.4","keywords":["ethereum","cryptography","digital signature","hash","encryption","prng","keccak","scrypt","pbkdf2","sha-256","ripemd-160","blake2b","aes","advanced encryption standar","secp256k1","ecdsa","bip32","hierarchical deterministic keys","hdwallet","hdkeys"],"license":"MIT","_id":"ethereum-cryptography@0.2.4","maintainers":[{"name":"alcuadrado","email":"email@patriciopalladino.com"}],"contributors":[{"name":"Patricio Palladino","email":"patricio@nomiclabs.io"},{"url":"https://paulmillr.com","name":"Paul Miller"}],"homepage":"https://github.com/ethereum/js-ethereum-cryptography#readme","bugs":{"url":"https://github.com/ethereum/js-ethereum-cryptography/issues"},"dist":{"shasum":"802e8b40a32c7e5ee2da3fcef429be519b3e5e0c","tarball":"http://registry-npm.ywwl.com/ethereum-cryptography/download/ethereum-cryptography-0.2.4.tgz","fileCount":123,"integrity":"sha512-QUZE7o+yoFybBx1WrkClLIbdNOAI8h7Fct5TFwCGKkLyygSUY7xBmyxzlyZthusJ0v9aM0FQRRhINFLZLfFJ2A==","signatures":[{"sig":"MEYCIQCCK75dJIHyy+/cKrtnfc1WRPQOhbrTJhmAhPVicmIsawIhAPFGihqsc8kGQBSljPkpsWIRa0Z1QNzNc3N/XuZT+DsR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":484070,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhxdF5CRA9TVsSAnZWagAAdtwP+wcGLvZqoPSei/pXxQrb\ny66vo5dVRMjKjwwDU2G8Bz5aPxNCk1Ghhf1m3lUr3kJ8mN+OW4vt/vI85Mj7\n8LA+YrEeOV7CiwSyhcFhI+MsijbjIqynSDyOtEunwTRT0ECAjPPIhnOzWe8G\n+i32xBsJVqpcbz7aqloZvAzvyFWv/inX42BE3IoDj/BCeoz4+Eyq376E+ds5\nL8RJGppj9dTMeY0+TJYpJXqohKKNmATk++57/pHa3tx83x70L2sQIB6sMnVX\nqTThiPrqf7WOLKieJhPzCA0amUsKoqmyVrpPSROnN0KJ2xehtoiBGekKM8ed\nF2VNgUudDfKn3iqSyov+PIs4f5uknvRWfXaWA1W589p+1mCcOjGiHhaBBy6p\n2pC8VfPeqjoC+Zo7LC9Ekv34sKhtSuXmtv8PjFAo6Qydz8bug6pUGQAMD/+j\nV/s8bJ2luCzRqcQPmA1OgY5vHPsPoK9G+usfFIlRVfF5BP9L+E//6bDtvct8\n9gLeo7C4Ru2Cck30mpxuhngJ2XDToeuGE/vs+SNhneZMS2828Fx0y5xgtQJj\nl892haoy8/CU9FH/QAmZFJN+sYO7FVIa7YL1vEc5xfJQfUJVWPMT1zBdMlNa\n7uMzNgTd7V847FD//bD3FGI5pwXfcTrQAel4P3wF3SC/ItCtjreiDvrIVszz\nqwR0\r\n=kFIP\r\n-----END PGP SIGNATURE-----\r\n","size":166576,"noattachment":false,"key":"/ethereum-cryptography/-/ethereum-cryptography-0.2.4.tgz"},"main":"./index.js","readme":"# ethereum-cryptography\n\n[![npm version][1]][2] [![Travis CI][3]][4] [![license][5]][6] [![Types][7]][8]\n\nThis package contains all pure-js cryptographic primitives normally used when\ndeveloping Javascript / TypeScript applications and tools for Ethereum.\n\nThe cryptographic primitives included are:\n\n* [Hashes: SHA256, keccak-256, RIPEMD160, BLAKE2b](#hashes-sha256-keccak-256-ripemd160-blake2b)\n* [KDFs: PBKDF2, Scrypt](#kdfs-pbkdf2-scrypt)\n* [CSPRNG (Cryptographically strong pseudorandom number generator)](#csprng-cryptographically-strong-pseudorandom-number-generator)\n* [secp256k1 curve](#secp256k1-curve)\n* [BIP32 HD Keygen](#bip32-hd-keygen)\n* [BIP39 Mnemonic phrases](#bip39-mnemonic-phrases)\n* [AES Encryption](#aes-encryption)\n\n**October 2021 update:** We're releasing **experimental** version 0.2 of the package.\nThe module has been completely rewritten:\n\n- ~6x smaller: 4,000 lines of code instead of 22,438 (with all deps); 185KB instead of 755KB\n- 3 dependencies (pending an audit) instead of 38\n- **Same functionality**, all old APIs remain the same except for two breaking changes:\n    1. 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\n  browsers and node.js. See [Upgrading](#upgrading)\n    2. We target runtimes with [bigint](https://caniuse.com/bigint) support,\n  which is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support older runtimes, use `ethereum-cryptography@0.1`\n    3. If you've used `secp256k1`, [rename it to `secp256k1-compat`](#legacy-secp256k1-compatibility-layer)\n- The new module [has not been audited yet](#security), but it's in the process of getting the audit. Use it at your own risk\n\n## Usage\n\nUse NPM / Yarn in node.js / browser:\n\n```bash\n# NPM\nnpm install ethereum-cryptography@next\n\n# Yarn\nyarn add ethereum-cryptography@next\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\nconst { sha256 } = require(\"ethereum-cryptography/sha256\");\nconst { keccak256 } = require(\"ethereum-cryptography/keccak\");\nconst { ripemd160 } = require(\"ethereum-cryptography/ripemd160\");\nconst { blake2b } = require(\"ethereum-cryptography/blake2b\");\n\n// KDFs\nconst { pbkdf2Sync } = require(\"ethereum-cryptography/pbkdf2\");\nconst { scryptSync } = require(\"ethereum-cryptography/scrypt\");\n\n// Random\nconst { getRandomBytesSync } = require(\"ethereum-cryptography/random\");\n\n// AES encryption\nconst { encrypt } = require(\"ethereum-cryptography/aes\");\n\n// secp256k1 elliptic curve operations\nconst { createPrivateKeySync, ecdsaSign } = require(\"ethereum-cryptography/secp256k1\");\n\n// BIP32 HD Keygen, BIP39 Mnemonic Phrases\nconst { HDKey } = require(\"ethereum-cryptography/hdkey\");\nconst { generateMnemonic } = require(\"ethereum-cryptography/bip39\");\nconst { wordlist } = require(\"ethereum-cryptography/bip39/wordlists/english\");\n\n// utilities\nconst { hexToBytes, toHex, utf8ToBytes } = require(\"ethereum-cryptography/utils\");\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\nconst { sha256 } = require(\"ethereum-cryptography/sha256\");\nconst { sha512 } = require(\"ethereum-cryptography/sha512\");\nconst { keccak256, keccak224, keccak384, keccak512 } = require(\"ethereum-cryptography/keccak\");\nconst { ripemd160 } = require(\"ethereum-cryptography/ripemd160\");\nconst { blake2b } = require(\"ethereum-cryptography/blake2b\");\n\nsha256(Uint8Array.from([1, 2, 3]))\n\n// Can be used with strings\nconst { utf8ToBytes } = require(\"ethereum-cryptography/utils\");\nsha256(utf8ToBytes(\"abc\"))\n\n// If you need hex\nconst { toHex } = require(\"ethereum-cryptography/utils\");\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): Promise<Uint8Array>;\nfunction scryptSync(password: Uint8Array, salt: Uint8Array, N: number, p: number, r: number, dkLen: number): 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\nconst { pbkdf2 } = require(\"ethereum-cryptography/pbkdf2\");\nconst { utf8ToBytes } = require(\"ethereum-cryptography/utils\");\n// Pass Uint8Array, or convert strings to Uint8Array\nconsole.log(await pbkdf2(utf8ToBytes(\"password\"), utf8ToBytes(\"salt\"), 131072, 32, \"sha256\"));\n```\n\n```js\nconst { scryptSync } = require(\"ethereum-cryptography/scrypt\");\nconst { utf8ToBytes } = require(\"ethereum-cryptography/utils\");\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\nconst { getRandomBytesSync } = require(\"ethereum-cryptography/random\");\nconsole.log(getRandomBytesSync(32));\n```\n\n## secp256k1 curve\n\n```ts\nfunction getPublicKey(privateKey: Uint8Array, isCompressed?: false): Uint8Array;\nfunction getSharedSecret(privateKeyA: Uint8Array, publicKeyB: Uint8Array): Uint8Array;\nfunction sign(msgHash: Uint8Array, privateKey: Uint8Array, opts?: Options): Promise<Uint8Array>;\nfunction signSync(msgHash: Uint8Array, privateKey: Uint8Array, opts?: Options): Uint8Array;\nfunction verify(signature: Uint8Array, msgHash: Uint8Array, publicKey: Uint8Array): boolean\nfunction recoverPublicKey(msgHash: Uint8Array, signature: Uint8Array, recovery: number): Uint8Array | undefined;\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-secp256k1`](https://github.com/paulmillr/noble-secp256k1), which the module uses as a backend.\n\nsecp256k1 private keys need to be cryptographically secure random numbers with\ncertain caracteristics. If this is not the case, the security of secp256k1 is\ncompromised. We strongly recommend using `utils.randomPrivateKey()` to generate them.\n\n```js\nconst secp = require(\"ethereum-cryptography/secp256k1\");\n(async () => {\n  // You pass either a hex string, or Uint8Array\n  const privateKey = \"6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e\";\n  const messageHash = \"a33321f98e4ff1c283c76998f14f57447545d339b3db534c6d886decb4209f28\";\n  const publicKey = secp.getPublicKey(privateKey);\n  const signature = await secp.sign(messageHash, privateKey);\n  const isSigned = secp.verify(signature, messageHash, publicKey);\n})();\n```\n\nNote: if you've been using ethereum-cryptography v0.1, it had different API. We're providing a compatibility layer for users who want to upgrade without hassle. Check out [the legacy documentation](#legacy-secp256k1-compatibility-layer).\n\n## BIP32 HD Keygen\n\nThis module exports a single class `HDKey`, which should be used like this:\n\n```ts\nconst { HDKey } = require(\"ethereum-cryptography/secp256k1\");\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 be used with a named import.\nThe implementation is [loosely based on hdkey, which has MIT License](#LICENSE).\n\n```js\nconst { HDKey } = require(\"ethereum-cryptography/hdkey\");\nconst { hexToBytes } = require(\"ethereum-cryptography/utils\");\n\nconst seed = \"fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542\";\nconst hdkey = HDKey.fromMasterSeed(hexToBytes(seed));\nconst childkey = hdkey.derive(\"m/0/2147483647'/1\");\n\nconsole.log(childkey.privateExtendedKey);\n```\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\n```js\nconst { generateMnemonic } = require(\"ethereum-cryptography/bip39\");\nconst { wordlist } = require(\"ethereum-cryptography/bip39/wordlists/english\");\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/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](#pbkdf2-submodule) or [scrypt](#scrypt-submodule).\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 compromissed.\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\nconst { encrypt } = require(\"ethereum-cryptography/aes\");\nconst { hexToBytes, utf8ToBytes } = require(\"ethereum-cryptography/utils\");\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**Note:** consider using `secp256k1` instead;\nThis module is only for users who upgraded\nfrom ethereum-cryptography v0.1. It could be removed in the future,\nbut we're keeping it around for now, for backwards-compatibility.\n\nThe API of `secp256k1-compat` is the same as [secp256k1-node](https://github.com/cryptocoinjs/secp256k1-node):\n\n```js\nconst { createPrivateKeySync, ecdsaSign } = require(\"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 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\nVersion 0.2 changes from 0.1:\n\n- **Breaking:** we target runtimes with [bigint](https://caniuse.com/bigint) support,\n  which is Chrome 67+, Edge 79+, Firefox 68+, Safari 14+, node.js 10+. If you need to support\n  older runtimes, use `ethereum-cryptography@0.1`\n- **Breaking:** 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\n  browsers and node.js:\n\n```\nconst { sha256 } = require(\"ethereum-cryptography/sha256\");\n\n// Old usage\nconst hasho = sha256(Buffer.from(\"string\", \"utf8\")).toString(\"hex\");\n\n// New usage\nconst { toHex } = require(\"ethereum-cryptography/utils\");\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\nThis library is in the process of getting a security audit.\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/travis/ethereum/js-ethereum-cryptography/master.svg?label=Travis%20CI\n[4]: https://travis-ci.org/ethereum/js-ethereum-cryptography\n[5]: https://img.shields.io/npm/l/ethereum-cryptography\n[6]: https://github.com/ethereum/js-ethereum-cryptography/blob/master/packages/ethereum-cryptography/LICENSE\n[7]: https://img.shields.io/npm/types/ethereum-cryptography.svg\n[8]: https://www.npmjs.com/package/ethereum-cryptography\n","browser":{"crypto":false},"gitHead":"2fe90d980bb538c59e00eaa7cfdfdb91e54a9d9d","scripts":{"lint":"tslint --project tsconfig.json","test":"npm-run-all test:node","build":"npm-run-all build:tsc","clean":"rimraf test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'","prepare":"npm run build","lint:fix":"tslint --fix --project tsconfig.json","build:tsc":"tsc --project tsconfig.prod.json","test:node":"mocha","browser-tests":"npm-run-all browser-tests:build browser-tests:test","browser-tests:test":"npm-run-all browser-tests:test-parcel browser-tests:test-browserify browser-tests:test-webpack browser-tests:test-rollup","browser-tests:build":"bash -x ./scripts/build-browser-tests.sh","browser-tests:test-parcel":"karma start --single-run --browsers ChromeHeadless test/karma.parcel.conf.js","browser-tests:test-rollup":"karma start --single-run --browsers ChromeHeadless test/karma.rollup.conf.js","browser-tests:test-webpack":"karma start --single-run --browsers ChromeHeadless test/karma.webpack.conf.js","browser-tests:test-browserify":"karma start --single-run --browsers ChromeHeadless test/karma.browserify.conf.js"},"targets":{"parcel_tests":{"context":"browser"}},"_npmUser":{"name":"alcuadrado","email":"email@patriciopalladino.com"},"repository":{"url":"git+https://github.com/ethereum/js-ethereum-cryptography.git","type":"git"},"_npmVersion":"7.20.3","description":"All the cryptographic primitives used in Ethereum","directories":{},"sideEffects":false,"_nodeVersion":"12.22.7","dependencies":{"micro-base":"^0.10.0","@noble/hashes":"^0.5.2","@noble/secp256k1":"^1.3.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"karma":"^4.3.0","mocha":"^6.2.0","parcel":"^2.0.0-rc.0","rimraf":"^3.0.0","rollup":"^2.53.0","tslint":"^5.19.0","ts-node":"^8.3.0","webpack":"^4.39.3","prettier":"1.18.2","browserify":"^16.5.0","typescript":"^4.3.5","@types/node":"^16.9.2","karma-mocha":"^1.3.0","npm-run-all":"^4.1.5","webpack-cli":"^3.3.8","@types/mocha":"^5.2.7","karma-mocha-reporter":"^2.2.5","karma-chrome-launcher":"^3.1.0","rollup-plugin-commonjs":"^10.1.0","tslint-config-prettier":"^1.18.0","tslint-plugin-prettier":"^2.0.1","@rollup/plugin-commonjs":"^20.0.0","rollup-plugin-node-resolve":"^5.2.0","@rollup/plugin-node-resolve":"^13.0.4"},"_npmOperationalInternal":{"tmp":"tmp/ethereum-cryptography_0.2.4_1640354169622_0.5700063748956294","host":"s3://npm-registry-packages"},"publish_time":1640354169866,"_cnpm_publish_time":1640354169866,"dist-tags":{"latest":"3.2.0"}}