Interface BearerDidSigner

A BearerDidSigner extends the Signer interface to include specific properties for signing with a Decentralized Identifier (DID). It encapsulates the algorithm and key identifier, which are often needed when signing JWTs, JWSs, JWEs, and other data structures.

Typically, the algorithm and key identifier are used to populate the alg and kid fields of a JWT or JWS header.

interface BearerDidSigner {
    algorithm: string;
    keyId: string;
    sign(params): Promise<Uint8Array>;
    verify(params): Promise<boolean>;
}

Hierarchy (view full)

Properties

Methods

Properties

algorithm: string

The cryptographic algorithm identifier used for signing operations.

Typically, this value is used to populate the alg field of a JWT or JWS header. The registered algorithm names are defined in the IANA JSON Web Signature and Encryption Algorithms registry.

Example

"ES256" // ECDSA using P-256 and SHA-256
keyId: string

The unique identifier of the key within the DID document that is used for signing and verification operations.

This identifier must be a DID URI with a fragment (e.g., did:method:123#key-0) that references a specific verification method in the DID document. It allows users of a BearerDidSigner to determine the DID and key that will be used for signing and verification operations.

Example

"did:dht:123#key-1" // A fragment identifier referring to a key in the DID document

Methods

  • Signs the provided data.

    Parameters

    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

    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.