@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

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 key d, 32-byte scalar nonce k. - Compute point R = k * G. Reject nonce if R's x coordinate is zero. - Compute 32-byte scalar r, the serialization of R's x coordinate. - Compose 32-byte scalar s = k^-1 * (r * d + m). Reject nonce if s 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 point Q, signature: (32-byte r, scalar s). - Signature is invalid if r is zero. - Signature is invalid if s is zero. - Compute point R = (s^-1 * m * G + s^-1 * r * Q). Reject if R is infinity. - Signature is valid if R's x coordinate equals to r.

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 {}

    property data

    data?: Uint8Array | undefined;

      property hashfn

      hashfn?:
      | ((x: Uint8Array, y: Uint8Array, data: Uint8Array) => Uint8Array)
      | undefined;

        property xbuf

        xbuf?: Uint8Array | undefined;

          property ybuf

          ybuf?: Uint8Array | undefined;

            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 onejsDocs.io badgeto 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
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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>