polytune: use Block type consistently#341
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the codebase to consistently use the Block type instead of u128 throughout the cryptographic protocol implementation, addressing issue #210. The changes also introduce a constant-time multiplication method (Block::const_mul) to mitigate potential timing side-channel vulnerabilities.
- Replaced
u128withBlocktype across OT functions, data types, and protocol implementations - Added
Block::const_mulmethod for constant-time multiplication with boolean values - Updated hash functions and serialization to work with
Blockinstead ofu128
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ot.rs | Removed block_to_u128 conversion function and updated OT sender/receiver to return Vec<Block> |
| src/mpc/protocol.rs | Updated label initialization to use Block::ZERO instead of 0 |
| src/mpc/garble.rs | Changed key/nonce generation to use as_bytes() and corrected endianness from to_be_bytes() to to_le_bytes() |
| src/mpc/fpre.rs | Updated Mac/Key initialization to use default() and comparison with Mac::default() |
| src/mpc/faand.rs | Extensive changes replacing u128 operations with Block, introducing const_mul for timing-safe operations |
| src/mpc/data_types.rs | Changed Delta, Mac, Key, and Label to wrap Block instead of u128 |
| src/block.rs | Added const_mul method for constant-time multiplication |
| src/bench_reexports.rs | Updated return types from Vec<u128> to Vec<Block> |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
62d407a to
f961705
Compare
closes #210 This also fixes some cases where there were potential timing side-channel issues by introducing a `Block::const_mul` method that multiplies a Block with a bool in constant time by using the conditional select implementation. This does not really change performance, as Block was already used in the performance critical parts.
f961705 to
b7d50cc
Compare
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThe PR systematically replaces u128 with Block types across the codebase to leverage SIMD operations for improved performance. Core data structures (Delta, Mac, Key, Label) now wrap Block instead of u128, with corresponding updates to arithmetic operations, serialization, hashing, and default initializers. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (8)
🧰 Additional context used🧬 Code graph analysis (3)src/ot.rs (3)
src/mpc/faand.rs (1)
src/mpc/data_types.rs (1)
🔇 Additional comments (33)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
closes #210
This also fixes some cases where there were potential timing side-channel issues by introducing a
Block::const_mulmethod that multiplies a Block with a bool in constant time by using the conditional select implementation.This does not really change performance, as Block was already used in the performance critical parts.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.