did

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: GPL-3.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Create_DID_Operation                    = "create"
	Update_DID_Operation                    = "update"
	Transfer_DID_Operation                  = "transfer"
	Deactivate_DID_Operation                = "deactivate"
	Declare_Verifiable_Credential_Operation = "declare"
	Revoke_Verifiable_Credential_Operation  = "revoke"
	DID_ELASTOS_PREFIX                      = "did:elastos:"
	ID_STRING                               = "id"
)
View Source
const DIDVersion = 0x00
View Source
const FeeRate int64 = 10000000000
View Source
const PrefixCRDID contract.PrefixType = 0x67
View Source
const VerifiableCredentialVersion = 0x00

Variables

View Source
var MainNetDIDParams = DIDParams{
	CustomIDFeeRate: 50000,
}
View Source
var RegNetDIDParams = DIDParams{
	CustomIDFeeRate: 50000,
}
View Source
var TestNetDIDParams = DIDParams{
	CustomIDFeeRate: 50000,
}

Functions

func CheckSignature

func CheckSignature(iDateContainer interfaces.IDataContainer, publickBase58, signatureBase64 string) error

func CreateCRIDContractByCode

func CreateCRIDContractByCode(code []byte) (*contract.Contract, error)

func GetCodeByPubKey

func GetCodeByPubKey(publicKey []byte) ([]byte, error)

func GetController

func GetController(uriPublic string) (string, string)

URI Public string like verification method and creator and so on

func GetDIDAddress

func GetDIDAddress(publicKey []byte) (string, error)

func GetDIDFromUri

func GetDIDFromUri(idURI string) string

func IsCompact

func IsCompact(target string) bool

func IsDID

func IsDID(ID string, publicKey []DIDPublicKeyInfo) bool

func IsMatched

func IsMatched(publicKey []byte, did string) bool

func IsPublickDIDMatched

func IsPublickDIDMatched(PublicKeyBase58 string, did string) bool

func JSONMarshal added in v0.2.0

func JSONMarshal(t interface{}) ([]byte, error)

func MarshalAuthentication added in v0.2.0

func MarshalAuthentication(auth interface{}, buf *bytes.Buffer) error

func MarshalCredentialSubject added in v0.2.0

func MarshalCredentialSubject(credentialSubject interface{}, buf *bytes.Buffer) error

func MarshalDIDPayloadData added in v0.2.0

func MarshalDIDPayloadData(p *DIDPayloadData) ([]byte, error)

func MarshalDocData added in v0.2.0

func MarshalDocData(doc *DIDDoc) ([]byte, error)

func MarshalService added in v0.2.0

func MarshalService(service interface{}, buf *bytes.Buffer) error

func MarshalVerifiableCredential added in v0.2.0

func MarshalVerifiableCredential(p VerifiableCredential, buf *bytes.Buffer) error

func MarshalVerifiableCredentialData added in v0.2.0

func MarshalVerifiableCredentialData(p *VerifiableCredentialData, buf *bytes.Buffer) error

func VerifyByVM

func VerifyByVM(iDateContainer interfaces.IDataContainer,
	code []byte,
	signature []byte) (bool, error)

Types

type ControllerSlice added in v0.2.0

type ControllerSlice []interface{}

func (ControllerSlice) Len added in v0.2.0

func (s ControllerSlice) Len() int

func (ControllerSlice) Less added in v0.2.0

func (s ControllerSlice) Less(i, j int) bool

func (ControllerSlice) Swap added in v0.2.0

func (s ControllerSlice) Swap(i, j int)

type CredentialProof

type CredentialProof struct {
	Type               string `json:"type,omitempty"`
	Created            string `json:"created,omitempty"`
	VerificationMethod string `json:"verificationMethod"`
	Nonce              string `json:"nonce,omitempty"`
	Realm              string `json:"realm,omitempty"`
	Signature          string `json:"signature"`
}

Proof of DID transaction payload

type CustomIDTicket

type CustomIDTicket struct {
	*CustomIDTicketData
	Proof interface{} `json:"proof"`
}

