mirror of
https://github.com/luxfi/coronad.git
synced 2026-10-30 16:59:09 +00:00
github.com/luxfi/coronad existed only as loose files: no .git, no history, no
remote. Invisible to any sweep that looks for a .git directory, and an rm -rf
would have destroyed it unrecoverably.
Includes two dependency repairs.
1. It did not build: "unknown revision v1.16.98" — the v1.16.x line was DELETED
from github.com/luxfi/geth. The requirement is baked into published modules
(crypto/constants/warp pin the dead tag, some also `exclude` the
alternative), so requiring crypto v1.20.2 / constants v1.6.2 / warp v1.24.1
is what escapes it.
2. Dropped two replace directives pointing at absolute paths on one disk:
replace github.com/luxfi/corona => /Users/z/work/lux/corona
replace github.com/luxfi/warp => /Users/z/work/lux/warp
Those would have made this module resolvable ONLY on this machine — CI or
any other checkout could never build it. They were also unnecessary: the
published versions the `require` lines already name (corona v0.10.4) build
and test clean without them.
Verified: go build ./... exits 0, go test ./... 1 ok / 0 fail.
The compiled coronad binary is ignored rather than committed.
NOTE: no remote — luxfi/coronad does not exist on GitHub. Still one copy.
62 lines
2.0 KiB
Go
62 lines
2.0 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package coronad_test
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/luxfi/coronad"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/ids"
|
|
|
|
"github.com/luxfi/corona/hash"
|
|
"github.com/luxfi/corona/reshare"
|
|
)
|
|
|
|
// TestActivationCircuitBreaker proves coronad can produce the post-reshare
|
|
// activation certificate the chain's VerifyActivation gate accepts: the
|
|
// committee threshold-signs the activation message under the group key, and the
|
|
// gate verifies both the transcript-hash binding and the signature.
|
|
func TestActivationCircuitBreaker(t *testing.T) {
|
|
const n, threshold = 3, 2
|
|
chainID := ids.ID{0xAC, 0x71, 0x7a}
|
|
era, err := coronad.Bootstrap(chainID, 3, threshold, committee(n), rand.Reader)
|
|
require.NoError(t, err)
|
|
|
|
// A reshare-transcript view (in production these come from the distributed
|
|
// commit/complaint exchange; here we build a consistent local view).
|
|
ti := reshare.TranscriptInputs{
|
|
ChainID: chainID[:],
|
|
KeyEraID: era.KeyEraID(),
|
|
NewEpochID: 1,
|
|
ThresholdOld: threshold,
|
|
ThresholdNew: threshold,
|
|
Variant: "reshare",
|
|
}
|
|
rt := reshare.ReshareTranscript{
|
|
QualifiedQuorum: []int{1, 2, 3},
|
|
}
|
|
msg := reshare.ActivationMessage{Transcript: ti, ReshareTranscript: rt}
|
|
|
|
cert, err := coronad.SignActivation(era, coronad.Loopback, msg)
|
|
require.NoError(t, err, "committee must produce an activation cert under the group key")
|
|
require.NotEmpty(t, cert.Signature)
|
|
|
|
suite := hash.Default()
|
|
localTH := ti.Hash(suite)
|
|
localEH := rt.Hash(suite)
|
|
|
|
require.NoError(t, coronad.VerifyActivationCert(era, cert, localTH, localEH),
|
|
"VerifyActivation must accept the committee's activation cert")
|
|
t.Log("PASS: coronad produced an activation cert; reshare.VerifyActivation accepted it")
|
|
|
|
// Negative: a chain whose local transcript differs rejects the cert.
|
|
var wrong [32]byte
|
|
wrong[0] = 0xFF
|
|
require.Error(t, coronad.VerifyActivationCert(era, cert, wrong, localEH),
|
|
"a mismatched local transcript hash must be rejected")
|
|
}
|