Commit Graph

4 Commits

Author SHA1 Message Date
Vano Chkheidze
998a2060d6
fix: mass code scanning cleanup (~4600 alerts) (#53)
* perf: replace std::endl with newline char (performance-avoid-endl)

Replace all 133 occurrences of std::endl with '\n' across 6 files.
std::endl forces a flush on every call, '\n' does not.

Files: precompute.cpp, test_comprehensive.cpp, test_arithmetic_correctness.cpp,
test_exhaustive.cpp, bench_adaptive_glv.cpp, bench_glv_decomp_profile.cpp

* fix: mass clang-tidy auto-fix (const, init, braces, auto, endl)

Run clang-tidy --fix on all 98 source files using .clang-tidy config:
- misc-const-correctness: add const to unmodified locals
- cppcoreguidelines-init-variables: initialize variables at decl
- readability-braces-around-statements: add braces to single-line
- modernize-use-auto: use auto where type is obvious
- performance-avoid-endl: replace remaining endl with newline

Manual fixes for 4 false-positive const additions:
- ct_point.cpp: y3/z3/one52 used as fe52_cmov output params
- selftest.cpp: path used as _dupenv_s output param
- precompute.cpp: end used as strtoul output param
- test_fuzz_address_bip32_ffi.cpp: out used as ufsecp_ctx_clone output

Build: 0 errors. Tests: 25/25 pass.

* fix: clang-tidy manual fixes for headers + test widening cast

- ct_utils.hpp: const-qualify w0a-w3a load variables
- field_optimal.hpp: FieldTier enum use uint8_t base type (performance-enum-size)
- test_comprehensive.cpp: fix widening cast order (cast before add)

Build: 0 errors. Tests: 25/25 pass.
2026-02-27 22:59:12 +04:00
vano
9ffcc985c8 style: replace all Unicode with ASCII across entire codebase
All non-ASCII characters replaced with ASCII equivalents:
- Greek letters: mu->u, phi->phi, lambda->lambda, etc.
- Box drawing: single/double -> +, -, |, =
- Math symbols: x (multiply), != (not equal), -> (arrow), etc.
- Superscripts/subscripts: ^2, ^3, _1, _2, etc.
- Emoji/bullets: [OK], [FAIL], [!], *, etc.
- parse_benchmark.py: simplified regex (only ASCII 'us' needed now)

190 files changed. Zero non-ASCII bytes remain in source.
Build verified: library, benchmarks, selftests all pass.
2026-02-23 02:16:57 +04:00
shrec
e6624ccc31 Phase 11: CT hot-path inlining + template optimization
Core changes (ct_point.cpp):
- Created always_inline template core versions of hot functions:
  table_lookup_core<NORMALIZE_Y>, unified_add_core<CHECK_INFINITY>,
  point_dbl_n_core(). Public API wrappers delegate to cores.
- scalar_mul/generator_mul main loops call cores directly with
  CHECK_INFINITY=false (saves 3 fe52_cmov + 1 fe52_is_zero per add)
  and NORMALIZE_Y=false (skips unnecessary normalize_weak on table
  entries already at magnitude 1).
- Added fe52_normalizes_to_zero(): cheaper CT zero check using
  normalize_weak + overflow reduce + dual representation check
  (~40 ops vs ~64 for full fe52_is_zero). Matches libsecp approach.
- Added #pragma clang loop unroll(disable) on main loops to prevent
  code bloat from inlined 66KB function body.

Benchmark improvements (bench_ct.cpp, bench_atomic_operations.cpp):
- Use pool of 32 random 256-bit scalars to prevent branch-predictor
  warming and ensure realistic workload measurements.
- Use full 256-bit field elements/scalars instead of trivially small
  values in atomic operation benchmarks.

Results (i5-14400F, clang-19, -O3 -march=native):
- CT scalar_mul:    23.3us -> 22.0us (~5% improvement, 1.25x -> 1.18x vs libsecp)
- CT generator_mul: 11.0us ->  9.6us (~13% improvement, 0.99x -> 0.87x vs libsecp)
- All CT audit tests pass (120,652 checks, 0 failures)
2026-02-20 20:41:35 +00:00
vano
c347bae204 feat: v2.2.0 — ECDSA (RFC 6979), Schnorr (BIP-340), SHA-256, CI/CD, fuzzing, CT bench
New features:
- ECDSA sign/verify with RFC 6979 deterministic nonce (HMAC-SHA256)
- Schnorr BIP-340 sign/verify with tagged hashing & x-only pubkeys
- Self-contained SHA-256 (header-only, no deps)
- Scalar::inverse (Fermat's theorem), negate(), is_even()

Build & tooling:
- GitHub Actions CI: Linux (gcc-13/clang-17), Windows (MSVC), macOS
- .clang-format + .editorconfig for code style
- cmake/version.hpp.in auto-generated version header
- CMake VERSION 1.0.0 -> 2.2.0
- Fixed install(TARGETS/EXPORT) — moved to cpu/ where target is defined
- MSVC compatibility via SECP256K1_NO_INT128 generator expression
- Fixed BUILD_TESTING standalone build

Testing & benchmarks:
- test_ecdsa_schnorr: 22 checks (SHA-256 NIST, inverse, ECDSA, Schnorr)
- bench_ct: CT vs fast comparison for all primitives
- 3 libFuzzer harnesses (field, scalar, point)
- Desktop CLI example (examples/basic_usage)

All 5 CTest targets pass (22/22 ECDSA+Schnorr checks).
2026-02-15 05:03:33 +04:00