Class BearerDid
-
- All Implemented Interfaces:
public final class BearerDidRepresents a Decentralized Identifier (DID) along with its DID document, key manager, metadata, and convenience functions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classBearerDid.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Stringuriprivate final Diddidprivate final KeyManagerkeyManagerprivate final DidDocumentdocumentpublic final static BearerDid.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description BearerDid(String uri, Did did, KeyManager keyManager, DidDocument document)
-
Method Summary
Modifier and Type Method Description final StringgetUri()final DidgetDid()final KeyManagergetKeyManager()final DidDocumentgetDocument()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. 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. final PortableDidexport()Converts a BearerDidobject to a portable format containing the URI and verification methods associated with the DID.-
-
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
-
getKeyManager
final KeyManager getKeyManager()
-
getDocument
final DidDocument getDocument()
-
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
BearerDidobject 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
PortableDidstructure.
-
-
-
-