func (*CustomIDTicket) GetData

func (c *CustomIDTicket) GetData() []byte

type CustomIDTicketData

type CustomIDTicketData struct {
	CustomID      string `json:"id"`
	To            string `json:"to"`
	TransactionID string `json:"txid"`
}

func (*CustomIDTicketData) GetData

func (c *CustomIDTicketData) GetData() []byte

type DIDDoc

type DIDDoc struct {
	*DIDPayloadData
	Proof interface{} `json:"proof,omitempty"`
}

payload in DID transaction payload

func (*DIDDoc) GetData added in v0.2.0

func (c *DIDDoc) GetData() []byte

type DIDParams

type DIDParams struct {
	// CustomIDFeeRate defines the default fee rate of registerCustomID transaction
	CustomIDFeeRate common.Fixed64
	IsTest          bool
}

type DIDPayload

type DIDPayload struct {
	Header  Header `json:"header"`
	Payload string `json:"payload"`
	Proof   Proof  `json:"proof"`

	DIDDoc        *DIDDoc                  `json:"-"`
	CredentialDoc *VerifiableCredentialDoc `json:"-"`
	Ticket        *CustomIDTicket          `json:"ticket,omitempty"`
}

payload of DID transaction

func (*DIDPayload) Data

func (p *DIDPayload) Data(version byte) []byte

func (*DIDPayload) Deserialize

func (p *DIDPayload) Deserialize(r io.Reader, version byte) error

func (*DIDPayload) GetDIDDoc

func (p *DIDPayload) GetDIDDoc() *DIDDoc

func (*DIDPayload) GetData

func (p *DIDPayload) GetData() []byte

func (*DIDPayload) Serialize

func (p *DIDPayload) Serialize(w io.Writer, version byte) error

type DIDPayloadData

type DIDPayloadData struct {
	Context              []string               `json:"@context,omitempty"`
	ID                   string                 `json:"id"`
	Controller           interface{}            `json:"controller,omitempty"`
	MultiSig             string                 `json:"multisig,omitempty"`
	PublicKey            []DIDPublicKeyInfo     `json:"publicKey,omitempty"`
	Authentication       []interface{}          `json:"authentication,omitempty"`
	Authorization        []interface{}          `json:"authorization,omitempty"`
	VerifiableCredential []VerifiableCredential `json:"verifiableCredential,omitempty"`
	Service              []interface{}          `json:"service,omitempty"`
	Expires              string                 `json:"expires"`
}

func (*DIDPayloadData) GetData

func (c *DIDPayloadData) GetData() []byte

type DIDPublicKeyInfo

type DIDPublicKeyInfo struct {
	ID              string `json:"id"`
	Type            string `json:"type,omitempty"`
	Controller      string `json:"controller"`
	PublicKeyBase58 string `json:"publicKeyBase58"`
}

public keys of payload in DID transaction payload

func (*DIDPublicKeyInfo) Deserialize

func (p *DIDPublicKeyInfo) Deserialize(r io.Reader, version byte) error

func (*DIDPublicKeyInfo) Serialize

func (p *DIDPublicKeyInfo) Serialize(w io.Writer, version byte) error

type DIDTransactionData

type DIDTransactionData struct {
	TXID      string     `json:"txid"`
	Timestamp string     `json:"timestamp"`
	Operation DIDPayload `json:"operation"`
}

type DocProof

type DocProof struct {
	Type           string `json:"type,omitempty"`
	Created        string `json:"created"`
	Creator        string `json:"creator"`
	SignatureValue string `json:"signatureValue"`
}

Proof of DID transaction doc

func (*DocProof) Deserialize

func (d *DocProof) Deserialize(r io.Reader, version byte) error

func (*DocProof) Serialize

func (d *DocProof) Serialize(w io.Writer, version byte) error
type Header struct {
	Specification string `json:"specification"`
	Operation     string `json:"operation"`
	PreviousTxid  string `json:"previousTxid,omitempty"`
	Ticket        string `json:"ticket,omitempty"`
}

