{"name":"tiny-secp256k1","version":"0.0.2","description":"","main":"index.js","gypfile":true,"engines":{"node":">=4.0.0"},"scripts":{"build":"node-gyp rebuild","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":{"bigi":"^1.4.2","bindings":"^1.3.0","create-hmac":"^1.1.7","ecurve":"^1.0.6","nan":"^2.10.0"},"devDependencies":{"tape":"^4.9.0"},"gitHead":"020926e1f06bc11a3b3f03850865939678ae0e30","_id":"tiny-secp256k1@0.0.2","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"dcousens","email":"npm@dcousens.com"},"dist":{"integrity":"sha512-lVZNKtF6/Pyf3taudfQ5FkW4eYHuiZwo27vHye2Q8YupXUFaVTDnNzlmvZZhzwlljagku5JpGMsdnrle5FUAig==","shasum":"913d5222d3ff76f7e7b598813b035528fe57b65b","tarball":"http://registry-npm.ywwl.com/tiny-secp256k1/download/tiny-secp256k1-0.0.2.tgz","fileCount":113,"unpackedSize":862686,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5/aVCRA9TVsSAnZWagAALDAP/RuYwQGkHfHENjNwEWV8\nU1QON6ts79679hXHtpj6VH/7GWWBL+3NcwBtMxsmWxTybCj+ovFqzdv36JZW\nfT4S+GTuu6VeiLDgMtf1WbalMX4IDDabYgrl08u7Y5v3Wfw4OTv4ojSKOgp0\nIMGdOL6iQUPBF9O4GrRSwu8wywHj+T90R/7PKWxjxVz57WOqs7XXMR1BrG0B\n9PHM85pWotws82PdOC5Tze3tfxoMAt3DVmpvzgshEFZfwOT/VukdIVoNfNY6\nlf46zQkCvBU1uwa2eU7pEYxlZFw+x8CMySEZO+cgfv95b8OH34YJPU4o5FUL\nt/twxRmfQdGrIp2owCsOm7wXc7UcUy+5g6UZc7dovtwRMCQIxSAoqvhwSaz4\nUKumvT+ehsd3tMyUHmpda2ufMAwak7ItSuLUOnUvEmVvK4YuEGQyV1s275TC\naaJnj3x/Pw6sgv/Hd3OsLzk82kP4oHYunJGwe4uqqLVfBaReGnA5vm0r1VQY\nbNFxTuGqpQo1AGkiqogtq1EVk1cU8c+bObKF70SQzWRqSCwxhZRkJ9trK3hU\nuIjg7Aq94JGqKGXMfZ7nkTrZOchVCheh1wUSYGC6zvOk79UmYA1HlVbafsqY\nf+JnCQZc0JPoHRwsorACor56000POf3ucef8f2xbD/BJelmSwNuhsi6X4brS\nCIrN\r\n=fVXx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHNxGTiWNVa3PPu5SJ2/Z7e9QoO3nX9CoilY9woDuQeiAiEAvBtxDIZ4zPZdSY7ZFMBDTQZxSzyl1zF1jCHZfhTJ+oY="}],"size":165252,"noattachment":false,"key":"/tiny-secp256k1/-/tiny-secp256k1-0.0.2.tgz"},"maintainers":[{"name":"dcousens","email":"npm@dcousens.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tiny-secp256k1_0.0.2_1525151380907_0.837565678582898"},"_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":1525151381100,"_cnpm_publish_time":1525151381100,"dist-tags":{"latest":"2.2.5","test":"0.0.0-rc-1560324438"}}