Documentation ¶
Overview ¶
Package peer DID Peer ------------------------------------------------ https://identity.foundation/peer-did-method-spec/
Peer based, self-signed DID method.
The method can be used independent of any central source of truth, and is intended to be cheap, fast, scalable, and secure. It is suitable for most private relationships between people, organizations, and things. We expect that peer-to-peer relationships in every blockchain ecosystem can benefit by offloading pairwise and n-wise relationships to peer DIDs.
Currently only methods 0 and 2 are supported. Method 1 will be supported in a future date.
Index ¶
Constants ¶
const ( DIDPeerPrefix = "did:peer" EncNumBasis = did.Base58BTCMultiBase DIDRegex = `^did:peer:(([01](z)([1-9a-km-zA-HJ-NP-Z]{46,47}))|(2((\.[AEVID](z)([1-9a-km-zA-HJ-NP-Z]{46,47}))+(\.(S)[0-9a-zA-Z=]*)?)))$` KnownContext = "https://w3id.org/did/v1" DIDCommMessagingAbbr string = "dm" DIDCommMessaging string = "DIDCommMessaging" Hash = "#" )
ANBF specified here: https://identity.foundation/peer-did-method-spec/#method-specific-identifier
Variables ¶
This section is empty.
Functions ¶
func GetSupportedDIDPeerTypes ¶
GetSupportedDIDPeerTypes returns all supported did;peer key types
func IsSupportedDIDPeerType ¶
IsSupportedDIDPeerType returns if a given key type is supported for did:peer
Types ¶
type DIDPeer ¶
type DIDPeer string
func (DIDPeer) GetMethodID ¶
func (DIDPeer) IsValidPurpose ¶
func (DIDPeer) IsValidPurpose(p PurposeType) bool
type Method0 ¶
type Method0 struct {
// contains filtered or unexported fields
}
Method0 Method 0: inception key without doc https://identity.foundation/peer-did-method-spec/index.html#generation-method The DID doc offers no endpoint. This makes the DID functionally equivalent to a did:key value For example, did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH is equivalent to did:peer:0z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH
type Method1 ¶
type Method1 struct{}
Method1 Method 1: genesis doc
func (Method1) Generate ¶
Generate https://identity.foundation/peer-did-method-spec/#generation-method Creates a genesis version of JSON text of the DID doc for the DID. This inception key is the key that creates the DID and authenticates when exchanging it with the first peer CANNOT include the DID itself This lets the doc be created without knowing the DID's value in advance. Suppressing the DID value creates a stored variant of peer DID doc data, as opposed to the resolved variant that would have an actual DID value in the root id property. (In either the stored or resolved variant of the doc, anywhere else that the DID value would appear, it should appear as a relative reference rather than an absolute value. For example, each controller property of a verificationMethod that is owned by this DID would say "controller": "#id".). Calculate the SHA256 [RFC4634] hash of the bytes of the stored variant of the genesis version of the DID doc, and make this value the new DID's numeric basis.
type Method2 ¶
Method2 Method 2: multiple inception key without doc
func (Method2) Generate ¶
Generate If numalgo == 2, the generation mode is similar to Method 0 (and therefore also did:key) with the ability to specify additional keys in the generated DID Document. This method is necessary when both an encryption key and a signing key are required. It determines the purpose implicitly by looking at the type of object: 1. Start with the did prefix did:peer:2 2. Construct a multibase encoded, multicodec-encoded form of each public key to be included. 3. Prefix each encoded key with a period character (.) and single character from the purpose codes table below. 4. Append the encoded key to the DID. 5. Encode and append a service type to the end of the peer DID if desired as described below.
type PeerDelta ¶
type PeerDelta struct { Change string `json:"change"` // <base64url encoding of a change fragment>, By []byValue `json:"by"` // [ {"key": <id of key>, "sig": <signature value>} ... ], When int64 `json:"when"` // <ISO8601/RFC3339 UTC timestamp with at least second precision> }
PeerDelta https://identity.foundation/peer-did-method-spec/#backing-storage
type PurposeType ¶
type PurposeType string
const ( PurposeEncryptionCode PurposeType = "E" PurposeAssertionCode PurposeType = "A" PurposeVerificationCode PurposeType = "V" PurposeCapabilityInvocationCode PurposeType = "I" PurposeCapabilityDelegationCode PurposeType = "D" PurposeCapabilityServiceCode PurposeType = "S" )
https://identity.foundation/peer-did-method-spec/index.html#generation-method
type ServiceBlockEncoded ¶
type ServiceBlockEncoded struct { ServiceType string `json:"t"` ServiceEndpoint string `json:"s"` RoutingKeys []string `json:"r"` Accept []string `json:"a"` }
ServiceBlockEncoded Remaps the service block for encoding