From cf545e48081b46e52f9598e2b76449741c07b444 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 5 Jul 2024 20:23:43 +0000 Subject: [PATCH] primitives: add extension field module, define GF1024 Again, strictly adding API surface, not removing anything. --- api/all-features.txt | 87 ++++++++++++ api/alloc-only.txt | 87 ++++++++++++ api/no-features.txt | 87 ++++++++++++ src/lib.rs | 1 + src/primitives/gf32_ext.rs | 272 +++++++++++++++++++++++++++++++++++++ src/primitives/mod.rs | 1 + 6 files changed, 535 insertions(+) create mode 100644 src/primitives/gf32_ext.rs diff --git a/api/all-features.txt b/api/all-features.txt index 93c718cce..233b3c2c1 100644 --- a/api/all-features.txt +++ b/api/all-features.txt @@ -20,7 +20,9 @@ #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) impl !core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeIoError impl !core::panic::unwind_safe::UnwindSafe for bech32::EncodeIoError +impl bech32::primitives::ExtensionField for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::Field for bech32::primitives::gf32::Fe32 +impl bech32::primitives::Field for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum @@ -333,28 +335,44 @@ impl core::marker::Unpin for bech32::segwit::EncodeError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::AddAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::DivAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::MulAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Neg for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::SubAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError @@ -585,6 +603,26 @@ impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Fe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe +impl bech32::primitives::gf32_ext::Fe32Ext where Self: bech32::primitives::ExtensionField +impl core::clone::Clone for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::Eq for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::PartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::convert::From for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Debug for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Display for bech32::primitives::gf32_ext::Fe32Ext +impl core::hash::Hash for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Copy for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Freeze for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Send for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::StructuralPartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Sync for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Unpin for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32_ext::Fe32Ext pub bech32::DecodeError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::DecodeError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::EncodeError::Fmt(core::fmt::Error) @@ -700,6 +738,14 @@ pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 +pub const bech32::primitives::gf32_ext::Fe1024::DEGREE: usize +pub const bech32::primitives::gf32_ext::Fe1024::EXT_ELEM: Self +pub const bech32::primitives::gf32_ext::Fe1024::GENERATOR: Self +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER: usize +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER_FACTORS: &'static [usize] +pub const bech32::primitives::gf32_ext::Fe1024::ONE: Self +pub const bech32::primitives::gf32_ext::Fe1024::POLYNOMIAL: Self +pub const bech32::primitives::gf32_ext::Fe1024::ZERO: Self pub const bech32::primitives::hrp::BC: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::BCRT: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::TB: bech32::primitives::hrp::Hrp @@ -708,6 +754,7 @@ pub const bech32::primitives::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::segwit::VERSION_1: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_1: bech32::primitives::gf32::Fe32 +pub const fn bech32::primitives::gf32_ext::Fe32Ext::new(inner: [bech32::primitives::gf32::Fe32; DEG]) -> Self pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self @@ -726,6 +773,16 @@ pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::DecodeError::clone(&self) -> bech32::DecodeError @@ -948,6 +1005,27 @@ pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::For pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self pub fn bech32::primitives::gf32::TryFromError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> +pub fn bech32::primitives::gf32_ext::Fe1024::_add(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_div(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_mul(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_neg(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_sub(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::add_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::div_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::mul_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::multiplicative_inverse(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::sub_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe32Ext::clone(&self) -> bech32::primitives::gf32_ext::Fe32Ext +pub fn bech32::primitives::gf32_ext::Fe32Ext::eq(&self, other: &bech32::primitives::gf32_ext::Fe32Ext) -> bool +pub fn bech32::primitives::gf32_ext::Fe32Ext::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub fn bech32::primitives::gf32_ext::Fe32Ext::from(fe: bech32::primitives::gf32::Fe32) -> Self +pub fn bech32::primitives::gf32_ext::Fe32Ext::hash<__H: core::hash::Hasher>(&self, state: &mut __H) +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option @@ -1057,6 +1135,7 @@ pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 +pub mod bech32::primitives::gf32_ext pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit @@ -1076,6 +1155,7 @@ pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator +pub struct bech32::primitives::gf32_ext::Fe32Ext pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp @@ -1094,7 +1174,10 @@ pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::c pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type &bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type &bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 +pub type bech32::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::ExtensionField::BaseField: bech32::primitives::Field @@ -1110,6 +1193,10 @@ pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primi pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe1024::BaseField = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 diff --git a/api/alloc-only.txt b/api/alloc-only.txt index 72ea31394..c36b173d9 100644 --- a/api/alloc-only.txt +++ b/api/alloc-only.txt @@ -17,7 +17,9 @@ #[non_exhaustive] pub struct bech32::segwit::DecodeError(pub bech32::primitives::decode::SegwitHrpstringError) #[repr(transparent)] pub struct bech32::Fe32(_) #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) +impl bech32::primitives::ExtensionField for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::Field for bech32::primitives::gf32::Fe32 +impl bech32::primitives::Field for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum @@ -304,28 +306,44 @@ impl core::marker::Unpin for bech32::segwit::EncodeError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::AddAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::DivAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::MulAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Neg for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::SubAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError @@ -556,6 +574,26 @@ impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Fe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe +impl bech32::primitives::gf32_ext::Fe32Ext where Self: bech32::primitives::ExtensionField +impl core::clone::Clone for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::Eq for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::PartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::convert::From for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Debug for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Display for bech32::primitives::gf32_ext::Fe32Ext +impl core::hash::Hash for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Copy for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Freeze for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Send for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::StructuralPartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Sync for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Unpin for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32_ext::Fe32Ext pub bech32::DecodeError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::DecodeError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::EncodeError::Fmt(core::fmt::Error) @@ -669,6 +707,14 @@ pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 +pub const bech32::primitives::gf32_ext::Fe1024::DEGREE: usize +pub const bech32::primitives::gf32_ext::Fe1024::EXT_ELEM: Self +pub const bech32::primitives::gf32_ext::Fe1024::GENERATOR: Self +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER: usize +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER_FACTORS: &'static [usize] +pub const bech32::primitives::gf32_ext::Fe1024::ONE: Self +pub const bech32::primitives::gf32_ext::Fe1024::POLYNOMIAL: Self +pub const bech32::primitives::gf32_ext::Fe1024::ZERO: Self pub const bech32::primitives::hrp::BC: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::BCRT: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::TB: bech32::primitives::hrp::Hrp @@ -677,6 +723,7 @@ pub const bech32::primitives::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::segwit::VERSION_1: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_1: bech32::primitives::gf32::Fe32 +pub const fn bech32::primitives::gf32_ext::Fe32Ext::new(inner: [bech32::primitives::gf32::Fe32; DEG]) -> Self pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self @@ -695,6 +742,16 @@ pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::DecodeError::clone(&self) -> bech32::DecodeError @@ -898,6 +955,27 @@ pub fn bech32::primitives::gf32::TryFromError::eq(&self, other: &bech32::primiti pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_add(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_div(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_mul(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_neg(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_sub(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::add_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::div_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::mul_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::multiplicative_inverse(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::sub_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe32Ext::clone(&self) -> bech32::primitives::gf32_ext::Fe32Ext +pub fn bech32::primitives::gf32_ext::Fe32Ext::eq(&self, other: &bech32::primitives::gf32_ext::Fe32Ext) -> bool +pub fn bech32::primitives::gf32_ext::Fe32Ext::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub fn bech32::primitives::gf32_ext::Fe32Ext::from(fe: bech32::primitives::gf32::Fe32) -> Self +pub fn bech32::primitives::gf32_ext::Fe32Ext::hash<__H: core::hash::Hasher>(&self, state: &mut __H) +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option @@ -999,6 +1077,7 @@ pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 +pub mod bech32::primitives::gf32_ext pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit @@ -1018,6 +1097,7 @@ pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator +pub struct bech32::primitives::gf32_ext::Fe32Ext pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp @@ -1036,7 +1116,10 @@ pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::c pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type &bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type &bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 +pub type bech32::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::ExtensionField::BaseField: bech32::primitives::Field @@ -1052,6 +1135,10 @@ pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primi pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe1024::BaseField = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 diff --git a/api/no-features.txt b/api/no-features.txt index fb4d8bd1c..661ae751d 100644 --- a/api/no-features.txt +++ b/api/no-features.txt @@ -14,7 +14,9 @@ #[non_exhaustive] pub struct bech32::primitives::segwit::InvalidWitnessVersionError(pub bech32::primitives::gf32::Fe32) #[repr(transparent)] pub struct bech32::Fe32(_) #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) +impl bech32::primitives::ExtensionField for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::Field for bech32::primitives::gf32::Fe32 +impl bech32::primitives::Field for bech32::primitives::gf32_ext::Fe1024 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum @@ -265,28 +267,44 @@ impl core::marker::Unpin for bech32::primitives::segwit::WitnessLengthError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Add<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Add> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::AddAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Div<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Div> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::DivAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Mul<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Mul> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::MulAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Neg for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for &bech32::primitives::gf32_ext::Fe1024 +impl core::ops::arith::Sub<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 +impl core::ops::arith::Sub> for &bech32::primitives::gf32_ext::Fe1024 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 +impl core::ops::arith::SubAssign<&bech32::primitives::gf32_ext::Fe32Ext<2>> for bech32::primitives::gf32_ext::Fe1024 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32 @@ -511,6 +529,26 @@ impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Fe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe +impl bech32::primitives::gf32_ext::Fe32Ext where Self: bech32::primitives::ExtensionField +impl core::clone::Clone for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::Eq for bech32::primitives::gf32_ext::Fe32Ext +impl core::cmp::PartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::convert::From for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Debug for bech32::primitives::gf32_ext::Fe32Ext +impl core::fmt::Display for bech32::primitives::gf32_ext::Fe32Ext +impl core::hash::Hash for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Copy for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Freeze for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Send for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::StructuralPartialEq for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Sync for bech32::primitives::gf32_ext::Fe32Ext +impl core::marker::Unpin for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for &bech32::primitives::gf32_ext::Fe32Ext +impl core::ops::arith::Mul for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32_ext::Fe32Ext +impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32_ext::Fe32Ext pub bech32::EncodeError::Fmt(core::fmt::Error) pub bech32::EncodeError::TooLong(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::CharError::InvalidChar(char) @@ -618,6 +656,14 @@ pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 +pub const bech32::primitives::gf32_ext::Fe1024::DEGREE: usize +pub const bech32::primitives::gf32_ext::Fe1024::EXT_ELEM: Self +pub const bech32::primitives::gf32_ext::Fe1024::GENERATOR: Self +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER: usize +pub const bech32::primitives::gf32_ext::Fe1024::MULTIPLICATIVE_ORDER_FACTORS: &'static [usize] +pub const bech32::primitives::gf32_ext::Fe1024::ONE: Self +pub const bech32::primitives::gf32_ext::Fe1024::POLYNOMIAL: Self +pub const bech32::primitives::gf32_ext::Fe1024::ZERO: Self pub const bech32::primitives::hrp::BC: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::BCRT: bech32::primitives::hrp::Hrp pub const bech32::primitives::hrp::TB: bech32::primitives::hrp::Hrp @@ -626,6 +672,7 @@ pub const bech32::primitives::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::segwit::VERSION_1: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_0: bech32::primitives::gf32::Fe32 pub const bech32::segwit::VERSION_1: bech32::primitives::gf32::Fe32 +pub const fn bech32::primitives::gf32_ext::Fe32Ext::new(inner: [bech32::primitives::gf32::Fe32; DEG]) -> Self pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self @@ -644,6 +691,16 @@ pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::add(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::div(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::mul(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe1024::sub(self, other: bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn &bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::EncodeError::clone(&self) -> bech32::EncodeError @@ -839,6 +896,27 @@ pub fn bech32::primitives::gf32::TryFromError::eq(&self, other: &bech32::primiti pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_add(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_div(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_mul(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_neg(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::_sub(&self, other: &Self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::add(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::add_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::div(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::div_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::mul(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::mul_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe1024::multiplicative_inverse(self) -> Self +pub fn bech32::primitives::gf32_ext::Fe1024::sub(self, other: &bech32::primitives::gf32_ext::Fe1024) -> bech32::primitives::gf32_ext::Fe1024 +pub fn bech32::primitives::gf32_ext::Fe1024::sub_assign(&mut self, other: &bech32::primitives::gf32_ext::Fe1024) +pub fn bech32::primitives::gf32_ext::Fe32Ext::clone(&self) -> bech32::primitives::gf32_ext::Fe32Ext +pub fn bech32::primitives::gf32_ext::Fe32Ext::eq(&self, other: &bech32::primitives::gf32_ext::Fe32Ext) -> bool +pub fn bech32::primitives::gf32_ext::Fe32Ext::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub fn bech32::primitives::gf32_ext::Fe32Ext::from(fe: bech32::primitives::gf32::Fe32) -> Self +pub fn bech32::primitives::gf32_ext::Fe32Ext::hash<__H: core::hash::Hasher>(&self, state: &mut __H) +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: &bech32::primitives::gf32::Fe32) -> Self::Output +pub fn bech32::primitives::gf32_ext::Fe32Ext::mul(self, other: bech32::primitives::gf32::Fe32) -> Self::Output pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option @@ -924,6 +1002,7 @@ pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 +pub mod bech32::primitives::gf32_ext pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit @@ -943,6 +1022,7 @@ pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator +pub struct bech32::primitives::gf32_ext::Fe32Ext pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp @@ -961,7 +1041,10 @@ pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::c pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type &bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type &bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 +pub type bech32::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::ExtensionField::BaseField: bech32::primitives::Field @@ -977,6 +1060,10 @@ pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primi pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024 = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe1024::BaseField = bech32::primitives::gf32::Fe32 +pub type bech32::primitives::gf32_ext::Fe1024::Output = bech32::primitives::gf32_ext::Fe32Ext<2> +pub type bech32::primitives::gf32_ext::Fe32Ext::Output = bech32::primitives::gf32_ext::Fe32Ext pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 diff --git a/src/lib.rs b/src/lib.rs index 3a90922b0..ab86aeb21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,6 +161,7 @@ use crate::primitives::decode::{ChecksumError, UncheckedHrpstring, UncheckedHrps pub use { crate::primitives::checksum::Checksum, crate::primitives::gf32::Fe32, + crate::primitives::gf32_ext::Fe1024, crate::primitives::hrp::Hrp, crate::primitives::iter::{ByteIterExt, Fe32IterExt}, crate::primitives::{Bech32, Bech32m, NoChecksum}, diff --git a/src/primitives/gf32_ext.rs b/src/primitives/gf32_ext.rs new file mode 100644 index 000000000..5fddebed8 --- /dev/null +++ b/src/primitives/gf32_ext.rs @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: MIT + +//! Extension Fields over GF32 +//! +//! Correcting errors in BCH codes requires working over an extension field +//! of GF32 (or whatever the base field is, which in this library is always +//! GF32 represented using the bech32 alphabet). +//! +//! We support specifically the fields GF1024 and GF32768 (the extension +//! fields of degree 2 and 3, respectively), though we have tried to write +//! the code in such a way that more can be added if codes require them. +//! + +use core::{fmt, ops}; + +use super::field::{ExtensionField, Field}; +use crate::Fe32; + +/// An element of the extension field. +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +pub struct Fe32Ext { + /// The polynomial representation of the element in "little-endian" order; + /// that is, the element is the sum `inner[i] * EXT_ELEM^i`. + inner: [Fe32; DEG], +} + +impl From for Fe32Ext { + fn from(fe: Fe32) -> Self { + let mut ret = Self { inner: [Fe32::Q; DEG] }; + ret.inner[0] = fe; + ret + } +} + +impl fmt::Debug for Fe32Ext { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } +} + +impl fmt::Display for Fe32Ext { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for elem in &self.inner { + elem.fmt(f)?; + } + Ok(()) + } +} + +impl ops::Mul<&Fe32> for Fe32Ext { + type Output = Fe32Ext; + fn mul(mut self, other: &Fe32) -> Self::Output { + for elem in &mut self.inner { + *elem *= other; + } + self + } +} + +impl ops::Mul for Fe32Ext { + type Output = Fe32Ext; + fn mul(self, other: Fe32) -> Self::Output { self.mul(&other) } +} + +impl ops::Mul for &Fe32Ext { + type Output = Fe32Ext; + fn mul(self, other: Fe32) -> Self::Output { (*self).mul(other) } +} + +impl ops::Mul<&Fe32> for &Fe32Ext { + type Output = Fe32Ext; + fn mul(self, other: &Fe32) -> Self::Output { (*self).mul(other) } +} + +impl Fe32Ext +where + Self: ExtensionField, +{ + /// Constructs a new extension-field element given a polynomial representation + /// of the element in terms of the base field. + pub const fn new(inner: [Fe32; DEG]) -> Self { Self { inner } } + + /// Multiplies a given element by the extension-defining element. + fn mul_by_ext_elem(&mut self) { + let xn_coeff = self.inner[DEG - 1]; + for i in (0..DEG - 1).rev() { + self.inner[i + 1] = self.inner[i]; + } + self.inner[0] = Fe32::Q; + for i in 0..DEG { + self.inner[i] += xn_coeff * Self::POLYNOMIAL.inner[i] + } + } + + // We just use naive n^2 muliplication because this is easy to write in + // generic code, and because our GF32 implementation makes multiplication + // (almost) as cheap as addition. + // + // Specifically for DEG = 2, 3 which we care about, Karatsuba multiplication + // may be more efficient -- but since it trades off adds for mults, it's not + // obviously so. Maybe worth benchmarking in the future. + fn mul_by_elem(&self, other: &Self) -> Self { + let mut acc = Self::ZERO; + for xi in other.inner.iter().rev() { + acc.mul_by_ext_elem(); + acc += self * xi; + } + acc + } +} + +/// The field of order 1024. +pub type Fe1024 = Fe32Ext<2>; + +impl Field for Fe1024 { + /// The zero element of the field. + const ZERO: Self = Self::new([Fe32::Q, Fe32::Q]); + + /// The one element of the field. + const ONE: Self = Self::new([Fe32::P, Fe32::Q]); + + // Chosen somewhat arbitrarily. + /// A generator of the field. + const GENERATOR: Self = Self::new([Fe32::P, Fe32::H]); + + /// The order of the multiplicative group of the field. + /// + /// This constant also serves as a compile-time check that we can count + /// the entire field using a `usize` as a counter. + const MULTIPLICATIVE_ORDER: usize = 1023; + + const MULTIPLICATIVE_ORDER_FACTORS: &'static [usize] = &[1, 3, 11, 31, 33, 93, 341, 1023]; + + #[inline] + fn _add(&self, other: &Self) -> Self { + Self::new([self.inner[0] + other.inner[0], self.inner[1] + other.inner[1]]) + } + + #[inline] + fn _sub(&self, other: &Self) -> Self { self._add(other) } + + #[inline] + fn _mul(&self, other: &Self) -> Self { self.mul_by_elem(other) } + + #[inline] + fn _div(&self, other: &Self) -> Self { other.multiplicative_inverse() * self } + + #[inline] + fn _neg(self) -> Self { self } + + fn multiplicative_inverse(self) -> Self { + // Aliases to make the below equations easier to read + let a0 = self.inner[0]; + let a1 = self.inner[1]; + let p0 = Self::POLYNOMIAL.inner[0]; + let p1 = Self::POLYNOMIAL.inner[1]; + + // Inverse of the 2x2 multiplication matrix defined by a0, a1. + let det = (a0 * a0) + (p1 * a0 * a1) + (p0 * a1 * a1); + Self::new([(a0 + p1 * a1) / det, (Fe32::Q - a1) / det]) + } +} +super::impl_ops_for_fe!(impl for Fe1024); + +impl ExtensionField for Fe1024 { + type BaseField = Fe32; + + const DEGREE: usize = 2; + + // Ultimately it doesn't really matter what choice of polynomial we make + // here. We choose the value from BIP 93, which we note differs from the + // value used in bech32 error correcting code, such as + // https://github.com/sipa/bech32/commit/e97932d4c86e343ace49ae6170ae0c4871820152 + // + // (Specifically, the third element of that exp table, 311, expanded into binary, + // 01001 10111, and mapped back to Fe32, gives us FH rather than PP. But really, + // it doesn't matter, except that it is part of the `Fe1024` API and we cannot + // change it once we have published it, since changing it amounts to moving to + // a different, though isomorphic, field.) + const POLYNOMIAL: Self = Self::new([Fe32::P, Fe32::P]); + + /// The element zeta such that the extension field is defined as `GF32[zeta]`. + /// + /// Alternately, the image of x in the mapping `GF32[x]/p(x) -> ` + const EXT_ELEM: Self = Self::new([Fe32::Q, Fe32::P]); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn gf1024_div() { + for a0 in 0..32 { + for a1 in 0..32 { + let gf1 = Fe1024::new([Fe32(a0), Fe32(a1)]); + if gf1 == Fe1024::ZERO { + continue; + } + assert_eq!(gf1 / gf1, Fe1024::ONE); + } + } + + const ITERS: u8 = 10; // max 32. + for a0 in 0..ITERS { + for a1 in 0..ITERS { + for b0 in 0..ITERS { + for b1 in 0..ITERS { + let gf1 = Fe1024::new([Fe32(a0), Fe32(a1)]); + let gf2 = Fe1024::new([Fe32(b0), Fe32(b1)]); + if gf1 == Fe1024::ZERO { + continue; + } + let rat = gf2 / gf1; + assert_eq!(rat * gf1, gf2); + assert_eq!(gf1 * rat, gf2); + } + } + } + } + } + + #[test] + fn gf1024_mult() { + // Check that all base field elements to the power of 32 are themselves + for i in 0..32 { + let mut sq = Fe32(i); + for _ in 0..5 { + sq = sq * sq; + } + assert_eq!(sq, Fe32(i)); + } + // Check that all ext field elements to the power of 1024 are themselves + for j in 0..32 { + for i in 0..32 { + let mut sq = Fe1024::new([Fe32(i), Fe32(j)]); + for _ in 0..10 { + sq = sq * sq; + } + assert_eq!(sq, Fe1024::new([Fe32(i), Fe32(j)])); + } + } + + assert_eq!(Fe1024::EXT_ELEM * Fe1024::EXT_ELEM, Fe1024::POLYNOMIAL,); + } + + #[test] + fn gf1024_mult_inverse() { + assert_eq!(Fe1024::ONE.multiplicative_inverse(), Fe1024::ONE); + + for i in 0..32 { + for j in 0..32 { + if i != 0 || j != 0 { + let fe1024 = Fe1024::new([Fe32(i), Fe32(j)]); + assert_eq!(fe1024.multiplicative_inverse().multiplicative_inverse(), fe1024,); + } + } + } + } + + #[test] + fn gf1024_powi() { + // A "random" element + let elem = Fe1024::new([Fe32::K, Fe32::L]); + assert_eq!(elem.powi(2), elem * elem); + assert_eq!(elem.powi(3), elem * elem * elem); + assert_eq!(elem.powi(0), Fe1024::ONE); + assert_eq!(elem.powi(-1), elem.multiplicative_inverse()); + + assert_eq!(elem.multiplicative_order(), 1023); + assert_eq!(elem.powi(3).multiplicative_order(), 341); + assert_eq!(elem.powi(341).multiplicative_order(), 3); + } +} diff --git a/src/primitives/mod.rs b/src/primitives/mod.rs index c90f9e94f..72d8c0e2b 100644 --- a/src/primitives/mod.rs +++ b/src/primitives/mod.rs @@ -7,6 +7,7 @@ pub mod decode; pub mod encode; mod field; pub mod gf32; +pub mod gf32_ext; pub mod hrp; pub mod iter; pub mod segwit;