-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling Lazy NTT, giving a speedup of about 2x for encryption/decryption/rerandomization. * Updated version to 0.2.0 * added poly operation benchmarks * added butterfly mod and tests * cleaned up interfaces. * basic lazy butterfly tests work * lazy butterfly and tests * added trait and tests for lazy transforms * swap * switch to use split_at * added lazy (i)ntt; tests pass. * conditional compilation * benchmarking * optimized performance by pure u64 impl * added benchmark for integer ops and gaussian sampling * sample ternary * optimized uniform sampling * clean up * enabled lazy ntt by default * fixing reviewer comments * fix underflow * further addressing comments * updating version to 0.2.1 * remove unused dependencies Co-authored-by: Hao Chen <sxxach@gmail.com>
- Loading branch information
1 parent
c8ee75a
commit df18280
Showing
22 changed files
with
1,086 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
src/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## 0.2.1 (August 30, 2021) | ||
|
||
* Performance optimizations: Faster encryption/decryption based on lazy NTT | ||
|
||
## 0.2.0 (June 1, 2021) | ||
|
||
* Added serailization support | ||
* Added ability to customize plaintext modulus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
#[macro_use] | ||
extern crate bencher; | ||
use bencher::Bencher; | ||
use cupcake::integer_arith::butterfly::{ | ||
butterfly, inverse_butterfly, lazy_butterfly, lazy_butterfly_u64, | ||
}; | ||
use cupcake::integer_arith::scalar::Scalar; | ||
use cupcake::integer_arith::ArithUtils; | ||
|
||
#[allow(non_snake_case)] | ||
fn bench_butterfly(bench: &mut Bencher) { | ||
let q = Scalar::new_modulus(18014398492704769u64); | ||
let x = rand::random::<u64>(); | ||
let y = rand::random::<u64>(); | ||
let w = rand::random::<u64>(); | ||
|
||
let mut X = Scalar::from(x); | ||
let mut Y = Scalar::from(y); | ||
let W = Scalar::from(w); | ||
|
||
bench.iter(|| { | ||
let _ = butterfly(&mut X, &mut Y, &W, &q); | ||
}) | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
fn bench_inverse_butterfly(bench: &mut Bencher) { | ||
let q = Scalar::new_modulus(18014398492704769u64); | ||
let x = rand::random::<u64>(); | ||
let y = rand::random::<u64>(); | ||
let w = rand::random::<u64>(); | ||
|
||
let mut X = Scalar::from(x); | ||
let mut Y = Scalar::from(y); | ||
let W = Scalar::from(w); | ||
|
||
bench.iter(|| { | ||
let _ = inverse_butterfly(&mut X, &mut Y, &W, &q); | ||
}) | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
fn bench_lazy_butterfly(bench: &mut Bencher) { | ||
let q = Scalar::new_modulus(18014398492704769u64); | ||
let x = rand::random::<u64>(); | ||
let y = rand::random::<u64>(); | ||
let w = rand::random::<u64>(); | ||
|
||
let mut X = Scalar::from(x); | ||
let mut Y = Scalar::from(y); | ||
let W = Scalar::from(w); | ||
|
||
let Wprime: u64 = cupcake::integer_arith::util::compute_harvey_ratio(W.rep(), q.rep()); | ||
|
||
let twoq: u64 = q.rep() << 1; | ||
|
||
bench.iter(|| { | ||
let _ = lazy_butterfly_u64(x, y, W.rep(), Wprime, q.rep(), twoq); | ||
}) | ||
} | ||
|
||
benchmark_group!( | ||
butterfly_group, | ||
bench_butterfly, | ||
bench_inverse_butterfly, | ||
bench_lazy_butterfly | ||
); | ||
|
||
benchmark_main!(butterfly_group); |
Oops, something went wrong.