vdr

package
Version: v0.0.0-...-95de4c1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 15 Imported by: 18

Documentation

Index

Constants

View Source
const (
	TRUSTEE         = "0"
	STEWARD         = "2"
	ENDORSER        = "101"
	NETWORK_MONITOR = "201"
)
View Source
const (
	NODE          = "0"
	NYM           = "1"
	ATTRIB        = "100"
	SCHEMA        = "101"
	CLAIM_DEF     = "102"
	POOL_UPGRADE  = "109"
	NODE_UPGRADE  = "110"
	POOL_CONFIG   = "111"
	GET_TXN       = "3"
	GET_ATTR      = "104"
	GET_NYM       = "105"
	GET_SCHEMA    = "107"
	GET_CLAIM_DEF = "108"
	GET_AUTH_RULE = "121"

	AuthActionAdd  = "ADD"
	AuthActionEdit = "EDIT"

	DefaultRequestDID = "LibindyDid111111111111"

	NoRole             = ""    // None (common USER)
	TrusteeRole        = "0"   // (TRUSTEE)
	Steward            = "2"   // (STEWARD)
	EndorserRole       = "101" // (ENDORSER)
	NetworkMonitorRole = "201" // (NETWORK_MONITOR))
)

Variables

This section is empty.

Functions

func SerializeSignature

func SerializeSignature(value map[string]interface{}) (string, error)

Types

type Attrib

type Attrib struct {
	Operation `json:",inline"`
	Dest      string                 `json:"dest"`
	Raw       interface{}            `json:"raw,omitempty"`
	Hash      string                 `json:"hash,omitempty"`
	Enc       string                 `json:"enc,omitempty"`
	Data      map[string]interface{} `json:"-"`
}

type AttribRequest

type AttribRequest struct {
	Operation `json:",inline"`
	Dest      string `json:"dest"`
	Raw       string `json:"raw,omitempty"`
	Hash      string `json:"hash,omitempty"`
	Enc       string `json:"enc,omitempty"`
}

type AuthAddRuleRequest

type AuthAddRuleRequest struct {
	AuthRuleRequest
	NewValue string `json:"new_value"`
}

type AuthEditRuleRequest

type AuthEditRuleRequest struct {
	AuthAddRuleRequest
	OldValue string `json:"old_value"`
}

type AuthRuleRequest

type AuthRuleRequest struct {
	Operation  `json:",inline"`
	AuthAction string `json:"auth_action,omitempty"`
	AuthType   string `json:"auth_type,omitempty"`
	Field      string `json:"field,omitempty"`
}

type ClaimDef

type ClaimDef struct {
	Operation     `json:",inline"`
	SignatureType string       `json:"signature_type"`
	Ref           uint32       `json:"ref"`
	Tag           string       `json:"tag,omitempty"`
	Data          ClaimDefData `json:"data"`
}

type ClaimDefData

type ClaimDefData struct {
	ID         string                 `json:"-"`
	Primary    map[string]interface{} `json:"primary"`
	Revocation map[string]interface{} `json:"revocation,omitempty"`
}

func (*ClaimDefData) PKey

func (r *ClaimDefData) PKey() string

func (*ClaimDefData) RKey

func (r *ClaimDefData) RKey() string

func (*ClaimDefData) UnmarshalReadReply

func (r *ClaimDefData) UnmarshalReadReply(rply *ReadReply) error

type Client

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

func New

func New(genesis io.ReadCloser) (*Client, error)

New creates an Indy IndyVDR client connected to the Indy distributed ledger identified by the genesis file provided as a reader.

func (*Client) Close

func (r *Client) Close() error

Close shuts down the connection and frees all resources form the indy distributed ledger

func (*Client) CreateAttrib

func (r *Client) CreateAttrib(did, from string, data map[string]interface{}, signer Signer) error

func (*Client) CreateClaimDef

func (r *Client) CreateClaimDef(from string, ref uint32, pubKey, revocation map[string]interface{}, signer Signer) (string, error)

func (*Client) CreateNym

func (r *Client) CreateNym(did, verkey, role, from string, signer Signer) error

func (*Client) CreateSchema

func (r *Client) CreateSchema(issuerDID, name, version string, attrs []string, signer Signer) (string, error)

func (*Client) Genesis

func (r *Client) Genesis() []byte

Genesis returns the genesis file of the network to which this client is connected

func (*Client) GetAcceptanceMethodList

func (r *Client) GetAcceptanceMethodList() (*ReadReply, error)

GetAcceptanceMethodList fetches the current ledger Acceptance Methods List (for the TAA)

func (*Client) GetAttrib

func (r *Client) GetAttrib(did, raw string) (*ReadReply, error)

GetAttrib fetches the attribute from the raw field of the provided DID

func (*Client) GetAuthRules

