Skip to content

Commit

Permalink
Update benches (#26)
Browse files Browse the repository at this point in the history
* chore: update benchmarks

* chore: add further benches

* chore: update git workflow

* chore: very minor fix
  • Loading branch information
enricobottazzi authored Feb 27, 2024
1 parent cd966ac commit 948c6d9
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 267 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/circuit-sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,9 @@ jobs:
- name: Generate Parameters for circuit and Run Tests
run: |
python3 scripts/circuit_sk.py -n 1024 -qis '[
1152921504606584833,
1152921504598720513,
1152921504597016577,
1152921504595968001,
1152921504595640321,
1152921504593412097,
1152921504592822273,
1152921504592429057,
1152921504589938689,
1152921504586530817,
1152921504585547777,
1152921504583647233,
1152921504581877761,
1152921504581419009,
1152921504580894721
python3 scripts/circuit_sk.py -n 4096 -qis '[
27424203952895201,
27424203952895203
]' -t 65537
cargo build
cargo test --release -- --nocapture
cargo test --release --features bench -- --nocapture
215 changes: 161 additions & 54 deletions README.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
bfv @ git+https://github.com/enricobottazzi/bfv-py.git@b32a20dede78b70359634a1f528d93ef3ed8fee2
galois==0.3.8
bfv @ git+https://github.com/enricobottazzi/bfv-py.git@e8239e946cab58c5c9fc974ff726010b71d92dbf
10 changes: 6 additions & 4 deletions src/constants/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod sk_enc_constants_1024_15x60_65537;
pub mod sk_enc_constants_2048_15x60_65537;
pub mod sk_enc_constants_4096_15x60_65537;
pub mod sk_enc_constants_8192_15x60_65537;
pub mod sk_enc_constants_1024_1x27_65537;
pub mod sk_enc_constants_16384_8x54_65537;
pub mod sk_enc_constants_2048_1x53_65537;
pub mod sk_enc_constants_32768_15x59_65537;
pub mod sk_enc_constants_4096_2x55_65537;
pub mod sk_enc_constants_8192_4x55_65537;
16 changes: 0 additions & 16 deletions src/constants/sk_enc_constants_1024_15x60_65537.rs

This file was deleted.

16 changes: 16 additions & 0 deletions src/constants/sk_enc_constants_1024_1x27_65537.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// `N` is the degree of the cyclotomic polynomial defining the ring `Rq = Zq[X]/(X^N + 1)`.
pub const N: usize = 1024;
/// The coefficients of the polynomial `e` should exist in the interval `[-E_BOUND, E_BOUND]` where `E_BOUND` is the upper bound of the gaussian distribution with 𝜎 = 3.2
pub const E_BOUND: u64 = 19;
/// The coefficients of the polynomial `s` should exist in the interval `[-S_BOUND, S_BOUND]`.
pub const S_BOUND: u64 = 1;
/// The coefficients of the polynomials `r1is` should exist in the interval `[-R1_BOUND[i], R1_BOUND[i]]` where `R1_BOUND[i]` is equal to `(qi-1)/2`
pub const R1_BOUNDS: [u64; 1] = [1246];
/// The coefficients of the polynomials `r2is` should exist in the interval `[-R2_BOUND[i], R2_BOUND[i]]` where `R2_BOUND[i]` is equal to $\frac{(N+2) \cdot \frac{q_i - 1}{2} + B + \frac{t - 1}{2} \cdot |K_{0,i}|}{q_i}$
pub const R2_BOUNDS: [u64; 1] = [41319090];
/// The coefficients of `k1` should exist in the interval `[-K1_BOUND, K1_BOUND]` where `K1_BOUND` is equal to `(t-1)/2`
pub const K1_BOUND: u64 = 32768;
/// List of scalars `qis` such that `qis[i]` is the modulus of the i-th CRT basis of `q` (ciphertext space modulus)
pub const QIS: [&str; 1] = ["82638181"];
/// List of scalars `k0is` such that `k0i[i]` is equal to the negative of the multiplicative inverses of t mod qi.
pub const K0IS: [&str; 1] = ["1849798"];
16 changes: 16 additions & 0 deletions src/constants/sk_enc_constants_16384_8x54_65537.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// `N` is the degree of the cyclotomic polynomial defining the ring `Rq = Zq[X]/(X^N + 1)`.
pub const N: usize = 16384;
/// The coefficients of the polynomial `e` should exist in the interval `[-E_BOUND, E_BOUND]` where `E_BOUND` is the upper bound of the gaussian distribution with 𝜎 = 3.2
pub const E_BOUND: u64 = 19;
/// The coefficients of the polynomial `s` should exist in the interval `[-S_BOUND, S_BOUND]`.
pub const S_BOUND: u64 = 1;
/// The coefficients of the polynomials `r1is` should exist in the interval `[-R1_BOUND[i], R1_BOUND[i]]` where `R1_BOUND[i]` is equal to `(qi-1)/2`
pub const R1_BOUNDS: [u64; 8] = [16113, 24818, 37593, 34517, 12912, 32948, 38917, 29910];
/// The coefficients of the polynomials `r2is` should exist in the interval `[-R2_BOUND[i], R2_BOUND[i]]` where `R2_BOUND[i]` is equal to $\frac{(N+2) \cdot \frac{q_i - 1}{2} + B + \frac{t - 1}{2} \cdot |K_{0,i}|}{q_i}$
pub const R2_BOUNDS: [u64; 8] = [6452516132120967, 6452516132120968, 6452516132120969, 6452516132120970, 6452516132120973, 6452516132120975, 6452516132120976, 6452516132120978];
/// The coefficients of `k1` should exist in the interval `[-K1_BOUND, K1_BOUND]` where `K1_BOUND` is equal to `(t-1)/2`
pub const K1_BOUND: u64 = 32768;
/// List of scalars `qis` such that `qis[i]` is the modulus of the i-th CRT basis of `q` (ciphertext space modulus)
pub const QIS: [&str; 8] = ["12905032264241935", "12905032264241937", "12905032264241939", "12905032264241941", "12905032264241947", "12905032264241951", "12905032264241953", "12905032264241957"];
/// List of scalars `k0is` such that `k0i[i]` is equal to the negative of the multiplicative inverses of t mod qi.
pub const K0IS: [&str; 8] = ["3119285534855982", "6547723161734179", "11578631950954274", "10367425251572977", "1858653883183236", "9749317979689080", "12100252264181577", "8552879692347062"];
16 changes: 0 additions & 16 deletions src/constants/sk_enc_constants_2048_15x60_65537.rs

