Files
zeekay d1ddbcc84d quasar: MagnetarQuorumCert — trustless Track-A hash-based PQ lane (type + evidence kind)
Magnetar-Quorum (Track A) is the trustless-TODAY hash-based PQ finality lane:
validators hold INDEPENDENT ordinary FIPS-205 SLH-DSA keypairs (no DKG, no
dealer, no shared seed) and sign the same consensus subject; a P3Q rollup
proves a >= policy-threshold WEIGHTED quorum of those independent signatures
verified under the STOCK FIPS-205 verifier. It sidesteps threshold SLH-DSA
entirely — trustless the moment the rollup relation is sound.

This commit adds the value-level vocabulary and the wire type:
  - MagnetarQuorumCert{SuiteID, RollupRoot, CertSet, Proof} + deterministic,
    fail-closed codec (magnetar_codec.go), mirroring the P3Q ML-DSA pattern.
  - MagnetarRollupRoot + magnetarPublicStatement domain-separated commitments.
  - BuildMagnetarQuorumCert (Direct constructor) enforcing the cross-family
    diversity invariant: every signer record must be SLH-DSA (FIPS-205).
  - EvidenceMagnetarRollup evidence mode (own primitive, not bolted onto Pulsar).
  - EvidenceMagnetarP3QSLHDSARollup kind 'magnetar-p3q-slhdsa-rollup' + lane
    mapping to (LegMagnetarSLHDSA, EvidenceMagnetarRollup).
  - Suites Lux-Magnetar-SLHDSA{192s,256s}-Direct-v1 + -192s-STARK-v1 (succinct
    seam). NO classical-assumption suite — a hash-based diversity lane must
    never rest on a pairing.

Composes the audited, scheme-generic WeightedQuorumCert (which already
dispatches SLH-DSA records to stock magnetar.VerifyCtx); verifier wired next.
2026-06-28 00:57:30 -07:00

61 lines
1.9 KiB
Go

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// magnetar_codec.go — deterministic, fail-closed wire codec for the
// Magnetar-Quorum rollup payload. Mirrors p3q_codec.go: bounds-checked, strict
// trailing-byte rejection, one canonical encoding per value, NEVER a panic and
// NEVER unbounded work (I13).
package quasar
// encodeMagnetarQuorumCert encodes a MagnetarQuorumCert deterministically:
//
// suite_id_len:4 suite_id:S
// rollup_root:32
// cert_set_len:4 cert_set:C (marshalled SLH-DSA WeightedQuorumCert; empty for succinct)
// proof_len:4 proof:R (succinct proof; empty for Direct)
func encodeMagnetarQuorumCert(mc *MagnetarQuorumCert) []byte {
buf := make([]byte, 0, 4+len(mc.SuiteID)+32+4+len(mc.CertSet)+4+len(mc.Proof))
buf = appendU32(buf, uint32(len(mc.SuiteID)))
buf = append(buf, mc.SuiteID...)
buf = append(buf, mc.RollupRoot[:]...)
buf = appendU32(buf, uint32(len(mc.CertSet)))
buf = append(buf, mc.CertSet...)
buf = appendU32(buf, uint32(len(mc.Proof)))
buf = append(buf, mc.Proof...)
return buf
}
// DecodeMagnetarQuorumCert is the strict inverse. Every read is bounds-checked
// by the shared qcReader; a truncated frame, an over-long length prefix, or any
// trailing byte is ErrEvidenceWireCorrupt.
func DecodeMagnetarQuorumCert(data []byte) (*MagnetarQuorumCert, error) {
r := &qcReader{buf: data}
suiteID, err := r.lenPrefixed()
if err != nil {
return nil, ErrEvidenceWireCorrupt
}
var root [32]byte
if err := r.read32(&root); err != nil {
return nil, ErrEvidenceWireCorrupt
}
certSet, err := r.lenPrefixed()
if err != nil {
return nil, ErrEvidenceWireCorrupt
}
proof, err := r.lenPrefixed()
if err != nil {
return nil, ErrEvidenceWireCorrupt
}
if len(r.buf) != 0 {
return nil, ErrEvidenceWireCorrupt
}
return &MagnetarQuorumCert{
SuiteID: string(suiteID),
RollupRoot: root,
CertSet: certSet,
Proof: proof,
}, nil
}