> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Fp

> Auto-generated API documentation

[**@tevm/voltaire**](../../../index.mdx)

***

[@tevm/voltaire](../../../index.mdx) / [crypto/Bls12381](../index.mdx) / Fp

# Fp

## Functions

### add()

> **add**(`a`, `b`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/add.js:10](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/add.js#L10)

Add two field elements

#### Parameters

##### a

`bigint`

First operand

##### b

`bigint`

Second operand

#### Returns

`bigint`

(a + b) mod p

***

### inv()

> **inv**(`a`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/inv.js:12](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/inv.js#L12)

Compute modular inverse using Fermat's little theorem
a^(-1) = a^(p-2) mod p

#### Parameters

##### a

`bigint`

Value to invert

#### Returns

`bigint`

a^(-1) mod p

#### Throws

If a is zero

***

### mod()

> **mod**(`a`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/mod.js:9](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/mod.js#L9)

Reduce a bigint modulo the field prime p

#### Parameters

##### a

`bigint`

Value to reduce

#### Returns

`bigint`

Value reduced to \[0, p-1]

***

### mul()

> **mul**(`a`, `b`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/mul.js:10](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/mul.js#L10)

Multiply two field elements

#### Parameters

##### a

`bigint`

First operand

##### b

`bigint`

Second operand

#### Returns

`bigint`

(a \* b) mod p

***

### neg()

> **neg**(`a`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/neg.js:9](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/neg.js#L9)

Negate a field element

#### Parameters

##### a

`bigint`

Value to negate

#### Returns

`bigint`

-a mod p

***

### pow()

> **pow**(`base`, `exp`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/pow.js:10](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/pow.js#L10)

Modular exponentiation using square-and-multiply

#### Parameters

##### base

`bigint`

Base value

##### exp

`bigint`

Exponent

#### Returns

`bigint`

base^exp mod p

***

### sqrt()

> **sqrt**(`a`): `bigint` | `null`

Defined in: [src/crypto/Bls12381/Fp/sqrt.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/sqrt.js#L19)

Compute square root in Fp (if it exists)
For BLS12-381, p = 3 mod 4, so we use Tonelli-Shanks simplification:
sqrt(a) = a^((p+1)/4) mod p

#### Parameters

##### a

`bigint`

Value to take square root of

#### Returns

`bigint` | `null`

Square root if it exists, null otherwise

***

### sub()

> **sub**(`a`, `b`): `bigint`

Defined in: [src/crypto/Bls12381/Fp/sub.js:10](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Bls12381/Fp/sub.js#L10)

Subtract two field elements

#### Parameters

##### a

`bigint`

First operand

##### b

`bigint`

Second operand

#### Returns

`bigint`

(a - b) mod p
