fix: gofmt -s across repo (CI format check)

This commit is contained in:
2026-06-02 11:38:55 -07:00
parent e1738e43ba
commit 9445ee3b2b
6 changed files with 24 additions and 23 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ type KATEntry struct {
// KATBundle is a collection of entries written to a JSON file at a // KATBundle is a collection of entries written to a JSON file at a
// stable path. C++ replay tests load the same file by path. // stable path. C++ replay tests load the same file by path.
type KATBundle struct { type KATBundle struct {
Schema string `json:"schema"` // "lux.math.kat.v1" Schema string `json:"schema"` // "lux.math.kat.v1"
Entries []KATEntry `json:"entries"` Entries []KATEntry `json:"entries"`
} }
+3 -3
View File
@@ -80,8 +80,8 @@ func computeQInv(q uint64) uint64 {
// big.Int allocation is amortized. // big.Int allocation is amortized.
func computeR2(q uint64) uint64 { func computeR2(q uint64) uint64 {
one := big.NewInt(1) one := big.NewInt(1)
r2 := new(big.Int).Lsh(one, 128) // 2^128 r2 := new(big.Int).Lsh(one, 128) // 2^128
r2.Mod(r2, new(big.Int).SetUint64(q)) // 2^128 mod q r2.Mod(r2, new(big.Int).SetUint64(q)) // 2^128 mod q
return r2.Uint64() return r2.Uint64()
} }
@@ -90,7 +90,7 @@ func computeR2(q uint64) uint64 {
func computeBarrett(q uint64) [2]uint64 { func computeBarrett(q uint64) [2]uint64 {
one := big.NewInt(1) one := big.NewInt(1)
mu := new(big.Int).Lsh(one, 128) mu := new(big.Int).Lsh(one, 128)
mu.Quo(mu, new(big.Int).SetUint64(q)) // floor(2^128 / q) mu.Quo(mu, new(big.Int).SetUint64(q)) // floor(2^128 / q)
low := new(big.Int).And(mu, new(big.Int).SetUint64(^uint64(0))) low := new(big.Int).And(mu, new(big.Int).SetUint64(^uint64(0)))
high := new(big.Int).Rsh(mu, 64) high := new(big.Int).Rsh(mu, 64)
+3 -3
View File
@@ -10,8 +10,8 @@ import (
// pulsarN256 is the Pulsar/LP-073 NTT instance: N=256, Q=2^48 + 4*N + 1. // pulsarN256 is the Pulsar/LP-073 NTT instance: N=256, Q=2^48 + 4*N + 1.
const ( const (
pulsarN = 256 pulsarN = 256
pulsarQ = uint64(0x1000000004A01) pulsarQ = uint64(0x1000000004A01)
) )
// TestSubRing_RoundTrip exercises the full path: // TestSubRing_RoundTrip exercises the full path:
@@ -123,7 +123,7 @@ func MulModSlow(x, y, q uint64) uint64 {
func mul64(x, y uint64) (hi, lo uint64) { func mul64(x, y uint64) (hi, lo uint64) {
xLo, xHi := x&0xffffffff, x>>32 xLo, xHi := x&0xffffffff, x>>32
yLo, yHi := y&0xffffffff, y>>32 yLo, yHi := y&0xffffffff, y>>32
t := xLo*yLo t := xLo * yLo
lo = t & 0xffffffff lo = t & 0xffffffff
t = (t >> 32) + xHi*yLo t = (t >> 32) + xHi*yLo
w1 := t & 0xffffffff w1 := t & 0xffffffff
+6 -6
View File
@@ -194,12 +194,12 @@ func (b BackendID) Validate() error {
// implementation_version) tuple so cross-runtime replay can match // implementation_version) tuple so cross-runtime replay can match
// like-for-like. // like-for-like.
type KATHeader struct { type KATHeader struct {
ParameterSet string `json:"parameter_set"` ParameterSet string `json:"parameter_set"`
ModulusID ModulusID `json:"modulus_id"` ModulusID ModulusID `json:"modulus_id"`
BackendID BackendID `json:"backend_id"` BackendID BackendID `json:"backend_id"`
HashSuiteID HashSuiteID `json:"hash_suite_id"` HashSuiteID HashSuiteID `json:"hash_suite_id"`
ImplementationName string `json:"implementation_name"` ImplementationName string `json:"implementation_name"`
ImplementationVersion string `json:"implementation_version"` ImplementationVersion string `json:"implementation_version"`
} }
// Validate ensures every required field is set and known. // Validate ensures every required field is set and known.
+8 -7
View File
@@ -15,11 +15,12 @@
// go run ./cmd/emit_sample_kat --out testdata/sample_kat.json // go run ./cmd/emit_sample_kat --out testdata/sample_kat.json
// //
// Each entry contains: // Each entry contains:
// Test: "Uniform/q=PulsarQ/i=N" -> param: q //
// "Ternary/q=PulsarQ/density=0.50/i=N" -> param: q, density // Test: "Uniform/q=PulsarQ/i=N" -> param: q
// "CenteredBinomial/q=PulsarQ/eta=2/i=N" -> param: q, eta // "Ternary/q=PulsarQ/density=0.50/i=N" -> param: q, density
// InputHex: raw entropy bytes (4096) from a SHA-256 hash chain // "CenteredBinomial/q=PulsarQ/eta=2/i=N" -> param: q, eta
// OutputHex: first 64 samples, packed little-endian (512 bytes) // InputHex: raw entropy bytes (4096) from a SHA-256 hash chain
// OutputHex: first 64 samples, packed little-endian (512 bytes)
// //
// Entropy bytes are deterministic from the test name + index seed so // Entropy bytes are deterministic from the test name + index seed so
// emit runs are byte-stable. // emit runs are byte-stable.
@@ -42,8 +43,8 @@ const (
PulsarQ uint64 = 0x1000000004A01 PulsarQ uint64 = 0x1000000004A01
NTT998 uint64 = 998244353 NTT998 uint64 = 998244353
NumSamples = 64 NumSamples = 64
EntropyBytes = 4096 EntropyBytes = 4096
) )
func main() { func main() {
+3 -3
View File
@@ -15,9 +15,9 @@ import (
) )
const ( const (
katNumSamples = 64 katNumSamples = 64
katPulsarQ = uint64(0x1000000004A01) katPulsarQ = uint64(0x1000000004A01)
katNTT998 = uint64(998244353) katNTT998 = uint64(998244353)
) )
// TestKATBundle_RoundTrip — load the JSON KAT bundle emitted by // TestKATBundle_RoundTrip — load the JSON KAT bundle emitted by