command

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 15

Documentation

Index

Constants

View Source
const (
	GetSTH            = "getSTH"
	GetSTHConsistency = "getSTHConsistency"
	GetEntries        = "getEntries"
	GetProofByHash    = "getProofByHash"
	GetEntryAndProof  = "getEntryAndProof"
	GetIssuers        = "getIssuers"
	Webfinger         = "webfinger"
	AddVC             = "addVC"
)

Command methods.

View Source
const (
	// PublicKeyType is the public key property in the Webfinger document.
	PublicKeyType = "https://trustbloc.dev/ns/public-key"
	// LedgerType is the ledger type property in the Webfinger document.
	LedgerType = "https://trustbloc.dev/ns/ledger-type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddVCRequest added in v0.1.2

type AddVCRequest struct {
	Alias   string `json:"alias"`
	VCEntry []byte `json:"vc_entry"`
}

AddVCRequest represents the request to add-vc.

type AddVCResponse

type AddVCResponse struct {
	SVCTVersion Version `json:"svct_version"`
	ID          []byte  `json:"id"`
	Timestamp   uint64  `json:"timestamp"`
	Extensions  string  `json:"extensions"`
	Signature   []byte  `json:"signature"`
}

AddVCResponse represents the response to add-vc.

type Cmd

type Cmd struct {
	VCLogID [32]byte

	PubKey []byte
	// contains filtered or unexported fields
}

Cmd is a controller for commands.

func New

func New(cfg *Config, mf monitoring.MetricFactory) (*Cmd, error)

New returns commands controller.

func (*Cmd) AddVC

func (c *Cmd) AddVC(w io.Writer, r io.Reader) error

AddVC adds verifiable credential to log.

func (*Cmd) GetEntries

func (c *Cmd) GetEntries(w io.Writer, r io.Reader) error

GetEntries retrieves entries from log.

func (*Cmd) GetEntryAndProof

func (c *Cmd) GetEntryAndProof(w io.Writer, r io.Reader) error

GetEntryAndProof retrieves entry and merkle audit proof from log.

func (*Cmd) GetHandlers

func (c *Cmd) GetHandlers() []Handler

GetHandlers returns list of all commands supported by this controller.

func (*Cmd) GetIssuers

func (c *Cmd) GetIssuers(w io.Writer, r io.Reader) error

GetIssuers returns issuers.

func (*Cmd) GetProofByHash

func (c *Cmd) GetProofByHash(w io.Writer, r io.Reader) error

GetProofByHash retrieves Merkle Audit proof from Log by leaf hash.

func (*Cmd) GetSTH

func (c *Cmd) GetSTH(w io.Writer, r io.Reader) error

GetSTH retrieves the latest signed tree head.

func (*Cmd) GetSTHConsistency

func (c *Cmd) GetSTHConsistency(w io.Writer, r io.Reader) error

GetSTHConsistency retrieves merkle consistency proofs between signed tree heads.

func (*Cmd) Webfinger added in v0.1.2

func (c *Cmd) Webfinger(w io.Writer, r io.Reader) error

Webfinger returns discovery info.

type CmdHandler

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

CmdHandler contains command handling details which can be used to build controller commands.

func NewCmdHandler

func NewCmdHandler(method string, exec Exec) *CmdHandler

NewCmdHandler returns instance of CmdHandler which can be used handle controller commands.

func (*CmdHandler) Handle

func (c *CmdHandler) Handle() Exec

Handle returns execute function of this command handler.

func (*CmdHandler) Method

func (c *CmdHandler) Method() string

Method name of the command.

type Config

type Config struct {
	KMS             KeyManager
	Crypto          Crypto
	VDR             vdr.Registry
	Logs            []Log
	DocumentLoaders map[string]jsonld.DocumentLoader // alias -> loader
	Key             Key
	BaseURL         string
}

Config for the Cmd.

type Crypto

type Crypto interface {
	Sign(msg []byte, kh interface{}) ([]byte, error)
}

Crypto interface.

type DigitallySigned

type DigitallySigned struct {
	Algorithm SignatureAndHashAlgorithm `json:"algorithm"`
	Signature []byte                    `json:"signature"`
}

DigitallySigned provides information about a signature.

type Exec

type Exec func(rw io.Writer, req io.Reader) error

Exec is controller command execution function type.

type GetEntriesRequest

type GetEntriesRequest struct {
	Alias string `json:"alias"`
	Start int64  `json:"start"`
	End   int64  `json:"end"`
}

GetEntriesRequest represents the request to the get-entries.

func (*GetEntriesRequest) Validate

func (r *GetEntriesRequest) Validate() error

Validate validates data.

type GetEntriesResponse

type GetEntriesResponse struct {
	Entries []LeafEntry `json:"entries"`
}

GetEntriesResponse represents the response to the get-entries.

type GetEntryAndProofRequest

type GetEntryAndProofRequest struct {
	Alias     string `json:"alias"`
	LeafIndex int64  `json:"leaf_index"`
	TreeSize  int64  `json:"tree_size"`
}

GetEntryAndProofRequest represents the request to get-entry-and-proof.

func (*GetEntryAndProofRequest) Validate

func (r *GetEntryAndProofRequest) Validate() error

Validate validates data.

type GetEntryAndProofResponse

type GetEntryAndProofResponse struct {
	LeafInput []byte   `json:"leaf_input"`
	ExtraData []byte   `json:"extra_data"`
	AuditPath [][]byte `json:"audit_path"`
}

GetEntryAndProofResponse represents the response to get-entry-and-proof.

type GetProofByHashRequest

type GetProofByHashRequest struct {
	Alias    string `json:"alias"`
	Hash     string `json:"hash"`
	TreeSize int64  `json:"tree_size"`
}

GetProofByHashRequest represents the request to the get-proof-by-hash.

func (*GetProofByHashRequest) Validate

func (r *GetProofByHashRequest) Validate() error

Validate validates data.

type GetProofByHashResponse

type GetProofByHashResponse struct {
	LeafIndex int64    `json:"leaf_index"`
	AuditPath [][]byte `json:"audit_path"`
}

GetProofByHashResponse represents the response to the get-proof-by-hash.

type GetSTHConsistencyRequest

type GetSTHConsistencyRequest struct {
	Alias          string `json:"alias"`
	FirstTreeSize  int64  `json:"first_tree_size"`
	SecondTreeSize int64  `json:"second_tree_size"`
}

GetSTHConsistencyRequest represents the request to the get-sth-consistency.

func (*GetSTHConsistencyRequest) Validate

func (r *GetSTHConsistencyRequest) Validate() error

Validate validates data.

type GetSTHConsistencyResponse

type GetSTHConsistencyResponse struct {
	Consistency [][]byte `json:"consistency"`
}

GetSTHConsistencyResponse represents the response to the get-sth-consistency.

type GetSTHResponse

type GetSTHResponse struct {
	TreeSize          uint64 `json:"tree_size"`
	Timestamp         uint64 `json:"timestamp"`
	SHA256RootHash    []byte `json:"sha256_root_hash"`
	TreeHeadSignature []byte `json:"tree_head_signature"`
}

GetSTHResponse represents the response to the get-sth.

type Handler

type Handler interface {
	// Method method name of the command
	Method() string
	// Handle execute function of the command
	Handle() Exec
}

Handler for each controller command.

type Key

type Key struct {
	ID string
}

Key holds info about a key that is using for signing.

type KeyManager

type KeyManager interface {
	Create(kt kms.KeyType, opts ...kms.KeyOpts) (string, interface{}, error)
	Get(keyID string) (interface{}, error)
	ExportPubKeyBytes(keyID string) ([]byte, kms.KeyType, error)
}

KeyManager key manager.

type LeafEntry

type LeafEntry struct {
	LeafInput []byte `json:"leaf_input"`
	ExtraData []byte `json:"extra_data"`
}

LeafEntry represents a leaf in the Log's Merkle tree.

type Log added in v0.1.2

type Log struct {
	// ID trillian`s log id.
	ID         int64
	Alias      string
	Permission string
	Endpoint   string
	Issuers    []string
	Client     TrillianLogClient
}

Log represents the log.

type LogEntryType

type LogEntryType uint64

LogEntryType type definition.

const (
	VCLogEntryType LogEntryType = 100
)

LogEntryType constants.

type MerkleLeafType

type MerkleLeafType uint64

MerkleLeafType type definition.

const (
	TimestampedEntryLeafType MerkleLeafType = 100
)

MerkleLeafType constants.

type MerkleTreeLeaf

type MerkleTreeLeaf struct {
	Version          Version           `json:"version"`
	LeafType         MerkleLeafType    `json:"leaf_type"`
	TimestampedEntry *TimestampedEntry `json:"timestamped_entry"`
}

MerkleTreeLeaf represents the deserialized structure of the hash input for the leaves of a log's Merkle tree.

func CreateLeaf

func CreateLeaf(timestamp uint64, vcBytes []byte, loader jsonld.DocumentLoader) (*MerkleTreeLeaf, error)

CreateLeaf creates MerkleTreeLeaf.

type SignatureAlgorithm

type SignatureAlgorithm string

SignatureAlgorithm type definition.

const (
	ECDSASignature SignatureAlgorithm = "ECDSA"
	EDDSASignature SignatureAlgorithm = "EDDSA"
)

SignatureAlgorithm constants.

type SignatureAndHashAlgorithm

type SignatureAndHashAlgorithm struct {
	Signature SignatureAlgorithm `json:"signature"`
	Type      kms.KeyType        `json:"type"`
}

SignatureAndHashAlgorithm provides information about the algorithm used for the signature.

type SignatureType

type SignatureType uint64

SignatureType differentiates signatures.

const (
	VCTimestampSignatureType SignatureType = 100
	TreeHeadSignatureType    SignatureType = 101
)

SignatureType constants.

type TimestampedEntry

type TimestampedEntry struct {
	Timestamp  uint64       `json:"timestamp"`
	EntryType  LogEntryType `json:"entry_type"`
	VCEntry    []byte       `json:"vc_entry"`
	Extensions []byte       `json:"extensions"`
}

TimestampedEntry is part of the MerkleTreeLeaf structure.

type TreeHeadSignature

type TreeHeadSignature struct {
	Version        Version       `json:"version"`
	SignatureType  SignatureType `json:"signature_type"`
	Timestamp      uint64        `json:"timestamp"`
	TreeSize       uint64        `json:"tree_size"`
	SHA256RootHash []byte        `json:"sha_256_root_hash"`
}

TreeHeadSignature keeps the data over which the signature in an STH is created.

type TrillianLogClient

type TrillianLogClient trillian.TrillianLogClient

TrillianLogClient is the API client for TrillianLog service.

type VCTimestampSignature

type VCTimestampSignature struct {
	SVCTVersion   Version       `json:"svct_version"`
	SignatureType SignatureType `json:"signature_type"`
	Timestamp     uint64        `json:"timestamp"`
	EntryType     LogEntryType  `json:"entry_type"`
	VCEntry       []byte        `json:"vc_entry"`
	Extensions    []byte        `json:"extensions"`
}

VCTimestampSignature keeps the data over which the signature is created.

func CreateVCTimestampSignature

func CreateVCTimestampSignature(leaf *MerkleTreeLeaf) *VCTimestampSignature

CreateVCTimestampSignature creates VCTimestampSignature structure.

type Version

type Version uint8

Version type definition.

const (
	V1 Version = 0
)

Version constants.

type WebFingerLink struct {
	Rel  string `json:"rel,omitempty"`
	Type string `json:"type,omitempty"`
	Href string `json:"href,omitempty"`
}

WebFingerLink web finger link.

type WebFingerResponse added in v0.1.2

type WebFingerResponse struct {
	Subject    string                 `json:"subject,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
	Links      []WebFingerLink        `json:"links,omitempty"`
}

WebFingerResponse web finger response.

Jump to

Keyboard shortcuts

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