did

package
v0.0.0-...-88713f8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthenticationDIDType = "MailioDIDAuth"
	MessagingDIDType      = "DIDCommMessaging"
)
View Source
const (
	MCed25519 = 0xED

	KeyTypeEd25519 = "Ed25519VerificationKey2020"

	PublicKeyJwkType = "JsonWebKey2020"

	KeyTypeX25519KeyAgreement = "X25519KeyAgreementKey2019"

	DIDKeyPrefix = "did:mailio:"
)
View Source
const (
	CtxDIDv1             = "https://www.w3.org/ns/did/v1"
	CtxSecEd25519_2020v1 = "https://w3id.org/security/suites/ed25519-2020/v1"
	CtxSecX25519_2019v1  = "https://w3id.org/security/suites/x25519-2019/v1"
	CtxDIDCommMsg_v2     = "https://didcomm.org/messaging/contexts/v2"
)

Variables

View Source
var (
	ErrInvalidSignature = fmt.Errorf("invalid signature")
)

Functions

This section is empty.

Types

type AuthorizedApplication

type AuthorizedApplication struct {
	ID              string    `json:"id"`      // target application did: did:example:123456789abcdefghi
	Domains         []string  `json:"domains"` // domains of the auth application: [example.com]
	ApprovalDate    time.Time `json:"approvalDate"`
	UserPermissions []string  `json:"userPermissions,omitempty"` // optional list of permissions specific to a target application
}

type CredentialStatus

type CredentialStatus struct {
	ID   string `json:"id"`   // https://example.edu/status/24"
	Type string `json:"type"` // CredentialStatusList2017
}

type CredentialSubject

type CredentialSubject struct {
	ID                    string                 `json:"id"`
	Origin                string                 `json:"origin,omitempty"`
	AuthorizedApplication *AuthorizedApplication `json:"authorizedApplication,omitempty"`
}

type DID

type DID struct {
	// contains filtered or unexported fields
}

func ParseDID

func ParseDID(s string) (DID, error)

func (*DID) Fragment

func (d *DID) Fragment() string

func (DID) MarshalJSON

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

func (*DID) Protocol

func (d *DID) Protocol() string

func (*DID) String

func (d *DID) String() string

func (*DID) UnmarshalJSON

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

func (*DID) Value

func (d *DID) Value() string

type Document

type Document struct {
	Context []string `json:"@context"`

	ID DID `json:"id"`

	AlsoKnownAs []string `json:"alsoKnownAs,omitempty"`

	Authentication []interface{} `json:"authentication,omitempty"`

	VerificationMethod []VerificationMethod `json:"verificationMethod,omitempty"`

	KeyAgreement []KeyAgreement `json:"keyAgreement,omitempty"`

	Service []Service `json:"service,omitempty"`
}

Each DID document can express cryptographic material, verification methods, or services, which provide a set of mechanisms enabling a DID controller to prove control of the DID. Services enable trusted interactions associated with the DID subject.

func NewMailioDIDDocument

func NewMailioDIDDocument(mk *MailioKey, mailioPublicKey ed25519.PublicKey, AuthServiceEndpoint string, MessageServiceEndpoint string) (*Document, error)

func (*Document) GetVerificationPublicKey

func (d *Document) GetVerificationPublicKey(id string) (*crypto.PublicKey, error)

get public key by finding a correct verification method and returning the public key

type Key

type Key struct {
	PublicKey ed25519.PublicKey
	Type      string
}

type KeyAgreement

type KeyAgreement struct {
	ID                 string        `json:"id,omitempty"`
	Type               string        `json:"type,omitempty"` // usually X25519KeyAgreementKey2019
	Controller         string        `json:"controller,omitempty"`
	PublicKeyMultibase string        `json:"publicKeyMultibase,omitempty"`
	PublicKeyJwk       *PublicKeyJwk `json:"publicKeyJwk,omitempty"`
}

A set of parameters that can be used together with a process to independently derive a shared key or secret that can be used for secure communication.

func (*KeyAgreement) GetPublicKey

func (ka *KeyAgreement) GetPublicKey() (*crypto.PublicKey, error)

GetPublicKey for an KeyAgreement

type MailioKey

type MailioKey struct {
	MasterSignKey      *Key
	MasterAgreementKey *Key
	VerificationKeys   []*Key
	AuthenticationKeys []*Key
}

