Skip to content

Commit

Permalink
fix: move ics23 to correct folder (cosmos#13549)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc authored Oct 14, 2022
1 parent 2582f0a commit d118681
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 85 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76

// vendor ics23
github.com/confio/ics23/go => ./ics23
github.com/confio/ics23/go => ./ics23/go

// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 10 additions & 9 deletions ics23/ics23.go → ics23/go/ics23.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/**
/*
*
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 ExistenceProof
type verifyMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key, value: Value) => boolean
// Assumes NonExistenceProof
type verifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key) => 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<Key, Value>) => boolean
// Assumes BatchProof - required ExistenceProofs may be a subset of all items proven
type batchVerifyMembership = (root: CommitmentRoot, proof: CommitmentProof, items: Map<Key, Value>) => boolean
// Assumes BatchProof - required NonExistenceProofs may be a subset of all items proven
type batchVerifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, keys: Set<Key>) => boolean
// Assumes BatchProof - required NonExistenceProofs may be a subset of all items proven
type batchVerifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, keys: Set<Key>) => 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
Expand Down
3 changes: 2 additions & 1 deletion ics23/ops.go → ics23/go/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ type opType interface {
}

// doLengthOp will calculate the proper prefix and return it prepended
// doLengthOp(op, data) -> length(data) || data
//
// doLengthOp(op, data) -> length(data) || data
func doLengthOp(lengthOp LengthOp, data []byte) ([]byte, error) {
switch lengthOp {
case LengthOp_NO_PREFIX:
Expand Down
8 changes: 4 additions & 4 deletions ics23/proof.go → ics23/go/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ func IsRightMost(spec *InnerSpec, path []*InnerOp) bool {

// 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
// 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]
Expand Down
136 changes: 66 additions & 70 deletions ics23/proofs.pb.go → ics23/go/proofs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d118681

Please sign in to comment.