Class Ed25519Signature

Class representing an Ed25519 signature.

This class provides methods for creating, converting, and managing Ed25519 signature objects.

Properties

ptr: number

Pointer to the native Ed25519 signature object.

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 signature to a raw byte array.

    This method serializes the Ed25519 signature into its raw binary representation.

    Returns Uint8Array

    A Uint8Array containing the raw byte representation of the signature.

    If the operation fails, such as due to memory allocation issues or internal errors in the underlying WASM module.

    try {
    const signature = Ed25519Signature.fromHex('abcdef0123456789...');
    const bytes = signature.toBytes();
    console.log('Signature as raw bytes:', bytes);
    } catch (error) {
    console.error('Failed to convert Ed25519 signature to bytes:', error);
    }
  • Converts the Ed25519 signature to a hexadecimal string.

    This method serializes the Ed25519 signature into a human-readable hexadecimal string.

    Returns string

    A string containing the hexadecimal representation of the signature.

    If the operation fails, such as due to memory allocation issues or internal errors in the underlying WASM module.

    try {
    const signature = Ed25519Signature.fromBytes(new Uint8Array([0x01, 0x02, 0x03]));
    const hex = signature.toHex();
    console.log('Signature as hex:', hex);
    } catch (error) {
    console.error('Failed to convert Ed25519 signature to hex:', error);
    }
  • Creates an Ed25519 signature from raw byte data.

    This method allows constructing an Ed25519 signature using its raw binary representation.

    Parameters

    • data: Uint8Array

      The raw byte data of the signature as a Uint8Array.

    Returns Ed25519Signature

    A new instance of Ed25519Signature.

    If the operation fails, such as due to invalid byte data or memory allocation issues.

    const rawBytes = new Uint8Array([0x01, 0x02, 0x03, ...]);
    try {
    const signature = Ed25519Signature.fromBytes(rawBytes);
    console.log('Signature created successfully:', signature);
    } catch (error) {
    console.error('Failed to create Ed25519 signature from bytes:', error);
    }
  • Creates an Ed25519 signature from a hexadecimal string.

    This method allows constructing an Ed25519 signature using its hexadecimal representation.

    Parameters

    • hex: string

      A string representing the hexadecimal data of the signature.

    Returns Ed25519Signature

    A new instance of Ed25519Signature.

    If the operation fails, such as due to invalid hexadecimal data or memory allocation issues.

    const hexString = 'abcdef0123456789...';
    try {
    const signature = Ed25519Signature.fromHex(hexString);
    console.log('Signature created successfully:', signature);
    } catch (error) {
    console.error('Failed to create Ed25519 signature from hex:', error);
    }