Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/all-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::ZERO: Self
pub const bech32::primitives::gf32::Fe32::ZERO: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32
Expand Down
1 change: 1 addition & 0 deletions api/alloc-only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::ZERO: Self
pub const bech32::primitives::gf32::Fe32::ZERO: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32
Expand Down
1 change: 1 addition & 0 deletions api/no-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::ZERO: Self
pub const bech32::primitives::gf32::Fe32::ZERO: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32
pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl<'hrp> Iterator for HrpFe32Iter<'hrp> {
Some(high) => return Some(Fe32(high >> 5)),
None => {
self.high_iter = None;
return Some(Fe32::Q);
return Some(Fe32::ZERO);
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/primitives/gf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const CHARS_INV: [i8; 128] = [
pub struct Fe32(pub(crate) u8);

impl Fe32 {
/// The Zero element is 0 numeric (character 'Q')
pub const ZERO: Fe32 = Fe32(0);

// These are a little gratuitous for a reference implementation, but it makes me happy to do it.
/// Numeric value maps to bech32 character: 0 == "q".
pub const Q: Fe32 = Fe32(0);
Expand Down Expand Up @@ -257,7 +260,7 @@ impl AsRef<u8> for Fe32 {
}

impl super::Field for Fe32 {
const ZERO: Self = Fe32::Q;
const ZERO: Self = Fe32::ZERO;
const ONE: Self = Fe32::P;
const GENERATOR: Self = Fe32::Z;
const MULTIPLICATIVE_ORDER: usize = 31;
Expand Down Expand Up @@ -487,6 +490,12 @@ mod tests {
assert_eq!(fe * Fe32::P, fe) // Fe32::P == Fe32(1)
}
}

#[test]
fn const_zero() {
assert_eq!(Fe32::ZERO.to_u8(), 0);
assert_eq!(Fe32::ZERO.to_char(), 'q');
}
}

#[cfg(kani)]
Expand Down