Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test FacProof with bad Paillier keys #160

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Nov 22, 2024

No description provided.


// `C^phi mod N^2` may be 0 if `C == N`, which is very unlikely for large `N`.
// Note that `C^phi mod N^2 / N < N`, so we can unwrap when converting to `Uint`
// Note that `C^phi mod N^2 / N < N`, so we can unwrap when converting to `Uint` <–– (DP) This assumes that `gcd(C, N) = 1`, but why is this guaranteed?
Copy link
Member

@fjarri fjarri Nov 27, 2024

Choose a reason for hiding this comment

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

Not sure what you mean here, if y = x mod N^2 then y < N^2, which means y / N < N. How does GCD factor in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I honestly no longer remember why I wrote that. Pff. :/

@fjarri
Copy link
Member

fjarri commented Nov 27, 2024

I think the reason the test passes is that the proof conditions are violated. You're sampling a small p and a regular-sized q, which makes the resulting N_0 to be of size PRIME_BITS + x, instead of 2 * PRIME_BITS. The П_fac assumes N0 ~ 2^(2l + eps) ~ 2^(2 * PRIME_BITS). The size of N_0 would be checked prior to П_fac (See Fig. 6, AuxInfo/KeyRefresh, Round 3, Step 1).

It is not trivial to make the proof fail while keeping the N_0 the proper size, because of the HalfUint limits on p and q (which raises the question of how it should be tested). But if you were to change their types, and have, say q ~ 2^(PRIME_BITS * 2), in the proof (see Fig. 28) you'd get z2 ~ 2^(4l + 2eps) * q, which would fail the range check z2 < 2^(l + eps) * sqrt(N0) ~ 2^(3l + 2eps). l = 256, so the difference would be quite noticeable.

(the references here are to the '21 version of the paper)

@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 28, 2024

Maybe all we need to do here is adding a check that N_0 is indeed 2*PRIME_BITS bits long?

I struggle to come up with an attack scenario where the a wrong-size N_0 could slip through the previous rounds, but given that the Paillier secret key is deserializable from bytes (without size checks) it is perhaps wise to adopt a defense in depth approach here.

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.

2 participants