diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-10-30 21:44:22 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-10-30 21:44:22 -0700 |
commit | 5c9d990068107e54a4d8206b9fd1d2c606ec8e95 (patch) | |
tree | 35bee9553f6ac5baf1dffb12e48a46055b10aa4a /src | |
parent | ad76ba22f345a181e86b50d4f75da1c2295a9f53 (diff) | |
download | geniza-5c9d990068107e54a4d8206b9fd1d2c606ec8e95.tar.gz geniza-5c9d990068107e54a4d8206b9fd1d2c606ec8e95.zip |
fix sleep error with parent hashing
Diffstat (limited to 'src')
-rw-r--r-- | src/sleep_register.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sleep_register.rs b/src/sleep_register.rs index 276e4c9..0687b3d 100644 --- a/src/sleep_register.rs +++ b/src/sleep_register.rs @@ -74,8 +74,8 @@ impl HyperRegister { let mut hash = Blake2b::new(32); hash.input(&[1; 1]); hash.input(&buf[32..40]); - hash.input(&lhash[..]); - hash.input(&rhash[..]); + hash.input(&lhash[0..32]); + hash.input(&rhash[0..32]); hash.result(&mut buf[0..32]); buf } @@ -165,6 +165,7 @@ impl HyperRegister { let right = ((tree_index | (1 << i))) & !(1 << (i - 1)); // smaller child has next lower bit cleared let left = tree_index & !(1 << (i - 1)); + assert!(left < right); return Ok((left, right)); } } @@ -206,7 +207,6 @@ fn test_tree_child_indices() { assert!(HyperRegister::tree_child_indices(0).is_err()); assert!(HyperRegister::tree_child_indices(1024).is_err()); assert_eq!(HyperRegister::tree_child_indices(1).unwrap(), (0, 2)); - assert_eq!(HyperRegister::tree_child_indices(3).unwrap(), (1, 5)); assert_eq!(HyperRegister::tree_child_indices(5).unwrap(), (4, 6)); assert_eq!(HyperRegister::tree_child_indices(7).unwrap(), (3, 11)); |