v1

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: ISC Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Routes
	RouteList             = "/v1/list/"             // list all records
	RoutePublicKey        = "/v1/publickey/"        // public signing key
	RouteRecordNew        = "/v1/recordnew/"        // new record
	RouteRecordGet        = "/v1/recordget/"        // retrieve record and proofs
	RouteRecordEntriesGet = "/v1/recordentriesget/" // retrieve record entries and proofs
	RouteRecordAppend     = "/v1/append/"           // append data to record
	RouteRecordFsck       = "/v1/fsck/"             // fsck record

	// Error status codes
	ErrorStatusInvalid      ErrorStatusT = 0
	ErrorStatusInvalidInput ErrorStatusT = 1

	Forward = "X-Forwarded-For"
)
View Source
const (
	// DataDescriptor.Type values. These may be freely edited since they
	// are solely hints to the application.
	DataTypeKeyValue  = "kv"     // Descriptor is empty but data is key/value
	DataTypeMime      = "mime"   // Descriptor contains a mime type
	DataTypeStructure = "struct" // Descriptor contains a structure

	DataDescriptorAnchor = "anchor" // Data is JSON Anchor structure
)

Variables

View Source
var (
	// ErrorStatus converts error status codes to human readable text.
	ErrorStatus = map[ErrorStatusT]string{
		ErrorStatusInvalid:      "invalid status",
		ErrorStatusInvalidInput: "invalid input",
	}
)

Functions

This section is empty.

Types

type DataAnchor

type DataAnchor struct {
	RecordId     int64                  `json:"recordid"`     // Record ID this STH belongs to
	STH          trillian.SignedLogRoot `json:"sth"`          // Signed tree head
	VerifyDigest dcrtime.VerifyDigest   `json:"verifydigest"` // dcrtime digest structure
}

DataAnchor describes what is stored in dcrtime. We store the SHA256 hash of STH.LogRoot in dcrtime

type DataDescriptor

type DataDescriptor struct {
	Type       string `json:"type,omitempty"`       // Type of data that is stored
	Descriptor string `json:"descriptor,omitempty"` // Description of the data
	ExtraData  string `json:"extradata,omitempty"`  // Value to be freely used by caller
}

DataDescriptor provides hints about a data blob. In practise we JSON encode this struture and stuff it into RecordEntry.DataHint.

type DataKeyValue

type DataKeyValue struct {
	Key   string `json:"key"`   // Key
	Value string `json:"value"` // Value
}

DataKeyValue is an encoded key/value pair.

type ErrorReply

type ErrorReply struct {
	ErrorCode    int64    `json:"errorcode,omitempty"`
	ErrorContext []string `json:"errorcontext,omitempty"`
}

ErrorReply are replies that the server returns a when it encounters an unrecoverable problem while executing a command. The HTTP Error Code shall be 500 if it's an internal server error or 4xx if it's a user error.

type ErrorStatusT

type ErrorStatusT int

type List

type List struct{}

List request a list of all trees.

type ListReply

type ListReply struct {
	Trees []*trillian.Tree `json:"trees"`
}

ListReply returns a list of all trees.

type PublicKey

type PublicKey struct{}

PublicKey retrieves the server public signing key.

type PublicKeyReply

type PublicKeyReply struct {
	SigningKey string `json:"signingkey"` // base64 encoded DER key
}

PublicKeyReply returns the server's signing key. It is a base64 encoded DER format.

type QueuedLeafProof

type QueuedLeafProof struct {
	QueuedLeaf trillian.QueuedLogLeaf `json:"queuedleaf"`      // A queued leaf and its status
	Proof      *trillian.Proof        `json:"proof,omitempty"` // Leaf inclusion proof
}

QueuedLeafProof contains a queued log leaf and an inclusion proof for the leaf. A queued log leaf will not have a leaf index so any client side verification must be done using the leaf hash.

type RecordAppend

type RecordAppend struct {
	Id            int64         `json:"id"`            // Record ID
	RecordEntries []RecordEntry `json:"recordentries"` // Entries to be stored
}

RecordAppend adds new record entries to a record. The server will not interpret the data at all. It will simply verify that the Data is signed with PublicKey. It also does not overwrite or delete items. The caller is expected to keep track of ordering etc. Note that The leafs do have timestamps.

type RecordAppendReply

