@blockchaincommons/crypto - v1.0.0-beta.3
    Preparing search index...

    Interface Ed25519

    The shape of the ed25519 family.

    interface Ed25519 {
        PRIVATE_KEY_SIZE: 32;
        PUBLIC_KEY_SIZE: 32;
        SIGNATURE_SIZE: 64;
        generatePrivateKey(options?: RngOptions): Uint8Array<ArrayBuffer>;
        publicKey(privateKey: Uint8Array): Uint8Array<ArrayBuffer>;
        sign(privateKey: Uint8Array, message: Uint8Array): Uint8Array<ArrayBuffer>;
        verify(
            publicKey: Uint8Array,
            signature: Uint8Array,
            message: Uint8Array,
        ): boolean;
    }
    Index
    PRIVATE_KEY_SIZE: 32

    Private key (seed) length in bytes.

    PUBLIC_KEY_SIZE: 32

    Public key length in bytes.

    SIGNATURE_SIZE: 64

    Signature length in bytes.

    • 32 random bytes from options.rng (default secure). The reference's ed25519_new_private_key_using draws through rand_core's fill_bytes, so the generator's fillBytesPacked is used when it has one (the packed stream of SeededRng), else fillBytes through rand's fillRandomBytes. A generator's own error propagates unwrapped; a fillBytesPacked that is present but not a function is rand's RandError InvalidGenerator.

      Parameters

      • Optionaloptions: RngOptions

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter unless options is an object or absent.

    • The public key of the 32-byte seed privateKey (RFC 8032).

      Parameters

      • privateKey: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong-length key.

    • Deterministic RFC 8032 signature (64 bytes).

      Parameters

      • privateKey: Uint8Array
      • message: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong-length key.

    • (publicKey, signature, message), the same order as ecdsa.verify and schnorr.verify.

      Uses the reference's uncofactored verification equation (verify_strict): false for a small-order key or R, a non-canonical R, an s ≥ L, or a signature that does not verify. The key is decoded as the reference's VerifyingKey::from_bytes decodes it (a non-canonical y is reduced), and its .unwrap() on a key with no point is a panic.

      Parameters

      • publicKey: Uint8Array
      • signature: Uint8Array
      • message: Uint8Array

      Returns boolean

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong-length key or signature; InvalidData when the key is not a point on the curve.