This file was deleted.

16 changes: 16 additions & 0 deletions src/constants/sk_enc_constants_2048_1x53_65537.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// `N` is the degree of the cyclotomic polynomial defining the ring `Rq = Zq[X]/(X^N + 1)`.
pub const N: usize = 2048;
/// The coefficients of the polynomial `e` should exist in the interval `[-E_BOUND, E_BOUND]` where `E_BOUND` is the upper bound of the gaussian distribution with 𝜎 = 3.2
pub const E_BOUND: u64 = 19;
/// The coefficients of the polynomial `s` should exist in the interval `[-S_BOUND, S_BOUND]`.
pub const S_BOUND: u64 = 1;
/// The coefficients of the polynomials `r1is` should exist in the interval `[-R1_BOUND[i], R1_BOUND[i]]` where `R1_BOUND[i]` is equal to `(qi-1)/2`
pub const R1_BOUNDS: [u64; 1] = [20368];
/// The coefficients of the polynomials `r2is` should exist in the interval `[-R2_BOUND[i], R2_BOUND[i]]` where `R2_BOUND[i]` is equal to $\frac{(N+2) \cdot \frac{q_i - 1}{2} + B + \frac{t - 1}{2} \cdot |K_{0,i}|}{q_i}$
pub const R2_BOUNDS: [u64; 1] = [3471589854547519];
/// The coefficients of `k1` should exist in the interval `[-K1_BOUND, K1_BOUND]` where `K1_BOUND` is equal to `(t-1)/2`
pub const K1_BOUND: u64 = 32768;
/// List of scalars `qis` such that `qis[i]` is the modulus of the i-th CRT basis of `q` (ciphertext space modulus)
pub const QIS: [&str; 1] = ["6943179709095039"];
/// List of scalars `k0is` such that `k0i[i]` is equal to the negative of the multiplicative inverses of t mod qi.
pub const K0IS: [&str; 1] = ["4098612896619616"];
16 changes: 16 additions & 0 deletions src/constants/sk_enc_constants_32768_15x59_65537.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// `N` is the degree of the cyclotomic polynomial defining the ring `Rq = Zq[X]/(X^N + 1)`.
pub const N: usize = 32768;
/// The coefficients of the polynomial `e` should exist in the interval `[-E_BOUND, E_BOUND]` where `E_BOUND` is the upper bound of the gaussian distribution with 𝜎 = 3.2
pub const E_BOUND: u64 = 19;
/// The coefficients of the polynomial `s` should exist in the interval `[-S_BOUND, S_BOUND]`.
pub const S_BOUND: u64 = 1;
/// The coefficients of the polynomials `r1is` should exist in the interval `[-R1_BOUND[i], R1_BOUND[i]]` where `R1_BOUND[i]` is equal to `(qi-1)/2`
pub const R1_BOUNDS: [u64; 15] = [17449, 44739, 23337, 23971, 38527, 41231, 47178, 25438, 29323, 21130, 36215, 41226, 47080, 20341, 18613];
/// The coefficients of the polynomials `r2is` should exist in the interval `[-R2_BOUND[i], R2_BOUND[i]]` where `R2_BOUND[i]` is equal to $\frac{(N+2) \cdot \frac{q_i - 1}{2} + B + \frac{t - 1}{2} \cdot |K_{0,i}|}{q_i}$
pub const R2_BOUNDS: [u64; 15] = [238750987231488128, 238750987231488128, 238750987231488128, 238750987231488128, 238750987231488128, 238750987231488128, 238750987231488128, 238750987231488128, 238750987231488160, 238750987231488160, 238750987231488160, 238750987231488160, 238750987231488160, 238750987231488160, 238750987231488160];
/// The coefficients of `k1` should exist in the interval `[-K1_BOUND, K1_BOUND]` where `K1_BOUND` is equal to `(t-1)/2`
pub const K1_BOUND: u64 = 32768;
/// List of scalars `qis` such that `qis[i]` is the modulus of the i-th CRT basis of `q` (ciphertext space modulus)
pub const QIS: [&str; 15] = ["477501974462976263", "477501974462976265", "477501974462976267", "477501974462976269", "477501974462976271", "477501974462976277", "477501974462976283", "477501974462976289", "477501974462976293", "477501974462976299", "477501974462976301", "477501974462976307", "477501974462976311", "477501974462976313", "477501974462976317"];
/// List of scalars `k0is` such that `k0i[i]` is equal to the negative of the multiplicative inverses of t mod qi.
pub const K0IS: [&str; 15] = ["15519160254606397", "413181248299753132", "101318987089463173", "110550337344198528", "322660099471945682", "362070023329770101", "448729597070750619", "131927434145614106", "188539582116643080", "69158624007851611", "288969678337063080", "361989877431741640", "447294256896967800", "57654044645399264", "32480946673725505"];
16 changes: 0 additions & 16 deletions src/constants/sk_enc_constants_4096_15x60_65537.rs

