mirror of
https://github.com/luxfi/accel.git
synced 2026-10-30 17:03:45 +00:00
Adds two layers for HQC (NIST PQC Round-4 selected, NIST IR 8528):
ops/code/ Go binding to luxcpp/gpu's libluxgpu_hqc.a — KEM batch
entry (keypair_batch, encaps_batch, decaps_batch) plus
low-level kernels (gf2_polymul, reed_solomon_decode,
reed_muller_decode). cgo / no-cgo variants per the
accel build-tag convention.
hqc/ Thin re-export of ops/code under HQC-named symbols, so
callers can import accel/hqc instead of accel/ops/code.
No duplication — types are aliased, helpers forward.
Both layers are byte-equal to the PQClean reference under
luxfi/crypto/hqc/pqclean. Validators reach consensus on encapsulation
ciphertexts, so byte-equality with PQClean is a hard requirement.
Consumed by luxfi/crypto/hqc/gpu_cgo.go (cgo single-shot polymul path)
and luxfi/crypto/hqc/gpu.go (batch KEM dispatch).
50 lines
1.7 KiB
Go
50 lines
1.7 KiB
Go
// Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
//go:build !accel || !cgo
|
|
|
|
// Default (no-accel) build wires the GPU entry points to the CPU
|
|
// kernels when cgo is available, and to a pure-Go stub otherwise.
|
|
//
|
|
// The pure-Go stub returns ErrInvalidInput uniformly — code-based
|
|
// crypto requires cgo to reach the PQClean reference. This is the
|
|
// same posture as crypto/hqc itself: without `-tags=hqc_pqclean` and
|
|
// cgo, every operation errors out cleanly. Callers should fall back
|
|
// to the crypto/hqc CPU path (which has its own cgo gate) and not
|
|
// rely on the accel surface to produce KEM ciphertexts.
|
|
|
|
package code
|
|
|
|
import (
|
|
"github.com/luxfi/accel"
|
|
)
|
|
|
|
// hqcKeypairGPU is a no-op stub when accel/cgo is not enabled.
|
|
// Production deployments link with cgo so this branch is unreachable
|
|
// at runtime; it exists to keep `GOWORK=off go build ./...` working
|
|
// on hosts without a C compiler.
|
|
func hqcKeypairGPU(sess *accel.Session, mode Mode, pks, sks, seeds []byte, count int) error {
|
|
_ = sess
|
|
return hqcKeypairCPU(mode, pks, sks, seeds, count)
|
|
}
|
|
|
|
func hqcEncapsGPU(sess *accel.Session, mode Mode, cts, sss, pks, seeds []byte, count int) error {
|
|
_ = sess
|
|
return hqcEncapsCPU(mode, cts, sss, pks, seeds, count)
|
|
}
|
|
|
|
func hqcDecapsGPU(sess *accel.Session, mode Mode, sss, cts, sks []byte, count int) error {
|
|
_ = sess
|
|
return hqcDecapsCPU(mode, sss, cts, sks, count)
|
|
}
|
|
|
|
func gf2PolymulGPU(sess *accel.Session, mode Mode, c, a, b []uint64, count int) error {
|
|
_ = sess
|
|
return gf2PolymulCPU(mode, c, a, b, count)
|
|
}
|
|
|
|
func rsDecodeGPU(sess *accel.Session, mode Mode, msgs, cdws []byte, count int) error {
|
|
_ = sess
|
|
return rsDecodeCPU(mode, msgs, cdws, count)
|
|
}
|