func (r *Client) GetAuthRules() (*ReadReply, error)

GetAuthRules fetches all AUTH rules for the ledger

func (*Client) GetCredDef

func (r *Client) GetCredDef(credDefID string) (*ReadReply, error)

GetCredDef returns the credential definition defined by credDefID on the Indy distributed ledger

func (*Client) GetEndpoint

func (r *Client) GetEndpoint(did string) (*ReadReply, error)

GetEndpoint fetches the registered endpoint for a DID

func (*Client) GetNym

func (r *Client) GetNym(did string) (*ReadReply, error)

GetNym fetches the NYM transaction associated with a DID

func (*Client) GetPoolStatus

func (r *Client) GetPoolStatus() (*PoolStatus, error)

GetPoolStatus fetches the current status and node list of the distributed ledger

func (*Client) GetSchema

func (r *Client) GetSchema(schemaID string) (*ReadReply, error)

GetSchema returns the schema definition defined by schemaID on the Indy distributed ledger

func (*Client) GetTxnAuthorAgreement

func (r *Client) GetTxnAuthorAgreement() (*ReadReply, error)

GetTxnAuthorAgreement fetches the current ledger Transaction Author Agreement

func (*Client) GetTxnTypeAuthRule

func (r *Client) GetTxnTypeAuthRule(typ, action, field string) (*ReadReply, error)

TODO: figure out why "*" doesn't work as a wildcard for field GetTxnTypeAuthRule fetches the AUTH rule for a specific transaction type and action

func (*Client) RefreshPool

func (r *Client) RefreshPool() error

RefreshPool retrieves the current pool transactions for the ledger

func (*Client) SetEndpoint

func (r *Client) SetEndpoint(did, from string, ep string, signer Signer) error

func (*Client) Submit

func (r *Client) Submit(request []byte) (*ReadReply, error)

Submit is used to send prepared read requests to the ledger where the request parameter is the JSON-formatted payload.

func (*Client) SubmitWrite

func (r *Client) SubmitWrite(req *Request, signer Signer) (*WriteReply, error)

SubmitWrite is used to send prepared write requests to the ledger where the req parameter is the JSON-formatted payload. the signer defined a service capable of signing a message that is allowed to be written to the ledger.

type ErrorReply

type ErrorReply struct {
	Op     string `json:"op"`
	Reason string `json:"reason"`
}

func (ErrorReply) Error

func (r ErrorReply) Error() string

type GetClaimDef

type GetClaimDef struct {
	Operation     `json:",inline"`
	Origin        string `json:"origin"`
	SignatureType string `json:"signature_type"`
	Ref           uint32 `json:"ref"`
	Tag           string `json:"tag,omitempty"`
}

type GetSchema

type GetSchema struct {
	Operation `json:",inline"`
	Dest      string        `json:"dest"`
	Data      getSchemaData `json:"data"`
}

type Handle

type Handle C.ulong

type Metadata

type Metadata struct {
	TxnTime int    `json:"txnTime"`
	SeqNo   int    `json:"seqNo"`
	TxnID   string `json:"txnId"`
}

type Nym

type Nym struct {
	Operation `json:",inline"`
	Dest      string `json:"dest"`
	Role      string `json:"role,omitempty"`
	Verkey    string `json:"verkey,omitempty"`
}

type NymRequest

type NymRequest struct {
	Operation `json:",inline"`
	Dest      string `json:"dest"`
}

type Operation

type Operation struct {
	Type string `json:"type"`
}

type PoolStatus

type PoolStatus struct {
	Root  string   `json:"mt_root"`
	Size  int      `json:"mt_size"`
	Nodes []string `json:"nodes"`
}

type ReadReply

type ReadReply struct {
	Type          string      `json:"type"`
	Identifier    string      `json:"identifier,omitempty"`
	ReqID         uint32      `json:"reqId"`
	SeqNo         uint32      `json:"seqNo"`
	TxnTime       uint32      `json:"TxnTime"`
	StateProof    StateProof  `json:"state_proof"`
	Data          interface{} `json:"data"`
	SignatureType string      `json:"signature_type,omitempty"`
	Origin        string      `json:"origin,omitempty"`
	Dest          string      `json:"dest,omitempty"`
	Ref           uint32      `json:"ref,omitempty"`
	Tag           string      `json:"tag,omitempty"`
}

type ReadSuccessReply

type ReadSuccessReply struct {
	Op     string     `json:"op"`
	Result *ReadReply `json:"result"`
}

type RefreshResponse

type RefreshResponse struct {
	ErrorCode int
}

type ReqSigValue

type ReqSigValue struct {
	From  string `json:"from"`
	Value string `json:"value"`
}

type ReqSignature

type ReqSignature struct {
	Type   string        `json:"type"`
	Values []ReqSigValue `json:"values"`
}

