> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Primitive type Field

Module: `std`

The native field type of the proving backend.

The size of a Noir field depends on the elliptic curve's finite field for the proving backend adopted. For example, a field would be a 254-bit integer when paired with the default backend that spans the Grumpkin curve.

Fields support integer arithmetic.

If proving efficiency is of priority, fields should be used as a default for solving problems. Smaller integer types (e.g. `u64`) incur extra range constraints.

## Implementations

```rust
impl Field
```

```rust
pub fn assert_max_bit_size<let BIT_SIZE: u32>(self)
```

Asserts that `self` can be represented in `bit_size` bits.

#### Failures

Causes a constraint failure for `Field` values exceeding `2^{bit_size}`.

```rust
pub fn to_le_bits<let N: u32>(self) -> [bool; N]
```

Decomposes `self` into its little endian bit decomposition as a `[bool; N]` array. This array will be zero padded should not all bits be necessary to represent `self`.

#### Failures

Causes a constraint failure for `Field` values exceeding `2^N` as the resulting array will not be able to represent the original `Field`.

#### Safety

The bit decomposition returned is canonical and is guaranteed to not overflow the modulus.

```rust
pub fn to_be_bits<let N: u32>(self) -> [bool; N]
```

Decomposes `self` into its big endian bit decomposition as a `[bool; N]` array. This array will be zero padded should not all bits be necessary to represent `self`.

#### Failures

Causes a constraint failure for `Field` values exceeding `2^N` as the resulting array will not be able to represent the original `Field`.

#### Safety

The bit decomposition returned is canonical and is guaranteed to not overflow the modulus.

```rust
pub fn to_le_bytes<let N: u32>(self) -> [u8; N]
```

Decomposes `self` into its little endian byte decomposition as a `[u8;N]` array This array will be zero padded should not all bytes be necessary to represent `self`.

#### Failures

The length N of the array must be big enough to contain all the bytes of the 'self', and no more than the number of bytes required to represent the field modulus

#### Safety

The result is ensured to be the canonical decomposition of the field element

```rust
pub fn to_be_bytes<let N: u32>(self) -> [u8; N]
```

Decomposes `self` into its big endian byte decomposition as a `[u8;N]` array of length required to represent the field modulus This array will be zero padded should not all bytes be necessary to represent `self`.

#### Failures

The length N of the array must be big enough to contain all the bytes of the 'self', and no more than the number of bytes required to represent the field modulus

#### Safety

The result is ensured to be the canonical decomposition of the field element

```rust
pub fn pow_32(self, exponent: Self) -> Self
```

```rust
pub fn sgn0(self) -> bool
```

```rust
pub fn lt(self, another: Self) -> bool
```

```rust
pub fn from_le_bytes<let N: u32>(bytes: [u8; N]) -> Self
```

Convert a little endian byte array to a field element. If the provided byte array overflows the field modulus then the Field will silently wrap around.

#### Failures

`N` must be no greater than the number of bytes required to represent the field modulus

```rust
pub fn from_be_bytes<let N: u32>(bytes: [u8; N]) -> Self
```

Convert a big endian byte array to a field element. If the provided byte array overflows the field modulus then the Field will silently wrap around.

#### Failures

`N` must be no greater than the number of bytes required to represent the field modulus

```rust
pub fn from_le_bytes_checked<let N: u32>(bytes: [u8; N]) -> Self
```

Convert a little endian byte array to a field element, asserting that the input is a canonical representation (strictly less than the field modulus).

#### Failures

Causes a constraint failure if `bytes` encodes a value greater than or equal to the field modulus.

```rust
pub fn from_be_bytes_checked<let N: u32>(bytes: [u8; N]) -> Self
```

Convert a big endian byte array to a field element, asserting that the input is a canonical representation (strictly less than the field modulus).

#### Failures

Causes a constraint failure if `bytes` encodes a value greater than or equal to the field modulus.

## Trait implementations

```rust
impl Add for Field
```

```rust
pub fn add(self, other: Self) -> Self
```

```rust
impl AsPrimitive<bool> for Field
```

```rust
pub fn as_(self) -> bool
```

```rust
impl AsPrimitive<u128> for Field
```

```rust
pub fn as_(self) -> u128
```

```rust
impl AsPrimitive<u16> for Field
```

```rust
pub fn as_(self) -> u16
```

```rust
impl AsPrimitive<u32> for Field
```

```rust
pub fn as_(self) -> u32
```

```rust
impl AsPrimitive<u64> for Field
```

```rust
pub fn as_(self) -> u64
```

```rust
impl AsPrimitive<u8> for Field
```

```rust
pub fn as_(self) -> u8
```

```rust
impl Default for Field
```

```rust
pub fn default() -> Self
```

```rust
impl Div for Field
```

```rust
pub fn div(self, other: Self) -> Self
```

```rust
impl Eq for Field
```

```rust
pub fn eq(self, other: Self) -> bool
```

```rust
impl From<bool> for Field
```

```rust
pub fn from(value: bool) -> Self
```

```rust
impl From<u128> for Field
```

```rust
pub fn from(value: u128) -> Self
```

```rust
impl From<u16> for Field
```

```rust
pub fn from(value: u16) -> Self
```

```rust
impl From<u32> for Field
```

```rust
pub fn from(value: u32) -> Self
```

```rust
impl From<u64> for Field
```

```rust
pub fn from(value: u64) -> Self
```

```rust
impl From<u8> for Field
```

```rust
pub fn from(value: u8) -> Self
```

```rust
impl Hash for Field
```

```rust
pub fn hash<H>(self, state: &mut H)
where
    H: Hasher
```

```rust
impl Mul for Field
```

```rust
pub fn mul(self, other: Self) -> Self
```

```rust
impl Neg for Field
```

```rust
pub fn neg(self) -> Self
```

```rust
impl Sub for Field
```

```rust
pub fn sub(self, other: Self) -> Self
```

```rust
impl WrappingAdd for Field
```

```rust
pub fn wrapping_add(self, y: Self) -> Self
```

```rust
impl WrappingMul for Field
```

```rust
pub fn wrapping_mul(self, y: Self) -> Self
```

```rust
impl WrappingSub for Field
```

```rust
pub fn wrapping_sub(self, y: Self) -> Self
```
