mirror of
https://github.com/luxfi/corona.git
synced 2026-07-27 02:50:34 +00:00
Leftover from Corona's "Pulsar-R" lineage. Pulsar (M-LWE) and Corona
(R-LWE) are independent constructions with separate hardness assumptions,
so their cSHAKE personalisation strings must be distinct.
Changes (Go, non-luxcpp):
- hash tags: PULSAR-HC-v1 -> CORONA-HC-v1, etc. (HU, TRANSCRIPT, PRF, MAC, PAIRWISE)
- profile IDs: "Pulsar-SHA3" -> "Corona-SHA3", "Pulsar-BLAKE3" -> "Corona-BLAKE3"
- context strings: pulsar.dkg2.A.v1 -> corona.dkg2.A.v1, etc.
- env vars: PULSAR_RESHARE_KAT_PATH -> CORONA_RESHARE_KAT_PATH, etc.
- struct names: pulsarSHA3 -> coronaSHA3
- KAT derive roots: sign_e2e_pulsar -> sign_e2e_corona
What's preserved (different scope):
- luxcpp/crypto/pulsar/* path references in comments (separate repo,
out of scope; the C++ side will rename in its own commit)
- Cross-runtime KAT files on disk (will regenerate next CI run)
All 11 packages test green: dkg, dkg2, hash, keyera, networking,
primitives, reshare, sign, threshold, utils, wire.
96 lines
2.4 KiB
Go
96 lines
2.4 KiB
Go
// Package main is the Go-side verifier for the Corona cross-runtime
|
|
// KAT gate (C++ → Go direction).
|
|
//
|
|
// Reads a C++-emitted manifest produced by
|
|
// luxcpp/crypto/corona/cmd/cross_runtime_oracle and confirms that each
|
|
// SHA-256 digest in the manifest matches the bytes Go observes for the
|
|
// same file path. Mismatch → non-zero exit code.
|
|
//
|
|
// Usage:
|
|
//
|
|
// cross_runtime_verify --manifest <path/to/cross_runtime_kat_cpp.json>
|
|
//
|
|
// This is the reverse leg of the cross-runtime gate. The forward leg
|
|
// (Go → C++) lives in luxcpp/crypto/corona/test/cross_runtime_test.cpp;
|
|
// CTest target `corona_cross_runtime_kat` exercises both directions.
|
|
package main
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type manifestEntry struct {
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
Sha256 string `json:"sha256"`
|
|
NumBytes int64 `json:"num_bytes"`
|
|
}
|
|
|
|
type manifest struct {
|
|
Description string `json:"description"`
|
|
Direction string `json:"direction"`
|
|
Files []manifestEntry `json:"files"`
|
|
}
|
|
|
|
func main() {
|
|
mPath := flag.String("manifest", "", "path to cross-runtime manifest JSON")
|
|
flag.Parse()
|
|
if *mPath == "" {
|
|
fmt.Fprintln(os.Stderr, "usage: cross_runtime_verify --manifest <path>")
|
|
os.Exit(2)
|
|
}
|
|
|
|
mBytes, err := os.ReadFile(*mPath)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "read manifest: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
var m manifest
|
|
if err := json.Unmarshal(mBytes, &m); err != nil {
|
|
fmt.Fprintf(os.Stderr, "parse manifest: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Printf("=== cross_runtime_verify (direction=%s) ===\n", m.Direction)
|
|
fmt.Printf("manifest: %s\n", *mPath)
|
|
fmt.Printf("entries: %d\n\n", len(m.Files))
|
|
|
|
failed := 0
|
|
passed := 0
|
|
for _, f := range m.Files {
|
|
b, err := os.ReadFile(f.Path)
|
|
if err != nil {
|
|
fmt.Printf(" [%-8s] FAIL read: %v\n", f.Name, err)
|
|
failed++
|
|
continue
|
|
}
|
|
if int64(len(b)) != f.NumBytes {
|
|
fmt.Printf(" [%-8s] FAIL size: got=%d want=%d\n",
|
|
f.Name, len(b), f.NumBytes)
|
|
failed++
|
|
continue
|
|
}
|
|
sum := sha256.Sum256(b)
|
|
got := hex.EncodeToString(sum[:])
|
|
if got != f.Sha256 {
|
|
fmt.Printf(" [%-8s] FAIL sha256\n want: %s\n got: %s\n",
|
|
f.Name, f.Sha256, got)
|
|
failed++
|
|
continue
|
|
}
|
|
fmt.Printf(" [%-8s] PASS sha256=%s..\n", f.Name, got[:16])
|
|
passed++
|
|
}
|
|
|
|
fmt.Printf("\nresult: %d/%d passed\n", passed, passed+failed)
|
|
if failed > 0 {
|
|
os.Exit(1)
|
|
}
|
|
}
|