did

package
v0.0.0-...-8bebe15 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DIDCore = 0x0d1d
View Source
const Ed25519 = 0xed
View Source
const KeyPrefix = Prefix + "key:"
View Source
const Prefix = "did:"
View Source
const RSA = 0x1205
View Source
const Secp256k1 = 0xe7

Variables

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

func Parse(str string) (DID, error)

func (DID) Defined

func (d DID) Defined() bool

func (DID) Identifier

func (d DID) Identifier() string

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) MarshalCBOR

func (d DID) MarshalCBOR(w io.Writer) error

func (DID) MarshalDagJSON

func (d DID) MarshalDagJSON(w io.Writer) error

func (DID) MarshalJSON

func (d DID) MarshalJSON() ([]byte, error)

func (DID) Method

func (d DID) Method() string

Method returns the DID method name (e.g. "key", "web") parsed from the scheme. Returns "" for an undefined DID.

func (DID) String

func (d DID) String() string

String formats the decentralized identity document (DID) as a string.

func (*DID) UnmarshalCBOR

func (d *DID) UnmarshalCBOR(r io.Reader) error

func (*DID) UnmarshalDagJSON

func (d *DID) UnmarshalDagJSON(r io.Reader) error

func (*DID) UnmarshalJSON

func (d *DID) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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