Documentation ¶
Overview ¶
Package cs defines types to work with Chainscripts.
Package cs defines types to work with Chainscripts.
Package cs defines types to work with Chainscripts.
Index ¶
Constants ¶
const ( // ErrBadJMESPATHQuery is returned when the JMESPATH engine fails to execute the query ErrBadJMESPATHQuery = "failed to execute JMESPATH query" // ErrEmptyJMESPATHResult is returned when the JMESPATH query does not match any part of the link ErrEmptyJMESPATHResult = "JMESPATH query does not match any link data" )
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 LinkMeta `json:"meta"` Signatures []*Signature `json:"signatures"` }
Link contains a state and meta data about the state.
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.
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 LinkMeta ¶ added in v0.3.0
type LinkMeta struct { MapID string `json:"mapId"` Process string `json:"process"` Action string `json:"action"` Type string `json:"type"` Inputs []interface{} `json:"inputs"` Tags []string `json:"tags"` Priority float64 `json:"priority"` PrevLinkHash string `json:"prevLinkHash"` Refs []SegmentReference `json:"refs"` Data map[string]interface{} `json:"data"` }
LinkMeta contains the typed meta data of a Link and data
func (*LinkMeta) GetPrevLinkHash ¶ added in v0.3.0
GetPrevLinkHash returns the previous link hash as a bytes. It will return nil if the previous link hash is null.
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()
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 SegmentReference ¶ added in v0.3.0
type SegmentReference struct { Segment *Segment `json:"segment"` Process string `json:"process"` LinkHash string `json:"linkHash"` }
SegmentReference is a reference to a segment or a linkHash
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.
type Signature ¶ added in v0.3.0
type Signature struct { // Type of the signature (eg: "EdDSA") Type string `json:"type"` // PublicKey is the base64 encoded public key that signed the payload PublicKey string `json:"publicKey"` // Signature is the base64 encoded string containg the signature bytes Signature string `json:"signature"` // Payload describes what has been signed, It is expressed using the JMESPATH query language. Payload string `json:"payload"` }
Signature contains a user-provided signature of a certain part of the link.
func NewSignature ¶ added in v0.3.0
NewSignature creates a new signature for a link. Only the data matching the JMESPATH query will be signed
type Signatures ¶ added in v0.3.0
type Signatures []*Signature
Signatures is a slice of Signature
func (*Signatures) Get ¶ added in v0.3.0
func (s *Signatures) Get(publicKey string) *Signature
Get returns the signature matching the provided public key
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 |