Documentation
¶
Overview ¶
Package balloon implements functionality to build balloons (a layer that comprises hyper and history trees, among other stuff), control their life cycle and operate them: add event digests (or bulk of event digests), ask for proofs of membership or consistency, etc..
Index ¶
- Variables
- func NewFakeMembershipProof(shouldVerify bool, hasher hashing.Hasher) *history.MembershipProof
- func NewFakeQueryProof(shouldVerify bool, value []byte, hasher hashing.Hasher) *hyper.QueryProof
- type Balloon
- func (b *Balloon) Add(eventDigest hashing.Digest) (*Snapshot, []*storage.Mutation, error)
- func (b *Balloon) AddBulk(eventBulkDigest []hashing.Digest) ([]*Snapshot, []*storage.Mutation, error)
- func (b *Balloon) Close()
- func (b Balloon) QueryConsistency(start, end uint64) (*IncrementalProof, error)
- func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest) (*MembershipProof, error)
- func (b Balloon) QueryDigestMembershipConsistency(keyDigest hashing.Digest, version uint64) (*MembershipProof, error)
- func (b Balloon) QueryMembership(event []byte) (*MembershipProof, error)
- func (b Balloon) QueryMembershipConsistency(event []byte, version uint64) (*MembershipProof, error)
- func (b *Balloon) RefreshVersion() error
- func (b Balloon) Version() uint64
- type IncrementalProof
- type MembershipProof
- type Snapshot
- type Verifiable
Constants ¶
This section is empty.
Variables ¶
var ( AddTotal = prometheus.NewCounter( prometheus.CounterOpts{ Namespace: namespace, Subsystem: subSystem, Name: "add_total", Help: "Number of add operations", }, ) MembershipTotal = prometheus.NewCounter( prometheus.CounterOpts{ Namespace: namespace, Subsystem: subSystem, Name: "membership_total", Help: "Number of membership queries.", }, ) DigestMembershipTotal = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: namespace, Subsystem: subSystem, Name: "digest_membership_total", Help: "Number of membership by digest queries.", }, ) IncrementalTotal = prometheus.NewCounter( prometheus.CounterOpts{ Namespace: namespace, Subsystem: subSystem, Name: "incremental_total", Help: "Number of incremental queries.", }, ) )
var (
BalloonVersionKey = []byte("version")
)
Functions ¶
func NewFakeMembershipProof ¶
func NewFakeMembershipProof(shouldVerify bool, hasher hashing.Hasher) *history.MembershipProof
func NewFakeQueryProof ¶
Types ¶
type Balloon ¶
type Balloon struct {
// contains filtered or unexported fields
}
Balloon exposes the necesary API to interact with the hyper and history trees.
func NewBalloon ¶
NewBalloon function instanciates a balloon given a storage and a hasher function.
func (*Balloon) Add ¶
Add funcion inserts an event hash into the history and hyper trees, creates a snapshot with these insertions results, and returns the snapshot along with certain mutations to do to the persistent storage.
func (*Balloon) AddBulk ¶
func (b *Balloon) AddBulk(eventBulkDigest []hashing.Digest) ([]*Snapshot, []*storage.Mutation, error)
AddBulk funcion inserts a bulk of event hashes into the history and hyper trees, creates an array of snapshots with these insertions results, and returns the array of snapshots along with certain mutations to do to the persistent storage.
func (*Balloon) Close ¶
func (b *Balloon) Close()
Close function closes both history and hyper trees, and restarts balloon version.
func (Balloon) QueryConsistency ¶
func (b Balloon) QueryConsistency(start, end uint64) (*IncrementalProof, error)
QueryConsistency function asks the history tree for an incremental proof, and returns the proof if there is no error. Previously, it checks that the given parameters are correct.
func (Balloon) QueryDigestMembership ¶
func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest) (*MembershipProof, error)
QueryDigestMembership function is used when an event digest is given to ask for a membership proof against the latest balloon version. It asks the hyper tree for this proof and returns the proof if there is no error.
func (Balloon) QueryDigestMembershipConsistency ¶
func (b Balloon) QueryDigestMembershipConsistency(keyDigest hashing.Digest, version uint64) (*MembershipProof, error)
QueryDigestMembership function is used when an event digest is given to ask for a membership proof against a certain balloon version. It asks the hyper tree for this proof and returns the proof if there is no error.
func (Balloon) QueryMembership ¶
func (b Balloon) QueryMembership(event []byte) (*MembershipProof, error)
QueryMembership function is used when an event is given to ask for a membership proof against the latest balloon version. It just hashes the event and ask QueryDigestMembership.
func (Balloon) QueryMembershipConsistency ¶
func (b Balloon) QueryMembershipConsistency(event []byte, version uint64) (*MembershipProof, error)
QueryMembership function is used when an event is given to ask for a membership proof against a certain balloon version. It just hashes the event and ask QueryDigestMembershipConsistency.
func (*Balloon) RefreshVersion ¶
RefreshVersion function gets the last stored version from the history-tree table and updates balloon's version.
type IncrementalProof ¶
type IncrementalProof struct {
Start, End uint64
AuditPath history.AuditPath
Hasher hashing.Hasher
}
IncrementalProof is the struct required to verify a consistency proof between two events. It has the History AuditPath, and the start and end versions which corresponds to these events.
func NewIncrementalProof ¶
func NewIncrementalProof(start, end uint64, auditPath history.AuditPath, hasher hashing.Hasher) *IncrementalProof
NewIcrementalProof function instanciates an incremental proof given the required parameters.
func (IncrementalProof) Verify ¶
func (p IncrementalProof) Verify(snapshotStart, snapshotEnd *Snapshot) bool
Verify verifies a proof and answer from QueryMembership. Returns true if the answer and proof are correct and consistent, otherwise false. Run by a client on input that should be verified.
type MembershipProof ¶
type MembershipProof struct {
Exists bool
HyperProof *hyper.QueryProof
HistoryProof *history.MembershipProof
CurrentVersion uint64
QueryVersion uint64
ActualVersion uint64
KeyDigest hashing.Digest
Hasher hashing.Hasher
}
MembershipProof is the struct required to verify an event existence proof. It has both Hyper and History AuditPaths, if the event exists, along with current balloon version, event version, and query version.
func NewMembershipProof ¶
func NewMembershipProof(exists bool, hyperProof *hyper.QueryProof, historyProof *history.MembershipProof, currentVersion, queryVersion, actualVersion uint64, keyDigest hashing.Digest, Hasher hashing.Hasher) *MembershipProof
NewMembershipProof function instanciates an membership proof given the required parameters.
func (MembershipProof) DigestVerify ¶
func (p MembershipProof) DigestVerify(digest hashing.Digest, snapshot *Snapshot) bool
DigestVerify verifies a proof and answer from QueryMembership. Returns true if the answer and proof are correct and consistent, otherwise false. Run by a client on input that should be verified.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cache implements the interface to interact with a cache.
|
Package cache implements the interface to interact with a cache. |
|
Package history implements the history tree (a merkel tree, append only structure) life cycle, its operations, different visitors to navigate the tree, as well as the functionality of request and verify membership and incremental proofs.
|
Package history implements the history tree (a merkel tree, append only structure) life cycle, its operations, different visitors to navigate the tree, as well as the functionality of request and verify membership and incremental proofs. |
|
Package hyper implements the history tree (a sparse merkel tree) life cycle, its operations, as well as the functionality of request and verify a membersip proof.
|
Package hyper implements the history tree (a sparse merkel tree) life cycle, its operations, as well as the functionality of request and verify a membersip proof. |