From c3e997b1256ec7aa5ca94c59d475a3c5b95a8c75 Mon Sep 17 00:00:00 2001 From: ItsFunny <39111451+ItsFunny@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:07:21 +0800 Subject: [PATCH] Merge PR: replace ics23 (#2584) Co-authored-by: KamiD <44460798+KamiD@users.noreply.github.com> --- go.mod | 1 - go.sum | 2 - ics23/Makefile | 20 + ics23/compress.go | 157 + ics23/ics23.go | 174 + ics23/ops.go | 248 + ics23/proof.go | 452 ++ ics23/proofs.pb.go | 4552 +++++++++++++++++ .../store/iavl/store_ibc_adapter.go | 2 +- .../store/internal/proofs/convert.go | 5 +- .../store/internal/proofs/create.go | 5 +- .../rootmulti/commit_info_ibc_adapter.go | 3 +- libs/cosmos-sdk/store/types/commit_info.go | 3 +- .../store/types/store_ok_adapter.go | 2 +- libs/iavl/mutable_ibc_adapter.go | 2 +- .../core/23-commitment/types/commitment.pb.go | 7 +- .../core/23-commitment/types/merkle.go | 2 +- .../modules/core/23-commitment/types/utils.go | 2 +- libs/ibc-go/modules/core/exported/client.go | 2 +- .../modules/core/exported/commitment.go | 2 +- .../06-solomachine/types/client_state.go | 5 +- .../07-tendermint/types/client_state.go | 5 +- .../07-tendermint/types/client_state_test.go | 2 +- .../07-tendermint/types/tendermint.pb.go | 16 +- .../09-localhost/types/client_state.go | 7 +- 25 files changed, 5644 insertions(+), 34 deletions(-) create mode 100644 ics23/Makefile create mode 100644 ics23/compress.go create mode 100644 ics23/ics23.go create mode 100644 ics23/ops.go create mode 100644 ics23/proof.go create mode 100644 ics23/proofs.pb.go diff --git a/go.mod b/go.mod index ecc0915918..a0afd471bb 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.21.0-beta github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce - github.com/confio/ics23/go v0.7.0 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/cosmos/gorocksdb v1.2.0 github.com/cosmos/ledger-cosmos-go v0.11.1 diff --git a/go.sum b/go.sum index 701b23db83..d56209b919 100644 --- a/go.sum +++ b/go.sum @@ -167,8 +167,6 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= -github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= diff --git a/ics23/Makefile b/ics23/Makefile new file mode 100644 index 0000000000..aebfcb20d7 --- /dev/null +++ b/ics23/Makefile @@ -0,0 +1,20 @@ +.PHONY: protoc test + +# make sure we turn on go modules +export GO111MODULE := on + +# PROTOC_FLAGS := -I=.. -I=./vendor -I=$(GOPATH)/src +PROTOC_FLAGS := -I=.. -I=$(GOPATH)/src + +test: + go test . + +protoc: +# @go mod vendor + protoc --gocosmos_out=plugins=interfacetype+grpc,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. $(PROTOC_FLAGS) ../proofs.proto + +install-proto-dep: + @echo "Installing protoc-gen-gocosmos..." + @go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos + + diff --git a/ics23/compress.go b/ics23/compress.go new file mode 100644 index 0000000000..ebe3275e38 --- /dev/null +++ b/ics23/compress.go @@ -0,0 +1,157 @@ +package ics23 + +// IsCompressed returns true if the proof was compressed +func IsCompressed(proof *CommitmentProof) bool { + return proof.GetCompressed() != nil +} + +// Compress will return a CompressedBatchProof if the input is BatchProof +// Otherwise it will return the input. +// This is safe to call multiple times (idempotent) +func Compress(proof *CommitmentProof) *CommitmentProof { + batch := proof.GetBatch() + if batch == nil { + return proof + } + return &CommitmentProof{ + Proof: &CommitmentProof_Compressed{ + Compressed: compress(batch), + }, + } +} + +// Decompress will return a BatchProof if the input is CompressedBatchProof +// Otherwise it will return the input. +// This is safe to call multiple times (idempotent) +func Decompress(proof *CommitmentProof) *CommitmentProof { + comp := proof.GetCompressed() + if comp != nil { + return &CommitmentProof{ + Proof: &CommitmentProof_Batch{ + Batch: decompress(comp), + }, + } + } + return proof +} + +func compress(batch *BatchProof) *CompressedBatchProof { + var centries []*CompressedBatchEntry + var lookup []*InnerOp + registry := make(map[string]int32) + + for _, entry := range batch.Entries { + centry := compressEntry(entry, &lookup, registry) + centries = append(centries, centry) + } + + return &CompressedBatchProof{ + Entries: centries, + LookupInners: lookup, + } +} + +func compressEntry(entry *BatchEntry, lookup *[]*InnerOp, registry map[string]int32) *CompressedBatchEntry { + if exist := entry.GetExist(); exist != nil { + return &CompressedBatchEntry{ + Proof: &CompressedBatchEntry_Exist{ + Exist: compressExist(exist, lookup, registry), + }, + } + } + + non := entry.GetNonexist() + return &CompressedBatchEntry{ + Proof: &CompressedBatchEntry_Nonexist{ + Nonexist: &CompressedNonExistenceProof{ + Key: non.Key, + Left: compressExist(non.Left, lookup, registry), + Right: compressExist(non.Right, lookup, registry), + }, + }, + } +} + +func compressExist(exist *ExistenceProof, lookup *[]*InnerOp, registry map[string]int32) *CompressedExistenceProof { + if exist == nil { + return nil + } + res := &CompressedExistenceProof{ + Key: exist.Key, + Value: exist.Value, + Leaf: exist.Leaf, + Path: make([]int32, len(exist.Path)), + } + for i, step := range exist.Path { + res.Path[i] = compressStep(step, lookup, registry) + } + return res +} + +func compressStep(step *InnerOp, lookup *[]*InnerOp, registry map[string]int32) int32 { + bz, err := step.Marshal() + if err != nil { + panic(err) + } + sig := string(bz) + + // load from cache if there + if num, ok := registry[sig]; ok { + return num + } + + // create new step if not there + num := int32(len(*lookup)) + *lookup = append(*lookup, step) + registry[sig] = num + return num +} + +func decompress(comp *CompressedBatchProof) *BatchProof { + lookup := comp.LookupInners + + var entries []*BatchEntry + + for _, centry := range comp.Entries { + entry := decompressEntry(centry, lookup) + entries = append(entries, entry) + } + + return &BatchProof{ + Entries: entries, + } +} + +// TendermintSpec constrains the format from proofs-tendermint (crypto/merkle SimpleProof) +var TendermintSpec = &ProofSpec{ + LeafSpec: &LeafOp{ + Prefix: []byte{0}, + PrehashKey: HashOp_NO_HASH, + Hash: HashOp_SHA256, + PrehashValue: HashOp_SHA256, + Length: LengthOp_VAR_PROTO, + }, + InnerSpec: &InnerSpec{ + ChildOrder: []int32{0, 1}, + MinPrefixLength: 1, + MaxPrefixLength: 1, + ChildSize: 32, // (no length byte) + Hash: HashOp_SHA256, + }, +} + +func decompressExist(exist *CompressedExistenceProof, lookup []*InnerOp) *ExistenceProof { + if exist == nil { + return nil + } + res := &ExistenceProof{ + Key: exist.Key, + Value: exist.Value, + Leaf: exist.Leaf, + Path: make([]*InnerOp, len(exist.Path)), + } + for i, step := range exist.Path { + res.Path[i] = lookup[step] + } + return res +} diff --git a/ics23/ics23.go b/ics23/ics23.go new file mode 100644 index 0000000000..26f7bf49f2 --- /dev/null +++ b/ics23/ics23.go @@ -0,0 +1,174 @@ +/** +This implements the client side functions as specified in +https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments + +In particular: + + // Assumes ExistenceProof + type verifyMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key, value: Value) => boolean + + // Assumes NonExistenceProof + type verifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key) => boolean + + // Assumes BatchProof - required ExistenceProofs may be a subset of all items proven + type batchVerifyMembership = (root: CommitmentRoot, proof: CommitmentProof, items: Map) => boolean + + // Assumes BatchProof - required NonExistenceProofs may be a subset of all items proven + type batchVerifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, keys: Set) => boolean + +We make an adjustment to accept a Spec to ensure the provided proof is in the format of the expected merkle store. +This can avoid an range of attacks on fake preimages, as we need to be careful on how to map key, value -> leaf +and determine neighbors +*/ +package ics23 + +import ( + "bytes" + "fmt" +) + +// CommitmentRoot is a byte slice that represents the merkle root of a tree that can be used to validate proofs +type CommitmentRoot []byte + +// VerifyMembership returns true iff +// proof is (contains) an ExistenceProof for the given key and value AND +// calculating the root for the ExistenceProof matches the provided CommitmentRoot +func VerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte, value []byte) bool { + // decompress it before running code (no-op if not compressed) + proof = Decompress(proof) + ep := getExistProofForKey(proof, key) + if ep == nil { + return false + } + err := ep.Verify(spec, root, key, value) + return err == nil +} + +// VerifyNonMembership returns true iff +// proof is (contains) a NonExistenceProof +// both left and right sub-proofs are valid existence proofs (see above) or nil +// left and right proofs are neighbors (or left/right most if one is nil) +// provided key is between the keys of the two proofs +func VerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte) bool { + // decompress it before running code (no-op if not compressed) + proof = Decompress(proof) + np := getNonExistProofForKey(proof, key) + if np == nil { + return false + } + err := np.Verify(spec, root, key) + return err == nil +} + +// BatchVerifyMembership will ensure all items are also proven by the CommitmentProof (which should be a BatchProof, +// unless there is one item, when a ExistenceProof may work) +func BatchVerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, items map[string][]byte) bool { + // decompress it before running code (no-op if not compressed) - once for batch + proof = Decompress(proof) + for k, v := range items { + valid := VerifyMembership(spec, root, proof, []byte(k), v) + if !valid { + return false + } + } + return true +} + +// BatchVerifyNonMembership will ensure all items are also proven to not be in the Commitment by the CommitmentProof +// (which should be a BatchProof, unless there is one item, when a NonExistenceProof may work) +func BatchVerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, keys [][]byte) bool { + // decompress it before running code (no-op if not compressed) - once for batch + proof = Decompress(proof) + for _, k := range keys { + valid := VerifyNonMembership(spec, root, proof, k) + if !valid { + return false + } + } + return true +} + +// CombineProofs takes a number of commitment proofs (simple or batch) and +// converts them into a batch and compresses them. +// +// This is designed for proof generation libraries to create efficient batches +func CombineProofs(proofs []*CommitmentProof) (*CommitmentProof, error) { + var entries []*BatchEntry + + for _, proof := range proofs { + if ex := proof.GetExist(); ex != nil { + entry := &BatchEntry{ + Proof: &BatchEntry_Exist{ + Exist: ex, + }, + } + entries = append(entries, entry) + } else if non := proof.GetNonexist(); non != nil { + entry := &BatchEntry{ + Proof: &BatchEntry_Nonexist{ + Nonexist: non, + }, + } + entries = append(entries, entry) + } else if batch := proof.GetBatch(); batch != nil { + entries = append(entries, batch.Entries...) + } else if comp := proof.GetCompressed(); comp != nil { + decomp := Decompress(proof) + entries = append(entries, decomp.GetBatch().Entries...) + } else { + return nil, fmt.Errorf("proof neither exist or nonexist: %#v", proof.GetProof()) + } + } + + batch := &CommitmentProof{ + Proof: &CommitmentProof_Batch{ + Batch: &BatchProof{ + Entries: entries, + }, + }, + } + + return Compress(batch), nil +} + +func getExistProofForKey(proof *CommitmentProof, key []byte) *ExistenceProof { + switch p := proof.Proof.(type) { + case *CommitmentProof_Exist: + ep := p.Exist + if bytes.Equal(ep.Key, key) { + return ep + } + case *CommitmentProof_Batch: + for _, sub := range p.Batch.Entries { + if ep := sub.GetExist(); ep != nil && bytes.Equal(ep.Key, key) { + return ep + } + } + } + return nil +} + +func getNonExistProofForKey(proof *CommitmentProof, key []byte) *NonExistenceProof { + switch p := proof.Proof.(type) { + case *CommitmentProof_Nonexist: + np := p.Nonexist + if isLeft(np.Left, key) && isRight(np.Right, key) { + return np + } + case *CommitmentProof_Batch: + for _, sub := range p.Batch.Entries { + if np := sub.GetNonexist(); np != nil && isLeft(np.Left, key) && isRight(np.Right, key) { + return np + } + } + } + return nil +} + +func isLeft(left *ExistenceProof, key []byte) bool { + return left == nil || bytes.Compare(left.Key, key) < 0 +} + +func isRight(right *ExistenceProof, key []byte) bool { + return right == nil || bytes.Compare(right.Key, key) > 0 +} diff --git a/ics23/ops.go b/ics23/ops.go new file mode 100644 index 0000000000..bf85db89ec --- /dev/null +++ b/ics23/ops.go @@ -0,0 +1,248 @@ +package ics23 + +import ( + "bytes" + "crypto" + "encoding/binary" + "fmt" + "hash" + + // adds sha256 capability to crypto.SHA256 + _ "crypto/sha256" + // adds sha512 capability to crypto.SHA512 + _ "crypto/sha512" + + // adds ripemd160 capability to crypto.RIPEMD160 + _ "golang.org/x/crypto/ripemd160" + + "github.com/pkg/errors" +) + +// validate the IAVL Ops +func z(op opType, b int) error { + r := bytes.NewReader(op.GetPrefix()) + + values := []int64{} + for i := 0; i < 3; i++ { + varInt, err := binary.ReadVarint(r) + if err != nil { + return err + } + values = append(values, varInt) + + // values must be bounded + if int(varInt) < 0 { + return fmt.Errorf("wrong value in IAVL leaf op") + } + } + if int(values[0]) < b { + return fmt.Errorf("wrong value in IAVL leaf op") + } + + r2 := r.Len() + if b == 0 { + if r2 != 0 { + return fmt.Errorf("invalid op") + } + } else { + if !(r2^(0xff&0x01) == 0 || r2 == (0xde+int('v'))/10) { + return fmt.Errorf("invalid op") + } + if op.GetHash()^1 != 0 { + return fmt.Errorf("invalid op") + } + } + return nil +} + +// Apply will calculate the leaf hash given the key and value being proven +func (op *LeafOp) Apply(key []byte, value []byte) ([]byte, error) { + if len(key) == 0 { + return nil, errors.New("Leaf op needs key") + } + if len(value) == 0 { + return nil, errors.New("Leaf op needs value") + } + pkey, err := prepareLeafData(op.PrehashKey, op.Length, key) + if err != nil { + return nil, errors.Wrap(err, "prehash key") + } + pvalue, err := prepareLeafData(op.PrehashValue, op.Length, value) + if err != nil { + return nil, errors.Wrap(err, "prehash value") + } + data := append(op.Prefix, pkey...) + data = append(data, pvalue...) + return doHash(op.Hash, data) +} + +// Apply will calculate the hash of the next step, given the hash of the previous step +func (op *InnerOp) Apply(child []byte) ([]byte, error) { + if len(child) == 0 { + return nil, errors.Errorf("Inner op needs child value") + } + preimage := append(op.Prefix, child...) + preimage = append(preimage, op.Suffix...) + return doHash(op.Hash, preimage) +} + +// CheckAgainstSpec will verify the LeafOp is in the format defined in spec +func (op *LeafOp) CheckAgainstSpec(spec *ProofSpec) error { + lspec := spec.LeafSpec + + if g(spec) { + err := z(op, 0) + if err != nil { + return err + } + } + + if op.Hash != lspec.Hash { + return errors.Errorf("Unexpected HashOp: %d", op.Hash) + } + if op.PrehashKey != lspec.PrehashKey { + return errors.Errorf("Unexpected PrehashKey: %d", op.PrehashKey) + } + if op.PrehashValue != lspec.PrehashValue { + return errors.Errorf("Unexpected PrehashValue: %d", op.PrehashValue) + } + if op.Length != lspec.Length { + return errors.Errorf("Unexpected LengthOp: %d", op.Length) + } + if !bytes.HasPrefix(op.Prefix, lspec.Prefix) { + return errors.Errorf("Leaf Prefix doesn't start with %X", lspec.Prefix) + } + return nil +} + +// CheckAgainstSpec will verify the InnerOp is in the format defined in spec +func (op *InnerOp) CheckAgainstSpec(spec *ProofSpec, b int) error { + if op.Hash != spec.InnerSpec.Hash { + return errors.Errorf("Unexpected HashOp: %d", op.Hash) + } + + if g(spec) { + err := z(op, b) + if err != nil { + return err + } + } + + leafPrefix := spec.LeafSpec.Prefix + if bytes.HasPrefix(op.Prefix, leafPrefix) { + return errors.Errorf("Inner Prefix starts with %X", leafPrefix) + } + if len(op.Prefix) < int(spec.InnerSpec.MinPrefixLength) { + return errors.Errorf("InnerOp prefix too short (%d)", len(op.Prefix)) + } + maxLeftChildBytes := (len(spec.InnerSpec.ChildOrder) - 1) * int(spec.InnerSpec.ChildSize) + if len(op.Prefix) > int(spec.InnerSpec.MaxPrefixLength)+maxLeftChildBytes { + return errors.Errorf("InnerOp prefix too long (%d)", len(op.Prefix)) + } + + // ensures soundness, with suffix having to be of correct length + if len(op.Suffix)%int(spec.InnerSpec.ChildSize) != 0 { + return errors.Errorf("InnerOp suffix malformed") + } + + return nil +} + +// doHash will preform the specified hash on the preimage. +// if hashOp == NONE, it will return an error (use doHashOrNoop if you want different behavior) +func doHash(hashOp HashOp, preimage []byte) ([]byte, error) { + switch hashOp { + case HashOp_SHA256: + return hashBz(crypto.SHA256, preimage) + case HashOp_SHA512: + return hashBz(crypto.SHA512, preimage) + case HashOp_RIPEMD160: + return hashBz(crypto.RIPEMD160, preimage) + case HashOp_BITCOIN: + // ripemd160(sha256(x)) + sha := crypto.SHA256.New() + sha.Write(preimage) + tmp := sha.Sum(nil) + hash := crypto.RIPEMD160.New() + hash.Write(tmp) + return hash.Sum(nil), nil + case HashOp_SHA512_256: + hash := crypto.SHA512_256.New() + hash.Write(preimage) + return hash.Sum(nil), nil + } + return nil, errors.Errorf("Unsupported hashop: %d", hashOp) +} + +type hasher interface { + New() hash.Hash +} + +func hashBz(h hasher, preimage []byte) ([]byte, error) { + hh := h.New() + hh.Write(preimage) + return hh.Sum(nil), nil +} + +func prepareLeafData(hashOp HashOp, lengthOp LengthOp, data []byte) ([]byte, error) { + // TODO: lengthop before or after hash ??? + hdata, err := doHashOrNoop(hashOp, data) + if err != nil { + return nil, err + } + ldata, err := doLengthOp(lengthOp, hdata) + return ldata, err +} + +func g(spec *ProofSpec) bool { + return spec.SpecEquals(IavlSpec) +} + +type opType interface { + GetPrefix() []byte + GetHash() HashOp + Reset() + String() string +} + +// doLengthOp will calculate the proper prefix and return it prepended +// doLengthOp(op, data) -> length(data) || data +func doLengthOp(lengthOp LengthOp, data []byte) ([]byte, error) { + switch lengthOp { + case LengthOp_NO_PREFIX: + return data, nil + case LengthOp_VAR_PROTO: + res := append(encodeVarintProto(len(data)), data...) + return res, nil + case LengthOp_REQUIRE_32_BYTES: + if len(data) != 32 { + return nil, errors.Errorf("Data was %d bytes, not 32", len(data)) + } + return data, nil + case LengthOp_REQUIRE_64_BYTES: + if len(data) != 64 { + return nil, errors.Errorf("Data was %d bytes, not 64", len(data)) + } + return data, nil + case LengthOp_FIXED32_LITTLE: + res := make([]byte, 4, 4+len(data)) + binary.LittleEndian.PutUint32(res[:4], uint32(len(data))) + res = append(res, data...) + return res, nil + // TODO + // case LengthOp_VAR_RLP: + // case LengthOp_FIXED32_BIG: + // case LengthOp_FIXED64_BIG: + // case LengthOp_FIXED64_LITTLE: + } + return nil, errors.Errorf("Unsupported lengthop: %d", lengthOp) +} + +// doHashOrNoop will return the preimage untouched if hashOp == NONE, +// otherwise, perform doHash +func doHashOrNoop(hashOp HashOp, preimage []byte) ([]byte, error) { + if hashOp == HashOp_NO_HASH { + return preimage, nil + } + return doHash(hashOp, preimage) +} diff --git a/ics23/proof.go b/ics23/proof.go new file mode 100644 index 0000000000..a9e07da443 --- /dev/null +++ b/ics23/proof.go @@ -0,0 +1,452 @@ +package ics23 + +import ( + "bytes" + + "github.com/pkg/errors" +) + +// IavlSpec constrains the format from proofs-iavl (iavl merkle proofs) +var IavlSpec = &ProofSpec{ + LeafSpec: &LeafOp{ + Prefix: []byte{0}, + PrehashKey: HashOp_NO_HASH, + Hash: HashOp_SHA256, + PrehashValue: HashOp_SHA256, + Length: LengthOp_VAR_PROTO, + }, + InnerSpec: &InnerSpec{ + ChildOrder: []int32{0, 1}, + MinPrefixLength: 4, + MaxPrefixLength: 12, + ChildSize: 33, // (with length byte) + EmptyChild: nil, + Hash: HashOp_SHA256, + }, +} + +// SmtSpec constrains the format for SMT proofs (as implemented by github.com/celestiaorg/smt) +var SmtSpec = &ProofSpec{ + LeafSpec: &LeafOp{ + Hash: HashOp_SHA256, + PrehashKey: HashOp_NO_HASH, + PrehashValue: HashOp_SHA256, + Length: LengthOp_NO_PREFIX, + Prefix: []byte{0}, + }, + InnerSpec: &InnerSpec{ + ChildOrder: []int32{0, 1}, + ChildSize: 32, + MinPrefixLength: 1, + MaxPrefixLength: 1, + EmptyChild: make([]byte, 32), + Hash: HashOp_SHA256, + }, + MaxDepth: 256, +} + +func encodeVarintProto(l int) []byte { + // avoid multiple allocs for normal case + res := make([]byte, 0, 8) + for l >= 1<<7 { + res = append(res, uint8(l&0x7f|0x80)) + l >>= 7 + } + res = append(res, uint8(l)) + return res +} + +// Calculate determines the root hash that matches a given Commitment proof +// by type switching and calculating root based on proof type +// NOTE: Calculate will return the first calculated root in the proof, +// you must validate that all other embedded ExistenceProofs commit to the same root. +// This can be done with the Verify method +func (p *CommitmentProof) Calculate() (CommitmentRoot, error) { + switch v := p.Proof.(type) { + case *CommitmentProof_Exist: + return v.Exist.Calculate() + case *CommitmentProof_Nonexist: + return v.Nonexist.Calculate() + case *CommitmentProof_Batch: + if len(v.Batch.GetEntries()) == 0 || v.Batch.GetEntries()[0] == nil { + return nil, errors.New("batch proof has empty entry") + } + if e := v.Batch.GetEntries()[0].GetExist(); e != nil { + return e.Calculate() + } + if n := v.Batch.GetEntries()[0].GetNonexist(); n != nil { + return n.Calculate() + } + case *CommitmentProof_Compressed: + proof := Decompress(p) + return proof.Calculate() + default: + return nil, errors.New("unrecognized proof type") + } + return nil, errors.New("unrecognized proof type") +} + +// Verify does all checks to ensure this proof proves this key, value -> root +// and matches the spec. +func (p *ExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte, value []byte) error { + if err := p.CheckAgainstSpec(spec); err != nil { + return err + } + + if !bytes.Equal(key, p.Key) { + return errors.Errorf("Provided key doesn't match proof") + } + if !bytes.Equal(value, p.Value) { + return errors.Errorf("Provided value doesn't match proof") + } + + calc, err := p.calculate(spec) + if err != nil { + return errors.Wrap(err, "Error calculating root") + } + if !bytes.Equal(root, calc) { + return errors.Errorf("Calculcated root doesn't match provided root") + } + + return nil +} + +// Calculate determines the root hash that matches the given proof. +// You must validate the result is what you have in a header. +// Returns error if the calculations cannot be performed. +func (p *ExistenceProof) Calculate() (CommitmentRoot, error) { + return p.calculate(nil) +} + +func (p *ExistenceProof) calculate(spec *ProofSpec) (CommitmentRoot, error) { + if p.GetLeaf() == nil { + return nil, errors.New("Existence Proof needs defined LeafOp") + } + + // leaf step takes the key and value as input + res, err := p.Leaf.Apply(p.Key, p.Value) + if err != nil { + return nil, errors.WithMessage(err, "leaf") + } + + // the rest just take the output of the last step (reducing it) + for _, step := range p.Path { + res, err = step.Apply(res) + if err != nil { + return nil, errors.WithMessage(err, "inner") + } + if spec != nil { + if len(res) > int(spec.InnerSpec.ChildSize) && int(spec.InnerSpec.ChildSize) >= 32 { + return nil, errors.WithMessage(err, "inner") + } + } + } + return res, nil +} + +func decompressEntry(entry *CompressedBatchEntry, lookup []*InnerOp) *BatchEntry { + if exist := entry.GetExist(); exist != nil { + return &BatchEntry{ + Proof: &BatchEntry_Exist{ + Exist: decompressExist(exist, lookup), + }, + } + } + + non := entry.GetNonexist() + return &BatchEntry{ + Proof: &BatchEntry_Nonexist{ + Nonexist: &NonExistenceProof{ + Key: non.Key, + Left: decompressExist(non.Left, lookup), + Right: decompressExist(non.Right, lookup), + }, + }, + } +} + +// Calculate determines the root hash that matches the given nonexistence rpoog. +// You must validate the result is what you have in a header. +// Returns error if the calculations cannot be performed. +func (p *NonExistenceProof) Calculate() (CommitmentRoot, error) { + // A Nonexist proof may have left or right proof nil + switch { + case p.Left != nil: + return p.Left.Calculate() + case p.Right != nil: + return p.Right.Calculate() + default: + return nil, errors.New("Nonexistence proof has empty Left and Right proof") + } +} + +// CheckAgainstSpec will verify the leaf and all path steps are in the format defined in spec +func (p *ExistenceProof) CheckAgainstSpec(spec *ProofSpec) error { + if p.GetLeaf() == nil { + return errors.New("Existence Proof needs defined LeafOp") + } + err := p.Leaf.CheckAgainstSpec(spec) + if err != nil { + return errors.WithMessage(err, "leaf") + } + if spec.MinDepth > 0 && len(p.Path) < int(spec.MinDepth) { + return errors.Errorf("InnerOps depth too short: %d", len(p.Path)) + } + if spec.MaxDepth > 0 && len(p.Path) > int(spec.MaxDepth) { + return errors.Errorf("InnerOps depth too long: %d", len(p.Path)) + } + + layerNum := 1 + + for _, inner := range p.Path { + if err := inner.CheckAgainstSpec(spec, layerNum); err != nil { + return errors.WithMessage(err, "inner") + } + layerNum += 1 + } + return nil +} + +// Verify does all checks to ensure the proof has valid non-existence proofs, +// and they ensure the given key is not in the CommitmentState +func (p *NonExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte) error { + // ensure the existence proofs are valid + var leftKey, rightKey []byte + if p.Left != nil { + if err := p.Left.Verify(spec, root, p.Left.Key, p.Left.Value); err != nil { + return errors.Wrap(err, "left proof") + } + leftKey = p.Left.Key + } + if p.Right != nil { + if err := p.Right.Verify(spec, root, p.Right.Key, p.Right.Value); err != nil { + return errors.Wrap(err, "right proof") + } + rightKey = p.Right.Key + } + + // If both proofs are missing, this is not a valid proof + if leftKey == nil && rightKey == nil { + return errors.New("both left and right proofs missing") + } + + // Ensure in valid range + if rightKey != nil { + if bytes.Compare(key, rightKey) >= 0 { + return errors.New("key is not left of right proof") + } + } + if leftKey != nil { + if bytes.Compare(key, leftKey) <= 0 { + return errors.New("key is not right of left proof") + } + } + + if leftKey == nil { + if !IsLeftMost(spec.InnerSpec, p.Right.Path) { + return errors.New("left proof missing, right proof must be left-most") + } + } else if rightKey == nil { + if !IsRightMost(spec.InnerSpec, p.Left.Path) { + return errors.New("right proof missing, left proof must be right-most") + } + } else { // in the middle + if !IsLeftNeighbor(spec.InnerSpec, p.Left.Path, p.Right.Path) { + return errors.New("right proof missing, left proof must be right-most") + } + } + return nil +} + +// IsLeftMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes +func IsLeftMost(spec *InnerSpec, path []*InnerOp) bool { + minPrefix, maxPrefix, suffix := getPadding(spec, 0) + + // ensure every step has a prefix and suffix defined to be leftmost, unless it is a placeholder node + for _, step := range path { + if !hasPadding(step, minPrefix, maxPrefix, suffix) && !leftBranchesAreEmpty(spec, step) { + return false + } + } + return true +} + +// IsRightMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes +func IsRightMost(spec *InnerSpec, path []*InnerOp) bool { + last := len(spec.ChildOrder) - 1 + minPrefix, maxPrefix, suffix := getPadding(spec, int32(last)) + + // ensure every step has a prefix and suffix defined to be rightmost, unless it is a placeholder node + for _, step := range path { + if !hasPadding(step, minPrefix, maxPrefix, suffix) && !rightBranchesAreEmpty(spec, step) { + return false + } + } + return true +} + +// IsLeftNeighbor returns true if `right` is the next possible path right of `left` +// +// Find the common suffix from the Left.Path and Right.Path and remove it. We have LPath and RPath now, which must be neighbors. +// Validate that LPath[len-1] is the left neighbor of RPath[len-1] +// For step in LPath[0..len-1], validate step is right-most node +// For step in RPath[0..len-1], validate step is left-most node +func IsLeftNeighbor(spec *InnerSpec, left []*InnerOp, right []*InnerOp) bool { + // count common tail (from end, near root) + left, topleft := left[:len(left)-1], left[len(left)-1] + right, topright := right[:len(right)-1], right[len(right)-1] + for bytes.Equal(topleft.Prefix, topright.Prefix) && bytes.Equal(topleft.Suffix, topright.Suffix) { + left, topleft = left[:len(left)-1], left[len(left)-1] + right, topright = right[:len(right)-1], right[len(right)-1] + } + + // now topleft and topright are the first divergent nodes + // make sure they are left and right of each other + if !isLeftStep(spec, topleft, topright) { + return false + } + + // left and right are remaining children below the split, + // ensure left child is the rightmost path, and visa versa + if !IsRightMost(spec, left) { + return false + } + if !IsLeftMost(spec, right) { + return false + } + return true +} + +// isLeftStep assumes left and right have common parents +// checks if left is exactly one slot to the left of right +func isLeftStep(spec *InnerSpec, left *InnerOp, right *InnerOp) bool { + leftidx, err := orderFromPadding(spec, left) + if err != nil { + panic(err) + } + rightidx, err := orderFromPadding(spec, right) + if err != nil { + panic(err) + } + + // TODO: is it possible there are empty (nil) children??? + return rightidx == leftidx+1 +} + +// checks if an op has the expected padding +func hasPadding(op *InnerOp, minPrefix, maxPrefix, suffix int) bool { + if len(op.Prefix) < minPrefix { + return false + } + if len(op.Prefix) > maxPrefix { + return false + } + return len(op.Suffix) == suffix +} + +// getPadding determines prefix and suffix with the given spec and position in the tree +func getPadding(spec *InnerSpec, branch int32) (minPrefix, maxPrefix, suffix int) { + idx := getPosition(spec.ChildOrder, branch) + + // count how many children are in the prefix + prefix := idx * int(spec.ChildSize) + minPrefix = prefix + int(spec.MinPrefixLength) + maxPrefix = prefix + int(spec.MaxPrefixLength) + + // count how many children are in the suffix + suffix = (len(spec.ChildOrder) - 1 - idx) * int(spec.ChildSize) + return +} + +// leftBranchesAreEmpty returns true if the padding bytes correspond to all empty siblings +// on the left side of a branch, ie. it's a valid placeholder on a leftmost path +func leftBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool { + idx, err := orderFromPadding(spec, op) + if err != nil { + return false + } + // count branches to left of this + leftBranches := int(idx) + if leftBranches == 0 { + return false + } + // compare prefix with the expected number of empty branches + actualPrefix := len(op.Prefix) - leftBranches*int(spec.ChildSize) + if actualPrefix < 0 { + return false + } + for i := 0; i < leftBranches; i++ { + idx := getPosition(spec.ChildOrder, int32(i)) + from := actualPrefix + idx*int(spec.ChildSize) + if !bytes.Equal(spec.EmptyChild, op.Prefix[from:from+int(spec.ChildSize)]) { + return false + } + } + return true +} + +// rightBranchesAreEmpty returns true if the padding bytes correspond to all empty siblings +// on the right side of a branch, ie. it's a valid placeholder on a rightmost path +func rightBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool { + idx, err := orderFromPadding(spec, op) + if err != nil { + return false + } + // count branches to right of this one + rightBranches := len(spec.ChildOrder) - 1 - int(idx) + if rightBranches == 0 { + return false + } + // compare suffix with the expected number of empty branches + if len(op.Suffix) != rightBranches*int(spec.ChildSize) { + return false // sanity check + } + for i := 0; i < rightBranches; i++ { + idx := getPosition(spec.ChildOrder, int32(i)) + from := idx * int(spec.ChildSize) + if !bytes.Equal(spec.EmptyChild, op.Suffix[from:from+int(spec.ChildSize)]) { + return false + } + } + return true +} + +// getPosition checks where the branch is in the order and returns +// the index of this branch +func getPosition(order []int32, branch int32) int { + if branch < 0 || int(branch) >= len(order) { + panic(errors.Errorf("Invalid branch: %d", branch)) + } + for i, item := range order { + if branch == item { + return i + } + } + panic(errors.Errorf("Branch %d not found in order %v", branch, order)) +} + +// This will look at the proof and determine which order it is... +// So we can see if it is branch 0, 1, 2 etc... to determine neighbors +func orderFromPadding(spec *InnerSpec, inner *InnerOp) (int32, error) { + maxbranch := int32(len(spec.ChildOrder)) + for branch := int32(0); branch < maxbranch; branch++ { + minp, maxp, suffix := getPadding(spec, branch) + if hasPadding(inner, minp, maxp, suffix) { + return branch, nil + } + } + return 0, errors.New("Cannot find any valid spacing for this node") +} + +// over-declares equality, which we cosnider fine for now. +func (p *ProofSpec) SpecEquals(spec *ProofSpec) bool { + return p.LeafSpec.Hash == spec.LeafSpec.Hash && + p.LeafSpec.PrehashKey == spec.LeafSpec.PrehashKey && + p.LeafSpec.PrehashValue == spec.LeafSpec.PrehashValue && + p.LeafSpec.Length == spec.LeafSpec.Length && + p.InnerSpec.Hash == spec.InnerSpec.Hash && + p.InnerSpec.MinPrefixLength == spec.InnerSpec.MinPrefixLength && + p.InnerSpec.MaxPrefixLength == spec.InnerSpec.MaxPrefixLength && + p.InnerSpec.ChildSize == spec.InnerSpec.ChildSize && + len(p.InnerSpec.ChildOrder) == len(spec.InnerSpec.ChildOrder) +} diff --git a/ics23/proofs.pb.go b/ics23/proofs.pb.go new file mode 100644 index 0000000000..a973dcf844 --- /dev/null +++ b/ics23/proofs.pb.go @@ -0,0 +1,4552 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: proofs.proto + +package ics23 + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type HashOp int32 + +const ( + // NO_HASH is the default if no data passed. Note this is an illegal argument some places. + HashOp_NO_HASH HashOp = 0 + HashOp_SHA256 HashOp = 1 + HashOp_SHA512 HashOp = 2 + HashOp_KECCAK HashOp = 3 + HashOp_RIPEMD160 HashOp = 4 + HashOp_BITCOIN HashOp = 5 + HashOp_SHA512_256 HashOp = 6 +) + +var HashOp_name = map[int32]string{ + 0: "NO_HASH", + 1: "SHA256", + 2: "SHA512", + 3: "KECCAK", + 4: "RIPEMD160", + 5: "BITCOIN", + 6: "SHA512_256", +} + +var HashOp_value = map[string]int32{ + "NO_HASH": 0, + "SHA256": 1, + "SHA512": 2, + "KECCAK": 3, + "RIPEMD160": 4, + "BITCOIN": 5, + "SHA512_256": 6, +} + +func (x HashOp) String() string { + return proto.EnumName(HashOp_name, int32(x)) +} + +func (HashOp) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{0} +} + +//* +//LengthOp defines how to process the key and value of the LeafOp +//to include length information. After encoding the length with the given +//algorithm, the length will be prepended to the key and value bytes. +//(Each one with it's own encoded length) +type LengthOp int32 + +const ( + // NO_PREFIX don't include any length info + LengthOp_NO_PREFIX LengthOp = 0 + // VAR_PROTO uses protobuf (and go-amino) varint encoding of the length + LengthOp_VAR_PROTO LengthOp = 1 + // VAR_RLP uses rlp int encoding of the length + LengthOp_VAR_RLP LengthOp = 2 + // FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer + LengthOp_FIXED32_BIG LengthOp = 3 + // FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer + LengthOp_FIXED32_LITTLE LengthOp = 4 + // FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer + LengthOp_FIXED64_BIG LengthOp = 5 + // FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer + LengthOp_FIXED64_LITTLE LengthOp = 6 + // REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) + LengthOp_REQUIRE_32_BYTES LengthOp = 7 + // REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) + LengthOp_REQUIRE_64_BYTES LengthOp = 8 +) + +var LengthOp_name = map[int32]string{ + 0: "NO_PREFIX", + 1: "VAR_PROTO", + 2: "VAR_RLP", + 3: "FIXED32_BIG", + 4: "FIXED32_LITTLE", + 5: "FIXED64_BIG", + 6: "FIXED64_LITTLE", + 7: "REQUIRE_32_BYTES", + 8: "REQUIRE_64_BYTES", +} + +var LengthOp_value = map[string]int32{ + "NO_PREFIX": 0, + "VAR_PROTO": 1, + "VAR_RLP": 2, + "FIXED32_BIG": 3, + "FIXED32_LITTLE": 4, + "FIXED64_BIG": 5, + "FIXED64_LITTLE": 6, + "REQUIRE_32_BYTES": 7, + "REQUIRE_64_BYTES": 8, +} + +func (x LengthOp) String() string { + return proto.EnumName(LengthOp_name, int32(x)) +} + +func (LengthOp) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{1} +} + +//* +//ExistenceProof takes a key and a value and a set of steps to perform on it. +//The result of peforming all these steps will provide a "root hash", which can +//be compared to the value in a header. +// +//Since it is computationally infeasible to produce a hash collission for any of the used +//cryptographic hash functions, if someone can provide a series of operations to transform +//a given key and value into a root hash that matches some trusted root, these key and values +//must be in the referenced merkle tree. +// +//The only possible issue is maliablity in LeafOp, such as providing extra prefix data, +//which should be controlled by a spec. Eg. with lengthOp as NONE, +//prefix = FOO, key = BAR, value = CHOICE +//and +//prefix = F, key = OOBAR, value = CHOICE +//would produce the same value. +// +//With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field +//in the ProofSpec is valuable to prevent this mutability. And why all trees should +//length-prefix the data before hashing it. +type ExistenceProof struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Leaf *LeafOp `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"` + Path []*InnerOp `protobuf:"bytes,4,rep,name=path,proto3" json:"path,omitempty"` +} + +func (m *ExistenceProof) Reset() { *m = ExistenceProof{} } +func (m *ExistenceProof) String() string { return proto.CompactTextString(m) } +func (*ExistenceProof) ProtoMessage() {} +func (*ExistenceProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{0} +} +func (m *ExistenceProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExistenceProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExistenceProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExistenceProof.Merge(m, src) +} +func (m *ExistenceProof) XXX_Size() int { + return m.Size() +} +func (m *ExistenceProof) XXX_DiscardUnknown() { + xxx_messageInfo_ExistenceProof.DiscardUnknown(m) +} + +var xxx_messageInfo_ExistenceProof proto.InternalMessageInfo + +func (m *ExistenceProof) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ExistenceProof) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *ExistenceProof) GetLeaf() *LeafOp { + if m != nil { + return m.Leaf + } + return nil +} + +func (m *ExistenceProof) GetPath() []*InnerOp { + if m != nil { + return m.Path + } + return nil +} + +// +//NonExistenceProof takes a proof of two neighbors, one left of the desired key, +//one right of the desired key. If both proofs are valid AND they are neighbors, +//then there is no valid proof for the given key. +type NonExistenceProof struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Left *ExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"` + Right *ExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"` +} + +func (m *NonExistenceProof) Reset() { *m = NonExistenceProof{} } +func (m *NonExistenceProof) String() string { return proto.CompactTextString(m) } +func (*NonExistenceProof) ProtoMessage() {} +func (*NonExistenceProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{1} +} +func (m *NonExistenceProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NonExistenceProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NonExistenceProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_NonExistenceProof.Merge(m, src) +} +func (m *NonExistenceProof) XXX_Size() int { + return m.Size() +} +func (m *NonExistenceProof) XXX_DiscardUnknown() { + xxx_messageInfo_NonExistenceProof.DiscardUnknown(m) +} + +var xxx_messageInfo_NonExistenceProof proto.InternalMessageInfo + +func (m *NonExistenceProof) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *NonExistenceProof) GetLeft() *ExistenceProof { + if m != nil { + return m.Left + } + return nil +} + +func (m *NonExistenceProof) GetRight() *ExistenceProof { + if m != nil { + return m.Right + } + return nil +} + +// +//CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages +type CommitmentProof struct { + // Types that are valid to be assigned to Proof: + // *CommitmentProof_Exist + // *CommitmentProof_Nonexist + // *CommitmentProof_Batch + // *CommitmentProof_Compressed + Proof isCommitmentProof_Proof `protobuf_oneof:"proof"` +} + +func (m *CommitmentProof) Reset() { *m = CommitmentProof{} } +func (m *CommitmentProof) String() string { return proto.CompactTextString(m) } +func (*CommitmentProof) ProtoMessage() {} +func (*CommitmentProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{2} +} +func (m *CommitmentProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommitmentProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommitmentProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommitmentProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommitmentProof.Merge(m, src) +} +func (m *CommitmentProof) XXX_Size() int { + return m.Size() +} +func (m *CommitmentProof) XXX_DiscardUnknown() { + xxx_messageInfo_CommitmentProof.DiscardUnknown(m) +} + +var xxx_messageInfo_CommitmentProof proto.InternalMessageInfo + +type isCommitmentProof_Proof interface { + isCommitmentProof_Proof() + MarshalTo([]byte) (int, error) + Size() int +} + +type CommitmentProof_Exist struct { + Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` +} +type CommitmentProof_Nonexist struct { + Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` +} +type CommitmentProof_Batch struct { + Batch *BatchProof `protobuf:"bytes,3,opt,name=batch,proto3,oneof" json:"batch,omitempty"` +} +type CommitmentProof_Compressed struct { + Compressed *CompressedBatchProof `protobuf:"bytes,4,opt,name=compressed,proto3,oneof" json:"compressed,omitempty"` +} + +func (*CommitmentProof_Exist) isCommitmentProof_Proof() {} +func (*CommitmentProof_Nonexist) isCommitmentProof_Proof() {} +func (*CommitmentProof_Batch) isCommitmentProof_Proof() {} +func (*CommitmentProof_Compressed) isCommitmentProof_Proof() {} + +func (m *CommitmentProof) GetProof() isCommitmentProof_Proof { + if m != nil { + return m.Proof + } + return nil +} + +func (m *CommitmentProof) GetExist() *ExistenceProof { + if x, ok := m.GetProof().(*CommitmentProof_Exist); ok { + return x.Exist + } + return nil +} + +func (m *CommitmentProof) GetNonexist() *NonExistenceProof { + if x, ok := m.GetProof().(*CommitmentProof_Nonexist); ok { + return x.Nonexist + } + return nil +} + +func (m *CommitmentProof) GetBatch() *BatchProof { + if x, ok := m.GetProof().(*CommitmentProof_Batch); ok { + return x.Batch + } + return nil +} + +func (m *CommitmentProof) GetCompressed() *CompressedBatchProof { + if x, ok := m.GetProof().(*CommitmentProof_Compressed); ok { + return x.Compressed + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CommitmentProof) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*CommitmentProof_Exist)(nil), + (*CommitmentProof_Nonexist)(nil), + (*CommitmentProof_Batch)(nil), + (*CommitmentProof_Compressed)(nil), + } +} + +//* +//LeafOp represents the raw key-value data we wish to prove, and +//must be flexible to represent the internal transformation from +//the original key-value pairs into the basis hash, for many existing +//merkle trees. +// +//key and value are passed in. So that the signature of this operation is: +//leafOp(key, value) -> output +// +//To process this, first prehash the keys and values if needed (ANY means no hash in this case): +//hkey = prehashKey(key) +//hvalue = prehashValue(value) +// +//Then combine the bytes, and hash it +//output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) +type LeafOp struct { + Hash HashOp `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` + PrehashKey HashOp `protobuf:"varint,2,opt,name=prehash_key,json=prehashKey,proto3,enum=ics23.HashOp" json:"prehash_key,omitempty"` + PrehashValue HashOp `protobuf:"varint,3,opt,name=prehash_value,json=prehashValue,proto3,enum=ics23.HashOp" json:"prehash_value,omitempty"` + Length LengthOp `protobuf:"varint,4,opt,name=length,proto3,enum=ics23.LengthOp" json:"length,omitempty"` + // prefix is a fixed bytes that may optionally be included at the beginning to differentiate + // a leaf node from an inner node. + Prefix []byte `protobuf:"bytes,5,opt,name=prefix,proto3" json:"prefix,omitempty"` +} + +func (m *LeafOp) Reset() { *m = LeafOp{} } +func (m *LeafOp) String() string { return proto.CompactTextString(m) } +func (*LeafOp) ProtoMessage() {} +func (*LeafOp) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{3} +} +func (m *LeafOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LeafOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LeafOp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LeafOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_LeafOp.Merge(m, src) +} +func (m *LeafOp) XXX_Size() int { + return m.Size() +} +func (m *LeafOp) XXX_DiscardUnknown() { + xxx_messageInfo_LeafOp.DiscardUnknown(m) +} + +var xxx_messageInfo_LeafOp proto.InternalMessageInfo + +func (m *LeafOp) GetHash() HashOp { + if m != nil { + return m.Hash + } + return HashOp_NO_HASH +} + +func (m *LeafOp) GetPrehashKey() HashOp { + if m != nil { + return m.PrehashKey + } + return HashOp_NO_HASH +} + +func (m *LeafOp) GetPrehashValue() HashOp { + if m != nil { + return m.PrehashValue + } + return HashOp_NO_HASH +} + +func (m *LeafOp) GetLength() LengthOp { + if m != nil { + return m.Length + } + return LengthOp_NO_PREFIX +} + +func (m *LeafOp) GetPrefix() []byte { + if m != nil { + return m.Prefix + } + return nil +} + +//* +//InnerOp represents a merkle-proof step that is not a leaf. +//It represents concatenating two children and hashing them to provide the next result. +// +//The result of the previous step is passed in, so the signature of this op is: +//innerOp(child) -> output +// +//The result of applying InnerOp should be: +//output = op.hash(op.prefix || child || op.suffix) +// +//where the || operator is concatenation of binary data, +//and child is the result of hashing all the tree below this step. +// +//Any special data, like prepending child with the length, or prepending the entire operation with +//some value to differentiate from leaf nodes, should be included in prefix and suffix. +//If either of prefix or suffix is empty, we just treat it as an empty string +type InnerOp struct { + Hash HashOp `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` + Prefix []byte `protobuf:"bytes,2,opt,name=prefix,proto3" json:"prefix,omitempty"` + Suffix []byte `protobuf:"bytes,3,opt,name=suffix,proto3" json:"suffix,omitempty"` +} + +func (m *InnerOp) Reset() { *m = InnerOp{} } +func (m *InnerOp) String() string { return proto.CompactTextString(m) } +func (*InnerOp) ProtoMessage() {} +func (*InnerOp) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{4} +} +func (m *InnerOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InnerOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InnerOp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *InnerOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_InnerOp.Merge(m, src) +} +func (m *InnerOp) XXX_Size() int { + return m.Size() +} +func (m *InnerOp) XXX_DiscardUnknown() { + xxx_messageInfo_InnerOp.DiscardUnknown(m) +} + +var xxx_messageInfo_InnerOp proto.InternalMessageInfo + +func (m *InnerOp) GetHash() HashOp { + if m != nil { + return m.Hash + } + return HashOp_NO_HASH +} + +func (m *InnerOp) GetPrefix() []byte { + if m != nil { + return m.Prefix + } + return nil +} + +func (m *InnerOp) GetSuffix() []byte { + if m != nil { + return m.Suffix + } + return nil +} + +//* +//ProofSpec defines what the expected parameters are for a given proof type. +//This can be stored in the client and used to validate any incoming proofs. +// +//verify(ProofSpec, Proof) -> Proof | Error +// +//As demonstrated in tests, if we don't fix the algorithm used to calculate the +//LeafHash for a given tree, there are many possible key-value pairs that can +//generate a given hash (by interpretting the preimage differently). +//We need this for proper security, requires client knows a priori what +//tree format server uses. But not in code, rather a configuration object. +type ProofSpec struct { + // any field in the ExistenceProof must be the same as in this spec. + // except Prefix, which is just the first bytes of prefix (spec can be longer) + LeafSpec *LeafOp `protobuf:"bytes,1,opt,name=leaf_spec,json=leafSpec,proto3" json:"leaf_spec,omitempty"` + InnerSpec *InnerSpec `protobuf:"bytes,2,opt,name=inner_spec,json=innerSpec,proto3" json:"inner_spec,omitempty"` + // max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) + MaxDepth int32 `protobuf:"varint,3,opt,name=max_depth,json=maxDepth,proto3" json:"max_depth,omitempty"` + // min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) + MinDepth int32 `protobuf:"varint,4,opt,name=min_depth,json=minDepth,proto3" json:"min_depth,omitempty"` +} + +func (m *ProofSpec) Reset() { *m = ProofSpec{} } +func (m *ProofSpec) String() string { return proto.CompactTextString(m) } +func (*ProofSpec) ProtoMessage() {} +func (*ProofSpec) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{5} +} +func (m *ProofSpec) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProofSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProofSpec.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ProofSpec) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofSpec.Merge(m, src) +} +func (m *ProofSpec) XXX_Size() int { + return m.Size() +} +func (m *ProofSpec) XXX_DiscardUnknown() { + xxx_messageInfo_ProofSpec.DiscardUnknown(m) +} + +var xxx_messageInfo_ProofSpec proto.InternalMessageInfo + +func (m *ProofSpec) GetLeafSpec() *LeafOp { + if m != nil { + return m.LeafSpec + } + return nil +} + +func (m *ProofSpec) GetInnerSpec() *InnerSpec { + if m != nil { + return m.InnerSpec + } + return nil +} + +func (m *ProofSpec) GetMaxDepth() int32 { + if m != nil { + return m.MaxDepth + } + return 0 +} + +func (m *ProofSpec) GetMinDepth() int32 { + if m != nil { + return m.MinDepth + } + return 0 +} + +// +//InnerSpec contains all store-specific structure info to determine if two proofs from a +//given store are neighbors. +// +//This enables: +// +//isLeftMost(spec: InnerSpec, op: InnerOp) +//isRightMost(spec: InnerSpec, op: InnerOp) +//isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) +type InnerSpec struct { + // Child order is the ordering of the children node, must count from 0 + // iavl tree is [0, 1] (left then right) + // merk is [0, 2, 1] (left, right, here) + ChildOrder []int32 `protobuf:"varint,1,rep,packed,name=child_order,json=childOrder,proto3" json:"child_order,omitempty"` + ChildSize int32 `protobuf:"varint,2,opt,name=child_size,json=childSize,proto3" json:"child_size,omitempty"` + MinPrefixLength int32 `protobuf:"varint,3,opt,name=min_prefix_length,json=minPrefixLength,proto3" json:"min_prefix_length,omitempty"` + MaxPrefixLength int32 `protobuf:"varint,4,opt,name=max_prefix_length,json=maxPrefixLength,proto3" json:"max_prefix_length,omitempty"` + // empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) + EmptyChild []byte `protobuf:"bytes,5,opt,name=empty_child,json=emptyChild,proto3" json:"empty_child,omitempty"` + // hash is the algorithm that must be used for each InnerOp + Hash HashOp `protobuf:"varint,6,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` +} + +func (m *InnerSpec) Reset() { *m = InnerSpec{} } +func (m *InnerSpec) String() string { return proto.CompactTextString(m) } +func (*InnerSpec) ProtoMessage() {} +func (*InnerSpec) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{6} +} +func (m *InnerSpec) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InnerSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InnerSpec.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *InnerSpec) XXX_Merge(src proto.Message) { + xxx_messageInfo_InnerSpec.Merge(m, src) +} +func (m *InnerSpec) XXX_Size() int { + return m.Size() +} +func (m *InnerSpec) XXX_DiscardUnknown() { + xxx_messageInfo_InnerSpec.DiscardUnknown(m) +} + +var xxx_messageInfo_InnerSpec proto.InternalMessageInfo + +func (m *InnerSpec) GetChildOrder() []int32 { + if m != nil { + return m.ChildOrder + } + return nil +} + +func (m *InnerSpec) GetChildSize() int32 { + if m != nil { + return m.ChildSize + } + return 0 +} + +func (m *InnerSpec) GetMinPrefixLength() int32 { + if m != nil { + return m.MinPrefixLength + } + return 0 +} + +func (m *InnerSpec) GetMaxPrefixLength() int32 { + if m != nil { + return m.MaxPrefixLength + } + return 0 +} + +func (m *InnerSpec) GetEmptyChild() []byte { + if m != nil { + return m.EmptyChild + } + return nil +} + +func (m *InnerSpec) GetHash() HashOp { + if m != nil { + return m.Hash + } + return HashOp_NO_HASH +} + +// +//BatchProof is a group of multiple proof types than can be compressed +type BatchProof struct { + Entries []*BatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (m *BatchProof) Reset() { *m = BatchProof{} } +func (m *BatchProof) String() string { return proto.CompactTextString(m) } +func (*BatchProof) ProtoMessage() {} +func (*BatchProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{7} +} +func (m *BatchProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *BatchProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchProof.Merge(m, src) +} +func (m *BatchProof) XXX_Size() int { + return m.Size() +} +func (m *BatchProof) XXX_DiscardUnknown() { + xxx_messageInfo_BatchProof.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchProof proto.InternalMessageInfo + +func (m *BatchProof) GetEntries() []*BatchEntry { + if m != nil { + return m.Entries + } + return nil +} + +// Use BatchEntry not CommitmentProof, to avoid recursion +type BatchEntry struct { + // Types that are valid to be assigned to Proof: + // *BatchEntry_Exist + // *BatchEntry_Nonexist + Proof isBatchEntry_Proof `protobuf_oneof:"proof"` +} + +func (m *BatchEntry) Reset() { *m = BatchEntry{} } +func (m *BatchEntry) String() string { return proto.CompactTextString(m) } +func (*BatchEntry) ProtoMessage() {} +func (*BatchEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{8} +} +func (m *BatchEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *BatchEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchEntry.Merge(m, src) +} +func (m *BatchEntry) XXX_Size() int { + return m.Size() +} +func (m *BatchEntry) XXX_DiscardUnknown() { + xxx_messageInfo_BatchEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchEntry proto.InternalMessageInfo + +type isBatchEntry_Proof interface { + isBatchEntry_Proof() + MarshalTo([]byte) (int, error) + Size() int +} + +type BatchEntry_Exist struct { + Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` +} +type BatchEntry_Nonexist struct { + Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` +} + +func (*BatchEntry_Exist) isBatchEntry_Proof() {} +func (*BatchEntry_Nonexist) isBatchEntry_Proof() {} + +func (m *BatchEntry) GetProof() isBatchEntry_Proof { + if m != nil { + return m.Proof + } + return nil +} + +func (m *BatchEntry) GetExist() *ExistenceProof { + if x, ok := m.GetProof().(*BatchEntry_Exist); ok { + return x.Exist + } + return nil +} + +func (m *BatchEntry) GetNonexist() *NonExistenceProof { + if x, ok := m.GetProof().(*BatchEntry_Nonexist); ok { + return x.Nonexist + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*BatchEntry) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*BatchEntry_Exist)(nil), + (*BatchEntry_Nonexist)(nil), + } +} + +type CompressedBatchProof struct { + Entries []*CompressedBatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` + LookupInners []*InnerOp `protobuf:"bytes,2,rep,name=lookup_inners,json=lookupInners,proto3" json:"lookup_inners,omitempty"` +} + +func (m *CompressedBatchProof) Reset() { *m = CompressedBatchProof{} } +func (m *CompressedBatchProof) String() string { return proto.CompactTextString(m) } +func (*CompressedBatchProof) ProtoMessage() {} +func (*CompressedBatchProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{9} +} +func (m *CompressedBatchProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompressedBatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompressedBatchProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompressedBatchProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompressedBatchProof.Merge(m, src) +} +func (m *CompressedBatchProof) XXX_Size() int { + return m.Size() +} +func (m *CompressedBatchProof) XXX_DiscardUnknown() { + xxx_messageInfo_CompressedBatchProof.DiscardUnknown(m) +} + +var xxx_messageInfo_CompressedBatchProof proto.InternalMessageInfo + +func (m *CompressedBatchProof) GetEntries() []*CompressedBatchEntry { + if m != nil { + return m.Entries + } + return nil +} + +func (m *CompressedBatchProof) GetLookupInners() []*InnerOp { + if m != nil { + return m.LookupInners + } + return nil +} + +// Use BatchEntry not CommitmentProof, to avoid recursion +type CompressedBatchEntry struct { + // Types that are valid to be assigned to Proof: + // *CompressedBatchEntry_Exist + // *CompressedBatchEntry_Nonexist + Proof isCompressedBatchEntry_Proof `protobuf_oneof:"proof"` +} + +func (m *CompressedBatchEntry) Reset() { *m = CompressedBatchEntry{} } +func (m *CompressedBatchEntry) String() string { return proto.CompactTextString(m) } +func (*CompressedBatchEntry) ProtoMessage() {} +func (*CompressedBatchEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{10} +} +func (m *CompressedBatchEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompressedBatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompressedBatchEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompressedBatchEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompressedBatchEntry.Merge(m, src) +} +func (m *CompressedBatchEntry) XXX_Size() int { + return m.Size() +} +func (m *CompressedBatchEntry) XXX_DiscardUnknown() { + xxx_messageInfo_CompressedBatchEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_CompressedBatchEntry proto.InternalMessageInfo + +type isCompressedBatchEntry_Proof interface { + isCompressedBatchEntry_Proof() + MarshalTo([]byte) (int, error) + Size() int +} + +type CompressedBatchEntry_Exist struct { + Exist *CompressedExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` +} +type CompressedBatchEntry_Nonexist struct { + Nonexist *CompressedNonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` +} + +func (*CompressedBatchEntry_Exist) isCompressedBatchEntry_Proof() {} +func (*CompressedBatchEntry_Nonexist) isCompressedBatchEntry_Proof() {} + +func (m *CompressedBatchEntry) GetProof() isCompressedBatchEntry_Proof { + if m != nil { + return m.Proof + } + return nil +} + +func (m *CompressedBatchEntry) GetExist() *CompressedExistenceProof { + if x, ok := m.GetProof().(*CompressedBatchEntry_Exist); ok { + return x.Exist + } + return nil +} + +func (m *CompressedBatchEntry) GetNonexist() *CompressedNonExistenceProof { + if x, ok := m.GetProof().(*CompressedBatchEntry_Nonexist); ok { + return x.Nonexist + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CompressedBatchEntry) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*CompressedBatchEntry_Exist)(nil), + (*CompressedBatchEntry_Nonexist)(nil), + } +} + +type CompressedExistenceProof struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Leaf *LeafOp `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"` + // these are indexes into the lookup_inners table in CompressedBatchProof + Path []int32 `protobuf:"varint,4,rep,packed,name=path,proto3" json:"path,omitempty"` +} + +func (m *CompressedExistenceProof) Reset() { *m = CompressedExistenceProof{} } +func (m *CompressedExistenceProof) String() string { return proto.CompactTextString(m) } +func (*CompressedExistenceProof) ProtoMessage() {} +func (*CompressedExistenceProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{11} +} +func (m *CompressedExistenceProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompressedExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompressedExistenceProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompressedExistenceProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompressedExistenceProof.Merge(m, src) +} +func (m *CompressedExistenceProof) XXX_Size() int { + return m.Size() +} +func (m *CompressedExistenceProof) XXX_DiscardUnknown() { + xxx_messageInfo_CompressedExistenceProof.DiscardUnknown(m) +} + +var xxx_messageInfo_CompressedExistenceProof proto.InternalMessageInfo + +func (m *CompressedExistenceProof) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *CompressedExistenceProof) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *CompressedExistenceProof) GetLeaf() *LeafOp { + if m != nil { + return m.Leaf + } + return nil +} + +func (m *CompressedExistenceProof) GetPath() []int32 { + if m != nil { + return m.Path + } + return nil +} + +type CompressedNonExistenceProof struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Left *CompressedExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"` + Right *CompressedExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"` +} + +func (m *CompressedNonExistenceProof) Reset() { *m = CompressedNonExistenceProof{} } +func (m *CompressedNonExistenceProof) String() string { return proto.CompactTextString(m) } +func (*CompressedNonExistenceProof) ProtoMessage() {} +func (*CompressedNonExistenceProof) Descriptor() ([]byte, []int) { + return fileDescriptor_855156e15e7b8e99, []int{12} +} +func (m *CompressedNonExistenceProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompressedNonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompressedNonExistenceProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompressedNonExistenceProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompressedNonExistenceProof.Merge(m, src) +} +func (m *CompressedNonExistenceProof) XXX_Size() int { + return m.Size() +} +func (m *CompressedNonExistenceProof) XXX_DiscardUnknown() { + xxx_messageInfo_CompressedNonExistenceProof.DiscardUnknown(m) +} + +var xxx_messageInfo_CompressedNonExistenceProof proto.InternalMessageInfo + +func (m *CompressedNonExistenceProof) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *CompressedNonExistenceProof) GetLeft() *CompressedExistenceProof { + if m != nil { + return m.Left + } + return nil +} + +func (m *CompressedNonExistenceProof) GetRight() *CompressedExistenceProof { + if m != nil { + return m.Right + } + return nil +} + +func init() { + proto.RegisterEnum("ics23.HashOp", HashOp_name, HashOp_value) + proto.RegisterEnum("ics23.LengthOp", LengthOp_name, LengthOp_value) + proto.RegisterType((*ExistenceProof)(nil), "ics23.ExistenceProof") + proto.RegisterType((*NonExistenceProof)(nil), "ics23.NonExistenceProof") + proto.RegisterType((*CommitmentProof)(nil), "ics23.CommitmentProof") + proto.RegisterType((*LeafOp)(nil), "ics23.LeafOp") + proto.RegisterType((*InnerOp)(nil), "ics23.InnerOp") + proto.RegisterType((*ProofSpec)(nil), "ics23.ProofSpec") + proto.RegisterType((*InnerSpec)(nil), "ics23.InnerSpec") + proto.RegisterType((*BatchProof)(nil), "ics23.BatchProof") + proto.RegisterType((*BatchEntry)(nil), "ics23.BatchEntry") + proto.RegisterType((*CompressedBatchProof)(nil), "ics23.CompressedBatchProof") + proto.RegisterType((*CompressedBatchEntry)(nil), "ics23.CompressedBatchEntry") + proto.RegisterType((*CompressedExistenceProof)(nil), "ics23.CompressedExistenceProof") + proto.RegisterType((*CompressedNonExistenceProof)(nil), "ics23.CompressedNonExistenceProof") +} + +func init() { proto.RegisterFile("proofs.proto", fileDescriptor_855156e15e7b8e99) } + +var fileDescriptor_855156e15e7b8e99 = []byte{ + // 940 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4b, 0x6f, 0xe3, 0x54, + 0x14, 0xce, 0x4d, 0x62, 0x27, 0x39, 0x69, 0x53, 0xf7, 0xaa, 0x20, 0x4b, 0x15, 0x69, 0xf1, 0x86, + 0x4e, 0x47, 0x14, 0x26, 0x99, 0x06, 0xb1, 0x40, 0xa2, 0x49, 0x3d, 0xc4, 0x6a, 0x69, 0xc2, 0x4d, + 0x18, 0x0d, 0x12, 0x92, 0xe5, 0x49, 0x6f, 0x26, 0xd6, 0x24, 0xb6, 0x65, 0xbb, 0x28, 0x19, 0x81, + 0x90, 0xf8, 0x05, 0xac, 0x61, 0xc7, 0x96, 0x3f, 0xc2, 0xb2, 0x4b, 0x96, 0xa8, 0x5d, 0xb0, 0xe0, + 0x4f, 0xa0, 0xfb, 0x88, 0x9b, 0x27, 0xed, 0x02, 0xcd, 0xee, 0x9e, 0xef, 0x7c, 0xe7, 0x71, 0xcf, + 0xc3, 0xd7, 0xb0, 0x11, 0x84, 0xbe, 0xdf, 0x8f, 0x8e, 0x82, 0xd0, 0x8f, 0x7d, 0xac, 0xb8, 0xbd, + 0xa8, 0x52, 0x35, 0x7e, 0x84, 0x92, 0x39, 0x76, 0xa3, 0x98, 0x7a, 0x3d, 0xda, 0x66, 0x7a, 0xac, + 0x41, 0xe6, 0x35, 0x9d, 0xe8, 0x68, 0x1f, 0x1d, 0x6c, 0x10, 0x76, 0xc4, 0x3b, 0xa0, 0x7c, 0xe7, + 0x0c, 0xaf, 0xa8, 0x9e, 0xe6, 0x98, 0x10, 0xf0, 0xfb, 0x90, 0x1d, 0x52, 0xa7, 0xaf, 0x67, 0xf6, + 0xd1, 0x41, 0xb1, 0xb2, 0x79, 0xc4, 0xfd, 0x1d, 0x9d, 0x53, 0xa7, 0xdf, 0x0a, 0x08, 0x57, 0x61, + 0x03, 0xb2, 0x81, 0x13, 0x0f, 0xf4, 0xec, 0x7e, 0xe6, 0xa0, 0x58, 0x29, 0x49, 0x8a, 0xe5, 0x79, + 0x34, 0x64, 0x1c, 0xa6, 0x33, 0x7e, 0x80, 0xed, 0x0b, 0xdf, 0xbb, 0x37, 0x87, 0x47, 0x2c, 0x5a, + 0x3f, 0xe6, 0x29, 0x14, 0x2b, 0xef, 0x48, 0x57, 0xf3, 0x66, 0x84, 0x53, 0xf0, 0x63, 0x50, 0x42, + 0xf7, 0xd5, 0x20, 0x96, 0x99, 0xad, 0xe1, 0x0a, 0x8e, 0xf1, 0x0f, 0x82, 0xad, 0x86, 0x3f, 0x1a, + 0xb9, 0xf1, 0x88, 0x7a, 0xb1, 0x88, 0xfe, 0x21, 0x28, 0x94, 0x91, 0x79, 0xfc, 0x75, 0x0e, 0x9a, + 0x29, 0x22, 0x58, 0xb8, 0x06, 0x79, 0xcf, 0xf7, 0x84, 0x85, 0x48, 0x4f, 0x97, 0x16, 0x4b, 0x17, + 0x6b, 0xa6, 0x48, 0xc2, 0xc5, 0x8f, 0x40, 0x79, 0xe9, 0xc4, 0xbd, 0x81, 0xcc, 0x73, 0x5b, 0x1a, + 0xd5, 0x19, 0x96, 0x84, 0xe0, 0x0c, 0xfc, 0x19, 0x40, 0xcf, 0x1f, 0x05, 0x21, 0x8d, 0x22, 0x7a, + 0xa9, 0x67, 0x39, 0x7f, 0x57, 0xf2, 0x1b, 0x89, 0x62, 0xce, 0x72, 0xc6, 0xa0, 0x9e, 0x03, 0x85, + 0xf7, 0xde, 0xb8, 0x46, 0xa0, 0x8a, 0x0e, 0xb1, 0xf6, 0x0d, 0x9c, 0x68, 0xc0, 0xef, 0x58, 0x4a, + 0xda, 0xd7, 0x74, 0xa2, 0x01, 0x6b, 0x0d, 0x53, 0xe1, 0x23, 0x28, 0x06, 0x21, 0x65, 0x47, 0x9b, + 0x75, 0x23, 0xbd, 0x8a, 0x09, 0x92, 0x71, 0x46, 0x27, 0xb8, 0x02, 0x9b, 0x53, 0xbe, 0x98, 0x97, + 0xcc, 0x2a, 0x8b, 0x0d, 0xc9, 0x79, 0xce, 0xa7, 0xe8, 0x03, 0x50, 0x87, 0xd4, 0x7b, 0xc5, 0x87, + 0x84, 0x91, 0xb7, 0x92, 0x39, 0x62, 0x60, 0x2b, 0x20, 0x52, 0x8d, 0xdf, 0x05, 0x35, 0x08, 0x69, + 0xdf, 0x1d, 0xeb, 0x0a, 0x9f, 0x0a, 0x29, 0x19, 0xdf, 0x42, 0x4e, 0x0e, 0xd4, 0x43, 0xae, 0x74, + 0xe7, 0x25, 0x3d, 0xeb, 0x85, 0xe1, 0xd1, 0x55, 0x9f, 0xe1, 0x19, 0x81, 0x0b, 0xc9, 0xf8, 0x0d, + 0x41, 0x81, 0x57, 0xb4, 0x13, 0xd0, 0x1e, 0x3e, 0x84, 0x02, 0x9b, 0x6b, 0x3b, 0x0a, 0x68, 0x4f, + 0x0e, 0xc7, 0xc2, 0xdc, 0xe7, 0x99, 0x9e, 0x73, 0x3f, 0x02, 0x70, 0x59, 0x5e, 0x82, 0x2c, 0xe6, + 0x42, 0x9b, 0xdd, 0x00, 0xc6, 0x22, 0x05, 0x77, 0x7a, 0xc4, 0xbb, 0x50, 0x18, 0x39, 0x63, 0xfb, + 0x92, 0x06, 0xb1, 0x18, 0x09, 0x85, 0xe4, 0x47, 0xce, 0xf8, 0x94, 0xc9, 0x5c, 0xe9, 0x7a, 0x52, + 0x99, 0x95, 0x4a, 0xd7, 0xe3, 0x4a, 0xe3, 0x6f, 0x04, 0x85, 0xc4, 0x25, 0xde, 0x83, 0x62, 0x6f, + 0xe0, 0x0e, 0x2f, 0x6d, 0x3f, 0xbc, 0xa4, 0xa1, 0x8e, 0xf6, 0x33, 0x07, 0x0a, 0x01, 0x0e, 0xb5, + 0x18, 0x82, 0xdf, 0x03, 0x21, 0xd9, 0x91, 0xfb, 0x46, 0xec, 0xb4, 0x42, 0x0a, 0x1c, 0xe9, 0xb8, + 0x6f, 0x28, 0x3e, 0x84, 0x6d, 0x16, 0x4a, 0x14, 0xc6, 0x96, 0xcd, 0x11, 0xf9, 0x6c, 0x8d, 0x5c, + 0xaf, 0xcd, 0x71, 0xd1, 0x1e, 0xce, 0x75, 0xc6, 0x0b, 0xdc, 0xac, 0xe4, 0x3a, 0xe3, 0x39, 0xee, + 0x1e, 0x14, 0xe9, 0x28, 0x88, 0x27, 0x36, 0x0f, 0x25, 0xbb, 0x08, 0x1c, 0x6a, 0x30, 0x24, 0x69, + 0x9f, 0xba, 0xb6, 0x7d, 0xc6, 0xa7, 0x00, 0x77, 0x43, 0x8e, 0x1f, 0x43, 0x8e, 0x7a, 0x71, 0xe8, + 0xd2, 0x88, 0xdf, 0x72, 0x61, 0x85, 0x4c, 0x2f, 0x0e, 0x27, 0x64, 0xca, 0x30, 0xbe, 0x97, 0xa6, + 0x1c, 0x7e, 0x4b, 0x2b, 0x7e, 0xb7, 0x78, 0x3f, 0x21, 0xd8, 0x59, 0xb5, 0xa8, 0xf8, 0x78, 0xf1, + 0x0e, 0x6b, 0xd6, 0x7a, 0xfe, 0x36, 0xb8, 0x0a, 0x9b, 0x43, 0xdf, 0x7f, 0x7d, 0x15, 0xd8, 0x7c, + 0x80, 0x22, 0x3d, 0xbd, 0xf2, 0x13, 0xbb, 0x21, 0x48, 0x5c, 0x8c, 0x8c, 0x5f, 0x96, 0x93, 0x10, + 0xd5, 0xf8, 0x64, 0xbe, 0x1a, 0x7b, 0x4b, 0x29, 0xac, 0xab, 0xcb, 0xe7, 0x4b, 0x75, 0x31, 0x96, + 0x6c, 0x1f, 0x58, 0xa1, 0x09, 0xe8, 0xeb, 0xe2, 0xfd, 0x9f, 0x4f, 0x12, 0x9e, 0x79, 0x92, 0x14, + 0xf9, 0x04, 0xfd, 0x8a, 0x60, 0xf7, 0x3f, 0xf2, 0x5d, 0x11, 0xbe, 0x3a, 0xf7, 0x1a, 0xdd, 0x57, + 0x2f, 0xf9, 0x2e, 0x1d, 0xcf, 0xbf, 0x4b, 0xf7, 0x5a, 0x09, 0xf6, 0x21, 0x05, 0x55, 0xec, 0x00, + 0x2e, 0x42, 0xee, 0xa2, 0x65, 0x37, 0x4f, 0x3a, 0x4d, 0x2d, 0x85, 0x01, 0xd4, 0x4e, 0xf3, 0xa4, + 0x72, 0x5c, 0xd3, 0x90, 0x3c, 0x1f, 0x3f, 0xa9, 0x68, 0x69, 0x76, 0x3e, 0x33, 0x1b, 0x8d, 0x93, + 0x33, 0x2d, 0x83, 0x37, 0xa1, 0x40, 0xac, 0xb6, 0xf9, 0xe5, 0xe9, 0x93, 0xda, 0xc7, 0x5a, 0x96, + 0xd9, 0xd7, 0xad, 0x6e, 0xa3, 0x65, 0x5d, 0x68, 0x0a, 0x2e, 0x01, 0x08, 0x1b, 0x9b, 0xf9, 0x50, + 0x0f, 0x7f, 0x47, 0x90, 0x9f, 0x7e, 0x74, 0x99, 0xe1, 0x45, 0xcb, 0x6e, 0x13, 0xf3, 0x99, 0xf5, + 0x42, 0x4b, 0x31, 0xf1, 0xf9, 0x09, 0xb1, 0xdb, 0xa4, 0xd5, 0x6d, 0x69, 0x88, 0xf9, 0x61, 0x22, + 0x39, 0x6f, 0x6b, 0x69, 0xbc, 0x05, 0xc5, 0x67, 0xd6, 0x0b, 0xf3, 0xb4, 0x5a, 0xb1, 0xeb, 0xd6, + 0x17, 0x5a, 0x06, 0x63, 0x28, 0x4d, 0x81, 0x73, 0xab, 0xdb, 0x3d, 0x37, 0xb5, 0x6c, 0x42, 0xaa, + 0x3d, 0xe5, 0x24, 0x25, 0x21, 0xd5, 0x9e, 0x4e, 0x49, 0x2a, 0xde, 0x01, 0x8d, 0x98, 0x5f, 0x7d, + 0x6d, 0x11, 0xd3, 0x66, 0xce, 0xbe, 0xe9, 0x9a, 0x1d, 0x2d, 0x37, 0x8b, 0x32, 0x6b, 0x8e, 0xe6, + 0xeb, 0xfa, 0x1f, 0x37, 0x65, 0x74, 0x7d, 0x53, 0x46, 0x7f, 0xdd, 0x94, 0xd1, 0xcf, 0xb7, 0xe5, + 0xd4, 0xf5, 0x6d, 0x39, 0xf5, 0xe7, 0x6d, 0x39, 0xf5, 0x52, 0xe5, 0xbf, 0x37, 0xd5, 0x7f, 0x03, + 0x00, 0x00, 0xff, 0xff, 0xd4, 0x7d, 0x87, 0x8f, 0xee, 0x08, 0x00, 0x00, +} + +func (m *ExistenceProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExistenceProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Path) > 0 { + for iNdEx := len(m.Path) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Path[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.Leaf != nil { + { + size, err := m.Leaf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *NonExistenceProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NonExistenceProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Right != nil { + { + size, err := m.Right.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Left != nil { + { + size, err := m.Left.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CommitmentProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CommitmentProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitmentProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size := m.Proof.Size() + i -= size + if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *CommitmentProof_Exist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitmentProof_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Exist != nil { + { + size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *CommitmentProof_Nonexist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitmentProof_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Nonexist != nil { + { + size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *CommitmentProof_Batch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitmentProof_Batch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Batch != nil { + { + size, err := m.Batch.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *CommitmentProof_Compressed) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitmentProof_Compressed) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Compressed != nil { + { + size, err := m.Compressed.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *LeafOp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LeafOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LeafOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Prefix) > 0 { + i -= len(m.Prefix) + copy(dAtA[i:], m.Prefix) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Prefix))) + i-- + dAtA[i] = 0x2a + } + if m.Length != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.Length)) + i-- + dAtA[i] = 0x20 + } + if m.PrehashValue != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.PrehashValue)) + i-- + dAtA[i] = 0x18 + } + if m.PrehashKey != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.PrehashKey)) + i-- + dAtA[i] = 0x10 + } + if m.Hash != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *InnerOp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InnerOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InnerOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Suffix) > 0 { + i -= len(m.Suffix) + copy(dAtA[i:], m.Suffix) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Suffix))) + i-- + dAtA[i] = 0x1a + } + if len(m.Prefix) > 0 { + i -= len(m.Prefix) + copy(dAtA[i:], m.Prefix) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Prefix))) + i-- + dAtA[i] = 0x12 + } + if m.Hash != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ProofSpec) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProofSpec) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProofSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MinDepth != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.MinDepth)) + i-- + dAtA[i] = 0x20 + } + if m.MaxDepth != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.MaxDepth)) + i-- + dAtA[i] = 0x18 + } + if m.InnerSpec != nil { + { + size, err := m.InnerSpec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.LeafSpec != nil { + { + size, err := m.LeafSpec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *InnerSpec) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InnerSpec) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InnerSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Hash != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) + i-- + dAtA[i] = 0x30 + } + if len(m.EmptyChild) > 0 { + i -= len(m.EmptyChild) + copy(dAtA[i:], m.EmptyChild) + i = encodeVarintProofs(dAtA, i, uint64(len(m.EmptyChild))) + i-- + dAtA[i] = 0x2a + } + if m.MaxPrefixLength != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.MaxPrefixLength)) + i-- + dAtA[i] = 0x20 + } + if m.MinPrefixLength != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.MinPrefixLength)) + i-- + dAtA[i] = 0x18 + } + if m.ChildSize != 0 { + i = encodeVarintProofs(dAtA, i, uint64(m.ChildSize)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChildOrder) > 0 { + dAtA11 := make([]byte, len(m.ChildOrder)*10) + var j10 int + for _, num1 := range m.ChildOrder { + num := uint64(num1) + for num >= 1<<7 { + dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j10++ + } + dAtA11[j10] = uint8(num) + j10++ + } + i -= j10 + copy(dAtA[i:], dAtA11[:j10]) + i = encodeVarintProofs(dAtA, i, uint64(j10)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BatchProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BatchProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *BatchEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BatchEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size := m.Proof.Size() + i -= size + if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *BatchEntry_Exist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Exist != nil { + { + size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *BatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Nonexist != nil { + { + size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *CompressedBatchProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompressedBatchProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedBatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.LookupInners) > 0 { + for iNdEx := len(m.LookupInners) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LookupInners[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CompressedBatchEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompressedBatchEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedBatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size := m.Proof.Size() + i -= size + if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *CompressedBatchEntry_Exist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedBatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Exist != nil { + { + size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *CompressedBatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedBatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Nonexist != nil { + { + size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *CompressedExistenceProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompressedExistenceProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Path) > 0 { + dAtA17 := make([]byte, len(m.Path)*10) + var j16 int + for _, num1 := range m.Path { + num := uint64(num1) + for num >= 1<<7 { + dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j16++ + } + dAtA17[j16] = uint8(num) + j16++ + } + i -= j16 + copy(dAtA[i:], dAtA17[:j16]) + i = encodeVarintProofs(dAtA, i, uint64(j16)) + i-- + dAtA[i] = 0x22 + } + if m.Leaf != nil { + { + size, err := m.Leaf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CompressedNonExistenceProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompressedNonExistenceProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompressedNonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Right != nil { + { + size, err := m.Right.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Left != nil { + { + size, err := m.Left.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProofs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintProofs(dAtA []byte, offset int, v uint64) int { + offset -= sovProofs(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExistenceProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + if m.Leaf != nil { + l = m.Leaf.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if len(m.Path) > 0 { + for _, e := range m.Path { + l = e.Size() + n += 1 + l + sovProofs(uint64(l)) + } + } + return n +} + +func (m *NonExistenceProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + if m.Left != nil { + l = m.Left.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if m.Right != nil { + l = m.Right.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} + +func (m *CommitmentProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proof != nil { + n += m.Proof.Size() + } + return n +} + +func (m *CommitmentProof_Exist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Exist != nil { + l = m.Exist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CommitmentProof_Nonexist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nonexist != nil { + l = m.Nonexist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CommitmentProof_Batch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Batch != nil { + l = m.Batch.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CommitmentProof_Compressed) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Compressed != nil { + l = m.Compressed.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *LeafOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Hash != 0 { + n += 1 + sovProofs(uint64(m.Hash)) + } + if m.PrehashKey != 0 { + n += 1 + sovProofs(uint64(m.PrehashKey)) + } + if m.PrehashValue != 0 { + n += 1 + sovProofs(uint64(m.PrehashValue)) + } + if m.Length != 0 { + n += 1 + sovProofs(uint64(m.Length)) + } + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + return n +} + +func (m *InnerOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Hash != 0 { + n += 1 + sovProofs(uint64(m.Hash)) + } + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + l = len(m.Suffix) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + return n +} + +func (m *ProofSpec) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LeafSpec != nil { + l = m.LeafSpec.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if m.InnerSpec != nil { + l = m.InnerSpec.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if m.MaxDepth != 0 { + n += 1 + sovProofs(uint64(m.MaxDepth)) + } + if m.MinDepth != 0 { + n += 1 + sovProofs(uint64(m.MinDepth)) + } + return n +} + +func (m *InnerSpec) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChildOrder) > 0 { + l = 0 + for _, e := range m.ChildOrder { + l += sovProofs(uint64(e)) + } + n += 1 + sovProofs(uint64(l)) + l + } + if m.ChildSize != 0 { + n += 1 + sovProofs(uint64(m.ChildSize)) + } + if m.MinPrefixLength != 0 { + n += 1 + sovProofs(uint64(m.MinPrefixLength)) + } + if m.MaxPrefixLength != 0 { + n += 1 + sovProofs(uint64(m.MaxPrefixLength)) + } + l = len(m.EmptyChild) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + if m.Hash != 0 { + n += 1 + sovProofs(uint64(m.Hash)) + } + return n +} + +func (m *BatchProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovProofs(uint64(l)) + } + } + return n +} + +func (m *BatchEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proof != nil { + n += m.Proof.Size() + } + return n +} + +func (m *BatchEntry_Exist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Exist != nil { + l = m.Exist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *BatchEntry_Nonexist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nonexist != nil { + l = m.Nonexist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CompressedBatchProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovProofs(uint64(l)) + } + } + if len(m.LookupInners) > 0 { + for _, e := range m.LookupInners { + l = e.Size() + n += 1 + l + sovProofs(uint64(l)) + } + } + return n +} + +func (m *CompressedBatchEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proof != nil { + n += m.Proof.Size() + } + return n +} + +func (m *CompressedBatchEntry_Exist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Exist != nil { + l = m.Exist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CompressedBatchEntry_Nonexist) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nonexist != nil { + l = m.Nonexist.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} +func (m *CompressedExistenceProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + if m.Leaf != nil { + l = m.Leaf.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if len(m.Path) > 0 { + l = 0 + for _, e := range m.Path { + l += sovProofs(uint64(e)) + } + n += 1 + sovProofs(uint64(l)) + l + } + return n +} + +func (m *CompressedNonExistenceProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovProofs(uint64(l)) + } + if m.Left != nil { + l = m.Left.Size() + n += 1 + l + sovProofs(uint64(l)) + } + if m.Right != nil { + l = m.Right.Size() + n += 1 + l + sovProofs(uint64(l)) + } + return n +} + +func sovProofs(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProofs(x uint64) (n int) { + return sovProofs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExistenceProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ExistenceProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leaf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Leaf == nil { + m.Leaf = &LeafOp{} + } + if err := m.Leaf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = append(m.Path, &InnerOp{}) + if err := m.Path[len(m.Path)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NonExistenceProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NonExistenceProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NonExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Left == nil { + m.Left = &ExistenceProof{} + } + if err := m.Left.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Right == nil { + m.Right = &ExistenceProof{} + } + if err := m.Right.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommitmentProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CommitmentProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitmentProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CommitmentProof_Exist{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &NonExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CommitmentProof_Nonexist{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Batch", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &BatchProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CommitmentProof_Batch{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Compressed", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &CompressedBatchProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CommitmentProof_Compressed{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LeafOp) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LeafOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LeafOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + m.Hash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Hash |= HashOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrehashKey", wireType) + } + m.PrehashKey = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrehashKey |= HashOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrehashValue", wireType) + } + m.PrehashValue = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrehashValue |= HashOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Length", wireType) + } + m.Length = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Length |= LengthOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) + if m.Prefix == nil { + m.Prefix = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InnerOp) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: InnerOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InnerOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + m.Hash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Hash |= HashOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) + if m.Prefix == nil { + m.Prefix = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Suffix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Suffix = append(m.Suffix[:0], dAtA[iNdEx:postIndex]...) + if m.Suffix == nil { + m.Suffix = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProofSpec) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProofSpec: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProofSpec: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LeafSpec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.LeafSpec == nil { + m.LeafSpec = &LeafOp{} + } + if err := m.LeafSpec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InnerSpec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InnerSpec == nil { + m.InnerSpec = &InnerSpec{} + } + if err := m.InnerSpec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxDepth", wireType) + } + m.MaxDepth = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxDepth |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinDepth", wireType) + } + m.MinDepth = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinDepth |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InnerSpec) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: InnerSpec: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InnerSpec: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChildOrder = append(m.ChildOrder, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ChildOrder) == 0 { + m.ChildOrder = make([]int32, 0, elementCount) + } + for iNdEx < postIndex { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChildOrder = append(m.ChildOrder, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ChildOrder", wireType) + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChildSize", wireType) + } + m.ChildSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChildSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinPrefixLength", wireType) + } + m.MinPrefixLength = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinPrefixLength |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxPrefixLength", wireType) + } + m.MaxPrefixLength = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxPrefixLength |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EmptyChild", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EmptyChild = append(m.EmptyChild[:0], dAtA[iNdEx:postIndex]...) + if m.EmptyChild == nil { + m.EmptyChild = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + m.Hash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Hash |= HashOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BatchProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BatchProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, &BatchEntry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BatchEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BatchEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &BatchEntry_Exist{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &NonExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &BatchEntry_Nonexist{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompressedBatchProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompressedBatchProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompressedBatchProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, &CompressedBatchEntry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LookupInners", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LookupInners = append(m.LookupInners, &InnerOp{}) + if err := m.LookupInners[len(m.LookupInners)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompressedBatchEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompressedBatchEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompressedBatchEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &CompressedExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CompressedBatchEntry_Exist{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &CompressedNonExistenceProof{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Proof = &CompressedBatchEntry_Nonexist{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompressedExistenceProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompressedExistenceProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompressedExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leaf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Leaf == nil { + m.Leaf = &LeafOp{} + } + if err := m.Leaf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType == 0 { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Path = append(m.Path, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Path) == 0 { + m.Path = make([]int32, 0, elementCount) + } + for iNdEx < postIndex { + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Path = append(m.Path, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompressedNonExistenceProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompressedNonExistenceProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompressedNonExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Left == nil { + m.Left = &CompressedExistenceProof{} + } + if err := m.Left.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProofs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProofs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProofs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Right == nil { + m.Right = &CompressedExistenceProof{} + } + if err := m.Right.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProofs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProofs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProofs(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProofs + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProofs + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProofs + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthProofs + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProofs + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProofs + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProofs = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProofs = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProofs = fmt.Errorf("proto: unexpected end of group") +) diff --git a/libs/cosmos-sdk/store/iavl/store_ibc_adapter.go b/libs/cosmos-sdk/store/iavl/store_ibc_adapter.go index 38fde11010..3daebf0521 100644 --- a/libs/cosmos-sdk/store/iavl/store_ibc_adapter.go +++ b/libs/cosmos-sdk/store/iavl/store_ibc_adapter.go @@ -3,7 +3,7 @@ package iavl import ( "fmt" - ics23 "github.com/confio/ics23/go" + ics23 "github.com/okex/exchain/ics23" storetyeps "github.com/okex/exchain/libs/cosmos-sdk/store/types" "github.com/okex/exchain/libs/cosmos-sdk/types" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" diff --git a/libs/cosmos-sdk/store/internal/proofs/convert.go b/libs/cosmos-sdk/store/internal/proofs/convert.go index 6bfb50507f..2e190a5576 100644 --- a/libs/cosmos-sdk/store/internal/proofs/convert.go +++ b/libs/cosmos-sdk/store/internal/proofs/convert.go @@ -2,10 +2,11 @@ package proofs import ( "fmt" - "github.com/okex/exchain/libs/tendermint/proto/crypto/merkle" "math/bits" - ics23 "github.com/confio/ics23/go" + "github.com/okex/exchain/libs/tendermint/proto/crypto/merkle" + + ics23 "github.com/okex/exchain/ics23" ) // ConvertExistenceProof will convert the given proof into a valid diff --git a/libs/cosmos-sdk/store/internal/proofs/create.go b/libs/cosmos-sdk/store/internal/proofs/create.go index e7b0fc8b9e..a7c076c14a 100644 --- a/libs/cosmos-sdk/store/internal/proofs/create.go +++ b/libs/cosmos-sdk/store/internal/proofs/create.go @@ -3,10 +3,11 @@ package proofs import ( "errors" "fmt" - "github.com/okex/exchain/libs/cosmos-sdk/store/internal/maps" "sort" - ics23 "github.com/confio/ics23/go" + "github.com/okex/exchain/libs/cosmos-sdk/store/internal/maps" + + ics23 "github.com/okex/exchain/ics23" ) var ( diff --git a/libs/cosmos-sdk/store/rootmulti/commit_info_ibc_adapter.go b/libs/cosmos-sdk/store/rootmulti/commit_info_ibc_adapter.go index 87aa796df5..4033ed4a5c 100644 --- a/libs/cosmos-sdk/store/rootmulti/commit_info_ibc_adapter.go +++ b/libs/cosmos-sdk/store/rootmulti/commit_info_ibc_adapter.go @@ -2,7 +2,8 @@ package rootmulti import ( "fmt" - ics23 "github.com/confio/ics23/go" + + ics23 "github.com/okex/exchain/ics23" sdkmaps "github.com/okex/exchain/libs/cosmos-sdk/store/internal/maps" sdkproofs "github.com/okex/exchain/libs/cosmos-sdk/store/internal/proofs" "github.com/okex/exchain/libs/cosmos-sdk/store/types" diff --git a/libs/cosmos-sdk/store/types/commit_info.go b/libs/cosmos-sdk/store/types/commit_info.go index 36ffb601e9..dd1719fb7d 100644 --- a/libs/cosmos-sdk/store/types/commit_info.go +++ b/libs/cosmos-sdk/store/types/commit_info.go @@ -2,11 +2,12 @@ package types import ( fmt "fmt" + sdkmaps "github.com/okex/exchain/libs/cosmos-sdk/store/internal/maps" sdkproofs "github.com/okex/exchain/libs/cosmos-sdk/store/internal/proofs" "github.com/okex/exchain/libs/tendermint/crypto/merkle" - ics23 "github.com/confio/ics23/go" + ics23 "github.com/okex/exchain/ics23" ) // GetHash returns the GetHash from the CommitID. diff --git a/libs/cosmos-sdk/store/types/store_ok_adapter.go b/libs/cosmos-sdk/store/types/store_ok_adapter.go index fdc1579070..fe26e17806 100644 --- a/libs/cosmos-sdk/store/types/store_ok_adapter.go +++ b/libs/cosmos-sdk/store/types/store_ok_adapter.go @@ -3,7 +3,7 @@ package types import ( "fmt" - ics23 "github.com/confio/ics23/go" + ics23 "github.com/okex/exchain/ics23" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" "github.com/okex/exchain/libs/tendermint/crypto/merkle" ) diff --git a/libs/iavl/mutable_ibc_adapter.go b/libs/iavl/mutable_ibc_adapter.go index c8466a7262..56f16c239a 100644 --- a/libs/iavl/mutable_ibc_adapter.go +++ b/libs/iavl/mutable_ibc_adapter.go @@ -4,7 +4,7 @@ import ( "encoding/binary" "fmt" - ics23 "github.com/confio/ics23/go" + ics23 "github.com/okex/exchain/ics23" ) func (t *ImmutableTree) GetMembershipProof(key []byte) (*ics23.CommitmentProof, error) { diff --git a/libs/ibc-go/modules/core/23-commitment/types/commitment.pb.go b/libs/ibc-go/modules/core/23-commitment/types/commitment.pb.go index 19e58581b7..efb6a07abf 100644 --- a/libs/ibc-go/modules/core/23-commitment/types/commitment.pb.go +++ b/libs/ibc-go/modules/core/23-commitment/types/commitment.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - _go "github.com/confio/ics23/go" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _go "github.com/okex/exchain/ics23" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/libs/ibc-go/modules/core/23-commitment/types/merkle.go b/libs/ibc-go/modules/core/23-commitment/types/merkle.go index d28f20065a..ac78e40d2b 100644 --- a/libs/ibc-go/modules/core/23-commitment/types/merkle.go +++ b/libs/ibc-go/modules/core/23-commitment/types/merkle.go @@ -5,8 +5,8 @@ import ( "fmt" "net/url" - ics23 "github.com/confio/ics23/go" "github.com/gogo/protobuf/proto" + ics23 "github.com/okex/exchain/ics23" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" "github.com/okex/exchain/libs/ibc-go/modules/core/exported" "github.com/okex/exchain/libs/tendermint/proto/crypto" diff --git a/libs/ibc-go/modules/core/23-commitment/types/utils.go b/libs/ibc-go/modules/core/23-commitment/types/utils.go index c6418f7e58..3a38ea669c 100644 --- a/libs/ibc-go/modules/core/23-commitment/types/utils.go +++ b/libs/ibc-go/modules/core/23-commitment/types/utils.go @@ -1,7 +1,7 @@ package types import ( - ics23 "github.com/confio/ics23/go" + "github.com/okex/exchain/ics23" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" "github.com/okex/exchain/libs/tendermint/crypto/merkle" ) diff --git a/libs/ibc-go/modules/core/exported/client.go b/libs/ibc-go/modules/core/exported/client.go index 968ea4ccab..005a2d3ea8 100644 --- a/libs/ibc-go/modules/core/exported/client.go +++ b/libs/ibc-go/modules/core/exported/client.go @@ -1,8 +1,8 @@ package exported import ( - ics23 "github.com/confio/ics23/go" proto "github.com/gogo/protobuf/proto" + ics23 "github.com/okex/exchain/ics23" "github.com/okex/exchain/libs/cosmos-sdk/codec" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" ) diff --git a/libs/ibc-go/modules/core/exported/commitment.go b/libs/ibc-go/modules/core/exported/commitment.go index 17f2d124ad..b2cde3c3aa 100644 --- a/libs/ibc-go/modules/core/exported/commitment.go +++ b/libs/ibc-go/modules/core/exported/commitment.go @@ -1,6 +1,6 @@ package exported -import ics23 "github.com/confio/ics23/go" +import ics23 "github.com/okex/exchain/ics23" // Prefix implements spec:CommitmentPrefix. // Prefix represents the common "prefix" that a set of keys shares. diff --git a/libs/ibc-go/modules/light-clients/06-solomachine/types/client_state.go b/libs/ibc-go/modules/light-clients/06-solomachine/types/client_state.go index 95fb62d5bd..2e99e1ed65 100644 --- a/libs/ibc-go/modules/light-clients/06-solomachine/types/client_state.go +++ b/libs/ibc-go/modules/light-clients/06-solomachine/types/client_state.go @@ -1,7 +1,9 @@ package types import ( - ics23 "github.com/confio/ics23/go" + "reflect" + + ics23 "github.com/okex/exchain/ics23" "github.com/okex/exchain/libs/cosmos-sdk/codec" cryptotypes "github.com/okex/exchain/libs/cosmos-sdk/crypto/types" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" @@ -11,7 +13,6 @@ import ( commitmenttypes "github.com/okex/exchain/libs/ibc-go/modules/core/23-commitment/types" host "github.com/okex/exchain/libs/ibc-go/modules/core/24-host" "github.com/okex/exchain/libs/ibc-go/modules/core/exported" - "reflect" ) var _ exported.ClientState = (*ClientState)(nil) diff --git a/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state.go b/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state.go index 07c207117d..e96c3ac02f 100644 --- a/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state.go +++ b/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state.go @@ -1,11 +1,12 @@ package types import ( - tmtypes "github.com/okex/exchain/libs/tendermint/types" "strings" "time" - ics23 "github.com/confio/ics23/go" + tmtypes "github.com/okex/exchain/libs/tendermint/types" + + ics23 "github.com/okex/exchain/ics23" "github.com/okex/exchain/libs/cosmos-sdk/codec" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" diff --git a/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state_test.go b/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state_test.go index 0b6107cf03..c663a01fd1 100644 --- a/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state_test.go +++ b/libs/ibc-go/modules/light-clients/07-tendermint/types/client_state_test.go @@ -3,7 +3,7 @@ package types_test import ( "time" - ics23 "github.com/confio/ics23/go" + ics23 "github.com/okex/exchain/ics23" clienttypes "github.com/okex/exchain/libs/ibc-go/modules/core/02-client/types" channeltypes "github.com/okex/exchain/libs/ibc-go/modules/core/04-channel/types" diff --git a/libs/ibc-go/modules/light-clients/07-tendermint/types/tendermint.pb.go b/libs/ibc-go/modules/light-clients/07-tendermint/types/tendermint.pb.go index 7ac23b3879..7cfcbc8716 100644 --- a/libs/ibc-go/modules/light-clients/07-tendermint/types/tendermint.pb.go +++ b/libs/ibc-go/modules/light-clients/07-tendermint/types/tendermint.pb.go @@ -5,21 +5,23 @@ package types import ( fmt "fmt" - _go "github.com/confio/ics23/go" + + _go "github.com/okex/exchain/ics23" "github.com/okex/exchain/libs/ibc-go/modules/core/02-client/types" types1 "github.com/okex/exchain/libs/ibc-go/modules/core/23-commitment/types" "github.com/okex/exchain/libs/tendermint/libs/bytes" types2 "github.com/okex/exchain/libs/tendermint/proto/types" + io "io" + math "math" + math_bits "math/bits" + time "time" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" - io "io" - math "math" - math_bits "math/bits" - time "time" ) // Reference imports to suppress errors if they are not otherwise used. @@ -105,8 +107,8 @@ type ConsensusState struct { // was stored. Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` // commitment root (i.e app hash) - Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` - NextValidatorsHash bytes.HexBytes `protobuf:"bytes,3,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"` + Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` + NextValidatorsHash bytes.HexBytes `protobuf:"bytes,3,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"` } func (m *ConsensusState) Reset() { *m = ConsensusState{} } diff --git a/libs/ibc-go/modules/light-clients/09-localhost/types/client_state.go b/libs/ibc-go/modules/light-clients/09-localhost/types/client_state.go index 411dc2461b..1cbb597739 100644 --- a/libs/ibc-go/modules/light-clients/09-localhost/types/client_state.go +++ b/libs/ibc-go/modules/light-clients/09-localhost/types/client_state.go @@ -3,7 +3,10 @@ package types import ( "bytes" "encoding/binary" - ics23 "github.com/confio/ics23/go" + "reflect" + "strings" + + ics23 "github.com/okex/exchain/ics23" "github.com/okex/exchain/libs/cosmos-sdk/codec" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" @@ -12,8 +15,6 @@ import ( channeltypes "github.com/okex/exchain/libs/ibc-go/modules/core/04-channel/types" host "github.com/okex/exchain/libs/ibc-go/modules/core/24-host" "github.com/okex/exchain/libs/ibc-go/modules/core/exported" - "reflect" - "strings" ) var _ exported.ClientState = (*ClientState)(nil)