From e6c0872415e09a11f7783e9a4ab4b6af81781f2d Mon Sep 17 00:00:00 2001 From: Hanzo AI Date: Tue, 2 Jun 2026 11:38:55 -0700 Subject: [PATCH] fix: gofmt -s across repo (CI format check) --- codec/kat.go | 2 +- modarith/modarith.go | 6 +++--- ntt/subring/subring_test.go | 6 +++--- params/params.go | 12 ++++++------ sample/cmd/emit_sample_kat/main.go | 15 ++++++++------- sample/kat_test.go | 6 +++--- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/codec/kat.go b/codec/kat.go index 18eafdd..8f767df 100644 --- a/codec/kat.go +++ b/codec/kat.go @@ -50,7 +50,7 @@ type KATEntry struct { // KATBundle is a collection of entries written to a JSON file at a // stable path. C++ replay tests load the same file by path. type KATBundle struct { - Schema string `json:"schema"` // "lux.math.kat.v1" + Schema string `json:"schema"` // "lux.math.kat.v1" Entries []KATEntry `json:"entries"` } diff --git a/modarith/modarith.go b/modarith/modarith.go index 40da294..e3a46fc 100644 --- a/modarith/modarith.go +++ b/modarith/modarith.go @@ -80,8 +80,8 @@ func computeQInv(q uint64) uint64 { // big.Int allocation is amortized. func computeR2(q uint64) uint64 { one := big.NewInt(1) - r2 := new(big.Int).Lsh(one, 128) // 2^128 - r2.Mod(r2, new(big.Int).SetUint64(q)) // 2^128 mod q + r2 := new(big.Int).Lsh(one, 128) // 2^128 + r2.Mod(r2, new(big.Int).SetUint64(q)) // 2^128 mod q return r2.Uint64() } @@ -90,7 +90,7 @@ func computeR2(q uint64) uint64 { func computeBarrett(q uint64) [2]uint64 { one := big.NewInt(1) 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))) high := new(big.Int).Rsh(mu, 64) diff --git a/ntt/subring/subring_test.go b/ntt/subring/subring_test.go index f066a42..d8604fd 100644 --- a/ntt/subring/subring_test.go +++ b/ntt/subring/subring_test.go @@ -10,8 +10,8 @@ import ( // pulsarN256 is the Pulsar/LP-073 NTT instance: N=256, Q=2^48 + 4*N + 1. const ( - pulsarN = 256 - pulsarQ = uint64(0x1000000004A01) + pulsarN = 256 + pulsarQ = uint64(0x1000000004A01) ) // 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) { xLo, xHi := x&0xffffffff, x>>32 yLo, yHi := y&0xffffffff, y>>32 - t := xLo*yLo + t := xLo * yLo lo = t & 0xffffffff t = (t >> 32) + xHi*yLo w1 := t & 0xffffffff diff --git a/params/params.go b/params/params.go index fb183bc..f191075 100644 --- a/params/params.go +++ b/params/params.go @@ -194,12 +194,12 @@ func (b BackendID) Validate() error { // implementation_version) tuple so cross-runtime replay can match // like-for-like. type KATHeader struct { - ParameterSet string `json:"parameter_set"` - ModulusID ModulusID `json:"modulus_id"` - BackendID BackendID `json:"backend_id"` - HashSuiteID HashSuiteID `json:"hash_suite_id"` - ImplementationName string `json:"implementation_name"` - ImplementationVersion string `json:"implementation_version"` + ParameterSet string `json:"parameter_set"` + ModulusID ModulusID `json:"modulus_id"` + BackendID BackendID `json:"backend_id"` + HashSuiteID HashSuiteID `json:"hash_suite_id"` + ImplementationName string `json:"implementation_name"` + ImplementationVersion string `json:"implementation_version"` } // Validate ensures every required field is set and known. diff --git a/sample/cmd/emit_sample_kat/main.go b/sample/cmd/emit_sample_kat/main.go index 9d678ce..9dad2d3 100644 --- a/sample/cmd/emit_sample_kat/main.go +++ b/sample/cmd/emit_sample_kat/main.go @@ -15,11 +15,12 @@ // go run ./cmd/emit_sample_kat --out testdata/sample_kat.json // // Each entry contains: -// Test: "Uniform/q=PulsarQ/i=N" -> param: q -// "Ternary/q=PulsarQ/density=0.50/i=N" -> param: q, density -// "CenteredBinomial/q=PulsarQ/eta=2/i=N" -> param: q, eta -// InputHex: raw entropy bytes (4096) from a SHA-256 hash chain -// OutputHex: first 64 samples, packed little-endian (512 bytes) +// +// Test: "Uniform/q=PulsarQ/i=N" -> param: q +// "Ternary/q=PulsarQ/density=0.50/i=N" -> param: q, density +// "CenteredBinomial/q=PulsarQ/eta=2/i=N" -> param: q, eta +// 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 // emit runs are byte-stable. @@ -42,8 +43,8 @@ const ( PulsarQ uint64 = 0x1000000004A01 NTT998 uint64 = 998244353 - NumSamples = 64 - EntropyBytes = 4096 + NumSamples = 64 + EntropyBytes = 4096 ) func main() { diff --git a/sample/kat_test.go b/sample/kat_test.go index 169c8ab..097133f 100644 --- a/sample/kat_test.go +++ b/sample/kat_test.go @@ -15,9 +15,9 @@ import ( ) const ( - katNumSamples = 64 - katPulsarQ = uint64(0x1000000004A01) - katNTT998 = uint64(998244353) + katNumSamples = 64 + katPulsarQ = uint64(0x1000000004A01) + katNTT998 = uint64(998244353) ) // TestKATBundle_RoundTrip — load the JSON KAT bundle emitted by