This file was deleted.

16 changes: 16 additions & 0 deletions src/constants/sk_enc_constants_4096_2x55_65537.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// `N` is the degree of the cyclotomic polynomial defining the ring `Rq = Zq[X]/(X^N + 1)`.
pub const N: usize = 4096;
/// The coefficients of the polynomial `e` should exist in the interval `[-E_BOUND, E_BOUND]` where `E_BOUND` is the upper bound of the gaussian distribution with 𝜎 = 3.2
pub const E_BOUND: u64 = 19;
/// The coefficients of the polynomial `s` should exist in the interval `[-S_BOUND, S_BOUND]`.
pub const S_BOUND: u64 = 1;
/// The coefficients of the polynomials `r1is` should exist in the interval `[-R1_BOUND[i], R1_BOUND[i]]` where `R1_BOUND[i]` is equal to `(qi-1)/2`
pub const R1_BOUNDS: [u64; 2] = [25966, 19503];
/// The coefficients of the polynomials `r2is` should exist in the interval `[-R2_BOUND[i], R2_BOUND[i]]` where `R2_BOUND[i]` is equal to $\frac{(N+2) \cdot \frac{q_i - 1}{2} + B + \frac{t - 1}{2} \cdot |K_{0,i}|}{q_i}$
pub const R2_BOUNDS: [u64; 2] = [13712101976447600, 13712101976447600];
/// The coefficients of `k1` should exist in the interval `[-K1_BOUND, K1_BOUND]` where `K1_BOUND` is equal to `(t-1)/2`
pub const K1_BOUND: u64 = 32768;
/// List of scalars `qis` such that `qis[i]` is the modulus of the i-th CRT basis of `q` (ciphertext space modulus)
pub const QIS: [&str; 2] = ["27424203952895201", "27424203952895203"];
/// List of scalars `k0is` such that `k0i[i]` is equal to the negative of the multiplicative inverses of t mod qi.
pub const K0IS: [&str; 2] = ["20017153978526555", "14608220699689817"];
16 changes: 0 additions & 16 deletions src/constants/sk_enc_constants_8192_15x60_65537.rs

This file was deleted.

Loading

0 comments on commit 948c6d9

Please sign in to comment.