Class Ed25519PublicKey

Represents an Ed25519 public key in the Cardano ecosystem. This class provides methods for creating, managing, and performing cryptographic operations with Ed25519 public keys, including signature verification and hashing.

Properties

ptr: number

Pointer to the native Ed25519 public key object in memory.

Methods

  • The reference count retrieved by this method reflects the number of references maintained internally by libcardano-c for this native instance of the object. This is unrelated to the reference counting mechanism in JavaScript, which is managed by the JavaScript engine's garbage collector.

    This method is primarily intended for diagnostic purposes.

    Returns number

    The current reference count of the object in the WASM context.

  • Converts the Ed25519 public key to raw bytes.

    Returns Uint8Array

    A Uint8Array containing the raw byte representation of the public key.

    If the operation fails, such as memory allocation issues.

    const publicKey = Ed25519PublicKey.fromHex('010203...');
    const publicKeyBytes = publicKey.toBytes();
    console.log(publicKeyBytes); // Outputs the raw byte data
  • Computes the BLAKE2b hash of this Ed25519 public key.

    Returns Uint8Array

    A Uint8Array containing the BLAKE2b hash of the public key.

    If the operation fails, such as memory allocation issues.

    const publicKey = Ed25519PublicKey.fromHex('010203...');
    const hash = publicKey.toHash();
    console.log(hash); // Outputs the BLAKE2b hash
  • Computes the BLAKE2b hash of this Ed25519 public key and returns it as a hexadecimal string.

    Returns string

    A string containing the hexadecimal representation of the BLAKE2b hash of the public key.

    If the operation fails.

    const publicKey = Ed25519PublicKey.fromHex('010203...');
    const hashHex = publicKey.toHashHex();
    console.log(hashHex); // Outputs the BLAKE2b hash as a hexadecimal string
  • Converts the Ed25519 public key to a hexadecimal string.

    Returns string

    A string containing the hexadecimal representation of the public key.

    If the operation fails, such as memory allocation issues.

    const publicKey = Ed25519PublicKey.fromBytes(new Uint8Array([0x01, 0x02, 0x03 ...]));
    const publicKeyHex = publicKey.toHex();
    console.log(publicKeyHex); // Outputs the hexadecimal string
  • Verifies a signature against a message using this Ed25519 public key.

    Parameters

    • signature: Ed25519Signature

      The Ed25519Signature object to verify.

    • message: Uint8Array

      The message data that was signed as a Uint8Array.

    Returns boolean

    true if the signature is valid, otherwise false.

    const publicKey = Ed25519PublicKey.fromHex('010203...');
    const signature = Ed25519Signature.fromHex('010203...');
    const message = new Uint8Array([0x01, 0x02, 0x03]);
    const isValid = publicKey.verify(signature, message);
    console.log(isValid); // Outputs true or false
  • Creates an Ed25519 public key from raw bytes.

    Parameters

    • data: Uint8Array

      The raw byte data of the public key as a Uint8Array.

    Returns Ed25519PublicKey

    A new Ed25519PublicKey instance.

    If the operation fails due to invalid data or memory issues.

    const publicKeyData = new Uint8Array([0x01, 0x02, 0x03]);
    const publicKey = Ed25519PublicKey.fromBytes(publicKeyData);
    console.log(publicKey); // Outputs the Ed25519PublicKey object
  • Creates an Ed25519 public key from a hexadecimal string.

    Parameters

    • hex: string

      A string containing the hexadecimal representation of the public key.

    Returns Ed25519PublicKey

    A new Ed25519PublicKey instance.

    If the operation fails due to invalid data or memory issues.

    const publicKeyHex = '010203...';
    const publicKey = Ed25519PublicKey.fromHex(publicKeyHex);
    console.log(publicKey); // Outputs the Ed25519PublicKey object