18template <
typename Params>
19class Secp224r1Rep
final {
21 static constexpr auto P = Params::P;
22 static constexpr size_t N = Params::N;
23 typedef typename Params::W W;
25 constexpr static std::array<W, N> redc(
const std::array<W, 2 * N>& z) {
41 const int64_t S0 = 0x00000001 + X00 - X07 - X11;
42 const int64_t S1 = 0x00000000 + X01 - X08 - X12;
43 const int64_t S2 = 0x00000000 + X02 - X09 - X13;
44 const int64_t S3 = 0xFFFFFFFF + X03 + X07 + X11 - X10;
45 const int64_t S4 = 0xFFFFFFFF + X04 + X08 + X12 - X11;
46 const int64_t S5 = 0xFFFFFFFF + X05 + X09 + X13 - X12;
47 const int64_t S6 = 0xFFFFFFFF + X06 + X10 - X13;
49 std::array<W, N> r = {};
64 const auto correction = p224_mul_mod_224(S);
65 W borrow =
bigint_sub2(r.data(), N, correction.data(), N);
72 constexpr static std::array<W, N> one() {
return std::array<W, N>{1}; }
74 constexpr static std::array<W, N> to_rep(
const std::array<W, N>& x) {
return x; }
76 constexpr static std::array<W, N> wide_to_rep(
const std::array<W, 2 * N>& x) {
return redc(x); }
78 constexpr static std::array<W, N> from_rep(
const std::array<W, N>& z) {
return z; }
84 constexpr static std::array<W, N> p224_mul_mod_224(W i) {
96 const W i32 = i << 32;
105class Params
final :
public EllipticCurveParameters<
106 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001",
107 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE",
108 "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4",
109 "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D",
110 "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21",
111 "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"> {
116class Curve
final :
public EllipticCurve<Params, Secp224r1Rep> {
119 static FieldElement fe_invert2(
const FieldElement& x) {
153 static Scalar scalar_invert(
const Scalar& x) {
155 auto t6 = x.square();
156 auto z = t6.square();
167 auto t10 = t6.square();