tiny-secp256k1 v2.2.3
tiny-secp256k1
This library is under development, and, like the secp256k1 C library it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.
Installation
npm
npm install tiny-secp256k1yarn
yarn add tiny-secp256k1If you are having problems, please read the guide at secp256k1-node, as the build instructions should be exactly the same (and this module is a direct derivation).
Documentation
isPoint (A)
isPoint :: Buffer -> BoolReturns false if
Ais not encoded with a sequence tag of0x02,0x03or0x04A.xis not in[1...p - 1]A.yis not in[1...p - 1]
isPointCompressed (A)
isPointCompressed :: Buffer -> BoolReturns false if the signature is not compressed.
isPrivate (d)
isPrivate :: Buffer -> BoolReturns false if
dis not 256-bit, ordis not in[1..order - 1]
pointAdd (A, B, compressed)
pointAdd :: Buffer -> Buffer [-> Bool] -> Maybe BufferReturns null if result is at infinity.
Throws:
Expected Pointif!isPoint(A)Expected Pointif!isPoint(B)
pointAddScalar (A, tweak, compressed)
pointAddScalar :: Buffer -> Buffer [-> Bool] -> Maybe BufferReturns null if result is at infinity.
Throws:
Expected Pointif!isPoint(A)Expected Tweakiftweakis not in[0...order - 1]
pointCompress (A, compressed)
pointCompress :: Buffer -> Bool -> BufferThrows:
Expected Pointif!isPoint(A)
pointFromScalar (d, compressed)
pointFromScalar :: Buffer [-> Bool] -> Maybe BufferReturns null if result is at infinity.
Throws:
Expected Privateif!isPrivate(d)
pointMultiply (A, tweak, compressed)
pointMultiply :: Buffer -> Buffer [-> Bool] -> Maybe BufferReturns null if result is at infinity.
Throws:
Expected Pointif!isPoint(A)Expected Tweakiftweakis not in[0...order - 1]
privateAdd (d, tweak)
privateAdd :: Buffer -> Buffer -> Maybe BufferReturns null if result is equal to 0.
Throws:
Expected Privateif!isPrivate(d)Expected Tweakiftweakis not in[0...order - 1]
privateSub (d, tweak)
privateSub :: Buffer -> Buffer -> Maybe BufferReturns null if result is equal to 0.
Throws:
Expected Privateif!isPrivate(d)Expected Tweakiftweakis not in[0...order - 1]
sign (h, d)
sign :: Buffer -> Buffer -> BufferReturns normalized signatures, each of (r, s) values are guaranteed to less than order / 2.
Uses RFC6979.
Throws:
Expected Privateif!isPrivate(d)Expected Scalarifhis not 256-bit
signWithEntropy (h, d, e)
sign :: Buffer -> Buffer -> Buffer -> BufferReturns normalized signatures, each of (r, s) values are guaranteed to less than order / 2.
Uses RFC6979.
Adds e as Added Entropy to the deterministic k generation.
Throws:
Expected Privateif!isPrivate(d)Expected Scalarifhis not 256-bitExpected Extra Data (32 bytes)ifeis not 256-bit
verify (h, Q, signature, strict = false)
verify :: Buffer -> Buffer -> Buffer -> BoolReturns false if any of (r, s) values are equal to 0, or if the signature is rejected.
If strict is true, valid signatures with any of (r, s) values greater than order / 2 are rejected.
Throws:
Expected Pointif!isPoint(Q)Expected Signatureifsignaturehas any (r, s) values not in range[0...order - 1]Expected Scalarifhis not 256-bit
Credit
This is a partially derived work of https://github.com/cryptocoinjs/secp256k1-node, specifically this commit.
This library uses the native library secp256k1 by the bitcoin-core developers, including derivatives of its tests and test vectors.
LICENSE MIT
1 year ago
2 years ago
2 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
