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

    Interface Ecdsa

    The shape of the ecdsa family.

    interface Ecdsa {
        PRIVATE_KEY_SIZE: 32;
        PUBLIC_KEY_SIZE: 33;
        UNCOMPRESSED_PUBLIC_KEY_SIZE: 65;
        MESSAGE_HASH_SIZE: 32;
        SIGNATURE_SIZE: 64;
        generatePrivateKey(options?: RngOptions): Uint8Array<ArrayBuffer>;
        publicKey(privateKey: Uint8Array): Uint8Array<ArrayBuffer>;
        decompressPublicKey(compressed: Uint8Array): Uint8Array<ArrayBuffer>;
        compressPublicKey(uncompressed: 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 (scalar) length in bytes.

    PUBLIC_KEY_SIZE: 33

    Compressed public key length in bytes.

    UNCOMPRESSED_PUBLIC_KEY_SIZE: 65

    Uncompressed (04 ‖ x ‖ y) public key length in bytes.

    MESSAGE_HASH_SIZE: 32

    Length of the message hash that is signed (double SHA-256).

    SIGNATURE_SIZE: 64

    Compact (r ‖ s) signature length in bytes.

    • 32 random bytes from options.rng (default secure), unvalidated; the reference's ecdsa_new_private_key_using (random_data). A generator's own error, including rand's InvalidGenerator, propagates unwrapped.

      Parameters

      • Optionaloptions: RngOptions

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter unless options is an object or absent.

    • Compressed (33-byte) public key.

      Parameters

      • privateKey: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong length; InvalidData when the key is not a valid scalar (0 or ≥ n).

    • Parameters

      • compressed: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong length; InvalidData when the bytes are not a point on the curve.

    • 65 bytes: 04 ‖ x ‖ y, or the hybrid 06/07 forms, whose low bit must equal the parity of y (libsecp256k1's parser, which the reference uses).

      Parameters

      • uncompressed: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong length; InvalidData when the bytes are not a point on the curve or a hybrid prefix disagrees with y.

    • Deterministic (RFC 6979) signature over doubleSha256(message); 64-byte compact form.

      Parameters

      • privateKey: Uint8Array
      • message: Uint8Array

      Returns Uint8Array<ArrayBuffer>

      InvalidParameter on a non-Uint8Array; InvalidSize on a wrong length; InvalidData when the key is not a valid scalar.

    • false on a signature that does not verify, r or s = 0 and a high s included (libsecp256k1's secp256k1_ecdsa_verify).

      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 or r or s ≥ n, the reference's .expected parses (PublicKey::from_slice, Signature::from_compact).