UltrafastSecp256k1
3.50.0
Ultra high-performance secp256k1 elliptic curve cryptography library
Loading...
Searching...
No Matches
selftest.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <string>
5
#include <vector>
6
7
namespace
secp256k1::fast
{
8
9
// -- Selftest execution modes --
10
// Controls which test subsets run and how many iterations stress tests perform.
11
//
12
// smoke -- 1-2 seconds, core KAT vectors only (suitable for app startup)
13
// ci -- 30-90 seconds, full coverage (GitHub Actions / every push)
14
// stress -- 10-60 minutes, extended iterations + big sweeps (nightly / manual)
15
enum class
SelftestMode
: uint8_t {
16
smoke
= 0,
// Core vectors + field/scalar identities (~1-2 s)
17
ci
= 1,
// All tests including batch sweeps, bilinearity, NAF (~30-90 s)
18
stress
= 2
// ci + extended iterations, large random sweeps (~10-60 min)
19
};
20
21
// -- Structured selftest result (for bindings / programmatic use) --
22
struct
SelftestCaseResult
{
23
std::string
name
;
// e.g. "scalar_mul_KAT_10_vectors"
24
bool
passed
;
// true = PASS
25
std::string
detail
;
// empty on pass; failure description on fail
26
};
27
28
struct
SelftestReport
{
29
bool
all_passed
;
// true if every case passed
30
int
total
;
// number of test cases run
31
int
passed
;
// number that passed
32
std::string
mode
;
// "smoke", "ci", or "stress"
33
uint64_t
seed
;
// PRNG seed used
34
std::string
platform
;
// e.g. "x86_64 clang-17"
35
std::vector<SelftestCaseResult>
cases
;
// per-test results
36
37
// Render as human-readable multi-line text
38
std::string
to_text
()
const
;
39
40
// Render as JSON string
41
std::string
to_json
()
const
;
42
};
43
44
// Run comprehensive self-tests on the library
45
// Returns true if all tests pass, false otherwise
46
// Set verbose=true to see detailed test output
47
bool
Selftest
(
bool
verbose);
48
49
// Run self-tests with explicit mode and deterministic PRNG seed.
50
// seed=0 uses default seed (deterministic but fixed).
51
// Prints repro bundle: commit, compiler, platform, seed, mode.
52
bool
Selftest
(
bool
verbose,
SelftestMode
mode, uint64_t seed = 0);
53
54
// Run self-tests and return a structured report (no stdout output).
55
// Suitable for bindings (Python, Rust, Node.js, etc.) that need
56
// a programmatic result rather than console output.
57
SelftestReport
selftest_report
(
SelftestMode
mode =
SelftestMode::smoke
,
58
uint64_t seed = 0);
59
60
}
// namespace secp256k1::fast
secp256k1::fast
Definition
batch_add_affine.hpp:8
secp256k1::fast::selftest_report
SelftestReport selftest_report(SelftestMode mode=SelftestMode::smoke, uint64_t seed=0)
secp256k1::fast::Selftest
bool Selftest(bool verbose)
secp256k1::fast::SelftestMode
SelftestMode
Definition
selftest.hpp:15
secp256k1::fast::SelftestMode::ci
@ ci
secp256k1::fast::SelftestMode::stress
@ stress
secp256k1::fast::SelftestMode::smoke
@ smoke
secp256k1::fast::SelftestCaseResult
Definition
selftest.hpp:22
secp256k1::fast::SelftestCaseResult::name
std::string name
Definition
selftest.hpp:23
secp256k1::fast::SelftestCaseResult::detail
std::string detail
Definition
selftest.hpp:25
secp256k1::fast::SelftestCaseResult::passed
bool passed
Definition
selftest.hpp:24
secp256k1::fast::SelftestReport
Definition
selftest.hpp:28
secp256k1::fast::SelftestReport::mode
std::string mode
Definition
selftest.hpp:32
secp256k1::fast::SelftestReport::to_text
std::string to_text() const
secp256k1::fast::SelftestReport::cases
std::vector< SelftestCaseResult > cases
Definition
selftest.hpp:35
secp256k1::fast::SelftestReport::platform
std::string platform
Definition
selftest.hpp:34
secp256k1::fast::SelftestReport::all_passed
bool all_passed
Definition
selftest.hpp:29
secp256k1::fast::SelftestReport::to_json
std::string to_json() const
secp256k1::fast::SelftestReport::seed
uint64_t seed
Definition
selftest.hpp:33
secp256k1::fast::SelftestReport::passed
int passed
Definition
selftest.hpp:31
secp256k1::fast::SelftestReport::total
int total
Definition
selftest.hpp:30
cpu
include
secp256k1
selftest.hpp
Generated by
1.9.8