mirror of
https://github.com/luxfi/corona.git
synced 2026-07-27 02:50:34 +00:00
The Pedersen-VSS DKG share-dealing now runs entirely on github.com/luxfi/dkg
(proven byte-identical at cutover); corona's own copy is dead. Remove it and its
now-orphaned tooling, keeping only corona-specific code (Ringtail signing, β
rounding, Path (a) finalize — all in sign/, utils/, keyera/, untouched).
Deleted:
- dkg2/ (the whole package: Round1/Round2/commits/complaint/GPU dispatch).
- cmd/dkg2_oracle/ (the dkg2 KAT generator; the DKG KAT now lives in
luxfi/dkg's own ring/vss vectors).
- keyera/cutover_gate_test.go (the transitional dkg2-vs-vss equality gate; its
job is done — permanent byte-stability is pinned by the golden KAT, and the
PIN-4 convention assertion is preserved dkg2-free in pin4_convention_test.go).
Updated:
- cmd/cross_runtime_oracle drops the dkg2 manifest leg (the luxcpp C++ dkg2
cross-runtime gate migrates to luxfi/dkg separately — flagged, not silently
broken).
- keyera/reanchor doc comments + threshold bench comment point at luxfi/dkg.
go build ./... + go test ./... -count=1 green (13 ok / 0 fail), go vet + gofmt
clean. The golden byte-stability KAT + Bootstrap→sign→verify + dishonest-dealer
abort all still pass on the vss path.
133 lines
3.9 KiB
Go
133 lines
3.9 KiB
Go
// Package main is the Corona cross-runtime KAT oracle.
|
|
//
|
|
// Emits a single JSON manifest at <out>/cross_runtime_kat.json that ties
|
|
// together the canonical Corona KATs (sign, reshare) with
|
|
// the SHA-256 of each individual KAT file. The C++ side
|
|
// (luxcpp/crypto/corona/test/cross_runtime_test.cpp) replays each KAT
|
|
// in C++ and verifies byte-equality; running this oracle first then
|
|
// the C++ test is the "Go → C++" direction of the gate.
|
|
//
|
|
// Reverse direction (C++ → Go) is handled by:
|
|
// - luxcpp/crypto/corona/cmd/cross_runtime_oracle/ (C++ writer)
|
|
// - lux/pulsar/cmd/cross_runtime_verify/ (Go reader)
|
|
//
|
|
// Determinism is required. Two runs with the same MasterSeed produce
|
|
// byte-equal manifests AND byte-equal individual KAT JSON files.
|
|
package main
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
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 sha256File(path string) (string, int64, error) {
|
|
b, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return "", 0, err
|
|
}
|
|
h := sha256.Sum256(b)
|
|
return hex.EncodeToString(h[:]), int64(len(b)), nil
|
|
}
|
|
|
|
func runOracle(cmd string, args []string) error {
|
|
c := exec.Command("go", append([]string{"run", cmd}, args...)...)
|
|
c.Stdout = os.Stdout
|
|
c.Stderr = os.Stderr
|
|
return c.Run()
|
|
}
|
|
|
|
func main() {
|
|
out := flag.String("out", "", "output directory (creates cross_runtime_kat.json + per-KAT files via the per-KAT oracles)")
|
|
flag.Parse()
|
|
if *out == "" {
|
|
fmt.Fprintln(os.Stderr, "usage: cross_runtime_oracle --out <dir>")
|
|
os.Exit(2)
|
|
}
|
|
|
|
if err := os.MkdirAll(*out, 0o755); err != nil {
|
|
fmt.Fprintf(os.Stderr, "mkdir: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// 1. Emit the per-KAT JSONs by invoking each per-KAT oracle.
|
|
if err := runOracle("./cmd/sign_oracle", []string{"--out", *out}); err != nil {
|
|
fmt.Fprintf(os.Stderr, "sign_oracle: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
// reshare_oracle doesn't expose --out; it writes to a hardcoded location
|
|
// in luxcpp/crypto. For the cross-runtime gate we hash the canonical path.
|
|
//
|
|
// The Pedersen-DKG KAT is no longer emitted here: corona's DKG share-dealing
|
|
// now runs on github.com/luxfi/dkg (vss), which owns its own ring/vss KATs.
|
|
// The luxcpp C++ dkg2 cross-runtime leg migrates to luxfi/dkg separately.
|
|
signPath := filepath.Join(*out, "sign_kat.json")
|
|
resharePath := filepath.Join(luxcppDir(), "crypto/corona/test/kat/reshare_kat.json")
|
|
|
|
files := []struct {
|
|
name string
|
|
path string
|
|
}{
|
|
{"sign", signPath},
|
|
{"reshare", resharePath},
|
|
}
|
|
|
|
m := manifest{
|
|
Description: "Corona cross-runtime KAT manifest. SHA-256 of each canonical Go-emitted KAT JSON. The C++ cross_runtime_test consumes the same paths and asserts byte-equality at every entry; this manifest pins the Go-side bytes so any drift produces a SHA-256 mismatch caught by the gate.",
|
|
Direction: "go-to-cpp",
|
|
}
|
|
for _, f := range files {
|
|
sum, sz, err := sha256File(f.path)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "hash %s: %v\n", f.path, err)
|
|
os.Exit(1)
|
|
}
|
|
m.Files = append(m.Files, manifestEntry{
|
|
Name: f.name,
|
|
Path: f.path,
|
|
Sha256: sum,
|
|
NumBytes: sz,
|
|
})
|
|
}
|
|
|
|
mPath := filepath.Join(*out, "cross_runtime_kat.json")
|
|
mBytes, err := json.MarshalIndent(m, "", " ")
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "marshal: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
if err := os.WriteFile(mPath, mBytes, 0o644); err != nil {
|
|
fmt.Fprintf(os.Stderr, "write: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Printf("wrote %s (%d entries)\n", mPath, len(m.Files))
|
|
}
|
|
|
|
// luxcppDir returns the luxcpp source root. LUXCPP_DIR overrides the default
|
|
// of $HOME/work/luxcpp.
|
|
func luxcppDir() string {
|
|
if d := os.Getenv("LUXCPP_DIR"); d != "" {
|
|
return d
|
|
}
|
|
return os.ExpandEnv("$HOME/work/luxcpp")
|
|
}
|