emit_modarith_kat

command
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Copyright (c) 2026 Lux Industries Inc. SPDX-License-Identifier: BSD-3-Clause

emit_modarith_kat — produces the canonical cross-runtime KAT bundle for luxfi/math/modarith. The C++ side at luxcpp/crypto/math/test/ modarith_cross_runtime_test.cpp reads the same JSON and asserts byte-equal Montgomery / Add / round-trip behavior on every entry.

LP-107 Phase 6.3: Go emits → C++ verifies. Cross-runtime release gate for modular arithmetic.

Usage:

go run ./cmd/emit_modarith_kat --out testdata/modarith_kat.json

Each entry's input is a packed little-endian byte stream:

"MontMulMod/...":  q (8) || a (8) || b (8)   -> output = MulMod(a,b,q) (8)
"AddMod/...":      q (8) || a (8) || b (8)   -> output = (a+b) mod q  (8)
"MontgomeryRoundTrip/...": q (8) || x (8)    -> output = x (8)

Determinism: operand stream is the SHA-256 hash chain of a fixed seed string. Same emit run → byte-equal JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL