Documentation ¶
Index ¶
- Constants
- type AbstractKey
- type DID
- func (did *DID) AddDIDKey(key *DIDKey) (*DID, error)
- func (did *DID) AddManagementKey(key *ManagementKey) (*DID, error)
- func (did *DID) AddService(service *Service) (*DID, error)
- func (did *DID) Copy() *DID
- func (did *DID) Create() (*factom.Entry, error)
- func (did *DID) Deactivate(signingKeyAlias string) (*factom.Entry, error)
- func (did *DID) GetChainID() string
- func (did *DID) RevokeDIDKey(alias string) (*DID, error)
- func (did *DID) RevokeManagementKey(alias string) (*DID, error)
- func (did *DID) RevokeService(alias string) (*DID, error)
- func (did *DID) SetMainnet() *DID
- func (did *DID) SetTestnet() *DID
- func (did *DID) String() string
- func (did *DID) Update(updatedDID *DID, signingKeyAlias string) (*factom.Entry, error)
- func (did *DID) Validate() error
- type DIDDeactivationEntrySchema
- type DIDKey
- type DIDKeyPurpose
- type DIDKeySchema
- type DIDManagementEntrySchema
- type DIDUpdateEntrySchema
- type ManagementKey
- type ManagementKeySchema
- type RevokeIDSchema
- type Service
- type ServiceSchema
Constants ¶
const ( // KeyTypeECDSA is a constant for "ECDSASecp256k1VerificationKey" KeyTypeECDSA = "ECDSASecp256k1VerificationKey" // KeyTypeEdDSA is a constant for "Ed25519VerificationKey" KeyTypeEdDSA = "Ed25519VerificationKey" // KeyTypeRSA is a constant for "RSAVerificationKey" KeyTypeRSA = "RSAVerificationKey" )
const ( // EntryTypeCreate is ExtID "DIDManagement" used in the first entry of DID chain EntryTypeCreate = "DIDManagement" // EntryTypeDeactivation is ExtID "DIDDeactivation" used in deactivation entry EntryTypeDeactivation = "DIDDeactivation" // EntryTypeUpdate is ExtID "DIDUpdate" used in update entry EntryTypeUpdate = "DIDUpdate" // EntryTypeVersionUpgrade is ExtID "DIDMethodVersionUpgrade" used in version upgrade entry EntryTypeVersionUpgrade = "DIDMethodVersionUpgrade" // NetworkMainnet is "mainnet" NetworkMainnet = "mainnet" // NetworkTestnet is "testnet" NetworkTestnet = "testnet" // NetworkUnspecified is empty string NetworkUnspecified = "" // DIDMethodName is method name for Factom DID, used in DID Document DIDMethodName = "did:factom" // MaxEntrySize is maximum size of Factom Entry MaxEntrySize = 10240 // EntrySchemaV100 is version 1.0.0 of entry schema EntrySchemaV100 = "1.0.0" // DIDMethodSpecV020 is version 0.2.0 of DID specification DIDMethodSpecV020 = "0.2.0" // LatestEntrySchema is latest available entry schema LatestEntrySchema = EntrySchemaV100 // LatestDIDMethodSpec is latest available DID specification version LatestDIDMethodSpec = DIDMethodSpecV020 )
const ( // KeyPurposeAuthentication is authentication purpose KeyPurposeAuthentication = "authentication" // KeyPurposePublic is publicKey purpose KeyPurposePublic = "publicKey" // OnChainPubKeyName is name of public key on-chain OnChainPubKeyName = "publicKeyBase58" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractKey ¶
type AbstractKey struct { Alias string `json:"alias" form:"alias" query:"alias" validate:"required"` KeyType string `` /* 143-byte string literal not displayed */ Controller string `json:"controller" form:"controller" query:"controller" validate:"required"` PriorityRequirement *int `json:"priorityRequirement" form:"priorityRequirement" query:"omitempty,priorityRequirement"` PublicKey []byte `json:"publicKey" form:"publicKey" query:"publicKey" validate:"required"` PrivateKey []byte `json:"privateKey" form:"privateKey" query:"privateKey" validate:"required"` }
AbstractKey represents the common fields and functionality in a ManagementKey and a DIDKey.
func (*AbstractKey) SetPriorityRequirement ¶
func (key *AbstractKey) SetPriorityRequirement(i int) *AbstractKey
SetPriorityRequirement sets PriorityRequirement for AbstractKey
type DID ¶
type DID struct { ID string `json:"id" form:"id" query:"id" validate:"required"` Network string `json:"network" form:"network" query:"network"` ManagementKeys []*ManagementKey `json:"managementKeys" form:"managementKeys" query:"managementKeys" validate:"required"` DIDKeys []*DIDKey `json:"didKeys" form:"didKeys" query:"didKeys" validate:"required"` Services []*Service `json:"services" form:"services" query:"services"` ExtIDs [][]byte `json:"extIDs" form:"extIDs" query:"extIDs"` }
DID describes DID document
func NewDID ¶
func NewDID() *DID
NewDID generates new blank DID document. DID.ExtIDs is a helper field that stores ExtIDs to be written on-chain to get expected ChainID for new DID chain. DID.ExtIDs is not a part of DID Document (JSON)
func (*DID) AddManagementKey ¶
func (did *DID) AddManagementKey(key *ManagementKey) (*DID, error)
AddManagementKey adds a new Management key to the DID object
func (*DID) AddService ¶
AddService adds a new Service to the DID object
func (*DID) Deactivate ¶
Deactivate generates DIDDeactivation Factom Entry signed with ManagementKey (priority=0 key required)
func (*DID) GetChainID ¶
GetChainID gets ChainID from DID string
func (*DID) RevokeDIDKey ¶
RevokeDIDKey revokes DID Key from DID object
func (*DID) RevokeManagementKey ¶
RevokeManagementKey revokes Management Key from DID object
func (*DID) RevokeService ¶
RevokeService revokes Service from DID object
func (*DID) SetMainnet ¶
SetMainnet sets the DID network to mainnet
func (*DID) SetTestnet ¶
SetTestnet sets the DID network to testnet
type DIDDeactivationEntrySchema ¶
type DIDDeactivationEntrySchema struct{}
type DIDKey ¶
type DIDKey struct { AbstractKey Purpose []DIDKeyPurpose `json:"purpose" form:"purpose" query:"purpose" validate:"len=1|len=2,unique,required,dive"` }
DIDKey is a key used to sign updates for an existing DID DIDKey.Purpose may be publicKey, authentication or both
type DIDKeyPurpose ¶
type DIDKeyPurpose struct {
Purpose string `json:"purpose" form:"purpose" query:"purpose" validate:"required,oneof=publicKey authentication"`
}
DIDKeyPurpose shows what purpose(s) the key serves
type DIDKeySchema ¶
type DIDKeySchema struct { Controller string `json:"controller" form:"controller" query:"controller"` ID string `json:"id" form:"id" query:"id"` PublicKeyBase58 string `json:"publicKeyBase58,omitempty" form:"publicKeyBase58" query:"publicKeyBase58"` PublicKeyPem string `json:"publicKeyPem,omitempty" form:"publicKeyPem" query:"publicKeyPem"` Purpose []string `json:"purpose" form:"purpose" query:"purpose"` Type string `json:"type" form:"type" query:"type"` PriorityRequirement *int `json:"priorityRequirement,omitempty" form:"priorityRequirement" query:"priorityRequirement"` BIP44 string `json:"bip44,omitempty" form:"bip44" query:"bip44"` }
type DIDManagementEntrySchema ¶
type DIDManagementEntrySchema struct { DIDKey []*DIDKeySchema `json:"didKey" form:"didKey" query:"didKey"` DIDMethodVersion string `json:"didMethodVersion" form:"didMethodVersion" query:"didMethodVersion"` ManagementKey []*ManagementKeySchema `json:"managementKey" form:"managementKey" query:"managementKey"` Service []*ServiceSchema `json:"service,omitempty" form:"service" query:"service"` }
type DIDUpdateEntrySchema ¶
type DIDUpdateEntrySchema struct { Add struct { DIDKey []*DIDKeySchema `json:"didKey,omitempty" form:"didKey" query:"didKey"` ManagementKey []*ManagementKeySchema `json:"managementKey,omitempty" form:"managementKey" query:"managementKey"` Service []*ServiceSchema `json:"service,omitempty" form:"service" query:"service"` } Revoke struct { DIDKey []*RevokeIDSchema `json:"didKey,omitempty" form:"didKey" query:"didKey"` ManagementKey []*RevokeIDSchema `json:"managementKey,omitempty" form:"managementKey" query:"managementKey"` Service []*RevokeIDSchema `json:"service,omitempty" form:"service" query:"service"` } }
type ManagementKey ¶
type ManagementKey struct { AbstractKey Priority int `json:"priority" form:"priority" query:"priority" validate:"min=0"` }
ManagementKey is a key used to sign updates for an existing DID
func NewManagementKey ¶
func NewManagementKey(alias string, keyType string, priority int) (*ManagementKey, error)
NewManagementKey generates new ManagementKey with alias and keyType
type ManagementKeySchema ¶
type ManagementKeySchema struct { Controller string `json:"controller" form:"controller" query:"controller"` ID string `json:"id" form:"id" query:"id"` PublicKeyBase58 string `json:"publicKeyBase58,omitempty" form:"publicKeyBase58" query:"publicKeyBase58"` PublicKeyPem string `json:"publicKeyPem,omitempty" form:"publicKeyPem" query:"publicKeyPem"` Type string `json:"type" form:"type" query:"type"` Priority int `json:"priority" form:"priority" query:"priority"` PriorityRequirement *int `json:"priorityRequirement,omitempty" form:"priorityRequirement" query:"priorityRequirement"` BIP44 string `json:"bip44,omitempty" form:"bip44" query:"bip44"` }
type RevokeIDSchema ¶
type RevokeIDSchema struct {
ID string `json:"id" form:"id" query:"id"`
}
type Service ¶
type Service struct { Alias string `json:"alias" form:"alias" query:"alias" validate:"required"` ServiceType string `json:"serviceType" form:"serviceType" query:"serviceType" validate:"required"` Endpoint string `json:"endpoint" form:"endpoint" query:"endpoint" validate:"required,url"` PriorityRequirement *int `json:"priorityRequirement" form:"priorityRequirement" query:"priorityRequirement" validate:"omitempty,min=0"` CustomField []byte `json:"customFields" form:"customFields" query:"customFields"` }
Service represents a service associated with a DID. A service is an end-point, which can be used to communicate with the DID or to carry out different tasks on behalf of the DID (such as signatures, e.g.)
func NewService ¶
NewService creates new Service
func (*Service) SetPriorityRequirement ¶
SetPriorityRequirement sets PriorityRequirement for Service
type ServiceSchema ¶
type ServiceSchema struct { ID string `json:"id" form:"id" query:"id"` Type string `json:"type" form:"type" query:"type"` ServiceEndpoint string `json:"serviceEndpoint" form:"serviceEndpoint" query:"serviceEndpoint"` PriorityRequirement *int `json:"priorityRequirement,omitempty" form:"priorityRequirement" query:"priorityRequirement"` }