Documentation
¶
Overview ¶
Package crypto provides GPU-accelerated cryptographic operations.
All operations use the unified accel backend selection and fallback to CPU. Backend is selected at runtime via GPU_BACKEND env or auto-detection.
Index ¶
- Variables
- func AggregatePublicKeys(pks [][]byte) ([]byte, error)
- func AggregateSignatures(sigs [][]byte) ([]byte, error)
- func BatchVerify(sigType SigType, sigs, msgs, pubkeys [][]byte) ([]bool, error)
- func Hash(hashType HashType, inputs [][]byte) ([][32]byte, error)
- func MSM(curve Curve, scalars, points [][]byte) ([]byte, error)
- type Curve
- type HashType
- type SigType
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidInput = errors.New("crypto: invalid input") ErrBatchEmpty = errors.New("crypto: empty batch") ErrVerifyFailed = errors.New("crypto: verification failed") ErrUnsupported = errors.New("crypto: unsupported curve") )
var ErrCPUNotImplemented = errors.New("crypto_cpu: CPU verifier not implemented at this layer; route through the dispatch site's per-element oracle (lux/precompile/mldsa, etc.)")
ErrCPUNotImplemented is returned by batchVerifyCPU when no CPU reference is wired for the requested signature type. Surfacing this as an error (rather than a silent false) prevents the consensus-split shape Red Probe 7 identified.
Functions ¶
func AggregatePublicKeys ¶
AggregatePublicKeys aggregates BLS public keys.
func AggregateSignatures ¶
AggregateSignatures aggregates BLS signatures.
func BatchVerify ¶
BatchVerify verifies multiple signatures in parallel. Returns a slice of bools indicating which signatures are valid. Uses GPU acceleration when available, falls back to CPU.
func MSM ¶
MSM performs multi-scalar multiplication on the given curve.
result = sum_{i=0..n-1} scalars[i] * points[i]
scalars[i] is 32-byte LE canonical; points[i] is the curve's wire-encoded affine form (see Curve doc). The result is the same wire format as a single point on the curve.
Routes through the GPU when available; falls back to a CPU implementation (luxcpp/crypto via cgo when built with -tags=lux_crypto_native, otherwise a pure-Go gnark-crypto path).
Types ¶
type Curve ¶ added in v1.0.8
type Curve uint32
Curve identifies the elliptic curve for MSM (multi-scalar multiplication).
Wire encoding for MSM(curve, scalars, points):
secp256k1 / bn254 g1 / banderwagon : 32-byte BE x || 32-byte BE y per point (64 bytes total) bls12_381 g1 : 48-byte BE x || 48-byte BE y per point (96 bytes total) scalars : 32-byte LE canonical (all curves)
Identity (point at infinity) is wire-encoded as all-zero point bytes.
The numeric values match GPUKIT_CURVE_* in luxcpp/crypto so the cgo bridge passes them through unchanged.