{"name":"tiny-secp256k1","version":"2.0.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","main":"./lib/index.js","browser":{"./lib/rand.js":"./lib/rand.browser.js","./lib/wasm_loader.js":"./lib/wasm_loader.browser.js"},"types":"./types/index.d.ts","devDependencies":{"@types/node":"^14.14.35","@typescript-eslint/eslint-plugin":"^4.18.0","@typescript-eslint/parser":"^4.18.0","browser-run":"^10.0.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"},"gitHead":"a155b1a6bfab385c0edcd8d82035415866727593","_id":"tiny-secp256k1@2.0.0","_nodeVersion":"14.16.1","_npmVersion":"7.11.1","dist":{"integrity":"sha512-fL2GZvXKbsXI3cV+uOpEThSiljKwyXOtmGCEh09j+eysTVdPwgei3yogM8BiXMwxDTlMZjQLYpiJLb1gO0vstw==","shasum":"b628df0697f6a2535c55e0bb90332d0cb03e7712","tarball":"http://registry-npm.ywwl.com/tiny-secp256k1/download/tiny-secp256k1-2.0.0.tgz","fileCount":18,"unpackedSize":200498,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghoVrCRA9TVsSAnZWagAAx7gP/2AN1FhXzQxhq7PlR4WM\n0ZSGqio3GsMPaPj2c9F88oxmsoubaeBxSNGcvmBfLqfcfK9nH0hLTBIRg1Mu\nw5ph+dxuEVRwUheBCGMMcllgM+o7SAMcMCl+GWZq6J7pwnFblMtcPAfuEOtg\nYU7VJjvkgVQOMBcYGiQ3zJIQ3hMPw4tHeV9mJDdDDexiK581dm/r7jy7vWkk\nMk5mLSjMrqN2FWaSTHWDBiZEHUaGuTAMNSjsqnkfyzNJVaiTejEf98Qu3YmI\n32tQ51dykUPyb0B9gXrUswBUD/wrUugUaqLdnfxs7I1ki5EwBBzjoILvb5jV\natEcGi4B1yxD8LoDbiRwtBIdv5pF4Vwt7nDV+cNNVZ/HGwmxbZNqZ5C230EN\nBrdoX0QfvAxAO29lByEgLDTNJ/R0oCXdaS/19eaGmqABCYVHhtEcI9jgXuIj\nnEDgDKlUyF8nAlPZe3ecLem9fP9pytytT4SlxdDPbUO9Wqr50NwJXW7pWlAa\nOt/HFWRPW4oGqUXV1rECbNVlWrmTm2V6JZ4lzzx1kzm10Y7TSN5O0aPatSKn\nJHmWmQbtQ7DT9wXzJ2NVZyR26rYaITmdYoXwbOAc51PsaVwKHvScudde46MY\nMpxcc+p65jt2dvURFW74IYAVAqzIKHaf8Ivp86eilZUsnLf7PsSD9OEiVj7O\nzgK6\r\n=1auB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIVYkD6q47tSdA302N69fYSGG3rGrnQ+IMSmEIVIufxgIhAJZC2FJsjjoldrPkulCCCS7CALcN9TKbIg6D/cTrM2dn"}],"size":60841,"noattachment":false,"key":"/tiny-secp256k1/-/tiny-secp256k1-2.0.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.0.0_1619428715418_0.9951801498827502"},"_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":1619428715582,"_cnpm_publish_time":1619428715582,"dist-tags":{"latest":"2.2.5","test":"0.0.0-rc-1560324438"}}