peer

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
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

func GetSupportedDIDPeerTypes() []crypto.KeyType

GetSupportedDIDPeerTypes returns all supported did;peer key types

func IsSupportedDIDPeerType

func IsSupportedDIDPeerType(kt crypto.KeyType) bool

IsSupportedDIDPeerType returns if a given key type is supported for did:peer

Types

type DIDPeer

type DIDPeer string

func (DIDPeer) Delta

func (DIDPeer) Delta(_ DIDPeer) (*PeerDelta, error)

func (DIDPeer) GetMethodID

func (d DIDPeer) GetMethodID() (string, error)

func (DIDPeer) IsValid

func (d DIDPeer) IsValid() bool

IsValid Checks if the Peer DID is correctly formatted

func (DIDPeer) IsValidPurpose

func (DIDPeer) IsValidPurpose(p PurposeType) bool

func (DIDPeer) Method

func (DIDPeer) Method() did.Method

func (DIDPeer) String

func (d DIDPeer) String() string

func (DIDPeer) Suffix

func (d DIDPeer) Suffix() (string, error)

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

func (Method0) Generate

func (Method0) Generate(kt crypto.KeyType, publicKey gocrypto.PublicKey) (*DIDPeer, error)

func (Method0) Method

func (Method0) Method() did.Method

type Method1

type Method1 struct{}

Method1 Method 1: genesis doc

func (Method1) Generate

func (Method1) Generate() (*DIDPeer, error)

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.

func (Method1) Method

func (Method1) Method() did.Method

type Method2

type Method2 struct {
	KT     crypto.KeyType
	Values []any
}

Method2 Method 2: multiple inception key without doc

func (Method2) Generate

func (m Method2) Generate() (*DIDPeer, error)

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.

func (Method2) Method

func (Method2) Method() did.Method

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 Resolver

type Resolver struct{}

func (Resolver) Methods

func (Resolver) Methods() []did.Method

func (Resolver) Resolve

func (Resolver) Resolve(_ context.Context, id string, opts ...resolution.Option) (*resolution.Result, error)

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

type ServiceTypeAbbreviationMap

type ServiceTypeAbbreviationMap map[string]string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL