diff --git a/src/circuit/gadget/sinsemilla/merkle.rs b/src/circuit/gadget/sinsemilla/merkle.rs index b7f8edc6f..38889b120 100644 --- a/src/circuit/gadget/sinsemilla/merkle.rs +++ b/src/circuit/gadget/sinsemilla/merkle.rs @@ -452,32 +452,30 @@ impl(l_star as u32); - let left: Vec<_> = left - .value() - .unwrap() - .to_le_bits() - .iter() - .by_val() - .take(L_ORCHARD_BASE) - .collect(); - let right: Vec<_> = right - .value() - .unwrap() - .to_le_bits() - .iter() - .by_val() - .take(L_ORCHARD_BASE) - .collect(); - let merkle_crh = HashDomain::new(MERKLE_CRH_PERSONALIZATION); + if let (Some(left), Some(right)) = (left.value(), right.value()) { + let l_star = i2lebsp::<10>(l_star as u32); + let left: Vec<_> = left + .to_le_bits() + .iter() + .by_val() + .take(L_ORCHARD_BASE) + .collect(); + let right: Vec<_> = right + .to_le_bits() + .iter() + .by_val() + .take(L_ORCHARD_BASE) + .collect(); + let merkle_crh = HashDomain::new(MERKLE_CRH_PERSONALIZATION); - let mut message = l_star.to_vec(); - message.extend_from_slice(&left); - message.extend_from_slice(&right); + let mut message = l_star.to_vec(); + message.extend_from_slice(&left); + message.extend_from_slice(&right); - let expected = merkle_crh.hash(message.into_iter()).unwrap(); + let expected = merkle_crh.hash(message.into_iter()).unwrap(); - assert_eq!(expected.to_bytes(), result.value().unwrap().to_bytes()); + assert_eq!(expected.to_bytes(), result.value().unwrap().to_bytes()); + } } Ok(result)