Options
All
  • Public
  • Public/Protected
  • All
Menu

@tendermint/sig

Index

Type aliases

BroadcastMode

BroadcastMode: "sync" | "async" | "block"

A transaction broadcast mode.

  • 'sync' defines a transaction broadcasting mode where the client returns immediately.
  • 'async' defines a transaction broadcasting mode where the client waits for a CheckTx execution response only.
  • 'block' defines a transaction broadcasting mode where the client waits for the transaction to be committed in a block.

Variables

Const BROADCAST_MODE_ASYNC

BROADCAST_MODE_ASYNC: "async" = "async"

Defines a transaction broadcast mode where the client waits for a CheckTx execution response only.

Const BROADCAST_MODE_BLOCK

BROADCAST_MODE_BLOCK: "block" = "block"

Defines a transaction broadcast mode where the client waits for the transaction to be committed in a block.

Const BROADCAST_MODE_SYNC

BROADCAST_MODE_SYNC: "sync" = "sync"

Defines a transaction broadcast mode where the client returns immediately.

Const COSMOS_PATH

COSMOS_PATH: "m/44'/118'/0'/0/0" = "m/44'/118'/0'/0/0"

BIP32 derivation path for Cosmos keys.

Const COSMOS_PREFIX

COSMOS_PREFIX: "cosmos" = "cosmos"

Bech32 prefix for Cosmos addresses.

Functions

createAddress

  • createAddress(publicKey: Bytes, prefix?: string): Bech32String
  • Derive a Bech32 address from a public key.

    Parameters

    • publicKey: Bytes

      public key bytes

    • Default value prefix: string = COSMOS_PREFIX

      Bech32 human readable part, defaulting to COSMOS_PREFIX

    Returns Bech32String

    Bech32-encoded address

createBroadcastTx

  • Prepare a signed transaction for broadcast.

    Parameters

    • tx: StdTx

      signed transaction

    • Default value mode: BroadcastMode = BROADCAST_MODE_SYNC

      broadcast mode

    Returns BroadcastTx

    a transaction broadcast

createKeyPairFromMasterKey

  • createKeyPairFromMasterKey(masterKey: BIP32Interface, path?: string): KeyPair
  • Derive a keypair from a BIP32 master key.

    throws

    will throw if a private key cannot be derived

    Parameters

    • masterKey: BIP32Interface

      BIP32 master key

    • Default value path: string = COSMOS_PATH

      BIP32 derivation path, defaulting to COSMOS_PATH

    Returns KeyPair

    derived public and private key pair

createMasterKeyFromMnemonic

  • createMasterKeyFromMnemonic(mnemonic: string): BIP32Interface
  • Derive a BIP32 master key from a mnemonic.

    throws

    will throw if the provided mnemonic is invalid

    Parameters

    • mnemonic: string

      BIP39 mnemonic seed

    Returns BIP32Interface

    BIP32 master key

createSignMsg

  • Create a transaction with metadata for signing.

    Parameters

    • tx: Tx

      unsigned transaction

    • meta: SignMeta

      metadata for signing

    Returns StdSignMsg

    a transaction with metadata for signing

createSignature

  • createSignature(signMsg: StdSignMsg, __namedParameters: { privateKey: Uint8Array; publicKey: Uint8Array }): StdSignature
  • Create a signature from a StdSignMsg.

    Parameters

    • signMsg: StdSignMsg

      transaction with metadata for signing

    • __namedParameters: { privateKey: Uint8Array; publicKey: Uint8Array }
      • privateKey: Uint8Array
      • publicKey: Uint8Array

    Returns StdSignature

    a signature and corresponding public key

createSignatureBytes

  • createSignatureBytes(signMsg: StdSignMsg, privateKey: Bytes): Bytes
  • Create signature bytes from a StdSignMsg.

    Parameters

    • signMsg: StdSignMsg

      transaction with metadata for signing

    • privateKey: Bytes

      private key bytes

    Returns Bytes

    signature bytes

createWalletFromMasterKey

  • createWalletFromMasterKey(masterKey: BIP32Interface, prefix?: string, path?: string): Wallet
  • Create a Wallet from a BIP32 master key.

    Parameters

    • masterKey: BIP32Interface

      BIP32 master key

    • Default value prefix: string = COSMOS_PREFIX

      Bech32 human readable part, defaulting to COSMOS_PREFIX

    • Default value path: string = COSMOS_PATH

      BIP32 derivation path, defaulting to COSMOS_PATH

    Returns Wallet

    a keypair and address derived from the provided master key

createWalletFromMnemonic

  • createWalletFromMnemonic(mnemonic: string, prefix?: string, path?: string): Wallet
  • Create a Wallet from a known mnemonic.

    throws

    will throw if the provided mnemonic is invalid

    Parameters

    • mnemonic: string

      BIP39 mnemonic seed

    • Default value prefix: string = COSMOS_PREFIX

      Bech32 human readable part, defaulting to COSMOS_PREFIX

    • Default value path: string = COSMOS_PATH

      BIP32 derivation path, defaulting to COSMOS_PATH

    Returns Wallet

    a keypair and address derived from the provided mnemonic

ripemd160

  • ripemd160(bytes: Bytes): Bytes
  • Hash bytes using RIPEMD160.

    Parameters

    • bytes: Bytes

      bytes to hash

    Returns Bytes

    hashed bytes

sha256

  • sha256(bytes: Bytes): Bytes
  • Hash bytes using SHA256.

    Parameters

    • bytes: Bytes

      bytes to hash

    Returns Bytes

    hashed bytes

sign

  • sign(bytes: Bytes, privateKey: Bytes): Bytes
  • Sign the sha256 hash of bytes with a secp256k1 private key.

    throws

    will throw if the provided private key is invalid

    Parameters

    • bytes: Bytes

      bytes to hash and sign

    • privateKey: Bytes

      private key bytes

    Returns Bytes

    signed hash of the bytes

signTx

  • Sign a transaction.

    This combines the Tx and SignMeta into a StdSignMsg, signs it, and attaches the signature to the transaction. If the transaction is already signed, the signature will be added to the existing signatures.

    Parameters

    • tx: Tx | StdTx

      transaction (signed or unsigned)

    • meta: SignMeta

      metadata for signing

    • keyPair: KeyPair

      public and private key pair (or Wallet)

    Returns StdTx

    a signed transaction

verifySignature

verifySignatureBytes

  • verifySignatureBytes(signMsg: StdSignMsg, signature: Bytes, publicKey: Bytes): boolean
  • Verify a signature against a StdSignMsg.

    Parameters

    • signMsg: StdSignMsg

      transaction with metadata for signing

    • signature: Bytes

      signature bytes

    • publicKey: Bytes

      public key bytes

    Returns boolean

    true if the signature is valid and matches, false otherwise

verifySignatures

  • Verify a StdSignMsg against multiple StdSignatures.

    Parameters

    Returns boolean

    true if all signatures are valid and match, false otherwise or if no signatures were provided

verifyTx

  • Verify a signed transaction's signatures.

    Parameters

    • tx: StdTx

      signed transaction

    • meta: SignMeta

      metadata for signing

    Returns boolean

    true if all signatures are valid and match, false otherwise or if no signatures were provided

Generated using TypeDoc