BW6FR
State Variables
MOD_EXP
MOD_EXP precompile address.
uint256 private constant MOD_EXP = 0x05;
Functions
r
Returns scalar field: r = 0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508c00000000001
function r() internal pure returns (Bw6Fr memory);
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Scalar field. |
zero
Returns the additive identity element of Bw6Fr.
function zero() internal pure returns (Bw6Fr memory);
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Bw6Fr(0, 0) |
one
Returns the multiplicative identity element of Bw6Fr.
function one() internal pure returns (Bw6Fr memory);
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Bw6Fr(0, 1) |
two
Returns the two of Bw6Fr.
function two() internal pure returns (Bw6Fr memory);
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Bw6Fr(0, 2) |
is_zero
Returns true
if self
is equal to the additive identity.
function is_zero(Bw6Fr memory self) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Result of zero check. |
is_geq_modulus
Returns true
if self
is equal or larger than r.
function is_geq_modulus(Bw6Fr memory self) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Result of check. |
eq
Returns true
if x
is equal to y
.
function eq(Bw6Fr memory x, Bw6Fr memory y) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bw6Fr. |
y | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Result of equal check. |
gt
Returns true
if x
is larger than y
.
function gt(Bw6Fr memory x, Bw6Fr memory y) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bw6Fr. |
y | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Result of gt check. |
add_nomod
Returns the result of x + y
.
function add_nomod(Bw6Fr memory x, Bw6Fr memory y) internal pure returns (Bw6Fr memory z);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bw6Fr. |
y | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr | x + y . |
add
Returns the result of (x + y) % p
.
function add(Bw6Fr memory x, Bw6Fr memory y) internal pure returns (Bw6Fr memory z);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bw6Fp. |
y | Bw6Fr | Bw6Fp. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr | (x + y) % p . |
subtract_modulus_to_norm
function subtract_modulus_to_norm(Bw6Fr memory self) internal pure returns (Bw6Fr memory z);
sub
Returns the result of (x - y) % p
.
function sub(Bw6Fr memory x, Bw6Fr memory y) internal pure returns (Bw6Fr memory z);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bls12Fp. |
y | Bw6Fr | Bls12Fp. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr | (x - y) % p . |
sub
Returns the result of x - y
.
function sub(Bw6Fr[2] memory x, Bw6Fr[2] memory y) internal pure returns (Bw6Fr[2] memory z);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr[2] | Bls12Fp[2]. |
y | Bw6Fr[2] | Bls12Fp[2]. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr[2] | x - y . |
mul
(x * y) = ((x + y)^2 - (x - y)^2) / 4
function mul(Bw6Fr memory x, Bw6Fr memory y) internal view returns (Bw6Fr memory z);
Parameters
Name | Type | Description |
---|---|---|
x | Bw6Fr | Bw6Fr. |
y | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr | Bw6Fr. |
sum
Sum of the list of Bw6Fr.
function sum(Bw6Fr[] memory xs) internal pure returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
xs | Bw6Fr[] | Bw6Fr[]. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of sum. |
mul_sum
Mul and Add.
function mul_sum(Bw6Fr[] memory xs, Bw6Fr[] memory ys) internal view returns (Bw6Fr memory z);
Parameters
Name | Type | Description |
---|---|---|
xs | Bw6Fr[] | Bw6Fr[]. |
ys | Bw6Fr[] | Bw6Fr[]. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr | Result of mul and add. |
div2
self / two
function div2(Bw6Fr[2] memory self) internal pure returns (Bw6Fr[2] memory z);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr[2] | Bw6Fr[2]. |
Returns
Name | Type | Description |
---|---|---|
z | Bw6Fr[2] | Result of div2. |
inverse
Constant time inversion using Fermat's little theorem. For a prime p and for any a < p, a^p = a % p => a^(p-1) = 1 % p => a^(p-2) = a^-1 % p
function inverse(Bw6Fr memory self) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of inverse. |
square
self^2 % r.
function square(Bw6Fr memory self) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of square. |
pow
base^exp % r
function pow(Bw6Fr memory base, uint256 exp) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
base | Bw6Fr | Bw6Fr. |
exp | uint256 | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of pow. |
mod_exp
base^base % modulus
function mod_exp(Bw6Fr memory base, uint256 exp, Bw6Fr memory modulus) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
base | Bw6Fr | Bw6Fr. |
exp | uint256 | Bw6Fr. |
modulus | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of mod_exp. |
square_nomod
self^2
function square_nomod(Bw6Fr memory self) internal view returns (Bw6Fr[2] memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr[2] | Result of square withoud mod. |
norm
Normalize Bw6Fr[2].
function norm(Bw6Fr[2] memory self) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr[2] | Bw6Fr[2]. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | self % r . |
powers
(max_exp+1)-sized vec: 1, base, base^2,... ,base^{max_exp}
function powers(Bw6Fr memory base, uint256 max_exp) internal view returns (Bw6Fr[] memory);
Parameters
Name | Type | Description |
---|---|---|
base | Bw6Fr | Bw6Fr. |
max_exp | uint256 | uint256. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr[] | Result of powers. |
horner_field
Horner field
function horner_field(Bw6Fr[] memory bases, Bw6Fr memory nu) internal view returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
bases | Bw6Fr[] | Bw6Fr[]. |
nu | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Result of horner_field. |
from_random_bytes
Derive Bw6Fr from bytes in LE order.
function from_random_bytes(bytes16 input) internal pure returns (Bw6Fr memory);
Parameters
Name | Type | Description |
---|---|---|
input | bytes16 | bytes16. |
Returns
Name | Type | Description |
---|---|---|
<none> | Bw6Fr | Bw6Fr. |
serialize
Serialize Bw6Fr.
function serialize(Bw6Fr memory self) internal pure returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | Compressed serialized bytes of Bls12G1. |
debug
Debug Bw6Fr in bytes.
function debug(Bw6Fr memory self) internal pure returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
self | Bw6Fr | Bw6Fr. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | Uncompressed serialized bytes of Bw6Fr. |