|
Botan 3.14.1
Crypto and TLS for C&
|
#include <bls12_381_fields.h>
Static Public Member Functions | |
| static constexpr FieldElement2 | _unchecked_from_words (std::array< word, FieldElement::N > c0, std::array< word, FieldElement::N > c1) |
| static std::optional< FieldElement2 > | deserialize (std::span< const uint8_t > bytes) |
| static FieldElement2 | one () |
| static FieldElement2 | zero () |
Static Public Attributes | |
| static constexpr size_t | BYTES = 2 * FieldElement::BYTES |
An element of the extension field Fp2 = Fp[u]/(u^2 + 1)
Represented as c0 + c1*u
Definition at line 156 of file bls12_381_fields.h.
|
constexprdefault |
Default constructed as zero
Referenced by _unchecked_from_words(), add(), conditional_assign(), conjugate(), deserialize(), invert(), mul(), mul_by_nonresidue(), negate(), one(), operator!=(), operator*=(), operator+=(), operator-=(), operator==(), sqrt(), square(), sub(), and zero().
|
inlineconstexpr |
Definition at line 163 of file bls12_381_fields.h.
| CT::Choice Botan::BLS12_381::FieldElement2::_is_lexicographically_largest | ( | ) | const |
Set iff this is larger than its negation
The comparison is lexicographic on (c1, c0), matching the ZCash convention: c1 > (p-1)/2, or c1 == 0 and c0 > (p-1)/2.
Definition at line 256 of file bls12_381_fp2.cpp.
|
inlinestaticconstexpr |
The inputs are assumed to be valid and already in Montgomery representation
Definition at line 259 of file bls12_381_fields.h.
References Botan::BLS12_381::FieldElement::_unchecked_from_words(), c0(), c1(), and FieldElement2().
Referenced by Botan::BLS12_381::Fp12::frobenius_map(), and Botan::BLS12_381::Fp6::frobenius_map().
| FieldElement2 Botan::BLS12_381::FieldElement2::add | ( | const FieldElement2 & | x | ) | const |
Definition at line 186 of file bls12_381_fp2.cpp.
References FieldElement2().
Referenced by Botan::BLS12_381::operator+(), and operator+=().
|
inline |
Definition at line 183 of file bls12_381_fields.h.
Referenced by _unchecked_from_words(), Botan::BLS12_381::Fp12::cyclotomic_square(), deserialize(), and FieldElement2().
|
inline |
Definition at line 185 of file bls12_381_fields.h.
Referenced by _unchecked_from_words(), deserialize(), and FieldElement2().
| void Botan::BLS12_381::FieldElement2::conditional_assign | ( | CT::Choice | cnd, |
| const FieldElement2 & | other ) |
If cnd is set assign other to this, in constant time
Definition at line 251 of file bls12_381_fp2.cpp.
References FieldElement2().
| FieldElement2 Botan::BLS12_381::FieldElement2::conjugate | ( | ) | const |
Return the conjugate c0 - c1*u, which is also the image of this element under the Frobenius endomorphism x -> x^p
Definition at line 223 of file bls12_381_fp2.cpp.
References FieldElement2().
Referenced by Botan::BLS12_381::pow_p2_minus_9_over_16().
|
static |
Deserialization; the c1 coefficient is encoded first, following the ZCash convention for G2 point encoding
Definition at line 161 of file bls12_381_fp2.cpp.
References BYTES, Botan::BLS12_381::FieldElement::BYTES, c0(), c1(), Botan::BLS12_381::FieldElement::deserialize(), and FieldElement2().
| FieldElement2 Botan::BLS12_381::FieldElement2::invert | ( | ) | const |
Return the multiplicative inverse of this element, or zero for zero
Definition at line 232 of file bls12_381_fp2.cpp.
References FieldElement2(), invert(), and negate().
Referenced by invert().
| CT::Choice Botan::BLS12_381::FieldElement2::is_zero | ( | ) | const |
Definition at line 182 of file bls12_381_fp2.cpp.
| FieldElement2 Botan::BLS12_381::FieldElement2::mul | ( | const FieldElement2 & | x | ) | const |
Definition at line 194 of file bls12_381_fp2.cpp.
References FieldElement2().
Referenced by Botan::BLS12_381::operator*(), and operator*=().
| FieldElement2 Botan::BLS12_381::FieldElement2::mul_by_nonresidue | ( | ) | const |
Multiplication by the sextic nonresidue u + 1
Definition at line 227 of file bls12_381_fp2.cpp.
References FieldElement2().
| FieldElement2 Botan::BLS12_381::FieldElement2::negate | ( | ) | const |
Definition at line 219 of file bls12_381_fp2.cpp.
References FieldElement2().
|
inlinestatic |
Definition at line 167 of file bls12_381_fields.h.
References FieldElement2(), Botan::BLS12_381::FieldElement::one(), and Botan::BLS12_381::FieldElement::zero().
Referenced by Botan::BLS12_381::G2Projective::_unchecked_from_affine_coords(), Botan::BLS12_381::G2Projective::generator(), Botan::BLS12_381::G2Affine::identity(), Botan::BLS12_381::Fp6::one(), and sqrt().
|
inline |
Definition at line 246 of file bls12_381_fields.h.
References FieldElement2().
|
inline |
Definition at line 205 of file bls12_381_fields.h.
References FieldElement2(), and mul().
|
inline |
Definition at line 195 of file bls12_381_fields.h.
References add(), and FieldElement2().
|
inline |
Definition at line 200 of file bls12_381_fields.h.
References FieldElement2(), and sub().
| CT::Choice Botan::BLS12_381::FieldElement2::operator== | ( | const FieldElement2 & | other | ) | const |
Constant time equality
Definition at line 247 of file bls12_381_fp2.cpp.
References FieldElement2().
|
inline |
Definition at line 177 of file bls12_381_fields.h.
References serialize_to().
| void Botan::BLS12_381::FieldElement2::serialize_to | ( | std::span< uint8_t, FieldElement2::BYTES > | bytes | ) | const |
Definition at line 177 of file bls12_381_fp2.cpp.
References Botan::BLS12_381::FieldElement::BYTES.
Referenced by serialize().
| CT::Option< FieldElement2 > Botan::BLS12_381::FieldElement2::sqrt | ( | ) | const |
Return the square root of this element, if one exists
If x and -x are both square roots, which of the two is returned is unspecified.
Definition at line 260 of file bls12_381_fp2.cpp.
References FieldElement2(), Botan::hex_to_words(), negate(), one(), Botan::BLS12_381::pow_msb(), and Botan::shift_right().
| FieldElement2 Botan::BLS12_381::FieldElement2::square | ( | ) | const |
Definition at line 204 of file bls12_381_fp2.cpp.
References FieldElement2().
Referenced by Botan::BLS12_381::Fp12::cyclotomic_square(), Botan::BLS12_381::pow_p2_minus_9_over_16(), and square_n().
| void Botan::BLS12_381::FieldElement2::square_n | ( | size_t | n | ) |
Definition at line 213 of file bls12_381_fp2.cpp.
References square().
| FieldElement2 Botan::BLS12_381::FieldElement2::sub | ( | const FieldElement2 & | x | ) | const |
Definition at line 190 of file bls12_381_fp2.cpp.
References FieldElement2().
Referenced by Botan::BLS12_381::operator-(), and operator-=().
|
inlinestatic |
Definition at line 165 of file bls12_381_fields.h.
References FieldElement2().
Referenced by Botan::BLS12_381::G2Affine::identity(), and Botan::BLS12_381::Fp6::one().
|
staticconstexpr |
Definition at line 158 of file bls12_381_fields.h.
Referenced by deserialize().