{"name":"tiny-secp256k1","version":"2.2.0","description":"A tiny secp256k1 JS","homepage":"https://github.com/bitcoinjs/tiny-secp256k1#readme","bugs":{"url":"https://github.com/bitcoinjs/tiny-secp256k1/issues"},"repository":{"type":"git","url":"git+https://github.com/bitcoinjs/tiny-secp256k1.git"},"license":"MIT","type":"module","exports":{".":{"node":{"module":"./lib/index.js","require":"./lib/cjs/index.cjs","import":"./lib/index.js"},"browser":"./lib/index.js","default":"./lib/index.js"}},"browser":{"./lib/rand.js":"./lib/rand.browser.js","./lib/wasm_loader.js":"./lib/wasm_loader.browser.js"},"types":"./lib/index.d.ts","dependencies":{"uint8array-tools":"0.0.6"},"devDependencies":{"@types/node":"^14.14.35","@typescript-eslint/eslint-plugin":"^4.18.0","@typescript-eslint/parser":"^4.18.0","browser-run":"^10.1.0","buffer":"^6.0.3","eslint":"^7.22.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","nyc":"^15.1.0","path-browserify":"^1.0.1","prettier":"^2.2.1","process":"^0.11.10","sort-package-json":"^1.49.0","stream-browserify":"^3.0.0","tap-summary":"^4.0.0","tape":"^5.2.2","typescript":"^4.2.3","webpack":"^5.24.4","webpack-cli":"^4.5.0"},"engines":{"node":">=14.0.0"},"_resolved":"","_integrity":"","_from":"file:tiny-secp256k1-2.2.0.tgz","_id":"tiny-secp256k1@2.2.0","_nodeVersion":"14.18.1","_npmVersion":"6.14.15","dist":{"integrity":"sha512-2hPuUGCroLrxh6xxwoe+1RgPpOOK1w2uTnhgiHBpvoutBR+krNuT4hOXQyOaaYnZgoXBB6hBYkuAJHxyeBOPzQ==","shasum":"e1247beba4429113c491070fc6bd48c3bf392c55","tarball":"http://registry-npm.ywwl.com/tiny-secp256k1/download/tiny-secp256k1-2.2.0.tgz","fileCount":28,"unpackedSize":249420,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh681hCRA9TVsSAnZWagAAujcP/Ro2rFZcNE0fXjErBrA5\nJm2jEiRAKndRHo8kQABEv1hRfc0xykaPxhTRkKF7o6fSB/L5JgjCaYLB8CPt\nBl7HpBaYi7eU0v7GorGtTJoJ8PNopmivrfOZjmvxtAdiNEZCDNf75r1onnSS\nQmI5CTNHQZG2V6t45RAxeoHBNwQhXyFxlyVYbAEXnLZ92+HjzIWq9KdL1wiK\nMlcyawBATRxSe9P2ljzrF1d9oS/UyEUe/ChWHBI+7sihOjQcfczh/pVYmq29\nZxae8mhaFt3A0031OXkfiIK4XnyjFPeqf1o/NwVokTo64g82d65udA8ObmuV\n1s11TYR5LbrSWBBM700wAKWaQhJOqsaCoiV6k3iH7mM7UomWheLH4v2G4tIH\nHIHuielHNbzdXK/FiW5jmo1+CjVSU5gKXr4El5sD+t8IoPJcuMtee5oR0l+D\nU110YgrdADzqJ/DQGg/rzjdyC/2an5ELtH+G7YzwD0k0fJjpg4i0ae7PT2oX\nK4IMYoumgYj9RNTo+Cazr6hXQk0ONqK3R6HUIbCLJLfHoqVpLsiJvjAxWV7O\nVjGw8AdwVvPaAwWMiViR3icQNwv9DWx9TdwxbAZl2/tR4N9Giz+lLLJp4uV1\nosdBtnJ3BibpH5b8W19RU74GNrqABPU2z5RVymbeIOGvM/C4FBwfu2vrmurr\n4rFH\r\n=4j9c\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDyoem2CkioX3lAMrL3DMDNu95gS0ah/JnctoCn3BLonAiEAkwPMo7fwpeKGR45jvqKiw5W1lROPU6kE3nsFHAoGSZA="}],"size":71350,"noattachment":false,"key":"/tiny-secp256k1/-/tiny-secp256k1-2.2.0.tgz"},"_npmUser":{"name":"junderw","email":"junderwood@bitcoinbank.co.jp"},"directories":{},"maintainers":[{"name":"jprichardson","email":"jprichardson@gmail.com"},{"name":"junderw","email":"junderwood@bitcoinbank.co.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tiny-secp256k1_2.2.0_1642843489591_0.9421561266710858"},"_hasShrinkwrap":false,"readme":"# tiny-secp256k1\n\n[![NPM](https://img.shields.io/npm/v/tiny-secp256k1.svg)](https://www.npmjs.org/package/tiny-secp256k1)\n\nThis library is under development, and, like the [secp256k1](https://github.com/bitcoin-core/secp256k1) C library (through [secp256k1-sys](https://github.com/rust-bitcoin/rust-secp256k1/) Rust crate) it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.\n\n## Installation\n\n### npm\n\n```bash\nnpm install tiny-secp256k1\n```\n\n### yarn\n\n```bash\nyarn add tiny-secp256k1\n```\n\n## WebAssembly and Node.js version\n\nPrevious version of `tiny-secp256k1` implement [C++ addon](https://nodejs.org/api/addons.html) through [NAN (Native Abstractions for Node.js)](https://github.com/nodejs/nan) and [elliptic](https://github.com/indutny/elliptic) as fallback when addon can not be built or in browser-like environement.\n\nCurrent version use Rust crate (which use C library) compiled to [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly). With Wasm same code executed in any environment. Wasm is faster than `elliptic` but slower than node bindings ([results in PR](https://github.com/bitcoinjs/tiny-secp256k1/pull/53#issuecomment-801844450) or you can run own benchmark in `benches` directory).\n\n## Building\n\nFor building locally you need C/C++ toolchain, Rust version >=1.50.0 and `wasm-opt` from [binaryen](https://github.com/WebAssembly/binaryen).\n\n[rustup](https://rustup.rs/) is a recommended way to install `Rust`. You also will need `wasm32-unknown-unknown` target.\n\n```\nrustup toolchain install stable --target wasm32-unknown-unknown --component clippy --component rustfmt\n```\n\nAfter installing development dependencies with `npm` you can build Wasm:\n\n```\nmake build-wasm\n```\n\nor run tests:\n\n```\nmake test\n```\n\nAlternative way is to use [Docker](https://www.docker.com/):\n\n```\n% docker build -t tiny-secp256k1 .\n% docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1\n# make build\n```\n\n## Examples\n\n`tiny-secp256k1` includes two examples. First is [simple script for Node.js](examples/random-in-node) which generate random data and print arguments and methods results. Second is [React app](examples/react-app).\n\nReact app is builded in GitHub Actions on each commit to master branch and uploaded to [gh-pages](https://github.com/bitcoinjs/tiny-secp256k1/tree/gh-pages) branch, which is always available online: https://bitcoinjs.github.io/tiny-secp256k1/\n\n## Documentation\n\n### isPoint (A)\n\n```haskell\nisPoint :: Buffer -> Bool\n```\n\nReturns `false` if\n\n- `A` is not encoded with a sequence tag of `0x02`, `0x03` or `0x04`\n- `A.x` is not in `[1...p - 1]`\n- `A.y` is not in `[1...p - 1]`\n\n### isPointCompressed (A)\n\n```haskell\nisPointCompressed :: Buffer -> Bool\n```\n\nReturns `false` if the pubkey is **not** compressed.\n\n### isXOnlyPoint (A)\n\n```haskell\nisXOnlyPoint :: Buffer -> Bool\n```\n\nReturns `false` if the pubkey is **not** an xOnlyPubkey.\n\n### isPrivate (d)\n\n```haskell\nisPrivate :: Buffer -> Bool\n```\n\nReturns `false` if\n\n- `d` is not 256-bit, or\n- `d` is not in `[1..order - 1]`\n\n### pointAdd (A, B[, compressed])\n\n```haskell\npointAdd :: Buffer -> Buffer [-> Bool] -> Maybe Buffer\n```\n\nReturns `null` if result is at infinity.\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(A)`\n- `Expected Point` if `!isPoint(B)`\n\n### pointAddScalar (A, tweak[, compressed])\n\n```haskell\npointAddScalar :: Buffer -> Buffer [-> Bool] -> Maybe Buffer\n```\n\nReturns `null` if result is at infinity.\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(A)`\n- `Expected Tweak` if `tweak` is not in `[0...order - 1]`\n\n### pointCompress (A, compressed)\n\n```haskell\npointCompress :: Buffer -> Bool -> Buffer\n```\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(A)`\n\n### pointFromScalar (d[, compressed])\n\n```haskell\npointFromScalar :: Buffer [-> Bool] -> Maybe Buffer\n```\n\nReturns `null` if result is at infinity.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n\n### xOnlyPointFromScalar (d)\n\n```haskell\nxOnlyPointFromScalar :: Buffer -> Buffer\n```\n\nReturns the xOnlyPubkey for a given private key\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n\n### xOnlyPointFromPoint (p)\n\n```haskell\nxOnlyPointFromPoint :: Buffer -> Buffer\n```\n\nReturns the xOnlyPubkey for a given DER public key\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(p)`\n\n### pointMultiply (A, tweak[, compressed])\n\n```haskell\npointMultiply :: Buffer -> Buffer [-> Bool] -> Maybe Buffer\n```\n\nReturns `null` if result is at infinity.\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(A)`\n- `Expected Tweak` if `tweak` is not in `[0...order - 1]`\n\n### privateAdd (d, tweak)\n\n```haskell\nprivateAdd :: Buffer -> Buffer -> Maybe Buffer\n```\n\nReturns `null` if result is equal to `0`.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n- `Expected Tweak` if `tweak` is not in `[0...order - 1]`\n\n### privateSub (d, tweak)\n\n```haskell\nprivateSub :: Buffer -> Buffer -> Maybe Buffer\n```\n\nReturns `null` if result is equal to `0`.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n- `Expected Tweak` if `tweak` is not in `[0...order - 1]`\n\n### privateNegate (d)\n\n```haskell\nprivateNegate :: Buffer -> Buffer\n```\n\nReturns the negation of d on the order n (`n - d`)\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n\n### xOnlyPointAddTweak (p, tweak)\n\n```haskell\nxOnlyPointAddTweak :: Buffer -> Buffer -> { parity: 1 | 0; xOnlyPubkey: Buffer; }\n```\n\nReturns the tweaked xOnlyPubkey along with the parity bit (number type of 1|0)\n\n##### Throws:\n\n- `Expected Point` if `!isXOnlyPoint(p)`\n- `Expected Tweak` if `!isXOnlyPoint(tweak)`\n\n### xOnlyPointAddTweakCheck (p1, p2, tweak[, tweakParity])\n\n```haskell\nxOnlyPointAddTweakCheck :: Buffer -> Buffer -> Buffer [-> 1 | 0] -> Bool\n```\n\nChecks the tweaked pubkey (p2) against the original pubkey (p1) and tweak.\nThis is slightly slower if you include tweakParity, tweakParity will make it\nfaster for aggregation later on.\n\n##### Throws:\n\n- `Expected Point` if `!isXOnlyPoint(p1)`\n- `Expected Point` if `!isXOnlyPoint(p2)`\n- `Expected Tweak` if `!isXOnlyPoint(tweak)`\n- `Expected Parity` if `tweakParity is not 1 or 0`\n\n### sign (h, d[, e])\n\n```haskell\nsign :: Buffer -> Buffer [-> Buffer] -> Buffer\n```\n\nReturns normalized signatures, each of (r, s) values are guaranteed to less than `order / 2`.\nUses RFC6979.\nAdds `e` as Added Entropy to the deterministic k generation.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n- `Expected Scalar` if `h` is not 256-bit\n- `Expected Extra Data (32 bytes)` if `e` is not 256-bit\n\n### signRecoverable (h, d[, e])\n\n```haskell\nsignRecoverable :: Buffer -> Buffer [-> Buffer] -> { recoveryId: 0 | 1 | 2 | 3; signature: Buffer; }\n```\n\nReturns normalized signatures and recovery Id, each of (r, s) values are guaranteed to less than `order / 2`.\nUses RFC6979.\nAdds `e` as Added Entropy to the deterministic k generation.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n- `Expected Scalar` if `h` is not 256-bit\n- `Expected Extra Data (32 bytes)` if `e` is not 256-bit\n\n### signSchnorr (h, d[, e])\n\n```haskell\nsignSchnorr :: Buffer -> Buffer [-> Buffer] -> Buffer\n```\n\nReturns normalized schnorr signature.\nUses BIP340 nonce generation.\nAdds `e` as Added Entropy.\n\n##### Throws:\n\n- `Expected Private` if `!isPrivate(d)`\n- `Expected Scalar` if `h` is not 256-bit\n- `Expected Extra Data (32 bytes)` if `e` is not 256-bit\n\n### verify (h, Q, signature[, strict = false])\n\n```haskell\nverify :: Buffer -> Buffer -> Buffer [-> Bool] -> Bool\n```\n\nReturns `false` if any of (r, s) values are equal to `0`, or if the signature is rejected.\n\nIf `strict` is `true`, valid signatures with any of (r, s) values greater than `order / 2` are rejected.\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(Q)`\n- `Expected Signature` if `signature` has any (r, s) values not in range `[0...order - 1]`\n- `Expected Scalar` if `h` is not 256-bit\n\n### recover (h, signature, recoveryId[, compressed = false])\n\n```haskell\nverify :: Buffer -> Buffer -> Number [-> Bool] -> Maybe Buffer\n```\n\nReturns the ECDSA public key from a signature if it can be recovered, `null` otherwise.\n\n\n##### Throws:\n\n- `Expected Signature` if `signature` has any (r, s) values not in range `(0...order - 1]`\n- `Bad Recovery Id` if `recid & 2 !== 0`  and `signature` has any r value not in range `(0...P - N - 1]`\n- `Expected Hash` if `h` is not 256-bit\n\n\n### verifySchnorr (h, Q, signature)\n\n```haskell\nverifySchnorr :: Buffer -> Buffer -> Buffer -> Bool\n```\n\nReturns `false` if any of (r, s) values are equal to `0`, or if the signature is rejected.\n\n##### Throws:\n\n- `Expected Point` if `!isPoint(Q)`\n- `Expected Signature` if `signature` has any (r, s) values not in range `[0...order - 1]`\n- `Expected Scalar` if `h` is not 256-bit\n\n## Credit\n\nThis library uses the native library [secp256k1](https://github.com/bitcoin-core/secp256k1) by the bitcoin-core developers through Rust crate [secp256k1-sys](https://crates.io/crates/secp256k1-sys), including derivatives of its tests and test vectors.\n\n# LICENSE [MIT](LICENSE)\n","publish_time":1642843489744,"_cnpm_publish_time":1642843489744,"dist-tags":{"latest":"2.2.5","test":"0.0.0-rc-1560324438"}}