{"name":"tiny-secp256k1","version":"0.2.0","description":"[![Build Status](https://travis-ci.org/bitcoinjs/tiny-secp256k1.png?branch=master)](https://travis-ci.org/bitcoinjs/tiny-secp256k1) [![NPM](https://img.shields.io/npm/v/tiny-secp256k1.svg)](https://www.npmjs.org/package/tiny-secp256k1) [![js-standard-styl","main":"index.js","gypfile":true,"engines":{"node":">=6.0.0"},"scripts":{"build":"node-gyp rebuild","unit":"tape tests/*.js","test":"npm run unit","install":"node-gyp rebuild"},"repository":{"type":"git","url":"git+https://github.com/dcousens/secp256k1-tiny.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/dcousens/secp256k1-tiny/issues"},"homepage":"https://github.com/dcousens/secp256k1-tiny#readme","dependencies":{"bindings":"^1.3.0","bn.js":"^4.11.8","create-hmac":"^1.1.7","elliptic":"^6.4.0","nan":"^2.10.0"},"devDependencies":{"tape":"^4.9.0"},"gitHead":"e3579d19fdd99d8f6d8d081247f26a629ede318d","_id":"tiny-secp256k1@0.2.0","_npmVersion":"6.1.0","_nodeVersion":"10.4.1","_npmUser":{"name":"dcousens","email":"npm@dcousens.com"},"dist":{"integrity":"sha512-R9632od56YYh+vL536Ja6YGk5f4pUhjoWAoi4W1whzAt8PVIVEyCUpIBt+/+h8x3cpF7BT7oi9ivj3pFsxLF5A==","shasum":"c261217c1a404c68cf3607f24e22cb821ee8d789","tarball":"http://registry-npm.ywwl.com/tiny-secp256k1/download/tiny-secp256k1-0.2.0.tgz","fileCount":116,"unpackedSize":883266,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbKdwQCRA9TVsSAnZWagAAzAsP/jE+HOy2ou4cmNHKqHbe\nAlIQBQYRa0nqO+PlQf51WeAtb24G5utr3VHtmcFR8Hw5uWMc5CcPQWAAIj42\nmKxBRbMWatS3UjpNwln4tyCqPCKi1lzZDMq/GEtiTvhu7OrV60nrIhSPZsyy\npoiSmIW0uFNeWF+jbnjelYiXU936Ew1SxHRbA5c8VuzVz/pLJgJW7UYFLj26\nhq0nG1E8EglJasOD6PqkPjeznQ5LSiNlDTHJZmuHFr4nSXFzwanBxYNWz8Xk\nZgKko3QT2dNjJVIz+4eoQAt0KzVibxRH5EKYINppo8rb2TFb/qNRPifryb37\nNGRXLpBYz3/ohr/g6eVEHZPyz+rT/ittB7CioOefVY8N6VBENHY1/N5DetEn\nTaq0DapqNmx/C2ShCzCwebXhQDznM65gpjJqNc6/JXVjzebI7ARJl4QICEyu\nQau+/5MHMYvI7lrnOGo4cg5UJFa7W+AYTCkDWAVE2V1OGsZDZehLAadZHgkm\nlXa8sFV4ITndyTKqVdQHKBna/0MlX2mIQOyeff73rdi/uL/sqA4mtDclshC5\nkHjtPgrSZ7kxKyqRvvTLsKxlHHUcaxaF4EGxyZL2ZJgn6iNMYEkLCyhG5F+D\nqMLbTNE5RKfKJLFLNPIdi0sYFaXUrRw/UuK97sVhT9mdzgNVWaqAev27p+in\n9wgl\r\n=yUaU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICRHx3acxL9XIntuaf5i4KrO1jc9sEduZkXNTi0/TL7KAiEA2qGSvRHGEu+SDDmY9JF6Fo7MNtyNi5XwUO34AKBJaK4="}],"size":168138,"noattachment":false,"key":"/tiny-secp256k1/-/tiny-secp256k1-0.2.0.tgz"},"maintainers":[{"name":"dcousens","email":"npm@dcousens.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tiny-secp256k1_0.2.0_1529469966680_0.7223796684099817"},"_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":1529469967212,"_cnpm_publish_time":1529469967212,"dist-tags":{"latest":"2.2.5","test":"0.0.0-rc-1560324438"}}