@types/secp256k1
- Version 4.0.6
- Published
- 8.05 kB
- 1 dependency
- MIT license
Install
npm i @types/secp256k1
yarn add @types/secp256k1
pnpm add @types/secp256k1
Overview
TypeScript definitions for secp256k1
Index
Functions
- contextRandomize()
- ecdh()
- ecdsaRecover()
- ecdsaSign()
- ecdsaVerify()
- privateKeyExport()
- privateKeyImport()
- privateKeyModInverse()
- privateKeyNegate()
- privateKeyTweakAdd()
- privateKeyTweakMul()
- privateKeyVerify()
- publicKeyCombine()
- publicKeyConvert()
- publicKeyCreate()
- publicKeyNegate()
- publicKeyTweakAdd()
- publicKeyTweakMul()
- publicKeyVerify()
- signatureExport()
- signatureImport()
- signatureNormalize()
Interfaces
Functions
function contextRandomize
contextRandomize: (seed: Uint8Array) => void;
Updates the context randomization to protect against side-channel leakage,
seed
should be Uint8Array with length 32.
function ecdh
ecdh: ( publicKey: Uint8Array, privateKey: Uint8Array, opt?: ecdhOptions, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Compute an EC Diffie-Hellman secret and applied sha256 to compressed public key.
function ecdsaRecover
ecdsaRecover: ( signature: Uint8Array, recid: number, message: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Recover an ECDSA public key from a signature.
function ecdsaSign
ecdsaSign: ( message: Uint8Array, privateKey: Uint8Array, options?: SignOptions, output?: Uint8Array | ((len: number) => Uint8Array)) => { signature: Uint8Array; recid: number };
Create an ECDSA signature. Always return low-S signature.
Inputs: 32-byte message
m
, 32-byte scalar keyd
, 32-byte scalar noncek
. - Compute pointR = k * G
. Reject nonce if R'sx
coordinate is zero. - Compute 32-byte scalarr
, the serialization of R'sx
coordinate. - Compose 32-byte scalars = k^-1 * (r * d + m)
. Reject nonce ifs
is zero. - The signature is(r, s)
.
function ecdsaVerify
ecdsaVerify: ( signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array) => boolean;
Verify an ECDSA signature.
Note: return false for high signatures!
Inputs: 32-byte message
m
, public key pointQ
, signature: (32-byter
, scalars
). - Signature is invalid ifr
is zero. - Signature is invalid ifs
is zero. - Compute pointR = (s^-1 * m * G + s^-1 * r * Q)
. Reject ifR
is infinity. - Signature is valid if R'sx
coordinate equals tor
.
function privateKeyExport
privateKeyExport: (privateKey: Uint8Array, compressed?: boolean) => Uint8Array;
Export a privateKey in DER format.
function privateKeyImport
privateKeyImport: (privateKey: Uint8Array) => Uint8Array;
Import a privateKey in DER format.
function privateKeyModInverse
privateKeyModInverse: (privateKey: Uint8Array) => Uint8Array;
Compute the inverse of a privateKey (modulo the order of the curve's base point).
function privateKeyNegate
privateKeyNegate: (privateKey: Uint8Array) => Uint8Array;
Negate a privateKey by subtracting it from the order of the curve's base point.
function privateKeyTweakAdd
privateKeyTweakAdd: (privateKey: Uint8Array, tweak: Uint8Array) => Uint8Array;
Tweak a privateKey by adding tweak to it.
function privateKeyTweakMul
privateKeyTweakMul: (privateKey: Uint8Array, tweak: Uint8Array) => Uint8Array;
Tweak a privateKey by multiplying it by a tweak.
function privateKeyVerify
privateKeyVerify: (privateKey: Uint8Array) => boolean;
Verify an ECDSA privateKey.
function publicKeyCombine
publicKeyCombine: ( publicKeys: Uint8Array[], compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Add a given publicKeys together.
function publicKeyConvert
publicKeyConvert: ( publicKey: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Convert a publicKey to compressed or uncompressed form.
function publicKeyCreate
publicKeyCreate: ( privateKey: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Compute the public key for a privateKey.
function publicKeyNegate
publicKeyNegate: ( publicKey: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Negates a public key in place.
function publicKeyTweakAdd
publicKeyTweakAdd: ( publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Tweak a publicKey by adding tweak times the generator to it.
function publicKeyTweakMul
publicKeyTweakMul: ( publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Tweak a publicKey by multiplying it by a tweak value.
function publicKeyVerify
publicKeyVerify: (publicKey: Uint8Array) => boolean;
Verify an ECDSA publicKey.
function signatureExport
signatureExport: ( signature: Uint8Array, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Serialize an ECDSA signature in DER format.
function signatureImport
signatureImport: ( signature: Uint8Array, output?: Uint8Array | ((len: number) => Uint8Array)) => Uint8Array;
Parse a DER ECDSA signature (follow by BIP66).
function signatureNormalize
signatureNormalize: (signature: Uint8Array) => Uint8Array;
Convert a signature to a normalized lower-S form.
Interfaces
interface ecdhOptions
interface ecdhOptions {}
interface SignOptions
interface SignOptions {}
Options for the
sign
function
property data
data?: Uint8Array | undefined;
Additional data for noncefn (RFC 6979 3.6) (32 bytes).
By default is
null
.
property noncefn
noncefn?: | (( message: Uint8Array, privateKey: Uint8Array, algo: Uint8Array | null, data: Uint8Array | null, attempt: number ) => Uint8Array) | undefined;
Nonce generator. By default it is rfc6979
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/secp256k1
.
- Markdown[](https://www.jsdocs.io/package/@types/secp256k1)
- HTML<a href="https://www.jsdocs.io/package/@types/secp256k1"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 906 ms. - Missing or incorrect documentation? Open an issue for this package.