Hi,
When researching depth overflow for BIP32 keys I've noticed that Zcash's child derivation can also overflow the depth. Consider the following example that panics:
diff --git a/src/zip32.rs b/src/zip32.rs
index 93b1cf5..247f1e4 100644
--- a/src/zip32.rs
+++ b/src/zip32.rs
@@ -244,6 +244,18 @@ mod tests {
assert!(xsk_5.is_ok());
}
+ #[test]
+ fn derive_child_depth_overflows() {
+ let seed = [0; 32];
+ let mut xsk = ExtendedSpendingKey::master(&seed).unwrap();
+
+ let i_5 = ChildIndex::hardened(5);
+ for _ in 0..256 {
+ xsk = xsk.derive_child(i_5).unwrap();
+ }
+
+ }
+
#[test]
fn path() {
let seed = [0; 32];
In case of Bitcoin the issue is then that the serialized keys overflow (the depth has to fit into a single byte). For Zcash, apart from the panic, I am not sure about other possible issues.