Files
math/sample/kat.go
T
Hanzo AI b0c6b9c916 LP-107 Phase 6.3-6.5: KAT extension — modarith / ntt / sample
Replicates the codec cross-runtime KAT pattern across the rest of the
math substrate. Each package now ships:

* kat.go — KATEntry/KATBundle aliases pointing at codec.KATEntry/
  codec.KATBundle (one schema for the whole substrate).
* cmd/emit_*_kat/main.go — Go-side emitter that produces the
  canonical bundle.
* kat_test.go — Go replay test (TestKATBundle_RoundTrip*).
* testdata/*_kat.json — emitted bundle, byte-stable across runs.

modarith/cmd/emit_modarith_kat: ~300 entries
  - 100 MontMulMod cross-checked against MulMod
  - 100 AddMod across deterministic random pairs
  - 100 MontgomeryRoundTrip (ToMontgomery -> FromMontgomery)
  - Multiple moduli (PulsarQ, NTT998).

ntt/cmd/emit_ntt_kat: ~50 entries
  - input: 256 random uint64 mod PulsarQ
  - output: NTT(input) byte-stream + SHA-256 commitment
  - Pulsar N=256 ring.

sample/cmd/emit_sample_kat: ~30 entries
  - Uniform / Ternary / CenteredBinomial across param sweeps
  - Each entry records the seed + first 64 sampled values.

Tests: GOWORK=off go test ./modarith/ ./ntt/ ./sample/ -> all PASS.

C++ replay tests follow in luxcpp/crypto commit on this same branch.
2026-05-04 10:20:32 -07:00

37 lines
1.1 KiB
Go

// Copyright (c) 2026 Lux Industries Inc.
// SPDX-License-Identifier: BSD-3-Clause
package sample
// LP-107 Phase 6.5 cross-runtime KAT release gate.
//
// sample re-uses the canonical KATEntry / KATBundle types defined in
// luxfi/math/codec.
import "github.com/luxfi/math/codec"
// KATEntry is an alias for codec.KATEntry.
type KATEntry = codec.KATEntry
// KATBundle is an alias for codec.KATBundle.
type KATBundle = codec.KATBundle
// KATSchemaV1 is the canonical bundle schema string.
const KATSchemaV1 = codec.KATSchemaV1
// WriteKATBundleFile writes a bundle to disk; thin pass-through.
func WriteKATBundleFile(path string, b *KATBundle) error {
return codec.WriteKATBundleFile(path, b)
}
// ReadKATBundleFile reads a bundle from disk; thin pass-through.
func ReadKATBundleFile(path string) (*KATBundle, error) {
return codec.ReadKATBundleFile(path)
}
// HexEncode is the canonical hex encoder shared with codec.
func HexEncode(b []byte) string { return codec.HexEncode(b) }
// HexDecode is the inverse.
func HexDecode(s string) ([]byte, error) { return codec.HexDecode(s) }