From 5c9d990068107e54a4d8206b9fd1d2c606ec8e95 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 30 Oct 2017 21:44:22 -0700 Subject: fix sleep error with parent hashing --- src/sleep_register.rs | 6 +++--- 1 file 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)); -- cgit v1.2.3