pub trait FieldHelpers<F> {
// Required methods
fn from_bytes(bytes: &[u8]) -> Result<F>;
fn from_hex(hex: &str) -> Result<F>;
fn from_bits(bits: &[bool]) -> Result<F>;
fn to_bytes(&self) -> Vec<u8> ⓘ;
fn to_hex(&self) -> String;
fn to_bits(&self) -> Vec<bool>;
fn bits_to_field(&self, start: usize, end: usize) -> Result<F>;
// Provided methods
fn from_biguint(big: &BigUint) -> Result<F>
where F: PrimeField { ... }
fn to_biguint(&self) -> BigUint
where F: PrimeField { ... }
fn to_bigint_positive(&self) -> BigInt
where F: PrimeField { ... }
fn size_in_bytes() -> usize
where F: PrimeField { ... }
fn modulus_biguint() -> BigUint
where F: PrimeField { ... }
}
Expand description
Field element helpers Unless otherwise stated everything is in little-endian byte order.
Required Methods§
Sourcefn from_bytes(bytes: &[u8]) -> Result<F>
fn from_bytes(bytes: &[u8]) -> Result<F>
Deserialize from bytes
Sourcefn bits_to_field(&self, start: usize, end: usize) -> Result<F>
fn bits_to_field(&self, start: usize, end: usize) -> Result<F>
Create a new field element from this field elements bits
Provided Methods§
Sourcefn from_biguint(big: &BigUint) -> Result<F>where
F: PrimeField,
fn from_biguint(big: &BigUint) -> Result<F>where
F: PrimeField,
Deserialize from BigUint
Sourcefn to_biguint(&self) -> BigUintwhere
F: PrimeField,
fn to_biguint(&self) -> BigUintwhere
F: PrimeField,
Serialize field element to a BigUint
Sourcefn to_bigint_positive(&self) -> BigIntwhere
F: PrimeField,
fn to_bigint_positive(&self) -> BigIntwhere
F: PrimeField,
Serialize field element f to a (positive) BigInt directly.
Sourcefn size_in_bytes() -> usizewhere
F: PrimeField,
fn size_in_bytes() -> usizewhere
F: PrimeField,
Field size in bytes
Sourcefn modulus_biguint() -> BigUintwhere
F: PrimeField,
fn modulus_biguint() -> BigUintwhere
F: PrimeField,
Get the modulus as BigUint
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.