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

    Interface Schnorr

    The shape of the schnorr family.

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

    x-only public key length in bytes.

    SIGNATURE_SIZE: 64

    BIP-340 signature length in bytes.

    • x-only (32-byte) public key of a secp256k1 private 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.

    • BIP-340 signature. Aux-rand comes from options.auxRand, else 32 bytes drawn from options.rng (the reference's schnorr_sign_using, random_data(32)); a generator's own error propagates unwrapped.

      Parameters

      Returns Uint8Array<ArrayBuffer>

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

    • false on a signature that does not verify (BIP-340 vectors 6–13).

      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 the x of a point on the curve (BIP-340 vectors 5 and 14), the reference's .expected XOnlyPublicKey::from_byte_array.