type Request

type Request struct {
	Operation       interface{}    `json:"operation"`
	Identifier      string         `json:"identifier,omitempty"`
	Endorser        string         `json:"endorser,omitempty"`
	ReqID           uint32         `json:"reqId"`
	ProtocolVersion int            `json:"protocolVersion"`
	Signature       string         `json:"signature,omitempty"`
	TAAAcceptance   *TAAAcceptance `json:"taaAcceptance,omitempty"`
}

func NewAuthAddRuleRequest

func NewAuthAddRuleRequest(typ, field string) *Request

func NewAuthEditRuleRequest

func NewAuthEditRuleRequest(typ, field string) *Request

func NewAuthRulesRequest

func NewAuthRulesRequest() *Request

func NewClaimDef

func NewClaimDef(from string, ref uint32, primary, revocation map[string]interface{}) *Request

func NewEncAttrib

func NewEncAttrib(did, data, from string) *Request

func NewEncAttribRequest

func NewEncAttribRequest(did, data, from string) *Request

func NewGetClaimDef

func NewGetClaimDef(origin string, ref uint32) *Request

func NewGetSchema

func NewGetSchema(issuerDID, name, version, from string) *Request

func NewHashAttrib

func NewHashAttrib(did, data, from string) *Request

func NewHashAttribRequest

func NewHashAttribRequest(did, data, from string) *Request

func NewNym

func NewNym(did, verkey, from, role string) *Request

func NewNymRequest

func NewNymRequest(did, from string) *Request

func NewRawAttrib

func NewRawAttrib(did, from string, data map[string]interface{}) *Request

func NewRawAttribRequest

func NewRawAttribRequest(did, raw, from string) *Request

func NewSchema

func NewSchema(issuerDID, name, version, from string, attrs []string) *Request

type Schema

type Schema struct {
	Operation `json:",inline"`
	Dest      string     `json:"dest"`
	Data      SchemaData `json:"data"`
}

type SchemaData

type SchemaData struct {
	ID        string   `json:"id"`
	SeqNo     uint32   `json:"seq_no"`
	Name      string   `json:"name"`
	Version   string   `json:"version"`
	AttrNames []string `json:"attr_names"`
}

type SigValue

type SigValue struct {
	Timestamp         int    `json:"timestamp"`
	LedgerID          int    `json:"ledger_id"`
	TxnRootHash       string `json:"txn_root_hash"`
	PoolStateRootHash string `json:"pool_state_root_hash"`
	StateRootHash     string `json:"state_root_hash"`
}

type Signatures

type Signatures struct {
	Value        SigValue `json:"value"`
	Signature    string   `json:"signature"`
	Participants []string `json:"participants"`
}

type Signer

type Signer interface {
	Sign([]byte) ([]byte, error)
}

type SortedMap

type SortedMap struct {
	Keys []string
	// contains filtered or unexported fields
}

func NewSortedMap

func NewSortedMap(m map[string]interface{}) *SortedMap

func (*SortedMap) Get

func (r *SortedMap) Get(k string) interface{}

type StateProof

type StateProof struct {
	RootHash        string     `json:"root_hash"`
	ProofNodes      string     `json:"proof_nodes"`
	MultiSignatures Signatures `json:"multi_signatures"`
}

type StatusResponse

type StatusResponse struct {
	ErrorCode int
	Response  string
}

type SubmitResponse

type SubmitResponse struct {
	ErrorCode int
	Response  string
}

type TAAAcceptance

type TAAAcceptance struct {
	Digest    string `json:"taaDigest,omitempty"`
	Mechanism string `json:"mechanism,omitempty"`
	Time      uint32 `json:"time,omitempty"`
}

type WriteReply

type WriteReply struct {
	Ver          string                      `json:"ver"`
	Txn          WriteReplyResultTxn         `json:"txn"`
	TxnMetadata  WriteReplyResultTxnMetadata `json:"txnMetadata"`
	ReqSignature ReqSignature                `json:"reqSignature"`
	RootHash     string                      `json:"rootHash"`
	AuditPath    []string                    `json:"auditPath"`
}

type WriteReplyResultTxn

type WriteReplyResultTxn struct {
	Type            string                 `json:"type"`
	ProtocolVersion int                    `json:"protocolVersion"`
	Data            map[string]interface{} `json:"data"`
	Metadata        map[string]interface{} `json:"metadata"`
}

type WriteReplyResultTxnMetadata

type WriteReplyResultTxnMetadata struct {
	TxnTime int    `json:"txnTime"`
	SeqNo   int    `json:"seqNo"`
	TxnID   string `json:"txnId"`
}

type WriteSuccessReply

type WriteSuccessReply struct {
	Op     string      `json:"op"`
	Result *WriteReply `json:"result"`
}

Jump to

Keyboard shortcuts

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