use alloc::vec;
use alloc::vec::Vec;
use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
use zeroize::Zeroize;
pub trait TowerField:
Copy
+ Default
+ Clone
+ PartialEq
+ Eq
+ core::fmt::Debug
+ Send
+ Sync
+ From<u8>
+ From<u32>
+ From<u64>
+ From<u128>
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ CanonicalSerialize
+ CanonicalDeserialize
+ Zeroize
{
const BITS: usize;
const ZERO: Self;
const ONE: Self;
const EXTENSION_TAU: Self;
fn invert(&self) -> Self;
fn from_uniform_bytes(bytes: &[u8; 32]) -> Self;
}
pub trait CanonicalSerialize {
fn serialized_size(&self) -> usize;
#[allow(clippy::result_unit_err)]
fn serialize(&self, writer: &mut [u8]) -> Result<(), ()>;
fn to_bytes(&self) -> Vec<u8> {
let size = self.serialized_size();
let mut buf = vec![0u8; size];
self.serialize(&mut buf).expect("Size calculation matches");
buf
}
}
pub trait CanonicalDeserialize: Sized {
#[allow(clippy::result_unit_err)]
fn deserialize(bytes: &[u8]) -> Result<Self, ()>;
}