@tevm/voltaire / crypto/Bls12381 / Fp
Fp
Functions
add()
add(Defined in: src/crypto/Bls12381/Fp/add.js:10 Add two field elementsa,b):bigint
Parameters
a
bigint
First operand
b
bigint
Second operand
Returns
bigint
(a + b) mod p
inv()
inv(Defined in: src/crypto/Bls12381/Fp/inv.js:12 Compute modular inverse using Fermat’s little theorem a^(-1) = a^(p-2) mod pa):bigint
Parameters
a
bigint
Value to invert
Returns
bigint
a^(-1) mod p
Throws
If a is zeromod()
mod(Defined in: src/crypto/Bls12381/Fp/mod.js:9 Reduce a bigint modulo the field prime pa):bigint
Parameters
a
bigint
Value to reduce
Returns
bigint
Value reduced to [0, p-1]
mul()
mul(Defined in: src/crypto/Bls12381/Fp/mul.js:10 Multiply two field elementsa,b):bigint
Parameters
a
bigint
First operand
b
bigint
Second operand
Returns
bigint
(a * b) mod p
neg()
neg(Defined in: src/crypto/Bls12381/Fp/neg.js:9 Negate a field elementa):bigint
Parameters
a
bigint
Value to negate
Returns
bigint
-a mod p
pow()
pow(Defined in: src/crypto/Bls12381/Fp/pow.js:10 Modular exponentiation using square-and-multiplybase,exp):bigint
Parameters
base
bigint
Base value
exp
bigint
Exponent
Returns
bigint
base^exp mod p
sqrt()
sqrt(Defined in: src/crypto/Bls12381/Fp/sqrt.js:19 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 pa):bigint|null
Parameters
a
bigint
Value to take square root of
Returns
bigint | null
Square root if it exists, null otherwise
sub()
sub(Defined in: src/crypto/Bls12381/Fp/sub.js:10 Subtract two field elementsa,b):bigint
Parameters
a
bigint
First operand
b
bigint
Second operand
Returns
bigint
(a - b) mod p
