Files
zeekay 5b7a06434c deps: dex v1.5.20 + crypto v1.19.26, regen go.sum (re-tag staleness); commit safekat KAT tooling
- bump dex v1.5.16 -> v1.5.20 (native D-Chain: dex_get_* RPC, dexcore permissionless resolver)
- bump crypto v1.19.24 -> v1.19.26
- regenerate go.sum: upstream re-tagged chains v1.3.18 / dex / zap after the old go.sum
  was recorded (node-gosum-retag-staleness); rm+tidy re-records CURRENT verified hashes
  (NOT a GONOSUM bypass — full re-verification against origin)
- commit cmd/safekat{dump,verify}: ground-truth KAT generator + on-precompile verifier
  for Corona(0x012206)/Pulsar(0x012204)/Magnetar(0x012207)/CGGMP21; fix safekatdump for
  corona v0.7.9 two-value Round1 (*Round1Data, error)
All library packages + KAT tests green (GOWORK=off CGO off).
2026-06-25 16:11:06 -07:00

76 lines
2.4 KiB
Go

// safekatverify feeds the KAT input blobs produced by safekatdump into the
// REAL precompile Run() implementations and asserts each returns the success
// word bytes32(1). This is the ground-truth check that the framed bytes the
// Solidity tests will assert against actually verify on-chain.
package main
import (
"encoding/hex"
"encoding/json"
"fmt"
"os"
"github.com/luxfi/geth/common"
cggmp21 "github.com/luxfi/precompile/cggmp21"
corona "github.com/luxfi/precompile/corona"
magnetar "github.com/luxfi/precompile/magnetar"
pulsar "github.com/luxfi/precompile/pulsar"
)
type katOut struct {
Scheme string `json:"scheme"`
InputHex string `json:"input"`
}
func main() {
var kats []katOut
if err := json.NewDecoder(os.Stdin).Decode(&kats); err != nil {
fmt.Fprintln(os.Stderr, "decode:", err)
os.Exit(1)
}
fail := false
for _, k := range kats {
input, err := hex.DecodeString(k.InputHex)
if err != nil {
fmt.Println(k.Scheme, "hex decode FAIL", err)
fail = true
continue
}
switch k.Scheme {
case "pulsar":
// pulsar Run returns (nil, gas, nil) on success, typed error on fail.
_, _, err := pulsar.PulsarVerifyPrecompile.Run(nil, common.Address{}, pulsar.ContractPulsarVerifyAddress, input, 50_000_000, true)
report("pulsar", err == nil, err, &fail)
case "magnetar":
out, _, err := magnetar.MagnetarVerifyPrecompile.Run(nil, common.Address{}, magnetar.ContractMagnetarVerifyAddress, input, 50_000_000, true)
ok := err == nil && len(out) == 32 && out[31] == 1
report("magnetar", ok, err, &fail)
case "corona":
out, _, err := corona.CoronaThresholdPrecompile.Run(nil, common.Address{}, corona.ContractCoronaThresholdAddress, input, 50_000_000, true)
ok := err == nil && len(out) == 32 && out[31] == 1
report("corona", ok, err, &fail)
case "cggmp21":
out, _, err := cggmp21.CGGMP21VerifyPrecompile.Run(nil, common.Address{}, cggmp21.ContractCGGMP21VerifyAddress, input, 50_000_000, true)
ok := err == nil && len(out) == 32 && out[31] == 1
report("cggmp21", ok, err, &fail)
default:
fmt.Println("unknown scheme", k.Scheme)
fail = true
}
}
if fail {
os.Exit(1)
}
fmt.Println("ALL KAT INPUTS VERIFY AGAINST REAL PRECOMPILES")
}
func report(name string, ok bool, err error, fail *bool) {
if ok {
fmt.Printf("%-10s VERIFY=1 (real precompile accepted KAT input)\n", name)
} else {
fmt.Printf("%-10s VERIFY=FAIL err=%v\n", name, err)
*fail = true
}
}