Interface Signer<SignInput, VerifyInput>

The Signer interface provides methods for signing data and verifying signatures.

It includes sign() for creating signatures and verify() for confirming the validity of signatures. The interface is designed to be flexible, accommodating various signing algorithms and their unique parameters.

It defaults to using EnclosedSignParams and EnclosedVerifyParams, which are intended to be used with a closure that captures the key and algorithm-specific parameters so that arbitrary data can be signed and verified without exposing the key or parameters to the caller. However, the interface can be extended to support other parameter types, such as SignParams and VerifyParams, which are intended to be used when the key and algorithm-specific parameters are known to the caller.

interface Signer<SignInput, VerifyInput> {
    sign(params): Promise<Uint8Array>;
    verify(params): Promise<boolean>;
}

Type Parameters

Hierarchy (view full)

Implemented by

Methods

Methods

  • Signs the provided data.

    Parameters

    • params: SignInput

      The parameters for the signing operation.

    Returns Promise<Uint8Array>

    A Promise resolving to the digital signature as a Uint8Array.

    Remarks

    The sign() method of the Signer interface generates a digital signature for the given data using a cryptographic key. This signature can be used to verify the data's authenticity and integrity.

  • Verifies a digital signature associated the provided data.

    Parameters

    • params: VerifyInput

      The parameters for the verification operation.

    Returns Promise<boolean>

    A Promise resolving to a boolean indicating whether the signature is valid.

    Remarks

    The verify() method of the Signer interface checks the validity of a digital signature against the original data and a cryptographic key. It confirms whether the signature was created by the holder of the corresponding private key and that the data has not been tampered with.