func (*MailioKey) DID

func (k *MailioKey) DID() string

func (*MailioKey) DIDFromKey

func (k *MailioKey) DIDFromKey() (DID, error)

func (*MailioKey) KeyType

func (k *MailioKey) KeyType() string

func (*MailioKey) MailioAddress

func (k *MailioKey) MailioAddress() string

type Proof

type Proof struct {
	Type               string    `json:"type"`
	Created            time.Time `json:"created"`
	ProofPurpose       string    `json:"proofPurpose"`
	VerificationMethod string    `json:"verificationMethod"`
	Challenge          string    `json:"challenge,omitempty"` // prevent replay attacks
	Domain             string    `json:"domain,omitempty"`    // prevent replay attacks
	Jws                string    `json:"jws"`
}

type PublicKeyJwk

type PublicKeyJwk struct {
	Key jwk.Key
}

func (*PublicKeyJwk) GetRawKey

func (pk *PublicKeyJwk) GetRawKey() (interface{}, error)

func (*PublicKeyJwk) MarshalJSON

func (pkj *PublicKeyJwk) MarshalJSON() ([]byte, error)

func (*PublicKeyJwk) UnmarshalJSON

func (pkj *PublicKeyJwk) UnmarshalJSON(b []byte) error

type Service

type Service struct {
	ID              string   `json:"id"`
	Type            string   `json:"type"`
	ServiceEndpoint string   `json:"serviceEndpoint"`
	Accept          []string `json:"accept,omitempty"`
	RoutingKeys     []string `json:"routingKeys,omitempty"`
}

Means of communicating or interacting with the DID subject or associated entities via one or more service endpoints. Examples include discovery services, agent services, social networking services, file storage services, and verifiable credential repository services.

type VerifiableCredential

type VerifiableCredential struct {
	Context           []string          `json:"@context"`
	ID                string            `json:"id,omitempty"`
	Type              []string          `json:"type"`
	Issuer            string            `json:"issuer"`
	IssuanceDate      time.Time         `json:"issuanceDate"`
	CredentialSubject CredentialSubject `json:"credentialSubject"`
	Proof             *Proof            `json:"proof,omitempty"`
	CredentialStatus  *CredentialStatus `json:"credentialStatus,omitempty"`
}

VerifiableCredential is a JSON-LD document that cryptographically proves that the subject identified by the DID has been verified against a given credential schema. The Verifiable Credential data model is defined in the W3C Verifiable Credentials Data Model 1.0 specification.

func NewVerifiableCredential

func NewVerifiableCredential(mailioDID string) *VerifiableCredential

func (*VerifiableCredential) CreateProof

func (vc *VerifiableCredential) CreateProof(privateKey ed25519.PrivateKey) error

CreateProof creates a proof for Verifiable Credential using private key from a signer

func (*VerifiableCredential) VerifyProof

func (vc *VerifiableCredential) VerifyProof(publicKey ed25519.PublicKey) (bool, error)

Verify if the proof of Verifialbe Credential is valid using public key from a signer

type VerifiablePresentation

type VerifiablePresentation struct {
	Context              []string               `json:"@context"`
	ID                   string                 `json:"id"`
	Type                 string                 `json:"type"`
	Holder               string                 `json:"holder"`
	VerifiableCredential []VerifiableCredential `json:"verifiableCredential"`
	Proof                Proof                  `json:"proof"`
}

VerifiablePresentation is a JSON-LD document that cryptographically proves that the holder of the DID has been verified against a given credential schema. (response to VC request)

type VerificationMethod

type VerificationMethod struct {
	ID           string        `json:"id,omitempty"`
	Type         string        `json:"type,omitempty"`
	Controller   string        `json:"controller,omitempty"`
	PublicKeyJwk *PublicKeyJwk `json:"publicKeyJwk,omitempty"`
}

A set of parameters that can be used together with a process to independently verify a proof. For example, a cryptographic public key can be used as a verification method with respect to a digital signature; in such usage, it verifies that the signer possessed the associated cryptographic private key.

func (VerificationMethod) GetPublicKey

func (vm VerificationMethod) GetPublicKey() (*crypto.PublicKey, error)

get public key from verification method

Jump to

Keyboard shortcuts

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