Class BearerDid

  • All Implemented Interfaces:

    
    public final class BearerDid
    
                        

    Represents a Decentralized Identifier (DID) along with its DID document, key manager, metadata, and convenience functions.

    • Constructor Detail

      • BearerDid

        BearerDid(String uri, Did did, KeyManager keyManager, DidDocument document)
        Parameters:
        did - The Decentralized Identifier (DID) to represent.
        keyManager - The KeyManager instance used to manage the cryptographic keys associated with the DID.
        document - The DID Document associated with the DID.
    • Method Detail

      • getSigner

        @JvmOverloads() final Pair<Function1<ByteArray, ByteArray>, VerificationMethod> getSigner(VMSelector selector)

        GetSigner returns a sign method that can be used to sign a payload using a key associated to the DID. This function also returns the verification method needed to verify the signature.

        Providing the verification method allows the caller to provide the signature's recipient with a reference to the verification method needed to verify the payload. This is often done by including the verification method id either alongside the signature or as part of the header in the case of JSON Web Signatures.

        The verifier can dereference the verification method id to obtain the public key needed to verify the signature.

        This function takes a Verification Method selector that can be used to select a specific verification method from the DID Document if desired. If no selector is provided, the payload will be signed with the key associated to the first verification method in the DID Document.

        The selector can either be a Verification Method ID or a Purpose. If a Purpose is provided, the first verification method in the DID Document that has the provided purpose will be used to sign the payload.

        The returned signer is a function that takes a byte payload and returns a byte signature.

      • getSigner

        @JvmOverloads() final Pair<Function1<ByteArray, ByteArray>, VerificationMethod> getSigner()

        GetSigner returns a sign method that can be used to sign a payload using a key associated to the DID. This function also returns the verification method needed to verify the signature.

        Providing the verification method allows the caller to provide the signature's recipient with a reference to the verification method needed to verify the payload. This is often done by including the verification method id either alongside the signature or as part of the header in the case of JSON Web Signatures.

        The verifier can dereference the verification method id to obtain the public key needed to verify the signature.

        This function takes a Verification Method selector that can be used to select a specific verification method from the DID Document if desired. If no selector is provided, the payload will be signed with the key associated to the first verification method in the DID Document.

        The selector can either be a Verification Method ID or a Purpose. If a Purpose is provided, the first verification method in the DID Document that has the provided purpose will be used to sign the payload.

        The returned signer is a function that takes a byte payload and returns a byte signature.

      • export

         final PortableDid export()

        Converts a BearerDid object to a portable format containing the URI and verification methods associated with the DID.

        This method is useful when you need to represent the key material and metadata associated with a DID in format that can be used independently of the specific DID method implementation. It extracts both public and private keys from the DID's key manager and organizes them into a PortableDid structure.