Trait o1_utils::field_helpers::FieldHelpers
source · 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