proofs

package
v0.46.13-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyKey       = errors.New("key is empty")
	ErrEmptyKeyInData = errors.New("data contains empty key")
)

Functions

func BuildMap

func BuildMap(size int) map[string][]byte

BuildMap creates random key/values and stores in a map, returns a list of all keys in sorted order

func CalcRoot

func CalcRoot(data map[string][]byte) []byte

func ConvertExistenceProof

func ConvertExistenceProof(p *crypto.Proof, key, value []byte) (*ics23.ExistenceProof, error)

ConvertExistenceProof will convert the given proof into a valid existence proof, if that's what it is.

This is the simplest case of the range proof and we will focus on demoing compatibility here

func CreateMembershipProof

func CreateMembershipProof(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error)

CreateMembershipProof will produce a CommitmentProof that the given key (and queries value) exists in the map. If the key doesn't exist in the tree, this will return an error.

func CreateNonMembershipProof

func CreateNonMembershipProof(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error)

CreateNonMembershipProof will produce a CommitmentProof that the given key doesn't exist in the map. If the key exists in the tree, this will return an error.

func GetKey

func GetKey(allkeys []string, loc Where) string

GetKey this returns a key, on Left/Right/Middle

func GetNonKey

func GetNonKey(allkeys []string, loc Where) string

GetNonKey returns a missing key - Left of all, Right of all, or in the Middle

func SortedKeys

func SortedKeys(data map[string][]byte) []string

Types

type SimpleResult

type SimpleResult struct {
	Key      []byte
	Value    []byte
	Proof    *tmcrypto.Proof
	RootHash []byte
}

SimpleResult contains a merkle.SimpleProof along with all data needed to build the confio/proof

func GenerateRangeProof

func GenerateRangeProof(size int, loc Where) *SimpleResult

GenerateRangeProof makes a tree of size and returns a range proof for one random element

returns a range proof and the root hash of the tree

type Where

type Where int

Where selects a location for a key - Left, Right, or Middle

const (
	Left Where = iota
	Right
	Middle
)

Jump to

Keyboard shortcuts

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