Documentation ¶
Overview ¶
Package cs defines types to work with Chainscripts.
Package cs defines types to work with Chainscripts.
Index ¶
- Variables
- type Evidence
- type Evidences
- type GenericProof
- type GetSegmentFunc
- type Link
- func (l *Link) GetMapID() string
- func (l *Link) GetPrevLinkHash() *types.Bytes32
- func (l *Link) GetPrevLinkHashString() string
- func (l *Link) GetPriority() float64
- func (l *Link) GetProcess() string
- func (l *Link) GetTagMap() map[string]struct{}
- func (l *Link) GetTags() []string
- func (l *Link) Hash() (*types.Bytes32, error)
- func (l *Link) HashString() (string, error)
- func (l Link) Segmentify() *Segment
- func (l *Link) Validate(getSegment GetSegmentFunc) error
- type LinkHashes
- type Proof
- type Segment
- type SegmentMeta
- type SegmentSlice
Constants ¶
This section is empty.
Variables ¶
var DeserializeMethods = make(map[string]func(json.RawMessage) (Proof, error), 0)
DeserializeMethods maps a proof backend (like "TMPop") to a deserializer function returning a specific proof
Functions ¶
This section is empty.
Types ¶
type Evidence ¶ added in v0.2.0
type Evidence struct { Backend string `json:"backend"` // can either be "TMPop", "bitcoin", "dummy"... Provider string `json:"provider"` // can either be a chainId (in case of a blockchain) or an identifier for a trusted third-party (timestamping authority, regulator...) Proof Proof `json:"proof"` }
Evidence contains data that can be used to externally verify a segment's proof of existence
func (*Evidence) MarshalRQL ¶ added in v0.2.0
MarshalRQL serializes an Evidence into an JSON-formatted byte array
func (*Evidence) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON serializes bytes into an Evidence
func (*Evidence) UnmarshalRQL ¶ added in v0.2.0
UnmarshalRQL serializes an interface{} into an Evidence
type Evidences ¶ added in v0.2.0
type Evidences []*Evidence
Evidences encapsulates a list of evidences contained in Segment.Meta
func (*Evidences) AddEvidence ¶ added in v0.2.0
AddEvidence sets the segment evidence
func (*Evidences) FindEvidences ¶ added in v0.2.0
FindEvidences find all evidences generated by a specified backend ("TMPop", "bcbatchfossilizer"...)
func (*Evidences) GetEvidence ¶ added in v0.2.0
GetEvidence gets an evidence from a provider
type GenericProof ¶ added in v0.2.0
type GenericProof struct { Timestamp uint64 `json:"timestamp"` Data interface{} `json:"data"` Pubkey []byte `json:"pubkey"` Signature []byte `json:"signature"` //sign(hash(time+data)) }
GenericProof implements the Proof interface
func (*GenericProof) FullProof ¶ added in v0.2.0
func (p *GenericProof) FullProof() []byte
FullProof returns a JSON formatted proof
func (*GenericProof) Time ¶ added in v0.2.0
func (p *GenericProof) Time() uint64
Time returns the timestamp from the block header
func (*GenericProof) Verify ¶ added in v0.2.0
func (p *GenericProof) Verify(_ interface{}) bool
Verify returns true if the proof of a given linkHash is correct
type GetSegmentFunc ¶ added in v0.2.0
GetSegmentFunc is the function signature to retrieve a Segment
type Link ¶
type Link struct { State map[string]interface{} `json:"state"` Meta map[string]interface{} `json:"meta"` }
Link contains a state and meta data about the state.
func (*Link) GetPrevLinkHash ¶
GetPrevLinkHash returns the previous link hash as a bytes. It assumes the link is valid. It will return nil if the previous link hash is null.
func (*Link) GetPrevLinkHashString ¶
GetPrevLinkHashString returns the previous link hash as a string. It assumes the link is valid. It will return an empty string if the previous link hash is null.
func (*Link) GetPriority ¶
GetPriority returns the priority as a float64 It assumes the link is valid. If priority is nil, it will return -Infinity.
func (*Link) GetProcess ¶
GetProcess returns the process name as a string. It assumes the link is valid.
func (*Link) GetTagMap ¶
GetTagMap returns the tags as a map of string to empty structs (a set). It assumes the link is valid.
func (*Link) GetTags ¶
GetTags returns the tags as an array of string. It assumes the link is valid. It will return nil if there are no tags.
func (*Link) HashString ¶ added in v0.2.0
HashString hashes the link and returns a string
func (Link) Segmentify ¶ added in v0.2.0
Segmentify returns a segment from a link, filling the link hash and appropriate meta.
func (*Link) Validate ¶ added in v0.2.0
func (l *Link) Validate(getSegment GetSegmentFunc) error
Validate checks for errors in a link.
type LinkHashes ¶ added in v0.2.0
LinkHashes is a slice of Bytes32-formatted link hashes
func NewLinkHashesFromStrings ¶ added in v0.2.0
func NewLinkHashesFromStrings(linkHashesStr []string) (LinkHashes, error)
NewLinkHashesFromStrings creates a slice of bytes-formatted link hashes from a slice of string-formatted link hashes
type Proof ¶ added in v0.2.0
type Proof interface { Time() uint64 // returns the timestamp (UNIX format) contained in the proof FullProof() []byte // returns data to independently validate the proof Verify(interface{}) bool // Checks the validity of the proof }
Proof is the generic interface which a custom proof type has to implement
type Segment ¶
type Segment struct { Link Link `json:"link"` Meta SegmentMeta `json:"meta"` }
Segment contains a link and meta data about the link.
func (*Segment) GetLinkHash ¶
GetLinkHash returns the link ID as bytes. It assumes the segment is valid.
func (*Segment) GetLinkHashString ¶
GetLinkHashString returns the link ID as a string. It assumes the segment is valid.
func (*Segment) HashLink ¶ added in v0.2.0
HashLink hashes the segment link and stores it into the Meta
func (*Segment) SetLinkHash ¶ added in v0.2.0
SetLinkHash overwrites the segment LinkHash using HashLink()
func (*Segment) Validate ¶
func (s *Segment) Validate(getSegment GetSegmentFunc) error
Validate checks for errors in a segment
type SegmentMeta ¶ added in v0.2.0
type SegmentMeta struct { Evidences Evidences `json:"evidences"` LinkHash string `json:"linkHash"` }
SegmentMeta contains additional information about the segment and a proof of existence
func (*SegmentMeta) AddEvidence ¶ added in v0.2.0
func (s *SegmentMeta) AddEvidence(evidence Evidence) error
AddEvidence sets the segment evidence
func (*SegmentMeta) FindEvidences ¶ added in v0.2.0
func (s *SegmentMeta) FindEvidences(backend string) (res Evidences)
FindEvidences find all evidences generated by a specified backend ("TMPop", "bcbatchfossilizer"...)
func (*SegmentMeta) GetEvidence ¶ added in v0.2.0
func (s *SegmentMeta) GetEvidence(provider string) *Evidence
GetEvidence gets an evidence from a provider
func (*SegmentMeta) GetLinkHash ¶ added in v0.2.0
func (s *SegmentMeta) GetLinkHash() *types.Bytes32
GetLinkHash returns the link ID as bytes. It assumes the segment is valid.
func (*SegmentMeta) GetLinkHashString ¶ added in v0.2.0
func (s *SegmentMeta) GetLinkHashString() string
GetLinkHashString returns the link ID as a string. It assumes the segment is valid.
type SegmentSlice ¶
type SegmentSlice []*Segment
SegmentSlice is a slice of segment pointers.
func (SegmentSlice) Less ¶
func (s SegmentSlice) Less(i, j int) bool
Less implements sort.Interface.Less.
func (SegmentSlice) Swap ¶
func (s SegmentSlice) Swap(i, j int)
Swap implements sort.Interface.Swap.
Directories ¶
Path | Synopsis |
---|---|
Package cstesting defines helpers to test Chainscripts.
|
Package cstesting defines helpers to test Chainscripts. |
Package evidences defines any type of proof that can be used in a chainscript segment It is needed by a store to know how to deserialize a segment containing any type of proof
|
Package evidences defines any type of proof that can be used in a chainscript segment It is needed by a store to know how to deserialize a segment containing any type of proof |