Class Secp256k1PublicKey

Represents a Secp256k1 ECDSA public key.

Hierarchy (view full)

Implementation - BCS

  • Serializes a Serializable value to its BCS representation. This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.

    Returns Uint8Array

    the BCS representation of the Serializable instance as a byte buffer.

  • Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

    Returns Hex

    A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.

Implementation - Serialization

  • Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array. This constructor validates the length of the provided signature data.

    Parameters

    • hexInput: HexInput

      A HexInput (string or Uint8Array) representing the signature data.

    Returns Secp256k1PublicKey

    Error if the length of the signature data is not equal to Secp256k1Signature.LENGTH.

  • Serializes the data into a byte array using the provided serializer. This function is essential for converting data into a format suitable for transmission or storage.

    Parameters

    • serializer: Serializer

      The serializer instance used to convert the data.

    Returns void

  • Verifies a Secp256k1 signature against the public key.

    This function checks the validity of a signature for a given message, ensuring that the signature is canonical as a malleability check.

    Parameters

    Returns boolean

  • Note: Secp256k1Signatures can be verified syncronously.

    Verifies the provided signature against the given message. This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.

    Parameters

    • args: {
          aptosConfig: AptosConfig;
          message: HexInput;
          signature: Secp256k1Signature;
      }

      The arguments for signature verification.

      • aptosConfig: AptosConfig

        The configuration object for connecting to the Aptos network

      • message: HexInput

        The message that was signed.

      • signature: Secp256k1Signature

        The signature to verify, which must be an instance of Secp256k1Signature.

    Returns Promise<boolean>

    A boolean indicating whether the signature is valid for the given message.

  • Determines if the provided public key is a valid instance of a Secp256k1 public key. This function checks for the presence of a "key" property and validates the length of the key data.

    Parameters

    • publicKey: PublicKey

      The public key to validate.

    Returns publicKey is Secp256k1PublicKey

    A boolean indicating whether the public key is a valid Secp256k1 public key.

Methods

Properties

keyType: string = "secp256k1"
COMPRESSED_LENGTH: number = 33
LENGTH: number = 65

The length of the Secp256k1 public key in bytes.