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

set parameters which guarantee all tests pass #29

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

jacksonwalters
Copy link
Collaborator

appears n=16 is necessary for tests to pass

@jacksonwalters jacksonwalters linked an issue Dec 24, 2024 that may be closed by this pull request
@jacksonwalters jacksonwalters changed the title n=32 causes prod test failure n=32 causes hom_prod test failure Dec 24, 2024
@jacksonwalters jacksonwalters changed the title n=32 causes hom_prod test failure set parameters which guarantee all tests pass Dec 24, 2024
@jacksonwalters
Copy link
Collaborator Author

jacksonwalters commented Dec 24, 2024

(n = 16, q = 1073741824, t = 1024) sometimes passes, sometimes fails. $\Delta = q / t = 2^{30} / 2^{10} = 2^{20}$.

@jacksonwalters
Copy link
Collaborator Author

it looks like with $q$ set this high, we're going to have $q^2 \approx 2^{60}$, which is close to the i64 max of $\approx 2^{64}$.

---- test::tests::test_hom_prod stdout ----
thread 'test::tests::test_hom_prod' panicked at /Users/jacksonwalters/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polynomial-ring-0.5.0/src/ops.rs:102:9:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@jacksonwalters
Copy link
Collaborator Author

jacksonwalters commented Dec 24, 2024

so it's really just line 55 in lib.rs, which is polymul:

let mut r = x*y;

This multiplication of polynomials occurs first, then we reduce modulo q. This causes an overflow for large q.

We can use i128, but we're probably missing something obvious.

anything bigger and tests do not pass
@jacksonwalters
Copy link
Collaborator Author

for now, the largest set of parameters that seem to pass are $n = 16, q = 1073741824, t = 512$.

@jacksonwalters
Copy link
Collaborator Author

one thing to note is that with q fixed, increasing t by powers of 2 causes the error to increase by powers of 2. so the constant term will be correct (= 6) but you'll get other terms either zero or say 16. If you increase t by a power of 2, you'll get e.g. [6,...,0,...,32,32,0,32,...,0,0,...,32]. This also holds for non-powers of 2, say primes q, t where you get some small constant error term or zero.

@jacksonwalters jacksonwalters merged commit 02a5190 into main Dec 24, 2024
1 check passed
@jacksonwalters jacksonwalters deleted the parameter_selection_for_passing_tests branch December 24, 2024 06:01
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.

determine parameters for which all tests to pass
2 participants