Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty with custom order #77

Merged
merged 3 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ func leftBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool {
return false
}
for i := 0; i < leftBranches; i++ {
from := actualPrefix + i*int(spec.ChildSize)
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
}
Expand All @@ -373,7 +374,8 @@ func rightBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool {
return false // sanity check
}
for i := 0; i < rightBranches; i++ {
from := i * int(spec.ChildSize)
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
}
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ics23"
version = "0.7.0-rc"
version = "0.7.0"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"
exclude = ["codegen"]
Expand Down
8 changes: 6 additions & 2 deletions rust/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ fn left_branches_are_empty(spec: &ics23::InnerSpec, op: &ics23::InnerOp) -> Resu
_ => return Ok(false),
};
for i in 0..left_branches {
let from = actual_prefix + i * child_size;
let idx = spec.child_order.iter().find(|&&x| x == i as i32).unwrap();
let idx = *idx as usize;
let from = actual_prefix + idx * child_size;
if spec.empty_child != op.prefix[from..from + child_size] {
return Ok(false);
}
Expand All @@ -300,7 +302,9 @@ fn right_branches_are_empty(spec: &ics23::InnerSpec, op: &ics23::InnerOp) -> Res
return Ok(false);
}
for i in 0..right_branches {
let from = i * spec.child_size as usize;
let idx = spec.child_order.iter().find(|&&x| x == i as i32).unwrap();
let idx = *idx as usize;
let from = idx * spec.child_size as usize;
if spec.empty_child != op.suffix[from..from + spec.child_size as usize] {
return Ok(false);
}
Expand Down