UltrafastSecp256k1 3.50.0
Ultra high-performance secp256k1 elliptic curve cryptography library
Loading...
Searching...
No Matches
debug_invariants.hpp File Reference
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include "secp256k1/field.hpp"
#include "secp256k1/scalar.hpp"
#include "secp256k1/point.hpp"

Go to the source code of this file.

Classes

struct  secp256k1::fast::debug::DebugCounters
 

Namespaces

namespace  secp256k1
 
namespace  secp256k1::fast
 
namespace  secp256k1::fast::debug
 

Macros

#define SECP_ASSERT(expr)
 
#define SECP_ASSERT_MSG(expr, msg)
 
#define SECP_ASSERT_NORMALIZED(fe)
 
#define SECP_ASSERT_ON_CURVE(pt)
 
#define SECP_ASSERT_SCALAR_VALID(s)
 
#define SECP_ASSERT_SCALAR_NONZERO(s)   SECP_ASSERT_SCALAR_VALID(s)
 
#define SECP_ASSERT_NOT_INFINITY(pt)
 
#define SECP_ASSERT_FE_LESS_THAN_P(fe)   SECP_ASSERT_NORMALIZED(fe)
 
#define SECP_DEBUG_COUNTER_INC(name)    (++secp256k1::fast::debug::counters().name ## _count)
 
#define SECP_DEBUG_COUNTER_REPORT()    secp256k1::fast::debug::counters().report()
 

Functions

bool secp256k1::fast::debug::is_normalized_field_element (const FieldElement &fe) noexcept
 
bool secp256k1::fast::debug::is_on_curve (const Point &pt) noexcept
 
bool secp256k1::fast::debug::is_valid_scalar (const Scalar &s) noexcept
 
DebugCounterssecp256k1::fast::debug::counters () noexcept
 

Macro Definition Documentation

◆ SECP_ASSERT

#define SECP_ASSERT (   expr)
Value:
do { \
if (!(expr)) { \
(void)std::fprintf(stderr, \
"SECP_ASSERT FAILED: %s\n at %s:%d (%s)\n", \
#expr, __FILE__, __LINE__, __func__); \
std::abort(); \
} \
} while(0)

Definition at line 180 of file debug_invariants.hpp.

◆ SECP_ASSERT_FE_LESS_THAN_P

#define SECP_ASSERT_FE_LESS_THAN_P (   fe)    SECP_ASSERT_NORMALIZED(fe)

Definition at line 243 of file debug_invariants.hpp.

◆ SECP_ASSERT_MSG

#define SECP_ASSERT_MSG (   expr,
  msg 
)
Value:
do { \
if (!(expr)) { \
(void)std::fprintf(stderr, \
"SECP_ASSERT FAILED: %s\n %s\n at %s:%d (%s)\n", \
#expr, msg, __FILE__, __LINE__, __func__); \
std::abort(); \
} \
} while(0)

Definition at line 189 of file debug_invariants.hpp.

◆ SECP_ASSERT_NORMALIZED

#define SECP_ASSERT_NORMALIZED (   fe)
Value:
do { \
(void)std::fprintf(stderr, \
"SECP_ASSERT_NORMALIZED FAILED: field element not canonical\n" \
" at %s:%d (%s)\n", __FILE__, __LINE__, __func__); \
const auto& _l = (fe).limbs(); \
(void)std::fprintf(stderr, " limbs: [%016llx, %016llx, %016llx, %016llx]\n", \
(unsigned long long)_l[0], (unsigned long long)_l[1], \
(unsigned long long)_l[2], (unsigned long long)_l[3]); \
std::abort(); \
} \
} while(0)
bool is_normalized_field_element(const FieldElement &fe) noexcept
DebugCounters & counters() noexcept

Definition at line 198 of file debug_invariants.hpp.

◆ SECP_ASSERT_NOT_INFINITY

#define SECP_ASSERT_NOT_INFINITY (   pt)
Value:
do { \
if ((pt).is_infinity()) { \
(void)std::fprintf(stderr, \
"SECP_ASSERT_NOT_INFINITY FAILED\n" \
" at %s:%d (%s)\n", __FILE__, __LINE__, __func__); \
std::abort(); \
} \
} while(0)

Definition at line 234 of file debug_invariants.hpp.

◆ SECP_ASSERT_ON_CURVE

#define SECP_ASSERT_ON_CURVE (   pt)
Value:
do { \
(void)std::fprintf(stderr, \
"SECP_ASSERT_ON_CURVE FAILED: point not on secp256k1\n" \
" at %s:%d (%s)\n", __FILE__, __LINE__, __func__); \
std::abort(); \
} \
} while(0)
bool is_on_curve(const Point &pt) noexcept

Definition at line 212 of file debug_invariants.hpp.

◆ SECP_ASSERT_SCALAR_NONZERO

#define SECP_ASSERT_SCALAR_NONZERO (   s)    SECP_ASSERT_SCALAR_VALID(s)

Definition at line 232 of file debug_invariants.hpp.

◆ SECP_ASSERT_SCALAR_VALID

#define SECP_ASSERT_SCALAR_VALID (   s)
Value:
do { \
(void)std::fprintf(stderr, \
"SECP_ASSERT_SCALAR_VALID FAILED: scalar is zero\n" \
" at %s:%d (%s)\n", __FILE__, __LINE__, __func__); \
std::abort(); \
} \
} while(0)
bool is_valid_scalar(const Scalar &s) noexcept

Definition at line 222 of file debug_invariants.hpp.

◆ SECP_DEBUG_COUNTER_INC

#define SECP_DEBUG_COUNTER_INC (   name)     (++secp256k1::fast::debug::counters().name ## _count)

Definition at line 245 of file debug_invariants.hpp.

◆ SECP_DEBUG_COUNTER_REPORT

#define SECP_DEBUG_COUNTER_REPORT ( )     secp256k1::fast::debug::counters().report()

Definition at line 248 of file debug_invariants.hpp.