mirror of
https://github.com/luxfi/threshold.git
synced 2026-10-30 15:15:53 +00:00
protocols/pulsar/ had no _test.go even though the surface is what luxfi/consensus imports (per the alias-layering comment in pulsar.go). The corresponding protocols/corona/ package was in the same shape; PR #22 (this session) adds tests there. This PR brings pulsar up to parity. Adds protocols/pulsar/pulsar_test.go (13 tests, all PASS in 0.013s): ParamsFor / MustParamsFor (4 + 3 subtests): - ParamsFor(ModeUnspecified) -> error, nil params - ParamsFor(P44/P65/P87) -> returns the pre-built ParamsXX *Params singleton by pointer equality (cache-keying contract) - MustParamsFor(ModeUnspecified) panics - MustParamsFor(ModeP65) returns ParamsP65 singleton GenerateIdentity / NewIdentityDirectory (3): - GenerateIdentity(rand.Reader) returns non-nil IdentityKey - Two generations from equivalent deterministic seeds both succeed - NewIdentityDirectory({}) does not panic — pins the alias contract Single-party FIPS 204 round-trip (5): - GenerateKey(ParamsP65, rand.Reader) returns non-nil PrivateKey - Sign + VerifyCtx happy path - VerifyCtx rejects a tampered message - VerifyCtx rejects a wrong context and still verifies the right one The VerifyCtx tests use a small test-local helper publicKeyFromPrivate that calls sk.Public() through a runtime interface assertion, so the test stays stable if the kernel reshapes the PrivateKey API. Run: go test ./protocols/pulsar/ -count=1 -v -timeout 120s PASS - 13/13, 0.013s