Skip to content

Conversation

@themighty1
Copy link
Collaborator

This PR implements gate randomization for garbling.

The rationale for it is discussed #7

@themighty1 themighty1 requested a review from th4s October 9, 2025 08:08
Copy link
Member

@th4s th4s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

pub(crate) const DEFAULT_BATCH_SIZE: usize = MAX_BATCH_SIZE / BYTES_PER_GATE;

/// The initial gate id.
#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be Copy, then we do not need to clone it.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]

@sinui0
Copy link
Collaborator

sinui0 commented Oct 17, 2025

I don't think I'm a fan of this change. Reading that paper the issue is the re-use of a tweak (gid). So the task is to ensure that a tweak is never reused. Rather than picking a starting gid for each circuit, I would prefer to maintain a global counter.

@themighty1
Copy link
Collaborator Author

@sinui0, can you elaborate how a global counter would work?
( keeping in mind that gid must be unique even across multiple independent sessions)

@sinui0
Copy link
Collaborator

sinui0 commented Oct 20, 2025

keeping in mind that gid must be unique even across multiple independent sessions

This is not clear to me, I'll need a definition of "session". The paper highlights an attack for recovering R (i.e. Δ) when the tweaks are reused. We never use the same Δ with multiple garbler instances.

It seems to me it is sufficient to maintain the counter per VM instance (what I meant by global) not per circuit. The circuit boundary is unnecessary, we just need to maintain a counter for the total number of AND gates garbled, which can start at 1 and be maintained implicitly by both parties.

If we really want to keep the randomization to mitigate the attack when a Δ is accidentally reused with multiple VMs, we could randomize the initial global counter.

@themighty1
Copy link
Collaborator Author

I see, you are suggesting randomizing the initial gate id and then incrementing per VM instance. That should work.

(the attack works even if different deltas are used across multiple circuits #7 (comment) )

@themighty1
Copy link
Collaborator Author

Closed in favour of #348

@themighty1 themighty1 closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants