near-api-js - v7.5.3
    Preparing search index...

    Class PublicKey

    PublicKey representation that has type and bytes of the key.

    Hierarchy

    • Enum
      • PublicKey
    Index
    ed25519Key?: ED25519PublicKey
    enum: string
    mlDsa65Key?: MLDSA65PublicKey
    secp256k1Key?: SECP256K1PublicKey
    • get keyPair(): | ED25519PublicKey
      | SECP256K1PublicKey
      | MLDSA65PublicKey
      | undefined

      Returns ED25519PublicKey | SECP256K1PublicKey | MLDSA65PublicKey | undefined

    • Returns the on-trie identifier used for access keys and universal state initialization.

      Returns string

      The curve-prefixed public key for Ed25519/secp256k1, or ml-dsa-65-hash: followed by the Base58 SHA3-256 public-key digest for ML-DSA-65. A hashed handle cannot verify signatures.

    • Returns a string representation of the public key.

      Returns string

      The string representation of the public key.

    • Verifies a message signature using the public key.

      Parameters

      • message: Uint8Array

        Signed message bytes. For secp256k1, supply the 32-byte digest; no prehash is applied.

      • signature: Uint8Array

        Raw signature bytes. For secp256k1, only the first 64 bytes (compact r/s) are verified.

      Returns boolean

      true if the signature is valid, otherwise false.

    • Creates a PublicKey instance from an encoded key string.

      Parameters

      • encodedKey: string

        Base58 public key, preferably curve-prefixed (ed25519:, secp256k1:, or ml-dsa-65:). Unprefixed legacy inputs infer secp256k1 for 64 decoded bytes and Ed25519 otherwise.

      Returns PublicKey

      The PublicKey instance created from the encoded key string.

      If the encoding, curve prefix, or decoded public key size is invalid.