Skip to main content
@tevm/voltaire
@tevm/voltaire / crypto/Bls12381 / Fp2

Fp2

Functions

add()

add(a, b): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/add.js:11 Add two Fp2 elements (a0 + a1i) + (b0 + b1i) = (a0+b0) + (a1+b1)*i

Parameters

a
Bls12381Fp2Type First operand
b
Bls12381Fp2Type Second operand

Returns

Bls12381Fp2Type

conjugate()

conjugate(a): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/conjugate.js:10 Compute conjugate of Fp2 element conj(a0 + a1i) = a0 - a1i

Parameters

a
Bls12381Fp2Type Value to conjugate

Returns

Bls12381Fp2Type

create()

create(c0, c1): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/create.js:10 Create an Fp2 element from two Fp elements

Parameters

c0
bigint Real component
c1
bigint Imaginary component

Returns

Bls12381Fp2Type

equal()

equal(a, b): boolean
Defined in: src/crypto/Bls12381/Fp2/equal.js:8 Check if two Fp2 elements are equal

Parameters

a
Bls12381Fp2Type First operand
b
Bls12381Fp2Type Second operand

Returns

boolean

inv()

inv(a): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/inv.js:11 Invert an Fp2 element 1/(a0 + a1i) = (a0 - a1i) / (a0^2 + a1^2) The denominator is in Fp since (a0 + a1i)(a0 - a1i) = a0^2 + a1^2

Parameters

a
Bls12381Fp2Type Value to invert

Returns

Bls12381Fp2Type

isZero()

isZero(a): boolean
Defined in: src/crypto/Bls12381/Fp2/isZero.js:7 Check if an Fp2 element is zero

Parameters

a
Bls12381Fp2Type Value to check

Returns

boolean

mul()

mul(a, b): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/mul.js:12 Multiply two Fp2 elements (a0 + a1i) * (b0 + b1i) = (a0b0 - a1b1) + (a0b1 + a1b0)*i Using Karatsuba: 3 multiplications instead of 4

Parameters

a
Bls12381Fp2Type First operand
b
Bls12381Fp2Type Second operand

Returns

Bls12381Fp2Type

mulScalar()

mulScalar(a, scalar): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/mulScalar.js:10 Multiply Fp2 element by Fp scalar

Parameters

a
Bls12381Fp2Type Fp2 element
scalar
bigint Fp scalar

Returns

Bls12381Fp2Type

neg()

neg(a): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/neg.js:10 Negate an Fp2 element -(a0 + a1*i) = -a0 + (-a1)*i

Parameters

a
Bls12381Fp2Type Value to negate

Returns

Bls12381Fp2Type

square()

square(a): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/square.js:11 Square an Fp2 element (a0 + a1i)^2 = (a0^2 - a1^2) + 2a0a1i Optimized: uses 2 muls instead of 3

Parameters

a
Bls12381Fp2Type Value to square

Returns

Bls12381Fp2Type

sub()

sub(a, b): Bls12381Fp2Type
Defined in: src/crypto/Bls12381/Fp2/sub.js:11 Subtract two Fp2 elements (a0 + a1i) - (b0 + b1i) = (a0-b0) + (a1-b1)*i

Parameters

a
Bls12381Fp2Type First operand
b
Bls12381Fp2Type Second operand

Returns

Bls12381Fp2Type