Skip to content

Add EC-SDSA (Schnorr) signatures with SHA-256/SHA-512 support#242

Open
yplo wants to merge 1 commit intokmackay:masterfrom
yplo:master
Open

Add EC-SDSA (Schnorr) signatures with SHA-256/SHA-512 support#242
yplo wants to merge 1 commit intokmackay:masterfrom
yplo:master

Conversation

@yplo
Copy link
Copy Markdown

@yplo yplo commented Apr 17, 2026

Add macro-preprocessor to enable/disable EC variants (EC-DSA or EC-SDSA) for code size optimisations.

  • Add pre-processor macro for uECC_SUPPORTS_ECDSA
  • Add pre-processor macro for uECC_SUPPORTS_ECSDSA_STANDARD
  • Add pre-processor macro for uECC_SUPPORTS_ECSDSA_OPTIMIZED

Add new EC variant (EC-SDSA) to uECC.

  • Support Standard variant: R = Hash(x1 || y1 || M) via uECC_SUPPORTS_ECSDSA_STANDARD
  • Support Optimised variant: : R = Hash(x1 || M) via uECC_SUPPORTS_ECSDSA_OPTIMIZED, excludes Y-coordinate from hash

uECC.h / uECC.c:
- uECC_SUPPORTS_ECDSA macro wraps existing sign/verify block.
- EC-SDSA (Schnorr) sign and verify for two variants:
    Optimized: R = Hash(x1 || M)
    Standard:  R = Hash(x1 || y1 || M)
  Shared impl in ecsdsa_sign_impl / ecsdsa_verify_impl (include_y flag).
- Public API: uECC_ecsdsa_sign/verify_optimized, uECC_ecsdsa_sign/verify_standard.
- Three-level preprocessor gates (all default to 1):
    uECC_SUPPORTS_ECDSA
    uECC_SUPPORTS_ECSDSA_OPTIMIZED
    uECC_SUPPORTS_ECSDSA_STANDARD
  Set any to 0 to strip the corresponding code from the build.
- bits2int and smax are common helpers kept outside all guards.

uECC_hash.h / uECC_hash.c:
- Self-contained SHA-256 and SHA-512 uECC_HashContext adapters.
- DISABLED BY DEFAULT (uECC_SUPPORTS_SHA256/SHA512 default to 0).
  Projects with an existing hash library incur zero cost.
- Each context embeds its own scratch buffer; no heap allocation needed.

test/test_ecsdsa.c:
- Known-answer vector tests for both variants x both hashes
  (secp256r1, M = "abc"):
    SHA-256 optimized, SHA-256 standard
    SHA-512 optimized, SHA-512 standard
- Random round-trip tests: 64 iterations x 5 curves x 2 variants x 2 hashes.

README.md:
- Documents EC-SDSA variants, hash support, and all preprocessor gates.

.gitignore: exclude *.obj and *.exe build artifacts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant