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

Ferret with IO #169

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
92e2c79
feat: mpz-common (#107)
sinui0 Mar 7, 2024
d328d90
refactor: cointoss (#108)
sinui0 Mar 7, 2024
020bc98
refactor: mpz-ot (#109)
sinui0 Mar 7, 2024
071924c
refactor: re-organize crates (#110)
sinui0 Mar 7, 2024
73441ff
Adds an ideal ROT functionality to mpz-ot-core (#102)
th4s Mar 7, 2024
42c7fe9
refactor(mpz-ot): Normalize OT and ideal functionalities (#122)
sinui0 May 8, 2024
94e8478
spcot with io, without tests
xiangxiecrypto May 13, 2024
4064907
feat(mpz-common): add try_/join convenience macros (#126)
sinui0 May 13, 2024
94a8c3a
fix(mpz-ot): Ideal RCOT (#131)
sinui0 May 13, 2024
04d9a68
Merge branch 'privacy-scaling-explorations:threading-refactor' into t…
xiangxiecrypto May 14, 2024
9d8e0b4
add spcot test
xiangxiecrypto May 14, 2024
b3fad45
add batch spcot in mpz-ot-core
xiangxiecrypto May 15, 2024
1e6cb93
docs: fix typos (#130)
themighty1 May 15, 2024
fe90dd0
add batch spcot in mpz-ot and rayon
xiangxiecrypto May 15, 2024
d324081
feat(mpz-common): dummy executor (#132)
sinui0 May 15, 2024
48b8ed1
feat(mpz-common): simple counter (#133)
sinui0 May 15, 2024
831367f
add general mpcot
xiangxiecrypto May 16, 2024
4480607
mpcot receiver
xiangxiecrypto May 16, 2024
ef2b3ac
fix a small bug in ggm tree
xiangxiecrypto May 16, 2024
9cc03c6
add regular mpcot in mpz-ot
xiangxiecrypto May 16, 2024
1ccfb36
fix a bug for multiple extension of spcot
xiangxiecrypto May 17, 2024
b89a23b
add ferret with io
xiangxiecrypto May 18, 2024
29e207a
minor
xiangxiecrypto May 18, 2024
26d82fb
fmt
xiangxiecrypto May 18, 2024
94dcf7a
clippy
xiangxiecrypto May 18, 2024
dbbb3f8
Merge branch 'privacy-scaling-explorations:threading-refactor' into t…
xiangxiecrypto May 18, 2024
e61013d
Merge branch 'threading-refactor' of https://github.com/xiangxiecrypt…
xiangxiecrypto May 18, 2024
22a1e51
fmt and minor changes
xiangxiecrypto Jun 5, 2024
7220274
unify mpcot type and simply ferret apis
xiangxiecrypto Jun 14, 2024
ef26d6c
clean up
xiangxiecrypto Jun 14, 2024
5f8f2d2
refine
xiangxiecrypto Jun 14, 2024
2109f34
fmt
xiangxiecrypto Jun 14, 2024
a8c6db4
feat(mpz-common): add try_/join convenience macros (#126)
sinui0 May 13, 2024
8a63a35
fix(mpz-ot): Ideal RCOT (#131)
sinui0 May 13, 2024
ba08108
add spcot test
xiangxiecrypto May 14, 2024
68a055a
add batch spcot in mpz-ot-core
xiangxiecrypto May 15, 2024
4aac024
add batch spcot in mpz-ot and rayon
xiangxiecrypto May 15, 2024
3efc31a
add general mpcot
xiangxiecrypto May 16, 2024
324cbcd
mpcot receiver
xiangxiecrypto May 16, 2024
9de8d5d
fix a small bug in ggm tree
xiangxiecrypto May 16, 2024
3cae26a
add regular mpcot in mpz-ot
xiangxiecrypto May 16, 2024
25fbbb2
fix a bug for multiple extension of spcot
xiangxiecrypto May 17, 2024
ee6a5b8
add ferret with io
xiangxiecrypto May 18, 2024
7957b00
minor
xiangxiecrypto May 18, 2024
d184051
fmt
xiangxiecrypto May 18, 2024
97744f2
clippy
xiangxiecrypto May 18, 2024
125361e
docs: fix typos (#130)
themighty1 May 15, 2024
804cd7e
feat(mpz-common): dummy executor (#132)
sinui0 May 15, 2024
efda239
feat(mpz-common): simple counter (#133)
sinui0 May 15, 2024
bedd3e4
fmt and minor changes
xiangxiecrypto Jun 5, 2024
a8d7cf4
unify mpcot type and simply ferret apis
xiangxiecrypto Jun 14, 2024
6806fae
clean up
xiangxiecrypto Jun 14, 2024
2dec238
refine
xiangxiecrypto Jun 14, 2024
c219347
fmt
xiangxiecrypto Jun 14, 2024
1be0596
Merge branch 'threading-refactor' of https://github.com/xiangxiecrypt…
xiangxiecrypto Jun 27, 2024
efd28e3
Merge branch 'dev' into threading-refactor
xiangxiecrypto Jun 28, 2024
4861d40
move Cargo.toml
xiangxiecrypto Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions crates/mpz-core/src/ggm_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,35 @@ impl GgmTree {
assert_eq!(k0.len(), self.depth);
assert_eq!(k1.len(), self.depth);
let mut buf = [Block::ZERO; 8];
self.tkprp.expand_1to2(tree, seed);
k0[0] = tree[0];
k1[0] = tree[1];
if self.depth > 1 {
self.tkprp.expand_1to2(tree, seed);
k0[0] = tree[0];
k1[0] = tree[1];

self.tkprp.expand_2to4(&mut buf, tree);
k0[1] = buf[0] ^ buf[2];
k1[1] = buf[1] ^ buf[3];
tree[0..4].copy_from_slice(&buf[0..4]);

for h in 2..self.depth {
k0[h] = Block::ZERO;
k1[h] = Block::ZERO;

// How many nodes there are in this layer
let sz = 1 << h;
for i in (0..=sz - 4).rev().step_by(4) {
self.tkprp.expand_4to8(&mut buf, &tree[i..]);
k0[h] ^= buf[0];
k0[h] ^= buf[2];
k0[h] ^= buf[4];
k0[h] ^= buf[6];
k1[h] ^= buf[1];
k1[h] ^= buf[3];
k1[h] ^= buf[5];
k1[h] ^= buf[7];
self.tkprp.expand_2to4(&mut buf, tree);
k0[1] = buf[0] ^ buf[2];
k1[1] = buf[1] ^ buf[3];
tree[0..4].copy_from_slice(&buf[0..4]);

tree[2 * i..2 * i + 8].copy_from_slice(&buf);
for h in 2..self.depth {
k0[h] = Block::ZERO;
k1[h] = Block::ZERO;

// How many nodes there are in this layer
let sz = 1 << h;
for i in (0..=sz - 4).rev().step_by(4) {
self.tkprp.expand_4to8(&mut buf, &tree[i..]);
k0[h] ^= buf[0];
k0[h] ^= buf[2];
k0[h] ^= buf[4];
k0[h] ^= buf[6];
k1[h] ^= buf[1];
k1[h] ^= buf[3];
k1[h] ^= buf[5];
k1[h] ^= buf[7];

tree[2 * i..2 * i + 8].copy_from_slice(&buf);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/mpz-core/src/lpn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<const D: usize> LpnEncoder<D> {
}

/// Lpn paramters
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Default)]
pub struct LpnParameters {
/// The length of output vecotrs.
pub n: usize,
Expand Down
78 changes: 17 additions & 61 deletions crates/mpz-garble-core/benches/garble.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,39 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use mpz_circuits::circuits::AES128;
use mpz_garble_core::{ChaChaEncoder, Encoder, Evaluator, Generator};
use mpz_garble_core::{ChaChaEncoder, Encoder, Generator};

fn criterion_benchmark(c: &mut Criterion) {
let mut gb_group = c.benchmark_group("garble");
let mut group = c.benchmark_group("garble_circuits");

let encoder = ChaChaEncoder::new([0u8; 32]);
let full_inputs = AES128
let inputs = AES128
.inputs()
.iter()
.map(|value| encoder.encode_by_type(0, &value.value_type()))
.collect::<Vec<_>>();

let active_inputs = vec![
full_inputs[0].clone().select([0u8; 16]).unwrap(),
full_inputs[1].clone().select([0u8; 16]).unwrap(),
];

gb_group.bench_function("aes128", |b| {
let mut gen = Generator::default();
b.iter(|| {
let mut gen_iter = gen
.generate(&AES128, encoder.delta(), full_inputs.clone())
.unwrap();

let _: Vec<_> = gen_iter.by_ref().collect();

black_box(gen_iter.finish().unwrap())
})
});

gb_group.bench_function("aes128_batched", |b| {
let mut gen = Generator::default();
b.iter(|| {
let mut gen_iter = gen
.generate_batched(&AES128, encoder.delta(), full_inputs.clone())
.unwrap();

let _: Vec<_> = gen_iter.by_ref().collect();

black_box(gen_iter.finish().unwrap())
})
});

gb_group.bench_function("aes128_with_hash", |b| {
let mut gen = Generator::default();
group.bench_function("aes128", |b| {
b.iter(|| {
let mut gen_iter = gen
.generate(&AES128, encoder.delta(), full_inputs.clone())
.unwrap();

gen_iter.enable_hasher();
let mut gen = Generator::new(AES128.clone(), encoder.delta(), &inputs).unwrap();

let _: Vec<_> = gen_iter.by_ref().collect();
let mut enc_gates = Vec::with_capacity(AES128.and_count());
for gate in gen.by_ref() {
enc_gates.push(gate);
}

black_box(gen_iter.finish().unwrap())
black_box(gen.outputs().unwrap())
})
});

drop(gb_group);

let mut ev_group = c.benchmark_group("evaluate");

ev_group.bench_function("aes128", |b| {
let mut gen = Generator::default();
let mut gen_iter = gen
.generate(&AES128, encoder.delta(), full_inputs.clone())
.unwrap();
let gates: Vec<_> = gen_iter.by_ref().collect();

let mut ev = Evaluator::default();
group.bench_function("aes128_with_hash", |b| {
b.iter(|| {
let mut ev_consumer = ev.evaluate(&AES128, active_inputs.clone()).unwrap();
let mut gen =
Generator::new_with_hasher(AES128.clone(), encoder.delta(), &inputs).unwrap();

for gate in &gates {
ev_consumer.next(*gate);
let mut enc_gates = Vec::with_capacity(AES128.and_count());
for gate in gen.by_ref() {
enc_gates.push(gate);
}

black_box(ev_consumer.finish().unwrap());
black_box(gen.outputs().unwrap())
})
});
}
Expand Down
Loading
Loading