type RecordAppendReply struct {
	STH    trillian.SignedLogRoot `json:"sth"`    // Signed tree head after record addition
	Proofs []QueuedLeafProof      `json:"proofs"` // Queued leaves and their proofs
}

RecordAppendReply returns all pertinent information about the record entries that were append to a record. It returns trillian types so that the client can perform verifications.

type RecordEntriesGet

type RecordEntriesGet struct {
	Entries []RecordEntryIdentifier `json:"entries"` // Entries to retrieve
}

RecordEntriesGet attempts to retrieve a batch of record entries and their proofs.

type RecordEntriesGetReply

type RecordEntriesGetReply struct {
	Proofs []RecordEntryProof `json:"proofs"` // All proofs and data
}

RecordEntriesGetReply is the array of the requested record entries and proofs.

type RecordEntry

type RecordEntry struct {
	PublicKey string `json:"publickey"` // Hex encoded public key used sign Data
	Hash      string `json:"hash"`      // Hex encoded hash of the string data
	Signature string `json:"signature"` // Hex encoded client ed25519 signature of Hash
	DataHint  string `json:"datahint"`  // Hint that describes the data, base64 encoded
	Data      string `json:"data"`      // Data payload, base64 encoded
}

Record contains user provided data and user attestation.

type RecordEntryIdentifier

type RecordEntryIdentifier struct {
	Id         int64  `json:"id"`         // Record ID
	MerkleHash string `json:"merklehash"` // Merkle hash
}

RecordEntryIdentifier uniquely identifies a single leaf+data+proof.

type RecordEntryProof

type RecordEntryProof struct {
	RecordEntry *RecordEntry              `json:"recordentry,omitempty"` // Data
	Leaf        *trillian.LogLeaf         `json:"leaf,omitempty"`        // Requested Leaf
	STH         *trillian.SignedLogRoot   `json:"sth,omitempty"`         // Signed tree head
	Proof       *trillian.Proof           `json:"proof,omitempty"`       // Inclusion proof for STH
	Anchor      *dcrtime.ChainInformation `json:"anchor,omitempty"`      // Anchor info for STH
	Error       string                    `json:"error,omitempty"`       // Error is set when record could not be retrieved
}

RecordEntryProof contains an entire record entry and anchor proof. The STH, Proof, and Anchor will ony be present once the RecordEntry has been successfully anchored. The STH corresponds to the LogRoot that was anchored. It is not the STH of the current tree. If error is set the record could not be retrieved.

type RecordFsck

type RecordFsck struct {
	Id int64 `json:"id"` // Record ID
}

RecordFsck performs an fsck on the record to ensure integrity.

type RecordFsckReply

type RecordFsckReply struct{}

RecordFsckReply is the reply to the RecordFsck command.

type RecordGet

type RecordGet struct {
	Id int64 `json:"id"` // Record ID
}

RecordGet retrieves the entire record including proofs. This is an expensive call.

type RecordGetReply

type RecordGetReply struct {
	Proofs []RecordEntryProof     `json:"recordentries"` // All entries and proofs. This may be big
	STH    trillian.SignedLogRoot `json:"sth"`           // Signed tree head
}

RecordGetReply returns all record entries and the proofs.

type RecordNew

type RecordNew struct {
	RecordEntries []RecordEntry `json:"recordentries"` // Entries to be stored
}

RecordNew creates a new record that consists of several record entries. The server will not interpret the data at all. It will simply verify that the Data is signed with PublicKey.

type RecordNewReply

type RecordNewReply struct {
	Tree        trillian.Tree          `json:"tree"`        // TreeId is the record id
	InitialRoot trillian.SignedLogRoot `json:"initialroot"` // Tree creation root
	STH         trillian.SignedLogRoot `json:"sth"`         // Signed tree head after record addition
	Proofs      []QueuedLeafProof      `json:"proofs"`      // Queued leaves and their proofs
}

RecordNewReply returns all pertinent information about a record. It returns trillian types so that the client can perform verifications.

type UserError

type UserError struct {
	ErrorCode    ErrorStatusT
	ErrorContext []string
}

UserError represents an error that is caused by something that the user did (malformed input, bad timing, etc).

func (UserError) Error

func (e UserError) Error() string

Error satisfies the error interface.

Jump to

Keyboard shortcuts

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