mirror of
https://github.com/luxfi/crypto.git
synced 2026-11-02 13:34:37 +00:00
Replaces the stub backend (ErrBackendNotWired) with a working byte-
for-byte NIST-compatible HQC implementation. Build tag hqc_pqclean
activates the cgo path; default builds remain stub for portability.
Vendored:
- PQClean HQC-128/192/256 clean reference C (2023-04-30 NIST
submission), public domain
- PQClean shared fips202 (SHA-3 / SHAKE)
- Per-mode/per-source shim TUs (36 total) to keep PQClean's
static helpers isolated and avoid duplicate-symbol collisions
- randombytes_shim.c wiring PQClean's randombytes() to a Go-side
io.Reader callback, mutex-protected for concurrent dispatch
Tests:
- TestKAT_HQC128/192/256 — all three NIST KAT vectors verified
byte-for-byte against META.yml nistkat-sha256
- TestRoundTrip_AllModes — keygen → encap → decap roundtrip,
shared secrets byte-equal in all 3 modes
- TestDeterminism_AllModes — same seed produces identical ct/ss
(load-bearing for the precompile's on-chain determinism)
- -race clean
Correction: ciphertext sizes updated from 4481/9026/14469 (older
HQC round-3 listing) to PQClean's 4433/8978/14421 (2023-04-30 NIST
submission); the prior numbers would have failed round-trip with
a 48-byte mismatch.
40 lines
1.7 KiB
Plaintext
40 lines
1.7 KiB
Plaintext
PQClean HQC vendored sources
|
|
============================
|
|
|
|
The C sources under crypto/hqc/pqclean/hqc-{128,192,256}/clean/ are
|
|
copied verbatim from PQClean (https://github.com/PQClean/PQClean),
|
|
specifically from crypto_kem/hqc-{128,192,256}/clean/ at the upstream
|
|
state `hqc-submission_2023-04-30` (commit referenced in each scheme's
|
|
META.yml under `implementations`).
|
|
|
|
The HQC reference is licensed by its authors as Public Domain; see
|
|
hqc-{128,192,256}/clean/LICENSE in each subdirectory.
|
|
|
|
The shared SHAKE/SHA-3 implementation (pqclean/common/fips202.c,
|
|
fips202.h) is taken from PQClean/common/, originally derived from the
|
|
public-domain Keccak Team reference (https://keccak.team/).
|
|
|
|
Modifications by Lux
|
|
--------------------
|
|
|
|
- Added pqclean/common/randombytes.h that declares only `randombytes(
|
|
uint8_t*, size_t)`. The HQC sources `#include "randombytes.h"` and
|
|
resolve the symbol at link time. The actual implementation lives in
|
|
crypto/hqc/randombytes_shim.c and forwards to a Go callback so that
|
|
the EVM precompile can drive HQC encapsulation from a caller-
|
|
supplied deterministic seed (see crypto/hqc/backend_pqclean.go).
|
|
- No changes to algorithmic code in hqc-*/clean/ — the HQC sources
|
|
are byte-for-byte upstream so NIST KAT vectors verify unchanged
|
|
(crypto/hqc/backend_pqclean_test.go's TestKAT_HQC{128,192,256}
|
|
compare sha256 of the KAT transcript against the values from
|
|
PQClean's META.yml).
|
|
|
|
Original PQClean license
|
|
------------------------
|
|
|
|
PQClean and its authors place the HQC reference into the public domain
|
|
("Public Domain", see each hqc-*/clean/LICENSE file). The randombytes
|
|
infrastructure file from PQClean/common/randombytes.c carries an MIT
|
|
license (Daan Sprenkels) — we do not vendor that file; we ship our own
|
|
shim instead.
|