chainscript

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 11 Imported by: 86

README

Go ChainScript

GoDoc build status codecov Go Report Card

Official Go implementation of ChainScript. This is the recommended way to use ChainScript in your Go projects.

However, it is opinionated and tries to keep the application data as abstract as possible. Some applications will have different requirements and might want to optimize for specific use-cases. If you are in that case, don't hesitate to implement your own ChainScript library. If you do so, don't forget to set the client_id field to make it easy for others to deserialize and validate your data.

Updating ChainScript

The ChainScript definitions are imported as a git subtree. Changes to the protobuf files should be done in the ChainScript repository.

To get the latest ChainScript definitions in this project, run:

make update_chainscript

Note that when you update the git subtree, you must not squash your commits when merging to the master branch, otherwise the subtree update will fail because it will be unable to find the previous subtree commit.

Compile the new protobuf definitions:

make protobuf
Fixing JSON struct tags

If the protobuf compiler added json tags (json:"map_id") to your structs, you might need to manually fix them if you want to be fully compatible with other languages.

Those tags create an issue for fields that contain an underscore in the proto definitions. For such fields you'll need to manually update the generated go file until the protobuf compiler provides configuration options to generate json tags properly.

Protobuf uses snake_case for field definitions (in your .proto files) but follows the JSON recommendation to use camelCase when serializing those fields to JSON. However the protobuf compiler also adds struct tags to tell the JSON serializer to use snake_case for fields that contain an underscore. As long as you use protobuf's JSON serializer you're fine because it will accept both snake_case and camelCase, but if you need to use another serializer at some point (in our case canonical-json for signatures v1.0.0) your JSON representation will use snake_case. Javascript correctly uses camelCase so your Javascript code will not be able to validate signatures generated by Go code (and the other way around as well).

The fix is simple: track all your snake_case fields and update the json:"snake_field" struct tag to json:"snakeField".

Updating dependencies

When updating dependencies (go-crypto, canonical-json, etc) we must stay backwards-compatible. That means that each dependency update should thoroughly check whether it introduces breaking changes in the serialized data. If it does, the version of some fields (link, signature) needs to be updated accordingly.

Documentation

Overview

Package chainscript contains the reference Go ChainScript implementation.

It provides helpers to manipulate ChainScript data structures conveniently and efficiently.

Index

Constants

View Source
const (
	// LinkVersion1_0_0 is the first version of the link encoding.
	// In that version we encode interfaces (link.data and link.meta.data) with
	// canonical JSON and hash the protobuf-encoded link bytes with SHA-256.
	LinkVersion1_0_0 = "1.0.0"

	// LinkVersion is the version used for new links.
	LinkVersion = LinkVersion1_0_0
)
View Source
const (
	// SignatureVersion1_0_0 is the first version of the link signature.
	// In that version we use canonical JSON to encode the link parts.
	// We use JMESPATH to select what parts of the link need to be signed.
	// We use SHA-256 on the JSON-encoded bytes and sign the resulting hash.
	// We use github.com/stratumn/go-crypto's 1.0.0 release to produce the
	// signature (which uses PEM-encoded private keys).
	SignatureVersion1_0_0 = "1.0.0"

	// SignatureVersion is the version used for new signatures.
	SignatureVersion = SignatureVersion1_0_0
)
View Source
const (
	// ClientID allows segment receivers to figure out how the segment was
	// encoded and can be decoded.
	ClientID = "github.com/stratumn/go-chainscript"
)

Variables

View Source
var (
	ErrMissingVersion     = errors.New("version is missing")
	ErrOutDegree          = errors.New("cannot create link: parent has too many children")
	ErrUnknownLinkVersion = errors.New("unknown link version")
	ErrUnknownClientID    = errors.New("link was created with a unknown client: can't deserialize it")
)

Link errors.

View Source
var (
	ErrMissingProcess  = errors.New("link process is missing")
	ErrMissingMapID    = errors.New("link map id is missing")
	ErrMissingLinkHash = errors.New("link hash is missing")
	ErrMissingLink     = errors.New("link is missing")
	ErrInvalidPriority = errors.New("priority needs to be positive")
)

Link errors.

View Source
var (
	ErrLinkHashMismatch  = errors.New("link hash from meta doesn't equal hashed link")
	ErrMissingBackend    = errors.New("evidence backend is missing")
	ErrMissingProvider   = errors.New("evidence provider is missing")
	ErrMissingProof      = errors.New("evidence proof is missing")
	ErrDuplicateEvidence = errors.New("evidence already exists for the given backend and provider")
)

