Documentation ¶
Index ¶
- Constants
- func AsVerifier(keyDef KeyDef) (proof.Verifier, error)
- func ExtractEdPublicKeyFromDID(did DID) (ed25519.PublicKey, error)
- func GenerateKeyID(did DID, fragment string) string
- type AdminDID
- type CredentialDefinition
- type DID
- type DIDDoc
- func AddKeyToDIDDoc(doc DIDDoc, keyToAdd KeyDef, signingKey ed25519.PrivateKey, ...) (*DIDDoc, error)
- func DeactivateDIDDoc(doc DIDDoc, key ed25519.PrivateKey) (*DIDDoc, error)
- func DeactivateDIDDocGeneric(signer proof.Signer, signatureType proof.SignatureType, did DID) (*DIDDoc, error)
- func GenerateWorkDIDDoc(keyType proof.KeyType, signatureType proof.SignatureType) (*DIDDoc, ed25519.PrivateKey)
- func GenerateWorkDIDDocWithContext(keyType proof.KeyType, signatureType proof.SignatureType, context []string) (*DIDDoc, ed25519.PrivateKey)
- type JWK
- type KeyDef
- type KeyRef
- type ServiceDef
- type StringOrArray
- type URI
Constants ¶
const ( // AdminDIDKey the key for ledger value of admin did AdminDIDKey = "admin_did" // InitialKey the key reference assigned to the first key in a DID Doc InitialKey = "key-1" IONDIDMethod = "did:ion:" // SchemaContext is the JSON-LD @context value that points to the W3C DID v1 context. // Workday has chosen not to use JSON-LD for DID Documents. // Deprecated: This field is kept for historical purposes only. New documents should exclude it. SchemaContext = "https://w3id.org/did/v1" )
const ( KeyDIDMethod = "did:key:" // https://tools.ietf.org/html/rfc8037#appendix-A.2 OctetKeyPairType = "OKP" Ed25519Curve = "Ed25519" )
const (
WorkDIDMethod = "did:work:"
)
Variables ¶
This section is empty.
Functions ¶
func AsVerifier ¶
AsVerifier builds a verifier given a key definition that can be used to verify signed objects by the key in the definition
func ExtractEdPublicKeyFromDID ¶
ExtractEdPublicKeyFromDID extracts an Ed25519 Public Key from a DID Key.
func GenerateKeyID ¶
GenerateKeyID builds a fully qualified key reference given a DID and a key fragment
Types ¶
type AdminDID ¶
type AdminDID struct {
ID DID `json:"id"`
}
Struct to contain identifier for an Admin DID
type CredentialDefinition ¶
type CredentialDefinition struct { CredDefDID DID `json:"did"` IssuerDID DID `json:"issuerDid"` SchemaID string `json:"schemaId"` }
CredentialDefinition JSON Schema Represents an identity that binds an issuer to a schema that allows specific issuance
type DID ¶
type DID string
DID is a Decentralized Identifier conforming to https://www.w3.org/TR/did-core/#did-syntax
func ExtractDIDFromKeyRef ¶
ExtractDIDFromKeyRef parses a key reference in the form of DID#keyID and returns the DID. If the key reference doesn't contain a hash "#" symbol, the entire key reference is returned.
func GenerateDID ¶
GenerateDID generates a Decentralized ID in the form of "did:work:<id>" based on an Ed25519 public key. Workday's DID method uses the first 16 bytes of the public key as a unique random value, assuming that the caller generates a new random key pair when creating a new ID.
func GenerateDIDFromB64PubKey ¶
GenerateDIDFromB64PubKey converts a base64 encoded Ed25519 public key into a Decentralized ID. See GenerateDID.
func GenerateDIDKey ¶
GenerateDIDKey generates a non-registry based Decentralized DID in the form of "did:key:<id>" based on an Ed25519 public key. The DID Key Method expands a cryptographic public key into a DID Document. Note: As of May 2020, the DID Key method is still in unofficial draft (https://w3c-ccg.github.io/did-method-key)
func GenerateDIDKeyFromB64PubKey ¶
GenerateDIDKeyFromB64PubKey converts a base64 encoded Ed25519 public key into a DID Key. See GenerateDIDKey.
func (DID) ToShortFormDid ¶
ToShortFormDid returns the short-form version of the DID
type DIDDoc ¶
type DIDDoc struct { // Deprecated: left here for backward compatibility. All new DID Docs should exclude this property. SchemaContext StringOrArray `json:"@context,omitempty"` ID DID `json:"id"` PublicKey []KeyDef `json:"publicKey"` // Deprecated: use `VerificationMethod` Authentication []KeyRef `json:"authentication"` // TODO: optional Service []ServiceDef `json:"service"` // TODO: optional VerificationMethod []KeyDef `json:"verificationMethod,omitempty"` // TODO: required AssertionMethod []KeyRef `json:"assertionMethod,omitempty"` CapabilityInvocation []KeyRef `json:"capabilityInvocation,omitempty"` CapabilityDelegation []KeyRef `json:"capabilityDelegation,omitempty"` KeyAgreement []KeyRef `json:"keyAgreement,omitempty"` AlsoKnownAs []URI `json:"alsoKnownAs,omitempty"` Controller StringOrArray `json:"controller,omitempty"` Proof *proof.Proof `json:"proof,omitempty"` }
DIDDoc a W3C compliant signed DID Document
func AddKeyToDIDDoc ¶
func AddKeyToDIDDoc(doc DIDDoc, keyToAdd KeyDef, signingKey ed25519.PrivateKey, signingKeyRef string) (*DIDDoc, error)
AddKeyToDIDDoc takes a DID Doc, a key to add, and a signing key and its reference. The signing key must match the key that the current DID Doc is signed with, this is used to update the proof on the document and authenticate the update action. The check is based on the deterministic generation of the DID, which is only applicable for did:work DIDs. Conflict checking is done on the key reference.
func DeactivateDIDDoc ¶
func DeactivateDIDDoc(doc DIDDoc, key ed25519.PrivateKey) (*DIDDoc, error)
DeactivateDIDDoc creates a deactivated DID Document. Returns an error if the Signer fails to generate the digital signature. Uses the same signature type as is on the provided DID Doc
func DeactivateDIDDocGeneric ¶
func DeactivateDIDDocGeneric(signer proof.Signer, signatureType proof.SignatureType, did DID) (*DIDDoc, error)
DeactivateDIDDocGeneric creates a deactivated DID Document. Returns an error if the Signer fails to generate the digital signature.
func GenerateWorkDIDDoc ¶
func GenerateWorkDIDDoc(keyType proof.KeyType, signatureType proof.SignatureType) (*DIDDoc, ed25519.PrivateKey)
func GenerateWorkDIDDocWithContext ¶
func GenerateWorkDIDDocWithContext(keyType proof.KeyType, signatureType proof.SignatureType, context []string) (*DIDDoc, ed25519.PrivateKey)
func (*DIDDoc) GetPublicKey ¶
func (*DIDDoc) GetVerificationMethod ¶
type KeyDef ¶
type KeyDef struct { ID URI `json:"id"` Type proof.KeyType `json:"type"` Controller DID `json:"controller"` PublicKeyBase58 string `json:"publicKeyBase58,omitempty"` PublicKeyJwk *JWK `json:"publicKeyJwk,omitempty"` }
KeyDef represents a DID public key (also known as Verification Method)
func GetProofCreatorKeyDef ¶
GetProofCreatorKeyDef returns the Key Definition that can be used to verify the Proof on the given DID Document. This assumes that DID Documents are self-signed, which is always the case in Workday. Returns an error if the public key is not found.
func (*KeyDef) GetDecodedPublicKey ¶
func (*KeyDef) GetKeyFragment ¶
type KeyRef ¶
KeyRef is either a string or an embedded KeyDef
func (KeyRef) MarshalJSON ¶
func (*KeyRef) UnmarshalJSON ¶
type ServiceDef ¶
type StringOrArray ¶
type StringOrArray []string
StringOrArray is a string or an ordered set of strings
func (StringOrArray) MarshalJSON ¶
func (s StringOrArray) MarshalJSON() ([]byte, error)
func (*StringOrArray) UnmarshalJSON ¶
func (s *StringOrArray) UnmarshalJSON(data []byte) error