proofs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AugusteumSpec = &ics23.ProofSpec{
	LeafSpec: &ics23.LeafOp{
		Prefix:       []byte{0},
		Hash:         ics23.HashOp_SHA256,
		PrehashValue: ics23.HashOp_SHA256,
		Length:       ics23.LengthOp_VAR_PROTO,
	},
	InnerSpec: &ics23.InnerSpec{
		ChildOrder:      []int32{0, 1},
		MinPrefixLength: 1,
		MaxPrefixLength: 1,
		ChildSize:       32,
		Hash:            ics23.HashOp_SHA256,
	},
}

AugusteumSpec constrains the format from ics23-augusteum (crypto/merkle SimpleProof)

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 iavl tree. 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 iavl tree. 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