Commit a43a16c
authored
feat(frost/signing): RFC-21 Phase 1B -- optional AttemptContextHash on protocol messages (#3964)
## Summary
RFC-21 Phase 1B: extends the three FROST/tbtc-signer protocol message
types with an optional 32-byte `AttemptContextHash` field that binds
each message to the deterministic `AttemptContext` introduced in
Phase 1A (#3963).
**No protocol behaviour change yet.** Receivers do not match the hash
against a locally-computed context in this phase; that lands later
behind a build tag. Phase 1B is purely the wire-format extension.
Stacked on #3963.
## Affected messages
- `nativeFROSTRoundOneCommitmentMessage`
- `nativeFROSTRoundTwoSignatureShareMessage`
- `buildTaggedTBTCSignerRoundContributionMessage`
## Migration contract
| Property | Behaviour |
|---|---|
| Field tag | `json:\"attemptContextHash,omitempty\"` -- absent on the
wire when the sender has not bound the message. |
| Old peer compatibility | Pre-Phase-1B JSON unmarshals cleanly; field
reports as absent via `GetAttemptContextHash`. |
| New peer compatibility | New JSON with a 32-byte hash field
unmarshals; `GetAttemptContextHash` returns `(hash, true)`. |
| Validation | Unmarshal rejects wrong-length hash fields; len must be
exactly 32 or absent. |
| Equal-or-reject | The existing first-write-wins helper
(`buildTaggedTBTCSignerRoundContributionMessagesEqual` from #3959) now
compares `AttemptContextHash` bytewise, so a peer mutating the binding
mid-stream is reported as a conflict. |
## Why split from Phase 1A
Phase 1A (#3963) added the `AttemptContext` type with no consumers.
Phase 1B (this PR) adds the wire-format extension. Splitting keeps the
type definition reviewable independently of the wire change, since
the wire change touches existing message structs in production code
paths.
## Test coverage
17 new tests under `pkg/frost/signing/attempt_context_binding_test.go`:
- `TestValidateAttemptContextHashField_AcceptsAbsentOrCorrectLength` (3
sub-tests)
- `TestValidateAttemptContextHashField_RejectsWrongLength` (3 sub-tests)
- `TestAttemptContextHashField_ArrayRoundTrip`
- `TestAttemptContextHashField_ArrayToArrayAbsent`
- `TestAttemptContextHashField_FromArrayDoesNotAliasCaller`
- `TestRoundOneCommitmentMessage_OptionalFieldRoundTrip` (2 sub-tests)
- `TestRoundOneCommitmentMessage_BackwardCompatWithOldJSON`
- `TestRoundOneCommitmentMessage_RejectsWrongLengthHashField`
- `TestRoundTwoSignatureShareMessage_OptionalFieldRoundTrip`
- `TestRoundTwoSignatureShareMessage_BackwardCompatWithOldJSON`
- `TestRoundTwoSignatureShareMessage_RejectsWrongLengthHashField`
-
`TestBuildTaggedTBTCSignerRoundContributionMessage_OptionalFieldRoundTrip`
-
`TestBuildTaggedTBTCSignerRoundContributionMessage_BackwardCompatWithOldJSON`
-
`TestBuildTaggedTBTCSignerRoundContributionMessage_RejectsWrongLengthHashField`
-
`TestBuildTaggedTBTCSignerRoundContributionMessagesEqual_HashFieldDifferentiates`
- `TestRoundOneCommitmentMessage_JSONEncoderOmitsAbsentField`
All pass under:
- `go test -tags 'frost_native frost_tbtc_signer' ./pkg/frost/...`
- `pkg/tbtc` regression subset:
`go test -tags 'frost_native frost_tbtc_signer' -run
'TestConfigureFrostSigningBackend|TestNewNode_ConfiguresFrostSigningBackend|TestSigningExecutor_Sign|TestRegisterSignerMaterialResolverForBuild'
./pkg/tbtc/`
## Test plan
- [ ] CI green.
- [ ] Reviewer confirms the `omitempty`/optional contract is what we
want as the *Phase 1* default (i.e., we are intentionally not
rejecting messages that lack the field).
- [ ] Reviewer confirms it's OK for the equal-or-reject helper to
now treat \"contribution with hash\" and \"contribution without
hash\" as unequal during the migration window (sketched in
Migration contract table above).4 files changed
Lines changed: 502 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments