ensure that hardened_get2 is used correctly with an assert

This commit is contained in:
bunnie 2025-12-05 22:43:49 +08:00
parent 32ffba0931
commit d9d146352f
No known key found for this signature in database

View file

@ -128,6 +128,10 @@ impl OneWayCounter {
/// if they are not, then something bad happened.
#[inline(always)]
pub fn hardened_get2(&self, offset: usize, dupe: usize) -> Result<(u32, u32), OneWayErr> {
assert!(
offset != dupe,
"hardened_get2 requires different offsets; use hardened_get for same offset gets"
);
bollard!(4);
const HARDENING_FACTOR: usize = 4;
#[cfg(not(feature = "std"))]