1#ifndef C870F4A3_192C_4B96_9AE6_497D1885C5D9
2#define C870F4A3_192C_4B96_9AE6_497D1885C5D9
21#if defined(__SIZEOF_INT128__) && !defined(SECP256K1_PLATFORM_ESP32) && !defined(SECP256K1_PLATFORM_STM32) && !defined(__EMSCRIPTEN__)
22 #ifndef SECP256K1_FAST_52BIT
23 #define SECP256K1_FAST_52BIT 1
47#if defined(SECP256K1_GLV_WINDOW_WIDTH)
50 static_assert(SECP256K1_GLV_WINDOW_WIDTH >= 4 && SECP256K1_GLV_WINDOW_WIDTH <= 7,
51 "SECP256K1_GLV_WINDOW_WIDTH must be in [4,7]");
53#elif defined(__riscv) || defined(__aarch64__) || defined(_M_ARM64)
55#elif defined(__x86_64__) || defined(_M_X64)
72 std::array<int32_t, kWnafBufLen>
wnaf1{};
74 std::array<int32_t, kWnafBufLen>
wnaf2{};
94 static Point from_hex(
const std::string& x_hex,
const std::string& y_hex);
99 bool is_gen() const noexcept {
return is_generator_; }
108#if defined(SECP256K1_FAST_52BIT)
115 const FieldElement52& Z52() const noexcept {
return z_; }
134 bool neg1,
bool neg2)
const;
140 const std::vector<int32_t>& wnaf2,
141 bool neg1,
bool neg2)
const;
144 const int32_t* wnaf2, std::size_t len2,
145 bool neg1,
bool neg2)
const;
176#if defined(SECP256K1_FAST_52BIT)
256 size_t chunk_size = 256);
261 const std::string& path);
269 const KPlan& plan,
const Point* pts,
size_t n,
270 const std::string& cache_path);
283 std::array<uint8_t, 33>* out);
288 std::array<uint8_t, 32>* out);
303#if defined(SECP256K1_FAST_52BIT)
314#if defined(SECP256K1_FAST_52BIT)
323#if defined(SECP256K1_FAST_52BIT)
332 bool z_fe_nonzero(
FieldElement& out_z_fe)
const noexcept;
335#if defined(SECP256K1_FAST_52BIT)
static Point from_hex(const std::string &x_hex, const std::string &y_hex)
static PointScanCacheHandle batch_scan_precompute(const KPlan &plan, const Point *pts, size_t n)
static Point from_affine(const FieldElement &x, const FieldElement &y)
static Point dual_scalar_mul_gen_point(const Scalar &a, const Scalar &b, const Point &P)
const FieldElement & z_raw() const noexcept
static Point from_jacobian_coords(const FieldElement &x, const FieldElement &y, const FieldElement &z, bool infinity)
static void batch_x_only_bytes(const Point *points, size_t n, std::array< uint8_t, 32 > *out)
std::array< std::uint8_t, 65 > to_uncompressed() const
void add_affine_constant_inplace(const FieldElement &ax, const FieldElement &ay)
const FieldElement & Y() const noexcept
std::pair< std::array< uint8_t, 32 >, bool > x_bytes_and_parity() const
static void batch_to_compressed(const Point *points, size_t n, std::array< uint8_t, 33 > *out)
Point scalar_mul_jacobian(const Scalar &scalar) const
static PointScanCacheHandle batch_scan_load(const std::string &path)
bool is_gen() const noexcept
std::array< uint8_t, 32 > x_only_bytes() const
std::shared_ptr< void > PointScanCacheHandle
static void batch_normalize(const Point *points, size_t n, FieldElement *out_x, FieldElement *out_y)
Point scalar_mul(const Scalar &scalar) const
static void batch_scan_run_lockstep(const PointScanCacheHandle &cache, const KPlan &plan, size_t cache_offset, Point *results, size_t n, size_t chunk_size=256)
void sub_mixed_inplace(const FieldElement &ax, const FieldElement &ay)
void add_inplace(const Point &other)
bool is_infinity() const noexcept
static bool batch_scan_save(const PointScanCacheHandle &cache, const std::string &path)
Point scalar_mul_with_plan(const KPlan &plan) const
bool is_normalized() const noexcept
Point add(const Point &other) const
static PointScanCacheHandle batch_scan_precompute_or_load(const KPlan &plan, const Point *pts, size_t n, const std::string &cache_path)
const FieldElement & z() const noexcept
const FieldElement & y_raw() const noexcept
static void batch_scan_run(const PointScanCacheHandle &cache, const KPlan &plan, size_t cache_offset, Point *results, size_t n)
void add_mixed_inplace(const FieldElement &ax, const FieldElement &ay)
static void batch_scalar_mul_fixed_k(const KPlan &plan, const Point *pts, size_t n, Point *results)
Point scalar_mul_precomputed_wnaf(const std::vector< int32_t > &wnaf1, const std::vector< int32_t > &wnaf2, bool neg1, bool neg2) const
Point scalar_mul_precomputed_wnaf(const int32_t *wnaf1, std::size_t len1, const int32_t *wnaf2, std::size_t len2, bool neg1, bool neg2) const
const FieldElement & x_raw() const noexcept
Point scalar_mul_predecomposed(const Scalar &k1, const Scalar &k2, bool neg1, bool neg2) const
void sub_inplace(const Point &other)
Point scalar_mul_precomputed_k(const Scalar &k) const
const FieldElement & X() const noexcept
std::array< uint8_t, 16 > x_first_half() const
static void batch_scalar_mul_fixed_k_4x(const KPlan &plan, const Point *pts, size_t n, Point *results)
std::array< std::uint8_t, 33 > to_compressed() const
std::array< uint8_t, 16 > x_second_half() const
bool Selftest(bool verbose)
constexpr std::size_t kWnafBufLen
constexpr uint8_t kDefaultGlvWindow
std::array< int32_t, kWnafBufLen > wnaf2
static KPlan from_scalar(const Scalar &k, uint8_t w=kDefaultGlvWindow)
std::array< int32_t, kWnafBufLen > wnaf1