Documentation
¶
Index ¶
- Constants
- Variables
- type DID
- func (d DID) Defined() bool
- func (d DID) Identifier() string
- func (d DID) MarshalCBOR(w io.Writer) error
- func (d DID) MarshalDagJSON(w io.Writer) error
- func (d DID) MarshalJSON() ([]byte, error)
- func (d DID) Method() string
- func (d DID) String() string
- func (d *DID) UnmarshalCBOR(r io.Reader) error
- func (d *DID) UnmarshalDagJSON(r io.Reader) error
- func (d *DID) UnmarshalJSON(b []byte) error
Constants ¶
const DIDCore = 0x0d1d
const Ed25519 = 0xed
const KeyPrefix = Prefix + "key:"
const Prefix = "did:"
const RSA = 0x1205
const Secp256k1 = 0xe7
Variables ¶
var MethodOffset = varint.UvarintSize(uint64(DIDCore))
var Undef = DID{}
Undef can be used to represent a nil or undefined DID, using DID{} directly is also acceptable.
Functions ¶
This section is empty.
Types ¶
type DID ¶
type DID struct {
// contains filtered or unexported fields
}
DID is a decentralized identity, it has the format:
"did:%s:%s"
The underlying type is string, so DIDs are safe to compare with == and to use as keys in maps.
Note: this is not `type DID string` because cbor-gen does not recognise MarshalCBOR or UnmarshalCBOR when type is not struct.
func (DID) Identifier ¶
Identifier returns the method-specific identifier — everything after "did:<method>:". Per the DID spec, this segment may itself contain colons (e.g. "did:mailto:web.mail:alice" yields "web.mail:alice"). Returns "" for an undefined DID.
func (DID) MarshalJSON ¶
func (DID) Method ¶
Method returns the DID method name (e.g. "key", "web") parsed from the scheme. Returns "" for an undefined DID.