header of Customized DID transaction payload

func (*Header) Deserialize

func (d *Header) Deserialize(r io.Reader, version byte) error

func (*Header) Serialize

func (d *Header) Serialize(w io.Writer, version byte) error

type ListDIDVerifCreentials added in v0.2.0

type ListDIDVerifCreentials struct {
	DID         string   `json:"did"`
	Credentials []string `json:"credentials"`
}

type Proof

type Proof struct {
	Type               string `json:"type,omitempty"`
	VerificationMethod string `json:"verificationMethod"`
	Signature          string `json:"signature"`
}

Proof of DID transaction payload

func (*Proof) Deserialize

func (d *Proof) Deserialize(r io.Reader, version byte) error

func (*Proof) Serialize

func (d *Proof) Serialize(w io.Writer, version byte) error

type PublicKeysSlice added in v0.1.3

type PublicKeysSlice []DIDPublicKeyInfo

func (PublicKeysSlice) Len added in v0.1.3

func (a PublicKeysSlice) Len() int

func (PublicKeysSlice) Less added in v0.1.3

func (a PublicKeysSlice) Less(i, j int) bool

func (PublicKeysSlice) Swap added in v0.1.3

func (a PublicKeysSlice) Swap(i, j int)

type Service

type Service struct {
	ID              string `json:"id"`
	Type            string `json:"type"`
	ServiceEndpoint string `json:"serviceEndpoint"`
}

type ServiceSlice added in v0.1.3

type ServiceSlice []interface{}

func (ServiceSlice) Len added in v0.1.3

func (s ServiceSlice) Len() int

func (ServiceSlice) Less added in v0.1.3

func (s ServiceSlice) Less(i, j int) bool

func (ServiceSlice) Swap added in v0.1.3

func (s ServiceSlice) Swap(i, j int)

type TicketProof

type TicketProof struct {
	Type               string `json:"type,omitempty"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	Signature          string `json:"signature"`
}

Proof of DID transaction ticket

type VerifiableCredential

type VerifiableCredential struct {
	*VerifiableCredentialData
	Proof CredentialProof `json:"proof,omitempty"`
}

func (*VerifiableCredential) CompleteCompact

func (p *VerifiableCredential) CompleteCompact(did string)

func (*VerifiableCredential) GetDIDProofInfo

func (p *VerifiableCredential) GetDIDProofInfo() *CredentialProof

type VerifiableCredentialData

type VerifiableCredentialData struct {
	Context           []string    `json:"@context,omitempty"`
	ID                string      `json:"id"`
	Type              []string    `json:"type,omitempty"`
	Issuer            string      `json:"issuer,omitempty"`
	IssuanceDate      string      `json:"issuanceDate,omitempty"`
	ExpirationDate    string      `json:"expirationDate,omitempty"`
	CredentialSubject interface{} `json:"credentialSubject,omitempty"`
}

func (*VerifiableCredentialData) GetData

func (p *VerifiableCredentialData) GetData() []byte

type VerifiableCredentialDoc

type VerifiableCredentialDoc struct {
	*VerifiableCredentialData
	Proof CredentialProof `json:"proof,omitempty"`
}

func (*VerifiableCredentialDoc) CompleteCompact added in v0.2.0

func (p *VerifiableCredentialDoc) CompleteCompact(did string)

type VerifiableCredentialSlice added in v0.1.3

type VerifiableCredentialSlice []VerifiableCredential

func (VerifiableCredentialSlice) Len added in v0.1.3

func (VerifiableCredentialSlice) Less added in v0.1.3

func (v VerifiableCredentialSlice) Less(i, j int) bool

func (VerifiableCredentialSlice) Swap added in v0.1.3

func (v VerifiableCredentialSlice) Swap(i, j int)

type VerifiableCredentialTxData

type VerifiableCredentialTxData struct {
	TXID      string     `json:"txid"`
	Timestamp string     `json:"timestamp"`
	Operation DIDPayload `json:"operation"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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