7#include <botan/internal/bls12_381_tower.h>
9#include <botan/internal/mp_core.h>
14 return m_c0.is_zero() && m_c1.is_zero() && m_c2.is_zero();
18 return Fp6(m_c0 + x.m_c0, m_c1 + x.m_c1, m_c2 + x.m_c2);
22 return Fp6(m_c0 - x.m_c0, m_c1 - x.m_c1, m_c2 - x.m_c2);
26 return Fp6(m_c0.negate(), m_c1.negate(), m_c2.negate());
34 const auto t0 = m_c0 * x.m_c0;
35 const auto t1 = m_c1 * x.m_c1;
36 const auto t2 = m_c2 * x.m_c2;
38 const auto s12 = (m_c1 + m_c2) * (x.m_c1 + x.m_c2);
39 const auto s01 = (m_c0 + m_c1) * (x.m_c0 + x.m_c1);
40 const auto s02 = (m_c0 + m_c2) * (x.m_c0 + x.m_c2);
46 const auto s0 = m_c0.
square();
47 const auto ab = m_c0 * m_c1;
48 const auto s1 = ab + ab;
49 const auto s2 = (m_c0 - m_c1 + m_c2).
square();
50 const auto bc = m_c1 * m_c2;
51 const auto s3 = bc + bc;
52 const auto s4 = m_c2.
square();
54 return Fp6(s3.mul_by_nonresidue() + s0, s4.mul_by_nonresidue() + s1, s1 + s2 + s3 - s0 - s4);
59 const auto c1 = m_c2.square().mul_by_nonresidue() - (m_c0 * m_c1);
60 const auto c2 = m_c1.square() - (m_c0 * m_c2);
62 const auto t = (((m_c1 *
c2) + (m_c2 *
c1)).mul_by_nonresidue() + (m_c0 *
c0)).invert();
69 return Fp6(m_c2.mul_by_nonresidue(), m_c0, m_c1);
77 const auto a_a = m_c0 * b0;
78 const auto b_b = m_c1 * b1;
81 const auto t2 = (b0 + b1) * (m_c0 + m_c1) - a_a - b_b;
82 const auto t3 = m_c2 * b0 + b_b;
84 return Fp6(t1, t2, t3);
91 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
93 "18f020655463874103f97d6e83d050d28eb60ebe01bacb9e587042afd3851b955dab22461fcda5d2cd03c9e48671f071"));
98 "14e56d3f1564853a14e4f04fe2db9068a20d1b8c7e88102450880866309b7e2c2af322533285a5d5890dc9e4867545c3"),
100 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
102 return Fp6(m_c0.conjugate(), m_c1.conjugate() * FP6_FROBENIUS_C1, m_c2.conjugate() * FP6_FROBENIUS_C2);
106 return (m_c0 == other.m_c0) && (m_c1 == other.m_c1) && (m_c2 == other.m_c2);
110 m_c0.conditional_assign(cnd, other.m_c0);
111 m_c1.conditional_assign(cnd, other.m_c1);
112 m_c2.conditional_assign(cnd, other.m_c2);
static constexpr FieldElement2 _unchecked_from_words(std::array< word, FieldElement::N > c0, std::array< word, FieldElement::N > c1)
void conditional_assign(CT::Choice cnd, const Fp6 &other)
Fp6 mul_by_01(const FieldElement2 &b0, const FieldElement2 &b1) const
CT::Choice operator==(const Fp6 &other) const
const FieldElement2 & c1() const
Fp6 frobenius_map() const
Fp6 mul(const Fp6 &x) const
CT::Choice is_zero() const
Fp6 sub(const Fp6 &x) const
Fp6 mul_by_1(const FieldElement2 &b1) const
Fp6 mul_by_nonresidue() const
const FieldElement2 & c2() const
const FieldElement2 & c0() const
Fp6 add(const Fp6 &x) const
constexpr auto hex_to_words(const char(&s)[N])