did

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: GPL-3.0 Imports: 13 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 VerifyByVM

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

Types

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

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
	CredentialDoc *VerifiableCredentialDoc
	Ticket        *CustomIDTicket
}

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 {
	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              []Service              `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"`
	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 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 Service

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

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 {
	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 {
	*VerifiableCredential `json:"verifiableCredential,omitempty"`
}

type VerifiableCredentialTxData

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

Directories

Path Synopsis
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.

Jump to

Keyboard shortcuts

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