Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace secp256k1

Functions

contextRandomize

  • contextRandomize(seed: Uint8Array): void
  • Updates the context randomization to protect against side-channel leakage, seed should be Uint8Array with length 32.

    Parameters

    • seed: Uint8Array

    Returns void

createPrivateKey

  • createPrivateKey(): Promise<Uint8Array>
  • Returns Promise<Uint8Array>

createPrivateKeySync

  • createPrivateKeySync(): Uint8Array
  • Returns Uint8Array

ecdh

  • ecdh(publicKey: Uint8Array, privateKey: Uint8Array, opt?: ecdhOptions, output?: Uint8Array | function): Uint8Array
  • Compute an EC Diffie-Hellman secret and applied sha256 to compressed public key.

    Parameters

    • publicKey: Uint8Array
    • privateKey: Uint8Array
    • Optional opt: ecdhOptions
    • Optional output: Uint8Array | function

    Returns Uint8Array

ecdsaRecover

  • ecdsaRecover(signature: Uint8Array, recid: number, message: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Recover an ECDSA public key from a signature.

    Parameters

    • signature: Uint8Array
    • recid: number
    • message: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

ecdsaSign

  • ecdsaSign(message: Uint8Array, privateKey: Uint8Array, options?: SignOptions, output?: Uint8Array | function): object
  • 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).

    Parameters

    • message: Uint8Array
    • privateKey: Uint8Array
    • Optional options: SignOptions
    • Optional output: Uint8Array | function

    Returns object

    • recid: number
    • signature: Uint8Array

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.

    Parameters

    • signature: Uint8Array
    • message: Uint8Array
    • publicKey: Uint8Array

    Returns boolean

privateKeyExport

  • privateKeyExport(privateKey: Uint8Array, compressed?: boolean): Uint8Array
  • Export a privateKey in DER format.

    Parameters

    • privateKey: Uint8Array
    • Optional compressed: boolean

    Returns Uint8Array

privateKeyImport

  • privateKeyImport(privateKey: Uint8Array): Uint8Array
  • Import a privateKey in DER format.

    Parameters

    • privateKey: Uint8Array

    Returns Uint8Array

privateKeyModInverse

  • privateKeyModInverse(privateKey: Uint8Array): Uint8Array
  • Compute the inverse of a privateKey (modulo the order of the curve's base point).

    Parameters

    • privateKey: Uint8Array

    Returns Uint8Array

privateKeyNegate

  • privateKeyNegate(privateKey: Uint8Array): Uint8Array
  • Negate a privateKey by subtracting it from the order of the curve's base point.

    Parameters

    • privateKey: Uint8Array

    Returns Uint8Array

privateKeyTweakAdd

  • privateKeyTweakAdd(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array
  • Tweak a privateKey by adding tweak to it.

    Parameters

    • privateKey: Uint8Array
    • tweak: Uint8Array

    Returns Uint8Array

privateKeyTweakMul

  • privateKeyTweakMul(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array
  • Tweak a privateKey by multiplying it by a tweak.

    Parameters

    • privateKey: Uint8Array
    • tweak: Uint8Array

    Returns Uint8Array

privateKeyVerify

  • privateKeyVerify(privateKey: Uint8Array): boolean
  • Verify an ECDSA privateKey.

    Parameters

    • privateKey: Uint8Array

    Returns boolean

publicKeyCombine

  • publicKeyCombine(publicKeys: Uint8Array[], compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Add a given publicKeys together.

    Parameters

    • publicKeys: Uint8Array[]
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyConvert

  • publicKeyConvert(publicKey: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Convert a publicKey to compressed or uncompressed form.

    Parameters

    • publicKey: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyCreate

  • publicKeyCreate(privateKey: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Compute the public key for a privateKey.

    Parameters

    • privateKey: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyNegate

  • publicKeyNegate(publicKey: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Negates a public key in place.

    Parameters

    • publicKey: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyTweakAdd

  • publicKeyTweakAdd(publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Tweak a publicKey by adding tweak times the generator to it.

    Parameters

    • publicKey: Uint8Array
    • tweak: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyTweakMul

  • publicKeyTweakMul(publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, output?: Uint8Array | function): Uint8Array
  • Tweak a publicKey by multiplying it by a tweak value.

    Parameters

    • publicKey: Uint8Array
    • tweak: Uint8Array
    • Optional compressed: boolean
    • Optional output: Uint8Array | function

    Returns Uint8Array

publicKeyVerify

  • publicKeyVerify(publicKey: Uint8Array): boolean
  • Verify an ECDSA publicKey.

    Parameters

    • publicKey: Uint8Array

    Returns boolean

signatureExport

  • signatureExport(signature: Uint8Array, output?: Uint8Array | function): Uint8Array
  • Serialize an ECDSA signature in DER format.

    Parameters

    • signature: Uint8Array
    • Optional output: Uint8Array | function

    Returns Uint8Array

signatureImport

  • signatureImport(signature: Uint8Array, output?: Uint8Array | function): Uint8Array
  • Parse a DER ECDSA signature (follow by BIP66).

    Parameters

    • signature: Uint8Array
    • Optional output: Uint8Array | function

    Returns Uint8Array

signatureNormalize

  • signatureNormalize(signature: Uint8Array): Uint8Array
  • Convert a signature to a normalized lower-S form.

    Parameters

    • signature: Uint8Array

    Returns Uint8Array

Generated using TypeDoc