Fix KMS-005: Convert AckData to use addresses for both player and dealer - #46
Conversation
|
Claude finished @mcclurejt's task in 3m 56s —— View job Code Review — Fix KMS-005: AckData Uses Addresses for Player and Dealer
SummaryThis PR correctly replaces the int64 node ID based identifiers in Bugs / Issues1. The function signature still accepts 2. Latent proof := &merkle.MerkleProof{
Leaf: leafHash,
Proof: broadcast.MerkleProof,
// LeafIndex defaults to 0
}When Phase 7 wires in the actual 3. Merkle proof is not cryptographically verified ( if len(proof.Proof) == 0 {
return fmt.Errorf("merkle proof is empty")
}The proof is only checked for non-emptiness, not verified against the root. The comment says "Phase 7 will add on-chain root from contract" — that's fine as a phased approach, but the function should be clearly marked incomplete (e.g. a Code Quality4. Field-order asymmetry between signing message and merkle leaf
5. The two functions differ only in the path string ( Testing6. Integration test still passes synthetic dealer address ( acks := testutil.CreateTestAcknowledgements(t, 3, 5, 99) // epoch=5, dealerID=99Blocked on issue #1 above. 7. The test verifies determinism across two calls to Positives
|
8f775a3 to
ae78778
Compare
9184d2f to
03de1ed
Compare
f673608 to
899e2f6
Compare
… AckData The AckData struct used `address player` but `uint64 dealerID` in Solidity, while Go used `int64 PlayerID`/`DealerID` with mismatched byte encoding for epoch (32 bytes vs 8 bytes). This caused proveEquivocation() to always revert with Ack1Invalid, making it impossible to slash a malicious operator. - Change `uint64 dealerID` to `address dealer` in Solidity AckData struct - Change Go Acknowledgement fields from int64 IDs to common.Address values - Fix epoch encoding to use 8-byte uint64 (matching Solidity) in Go hash functions - Update merkle leaf hash: keccak256(player_20B || dealer_20B || epoch_8B || shareHash || commitmentHash) - Update ABI binding, node signing, transport routing, and persistence to use addresses - Add happy-path test for proveEquivocation that constructs a valid merkle proof Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dgementForMerkle Remove the duplicate hash implementation in pkg/merkle and delegate to the canonical crypto.HashAcknowledgementForMerkle to prevent the two from diverging silently. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dgementMerkleTree pkg/reshare had byte-for-byte copies of both functions from pkg/dkg. Delegate to the canonical dkg implementations, following the same pattern used for merkle.HashAcknowledgement -> crypto.HashAcknowledgementForMerkle. Also replace the local threshold() helper in reshare_fuzz_test.go with dkg.CalculateThreshold to avoid the same formula existing in two places. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…AcknowledgementForMerkle directly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nical implementation Remove the copies from pkg/dkg and pkg/reshare and update all callers (node.go, tests, integration tests) to use crypto.CreateAcknowledgement directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update comment to say "by player address" instead of "by player ID" to match the actual sort key used in SortAcknowledgements. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
899e2f6 to
2874e89
Compare
1. Fix epoch encoding mismatch in HashAcknowledgementForMerkle: use 8-byte uint64 encoding to match Solidity's abi.encodePacked(uint64), not 32-byte uint256. This was causing Go-computed merkle leaves to never match on-chain verification in proveEquivocation. 2. Fix port string bug in CreateTestOperators: string(rune(9000+i)) produces Unicode characters, not decimal port strings. Use fmt.Sprintf instead. 3. Remove unused senderNodeID parameter from verifyAcknowledgement. The function validates using PlayerAddress/DealerAddress from the ack struct and no longer needs the int64 sender ID. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
lgtm |
Uh oh!
There was an error while loading. Please reload this page.