Segment errors.

View Source
var (
	ErrUnknownSignatureVersion = errors.New("unknown signature version")
	ErrInvalidSignature        = errors.New("signature is invalid")
)

Signature errors.

Functions

func MarshalEvidence

func MarshalEvidence(e *Evidence) ([]byte, error)

MarshalEvidence marshals using protobuf.

func MarshalLink(l *Link) ([]byte, error)

MarshalLink marshals using protobuf.

func MarshalSegment

func MarshalSegment(s *Segment) ([]byte, error)

MarshalSegment marshals using protobuf.

Types

type Evidence

type Evidence struct {
	// Version of the evidence format.
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// Identifier of the evidence type.
	// For example, in the case of a timestamp on the Bitcoin blockchain,
	// this would be "bitcoin".
	Backend string `protobuf:"bytes,10,opt,name=backend,proto3" json:"backend,omitempty"`
	// Instance of the backend used.
	// For example, in the case of a timestamp on the Bitcoin blockchain,
	// this would be the chain ID (to identify testnet from mainnet).
	Provider string `protobuf:"bytes,11,opt,name=provider,proto3" json:"provider,omitempty"`
	// Data that should be usable offline by any client wishing to validate
	// the evidence.
	// For backwards compatibility, you should update the evidence version
	// when the structure of this proof changes.
	Proof                []byte   `protobuf:"bytes,20,opt,name=proof,proto3" json:"proof,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Evidences can be used to externally verify a link's existence at a given moment in time. An evidence can be a proof of inclusion in a public blockchain, a timestamp signed by a trusted authority or anything that you trust to provide an immutable ordering of your process' steps.

func NewEvidence

func NewEvidence(version, backend, provider string, proofData []byte) (*Evidence, error)

NewEvidence creates a new evidence that can be added to a segment.

func UnmarshalEvidence

func UnmarshalEvidence(b []byte) (*Evidence, error)

UnmarshalEvidence unmarshals protobuf bytes.

func (*Evidence) Descriptor

func (*Evidence) Descriptor() ([]byte, []int)

func (*Evidence) GetBackend

func (m *Evidence) GetBackend() string

func (*Evidence) GetProof

func (m *Evidence) GetProof() []byte

func (*Evidence) GetProvider

func (m *Evidence) GetProvider() string

func (*Evidence) GetVersion

func (m *Evidence) GetVersion() string

func (*Evidence) ProtoMessage

func (*Evidence) ProtoMessage()

func (*Evidence) Reset

func (m *Evidence) Reset()

func (*Evidence) String

func (m *Evidence) String() string

func (*Evidence) Validate

func (e *Evidence) Validate() error

Validate that the evidence is well-formed. The proof is opaque bytes so it isn't validated here.

func (*Evidence) XXX_DiscardUnknown

func (m *Evidence) XXX_DiscardUnknown()

func (*Evidence) XXX_Marshal

func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Evidence) XXX_Merge

func (dst *Evidence) XXX_Merge(src proto.Message)

func (*Evidence) XXX_Size

func (m *Evidence) XXX_Size() int

func (*Evidence) XXX_Unmarshal

func (m *Evidence) XXX_Unmarshal(b []byte) error
type Link struct {
	// Version of the link format.
	// You can for example use the git tag of the code used to create the link.
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// Data representing the process' step details.
	// For backwards compatibility, you should update the link version
	// in meta when the structure/encoding of this field changes.
	Data []byte `protobuf:"bytes,10,opt,name=data,proto3" json:"data,omitempty"`
	// Metadata associated to the process' step.
	// Some of this metadata is used to provide filtering options when
	// fetching links.
	Meta *LinkMeta `protobuf:"bytes,11,opt,name=meta,proto3" json:"meta,omitempty"`
	// (Optional) Signatures of configurable parts of the link.
	Signatures           []*Signature `protobuf:"bytes,20,rep,name=signatures,proto3" json:"signatures,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

A link is the immutable part of a segment. A link contains all the data that represents a process' step.

func UnmarshalLink(b []byte) (*Link, error)

UnmarshalLink unmarshals protobuf bytes.

func (*Link) Clone

func (l *Link) Clone() (*Link, error)

Clone returns a copy of the link.

func (*Link) Descriptor

func (*Link) Descriptor() ([]byte, []int)

func (*Link) GetData

func (m *Link) GetData() []byte

func (*Link) GetMeta

func (m *Link) GetMeta() *LinkMeta

func (*Link) GetSignatures

func (m *Link) GetSignatures() []*Signature

func (*Link) GetVersion

func (m *Link) GetVersion() string

func (*Link) Hash

func (l *Link) Hash() (LinkHash, error)

Hash serializes the link and computes a hash of the resulting bytes. The serialization and hashing algorithm used depend on the link version.

func (*Link) PrevLinkHash

func (l *Link) PrevLinkHash() LinkHash

PrevLinkHash returns the link's parent hash. If the link doesn't have a parent, it returns nil.

func (*Link) ProtoMessage

func (*Link) ProtoMessage()

func (*Link) Reset

func (m *Link) Reset()

func (*Link) Segmentify

func (l *Link) Segmentify() (*Segment, error)

Segmentify returns a segment from a link, filling the link hash.

func (*Link) SetData

func (l *Link) SetData(data interface{}) error

SetData uses the given object as link's custom data.

func (*Link) SetMetadata

func (l *Link) SetMetadata(metadata interface{}) error

SetMetadata uses the given object as link's custom metadata.

func (*Link) Sign

func (l *Link) Sign(privateKey []byte, payloadPath string) error

Sign configurable parts of the link with the current signature version. The payloadPath is used to select what parts of the link need to be signed with the given private key. If no payloadPath is provided, the whole link is signed.

func (*Link) SignedBytes

func (l *Link) SignedBytes(sigVersion, payloadPath string) ([]byte, error)

SignedBytes computes the bytes that should be signed. The signature version impacts how those bytes are computed.

func (*Link) String

func (m *Link) String() string

func (*Link) StructurizeData

func (l *Link) StructurizeData(data interface{}) error

StructurizeData deserializes the link's data into the given object. The provided argument should be a pointer to a struct.

func (*Link) StructurizeMetadata

func (l *Link) StructurizeMetadata(metadata interface{}) error

StructurizeMetadata deserializes the link's metadata into the given object. The provided argument should be a pointer to a struct.

func (*Link) TagMap

func (l *Link) TagMap() map[string]struct{}

TagMap returns the tags as a map of string to empty structs (a set). It makes it easier to test inclusion.

func (*Link) Validate

func (l *Link) Validate(ctx context.Context) error

Validate checks for errors in a link.

func (*Link) XXX_DiscardUnknown

func (m *Link) XXX_DiscardUnknown()

func (*Link) XXX_Marshal

func (m *Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Link) XXX_Merge

func (dst *Link) XXX_Merge(src proto.Message)

func (*Link) XXX_Size

func (m *Link) XXX_Size() int

func (*Link) XXX_Unmarshal

func (m *Link) XXX_Unmarshal(b []byte) error

type LinkBuilder

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

LinkBuilder makes it easy to create links that adhere to the ChainScript spec. It provides valid default values for required fields and allows the user to set fields to valid values. Note that link builders are not thread safe. They are meant to build an object instance which is generally done in a single go routine.

func NewLinkBuilder

func NewLinkBuilder(process string, mapID string) *LinkBuilder

NewLinkBuilder creates a new link builder.

func (*LinkBuilder) Build

func (b *LinkBuilder) Build() (*Link, error)

Build returns the corresponding link or an error.

func (*LinkBuilder) WithAction

func (b *LinkBuilder) WithAction(action string) *LinkBuilder

WithAction sets the link's action. The action is what caused the link to be created.

func (*LinkBuilder) WithData

func (b *LinkBuilder) WithData(data interface{}) *LinkBuilder

WithData uses the given object as link's custom data.

func (*LinkBuilder) WithDegree

func (b *LinkBuilder) WithDegree(d int) *LinkBuilder

WithDegree sets the maximum number of children a link is allowed to have. By default this is set to -1 to allow any number of children.

func (*LinkBuilder) WithMetadata

func (b *LinkBuilder) WithMetadata(data interface{}) *LinkBuilder

WithMetadata uses the given object as link's custom metadata.

func (*LinkBuilder) WithParent

func (b *LinkBuilder) WithParent(linkHash LinkHash) *LinkBuilder

WithParent sets the link's parent, referenced by its hash.

func (*LinkBuilder) WithPriority

func (b *LinkBuilder) WithPriority(priority float64) *LinkBuilder

WithPriority sets the link's priority.

func (*LinkBuilder) WithProcessState

func (b *LinkBuilder) WithProcessState(state string) *LinkBuilder

WithProcessState sets the state of the process. If your process can be represented as a state machine and the current link changes the state machine, it allows easy tracking of the process evolution.

func (*LinkBuilder) WithRefs

func (b *LinkBuilder) WithRefs(refs ...*LinkReference) *LinkBuilder

WithRefs references links that are related to the current link.

func (*LinkBuilder) WithStep

func (b *LinkBuilder) WithStep(step string) *LinkBuilder

WithStep sets the specific process step represented by the link.

func (*LinkBuilder) WithTags

func (b *LinkBuilder) WithTags(tags ...string) *LinkBuilder

WithTags adds some tags to the link.

type LinkHash

type LinkHash []byte

LinkHash is a byte array for which we provide utility methods.

func NewLinkHashFromString

func NewLinkHashFromString(lh string) (LinkHash, error)

NewLinkHashFromString decodes a string and returns a link hash.

func (LinkHash) String

func (lh LinkHash) String() string

String encodes the link hash to a string.

type LinkMeta

type LinkMeta struct {
	// The Client ID should be set by the client code creating the link.
	// Use a unique ID that easily identifies your library, for example the
	// github url of your repository.
	ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"clientId,omitempty"`
	// Hash of the previous link (in the same process).
	PrevLinkHash []byte `protobuf:"bytes,10,opt,name=prev_link_hash,json=prevLinkHash,proto3" json:"prevLinkHash,omitempty"`
	// Priority of the link.
	// Can be used to order and filter search results.
	Priority float64 `protobuf:"fixed64,11,opt,name=priority,proto3" json:"priority,omitempty"`
	// References to related links (potentially in other processes).
	Refs []*LinkReference `protobuf:"bytes,12,rep,name=refs,proto3" json:"refs,omitempty"`
	// Maximum number of children the current link is allowed to have.
	// A reference doesn't count as a child, only usage of prev_link_hash
	// counts as a link child.
	// It is the application's responsibility to comply with this property.
	// If set to -1, the link can have as many children as it wants.
	// If set to 0, the link can't have any children.
	// If set to n > 0, the link can have at most n children.
	OutDegree int32 `protobuf:"varint,13,opt,name=out_degree,json=outDegree,proto3" json:"outDegree,omitempty"`
	// A link is a step in a given process.
	Process *Process `protobuf:"bytes,20,opt,name=process,proto3" json:"process,omitempty"`
	// A link always belongs to a specific map in that process.
	// A map is an instance of a process.
	MapId string `protobuf:"bytes,21,opt,name=map_id,json=mapId,proto3" json:"mapId,omitempty"`
	// (Optional) Action in the process that resulted in the link's creation.
	// Can be used to filter link search results.
	Action string `protobuf:"bytes,30,opt,name=action,proto3" json:"action,omitempty"`
	// (Optional) Step of the process that results from the action.
	// Can be used to help deserialize link data or filter link search results.
	Step string `protobuf:"bytes,31,opt,name=step,proto3" json:"step,omitempty"`
	// (Optional) Tags that can be used to filter link search results.
	Tags []string `protobuf:"bytes,32,rep,name=tags,proto3" json:"tags,omitempty"`
	// (Optional) Additional metadata needed by your business logic.
	// For backwards compatibility, you should update the link version when the
	// structure of this field changes.
	Data                 []byte   `protobuf:"bytes,100,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Metadata associated to a process' step. Once included in a segment, this is immutable.

func (*LinkMeta) Descriptor

func (*LinkMeta) Descriptor() ([]byte, []int)

func (*LinkMeta) GetAction

func (m *LinkMeta) GetAction() string

func (*LinkMeta) GetClientId

func (m *LinkMeta) GetClientId() string

func (*LinkMeta) GetData

func (m *LinkMeta) GetData() []byte

func (*LinkMeta) GetMapId

func (m *LinkMeta) GetMapId() string

func (*LinkMeta) GetOutDegree

func (m *LinkMeta) GetOutDegree() int32

func (*LinkMeta) GetPrevLinkHash

func (m *LinkMeta) GetPrevLinkHash() []byte

func (*LinkMeta) GetPriority

func (m *LinkMeta) GetPriority() float64

func (*LinkMeta) GetProcess

func (m *LinkMeta) GetProcess() *Process

func (*LinkMeta) GetRefs

func (m *LinkMeta) GetRefs() []*LinkReference

func (*LinkMeta) GetStep

func (m *LinkMeta) GetStep() string

func (*LinkMeta) GetTags

func (m *LinkMeta) GetTags() []string

func (*LinkMeta) ProtoMessage

func (*LinkMeta) ProtoMessage()

func (*LinkMeta) Reset

func (m *LinkMeta) Reset()

func (*LinkMeta) String

func (m *LinkMeta) String() string

func (*LinkMeta) XXX_DiscardUnknown

func (m *LinkMeta) XXX_DiscardUnknown()

func (*LinkMeta) XXX_Marshal

func (m *LinkMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LinkMeta) XXX_Merge

func (dst *LinkMeta) XXX_Merge(src proto.Message)

func (*LinkMeta) XXX_Size

func (m *LinkMeta) XXX_Size() int

func (*LinkMeta) XXX_Unmarshal

func (m *LinkMeta) XXX_Unmarshal(b []byte) error

type LinkReference

type LinkReference struct {
	// Hash of the referenced link.
	LinkHash []byte `protobuf:"bytes,1,opt,name=link_hash,json=linkHash,proto3" json:"linkHash,omitempty"`
	// Process containing the referenced link.
	Process              string   `protobuf:"bytes,10,opt,name=process,proto3" json:"process,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A reference to a link that can be in another process.

func (*LinkReference) Descriptor

func (*LinkReference) Descriptor() ([]byte, []int)

func (*LinkReference) GetLinkHash

func (m *LinkReference) GetLinkHash() []byte

func (*LinkReference) GetProcess

func (m *LinkReference) GetProcess() string

func (*LinkReference) ProtoMessage

func (*LinkReference) ProtoMessage()

func (*LinkReference) Reset

func (m *LinkReference) Reset()

func (*LinkReference) String

func (m *LinkReference) String() string

func (*LinkReference) XXX_DiscardUnknown

func (m *LinkReference) XXX_DiscardUnknown()

func (*LinkReference) XXX_Marshal

func (m *LinkReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LinkReference) XXX_Merge

func (dst *LinkReference) XXX_Merge(src proto.Message)

func (*LinkReference) XXX_Size

func (m *LinkReference) XXX_Size() int

func (*LinkReference) XXX_Unmarshal

func (m *LinkReference) XXX_Unmarshal(b []byte) error

type Process

type Process struct {
	// The name of the process.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The current state of the process.
	State                string   `protobuf:"bytes,10,opt,name=state,proto3" json:"state,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A process represents a real-world process that is shared between multiple independent actors.

func (*Process) Descriptor

func (*Process) Descriptor() ([]byte, []int)

func (*Process) GetName

func (m *Process) GetName() string

func (*Process) GetState

func (m *Process) GetState() string

func (*Process) ProtoMessage

func (*Process) ProtoMessage()

func (*Process) Reset

func (m *Process) Reset()

func (*Process) String

func (m *Process) String() string

func (*Process) XXX_DiscardUnknown

func (m *Process) XXX_DiscardUnknown()

func (*Process) XXX_Marshal

func (m *Process) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Process) XXX_Merge

func (dst *Process) XXX_Merge(src proto.Message)

func (*Process) XXX_Size

func (m *Process) XXX_Size() int

func (*Process) XXX_Unmarshal

func (m *Process) XXX_Unmarshal(b []byte) error

type Proof

type Proof interface {
	// Time returns the timestamp (UNIX format) of the proof
	Time() uint64

	// Verify the validity of the proof.
	// For most proof an input is required. For example, a proof containing a
	// merkle path would require the link's hash to verify that it is correctly
	// contained in the merkle path.
	Verify(interface{}) bool
}

Proof is the generic interface an evidence's proof should implement.

type Segment

type Segment struct {
	// The link is the immutable part of a segment.
	// It contains the details of the step.
	Link *Link `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"`
	// The link can be enriched with potentially mutable metadata.
	Meta                 *SegmentMeta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

A segment describes an atomic step in your process.

func UnmarshalSegment

func UnmarshalSegment(b []byte) (*Segment, error)

UnmarshalSegment unmarshals protobuf bytes.

func (*Segment) AddEvidence

func (s *Segment) AddEvidence(evidence *Evidence) error

AddEvidence adds an evidence to the segment.

func (*Segment) Descriptor

func (*Segment) Descriptor() ([]byte, []int)

func (*Segment) FindEvidences

func (s *Segment) FindEvidences(backend string) []*Evidence

FindEvidences finds all evidences from a specific backend.

func (*Segment) GetEvidence

func (s *Segment) GetEvidence(backend, provider string) *Evidence

GetEvidence gets an evidence from a provider in a given backend.

func (m *Segment) GetLink() *Link

func (*Segment) GetMeta

func (m *Segment) GetMeta() *SegmentMeta

func (*Segment) LinkHash

func (s *Segment) LinkHash() LinkHash

LinkHash returns the link hash.

func (*Segment) ProtoMessage

func (*Segment) ProtoMessage()

func (*Segment) Reset

func (m *Segment) Reset()

func (*Segment) SetLinkHash

func (s *Segment) SetLinkHash() error

SetLinkHash computes and sets the link hash.

func (*Segment) String

func (m *Segment) String() string

func (*Segment) Validate

func (s *Segment) Validate(ctx context.Context) error

Validate checks for errors in a segment

func (*Segment) XXX_DiscardUnknown

func (m *Segment) XXX_DiscardUnknown()

func (*Segment) XXX_Marshal

func (m *Segment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Segment) XXX_Merge

func (dst *Segment) XXX_Merge(src proto.Message)

func (*Segment) XXX_Size

func (m *Segment) XXX_Size() int

func (*Segment) XXX_Unmarshal

func (m *Segment) XXX_Unmarshal(b []byte) error

type SegmentMeta

type SegmentMeta struct {
	// Hash of the segment's link.
	LinkHash []byte `protobuf:"bytes,1,opt,name=link_hash,json=linkHash,proto3" json:"linkHash,omitempty"`
	// Evidences produced for the segment's link.
	Evidences            []*Evidence `protobuf:"bytes,10,rep,name=evidences,proto3" json:"evidences,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

Segment metadata. This is the potentially mutable part of a segment. It contains some invariants (hash of the immutable link) and evidences for the link that can be produced after the link is created.

func (*SegmentMeta) Descriptor

func (*SegmentMeta) Descriptor() ([]byte, []int)

func (*SegmentMeta) GetEvidences

func (m *SegmentMeta) GetEvidences() []*Evidence

func (*SegmentMeta) GetLinkHash

func (m *SegmentMeta) GetLinkHash() []byte

func (*SegmentMeta) ProtoMessage

func (*SegmentMeta) ProtoMessage()

func (*SegmentMeta) Reset

func (m *SegmentMeta) Reset()

func (*SegmentMeta) String

func (m *SegmentMeta) String() string

func (*SegmentMeta) XXX_DiscardUnknown

func (m *SegmentMeta) XXX_DiscardUnknown()

func (*SegmentMeta) XXX_Marshal

func (m *SegmentMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SegmentMeta) XXX_Merge

func (dst *SegmentMeta) XXX_Merge(src proto.Message)

func (*SegmentMeta) XXX_Size

func (m *SegmentMeta) XXX_Size() int

func (*SegmentMeta) XXX_Unmarshal

func (m *SegmentMeta) XXX_Unmarshal(b []byte) error

type Signature

type Signature struct {
	// Version of the signature format.
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// Signature algorithm used (for example, "EdDSA").
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// A description of the parts of the links that are signed.
	// This should unambiguously let the verifier recompute the signed payload
	// bytes from the link's content.
	PayloadPath string `protobuf:"bytes,10,opt,name=payload_path,json=payloadPath,proto3" json:"payloadPath,omitempty"`
	// Encoded signer's public key.
	// For backwards compatibility, you should update the signature version
	// or the signature type when changing the encoding used.
	PublicKey []byte `protobuf:"bytes,20,opt,name=public_key,json=publicKey,proto3" json:"publicKey,omitempty"`
	// Signature bytes.
	Signature            []byte   `protobuf:"bytes,21,opt,name=signature,proto3" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A signature of configurable parts of a link. Different signature types and versions are allowed to sign different encodings of the data, but we recommend signing a hash of the protobuf-encoded bytes.

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) GetPayloadPath

func (m *Signature) GetPayloadPath() string

func (*Signature) GetPublicKey

func (m *Signature) GetPublicKey() []byte

func (*Signature) GetSignature

func (m *Signature) GetSignature() []byte

func (*Signature) GetType

func (m *Signature) GetType() string

func (*Signature) GetVersion

func (m *Signature) GetVersion() string

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) String

func (m *Signature) String() string

func (*Signature) Validate

func (s *Signature) Validate(l *Link) error

Validate the signature.

func (*Signature) XXX_DiscardUnknown

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal

func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signature) XXX_Merge

func (dst *Signature) XXX_Merge(src proto.Message)

func (*Signature) XXX_Size

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal

func (m *Signature) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis
Package main defines the end-to-end compatibility tests.
Package main defines the end-to-end compatibility tests.

Jump to

Keyboard shortcuts

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