Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "ecdsa"

Index

Functions

Const generateK

  • generateK(hash: Buffer, privateKey: Buffer, curve?: Curve): bigint
  • Generate a deterministic value for k, according to RFC6979.

    Parameters

    • hash: Buffer
    • privateKey: Buffer
    • Default value curve: Curve = secp256k1

    Returns bigint

Const getHashedMessage

  • getHashedMessage(message: string | Buffer, prefix?: boolean): Buffer
  • Get the message hashed with hash('\x19Ethereum Signed Message:\n32', hash(message)). The hash used is Keccak-256, and the output should match the hashes used by eth_sign.

    Parameters

    • message: string | Buffer
    • Default value prefix: boolean = true

    Returns Buffer

Const isValidPrivateKey

  • isValidPrivateKey(privateKey: bigint, curve: Curve): boolean
  • Check if a private key is within the range 0 < x < n.

    Parameters

    • privateKey: bigint
    • curve: Curve

    Returns boolean

Const recover

  • recover(message: string, __namedParameters: object, curve?: Curve): string
  • Recover an Ethereum address from a message and signature. Returns the address as string.

    Parameters

    • message: string
    • __namedParameters: object
      • r: bigint
      • s: bigint
      • v: number
    • Default value curve: Curve = secp256k1

    Returns string

Const sign

  • sign(message: string | Buffer, privateKey: Buffer, deterministic?: boolean, prefix?: boolean, chainId?: undefined | number, curve?: Curve): ECDSASignature
  • Sign a message with the private key. When deterministic is set to true (default), this will use RFC6979 to generate a deterministic k value, otherwise a random k value is used. If a chainId is specified, this will use EIP-155 for the v value.

    Note that the message is automatically hashed and prefixed, to match the hashes used by eth_sign, unless prefix is disabled.

    Parameters

    • message: string | Buffer
    • privateKey: Buffer
    • Default value deterministic: boolean = true
    • Default value prefix: boolean = true
    • Optional chainId: undefined | number
    • Default value curve: Curve = secp256k1

    Returns ECDSASignature

Const signTransaction

  • signTransaction(transaction: Transaction, privateKey: Buffer): object
  • Sign a transaction with a private key. Returns the RLP encoded signed transaction as Buffer.

    Parameters

    Returns object

    • raw: Buffer
    • signed: Buffer

Const verify

  • verify(message: string, __namedParameters: object, publicKey: Buffer, curve?: Curve): boolean
  • Verify a message with a signature and public key. Returns true if the signature is valid, or false otherwise.

    Parameters

    • message: string
    • __namedParameters: object
      • r: bigint
      • s: bigint
    • publicKey: Buffer
    • Default value curve: Curve = secp256k1

    Returns boolean

Generated using TypeDoc