Skip to content

Fix various inconsistencies in OU implementation#6

Merged
ekkolon merged 3 commits intomainfrom
patch-inconsistencies
Mar 25, 2026
Merged

Fix various inconsistencies in OU implementation#6
ekkolon merged 3 commits intomainfrom
patch-inconsistencies

Conversation

@ekkolon
Copy link
Copy Markdown
Owner

@ekkolon ekkolon commented Mar 25, 2026

Critical: enforce m < p plaintext bound (not m < n); remove Ciphertext::Mul which was missing mod n reduction; fix stream format to preserve leading-zero bytes and distinguish empty from zero plaintext.

Security: validate gcd(r,n)=1 for encryption nonce; privatize PrivateKey fields; replace safe prime generation with standard primes (not required by OU, 473x slower at 2048 bits); migrate decryption modpow to crypto-bigint BoxedMontyForm for constant-time exponentiation.

Correctness: add gcd(g,n)=1 generator check; precompute l_gp_inv and p² in PrivateKey, eliminating runtime mod_inverse and repeated p² allocation; add Plaintext type with checked_add to surface homomorphic overflow.

API: remove Ciphertext::Deref and unvalidated From<&[u8]>; replace glob re-exports with explicit items; cap untrusted block_count at 4M; extract parse_blocks(); make homomorphic_add_packed pub.

ekkolon added 3 commits March 25, 2026 18:03
Critical: enforce m < p plaintext bound (not m < n); remove Ciphertext::Mul
which was missing mod n reduction; fix stream format to preserve leading-zero
bytes and distinguish empty from zero plaintext.

Security: validate gcd(r,n)=1 for encryption nonce; privatize PrivateKey
fields; replace safe prime generation with standard primes (not required by
OU, 473x slower at 2048 bits); migrate decryption modpow to crypto-bigint
BoxedMontyForm for constant-time exponentiation.

Correctness: add gcd(g,n)=1 generator check; precompute l_gp_inv and p²
in PrivateKey, eliminating runtime mod_inverse and repeated p² allocation;
add Plaintext type with checked_add to surface homomorphic overflow.

API: remove Ciphertext::Deref and unvalidated From<&[u8]>; replace glob
re-exports with explicit items; cap untrusted block_count at 4M; extract
parse_blocks(); make homomorphic_add_packed pub.
@ekkolon ekkolon merged commit cf6c355 into main Mar 25, 2026
1 check passed
@ekkolon ekkolon deleted the patch-inconsistencies branch March 25, 2026 17:11
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.

1 participant