Documentation
¶
Index ¶
- Constants
- Variables
- type Document
- func GetOrCreate(identifier string, controller string) (*Document, error)
- func GetOrFetch(id string) (*Document, error)
- func New(identifier string, controller string) (*Document, error)
- func NewFromKeyset(k *set.Keyset) (*Document, error)
- func NewFromKeysetWithController(k *set.Keyset, controller string) (*Document, error)
- func Payload(d Document) (Document, error)
- func (d *Document) AddController(controller string)
- func (d *Document) AddVerificationMethod(method VerificationMethod)
- func (d *Document) AssertionMethodPublicKey() (ed25519.PublicKey, error)
- func (d *Document) DeleteController(controller string)
- func (d *Document) DeleteVerificationMethod(method VerificationMethod) error
- func (d *Document) Equal(other *Document) bool
- func (d *Document) GetAssertionMethod() (VerificationMethod, error)
- func (d *Document) GetKeyAgreementMethod() (VerificationMethod, error)
- func (d *Document) GetVerificationMethodbyID(vmid string) (VerificationMethod, error)
- func (d *Document) KeyAgreementPublicKeyBytes() ([]byte, error)
- func (d *Document) MarshalPayloadToCBOR() ([]byte, error)
- func (d *Document) MarshalToCBOR() ([]byte, error)
- func (d *Document) Node() (*cbor.Node, error)
- func (d *Document) PayloadHash() ([]byte, error)
- func (d *Document) Publish(opts *PublishOptions) (ipns.Name, error)
- func (d *Document) PublishGoroutine(wg *sync.WaitGroup, cancel context.CancelFunc, opts *PublishOptions)
- func (d *Document) Sign(signKey *key.SigningKey, vm VerificationMethod) error
- func (d *Document) String() string
- func (d *Document) Verify() error
- type Proof
- type PublishOptions
- type VerificationMethod
Constants ¶
const (
VerificationMethodDefaultTTL = time.Duration(7) * time.Hour * 24
)
Variables ¶
var DID_CONTEXT = []string{
"https://w3id.org/did/v1",
}
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct { Context []string `cbor:"@context,toarray" json:"@context"` Version string `cbor:"version" json:"version"` ID string `cbor:"id" json:"id"` Controller []string `cbor:"controller,toarray" json:"controller"` VerificationMethod []VerificationMethod `cbor:"verificationMethod,toarray" json:"verificationMethod"` AssertionMethod string `cbor:"assertionMethod" json:"assertionMethod"` KeyAgreement string `cbor:"keyAgreement" json:"keyAgreement"` Proof Proof `cbor:"proof" json:"proof"` }
func GetOrCreate ¶ added in v0.1.0
GetOrCreate document from cache or fetch from IPFS identifier is a did string, eg. "did:ma:k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr#foo"
func GetOrFetch ¶ added in v0.2.0
func NewFromKeyset ¶
Takes a keyset and generates a DID Document. Also takes a controller string which is the DID of the controller of the keyset. This is used to set the controller of the DID Document. It's OK to set it as the DID of the keyset.IPNSKey.DID, but it's not required.
func NewFromKeysetWithController ¶ added in v0.0.6
func Payload ¶
Payload generates the unsigned DID, This is everything non-metadata in the DID document. We don't use a pointer here, so that we don't have to reiterate the struct in the function. We just need to change the signature.
func (*Document) AddController ¶ added in v0.1.0
func (*Document) AddVerificationMethod ¶
func (d *Document) AddVerificationMethod(method VerificationMethod)
func (*Document) AssertionMethodPublicKey ¶
func (*Document) DeleteController ¶ added in v0.1.0
func (*Document) DeleteVerificationMethod ¶ added in v0.1.0
func (d *Document) DeleteVerificationMethod(method VerificationMethod) error
func (*Document) GetAssertionMethod ¶
func (d *Document) GetAssertionMethod() (VerificationMethod, error)
func (*Document) GetKeyAgreementMethod ¶
func (d *Document) GetKeyAgreementMethod() (VerificationMethod, error)
func (*Document) GetVerificationMethodbyID ¶
func (d *Document) GetVerificationMethodbyID(vmid string) (VerificationMethod, error)
func (*Document) KeyAgreementPublicKeyBytes ¶
func (*Document) MarshalPayloadToCBOR ¶
Marshals the payload to CBOR for publication
func (*Document) MarshalToCBOR ¶ added in v0.1.0
func (*Document) Node ¶ added in v0.0.6
IPFSDagAddCBOR takes a CBOR encoded byte array and adds it to IPFS.
func (*Document) PayloadHash ¶
func (*Document) Publish ¶
func (d *Document) Publish(opts *PublishOptions) (ipns.Name, error)
Publish publishes the document to IPFS and returns the CID If the opts is nil, the default options are used.
func (*Document) PublishGoroutine ¶ added in v0.2.0
func (d *Document) PublishGoroutine(wg *sync.WaitGroup, cancel context.CancelFunc, opts *PublishOptions)
The Goroutine version of Publish must get a cancel function as argument. This is to force the caller to use a context with a cancel function. Obviously this should probably be a timeout context. Other than that it is the same as Publish.
func (*Document) Sign ¶
func (d *Document) Sign(signKey *key.SigningKey, vm VerificationMethod) error
type Proof ¶
type Proof struct { Created string `cbor:"created" json:"created"` Type string `cbor:"type" json:"type"` VerificationMethod string `cbor:"verificationMethod" json:"verificationMethod"` ProofPurpose string `cbor:"proofPurpose" json:"proofPurpose"` ProofValue string `cbor:"proofValue" json:"proofValue"` }
type PublishOptions ¶ added in v0.2.0
func DefaultPublishOptions ¶ added in v0.2.0
func DefaultPublishOptions() *PublishOptions
type VerificationMethod ¶
type VerificationMethod struct { // The full name of the verification method, eg. did:ma:123456789abcdefghi#signature-key-id ID string `cbor:"id" json:"id"` // The type of verification method. We only use MultiKey. It's unofficial, but it works. // https://w3c-ccg.github.io/did-method-key/ Type string `cbor:"type" json:"type"` // The controller of the verification method. This is the DID of the entity that controls the key. // Should probably always be the DID itself, but maybe the DID controller. Controller []string `cbor:"controller,toarray" json:"controller"` // Created is the time the verification method was created PublicKeyMultibase string `cbor:"publicKeyMultibase" json:"publicKeyMultibase"` }
VerificationMethod defines the structure of a Verification Method
func NewVerificationMethod ¶
func NewVerificationMethod( id string, controller string, vmType string, fragment string, publicKeyMultibase string, ) (VerificationMethod, error)
NewVerificationMethod creates a new VerificationMethod id is the identifier of the verification method, eg. k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr id must be a valid IPNS name. A random fragment will be added to the id vmType must be of type MultiKey, so that the format never changes - even if the underlying key type changes.
func (*VerificationMethod) AddController ¶ added in v0.1.0
func (v *VerificationMethod) AddController(controller string)
func (*VerificationMethod) DeleteController ¶ added in v0.1.0
func (v *VerificationMethod) DeleteController(controller string)
func (VerificationMethod) Equal ¶ added in v0.2.0
func (vm VerificationMethod) Equal(other VerificationMethod) bool
func (VerificationMethod) Fragment ¶
func (vm VerificationMethod) Fragment() string