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§

source

fn from_bytes(bytes: &[u8]) -> Result<F>

Deserialize from bytes

source

fn from_hex(hex: &str) -> Result<F>

Deserialize from little-endian hex

source

fn from_bits(bits: &[bool]) -> Result<F>

Deserialize from bits

source

fn to_bytes(&self) -> Vec<u8>

Serialize to bytes

source

fn to_hex(&self) -> String

Serialize to hex

source

fn to_bits(&self) -> Vec<bool>

Serialize to bits

source

fn bits_to_field(&self, start: usize, end: usize) -> Result<F>

Create a new field element from this field elements bits

Provided Methods§

source

fn from_biguint(big: &BigUint) -> Result<F>
where F: PrimeField,

Deserialize from BigUint

source

fn to_biguint(&self) -> BigUint
where F: PrimeField,

Serialize field element to a BigUint

source

fn to_bigint_positive(&self) -> BigInt
where F: PrimeField,

Serialize field element f to a (positive) BigInt directly.

source

fn size_in_bytes() -> usize
where F: PrimeField,

Field size in bytes

source

fn modulus_biguint() -> BigUint
where F: PrimeField,

Get the modulus as BigUint

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<F: Field> FieldHelpers<F> for F