Skip to content

Commit a9599fc

Browse files
AdamDawidKrolWondertan
authored andcommitted
fix(mpc-tls): domain-separate per-consumer KOS instances
Addresses the review on this PR: each RCOT consumer gets its own KOS instance but they all share one global `delta`. Give each logical consumer a distinct `instance_id` (matched across prover and verifier: sender id N ↔ receiver id N; proxy uses a single fixed id) so the same-`delta` instances are domain-separated. Depends on the KOS `instance_id` change (ethereum/mpz#446). Until that lands in a release, the `[patch]` block temporarily points mpz at an alpha.6-compatible build of the same change.
1 parent 238d83b commit a9599fc

4 files changed

Lines changed: 86 additions & 46 deletions

File tree

Cargo.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,30 @@ webpki-roots = { version = "1.0" }
173173
webpki-root-certs = { version = "1.0" }
174174
ws_stream_wasm = { version = "0.7.5" }
175175
zeroize = { version = "1.8" }
176+
177+
# Patch mpz to the fork carrying the per-instance KOS domain-separation change.
178+
[patch."https://github.com/privacy-ethereum/mpz"]
179+
clmul = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
180+
matrix-transpose = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
181+
mpz-circuits = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
182+
mpz-circuits-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
183+
mpz-circuits-data = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
184+
mpz-cointoss = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
185+
mpz-cointoss-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
186+
mpz-common = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
187+
mpz-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
188+
mpz-fields = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
189+
mpz-garble = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
190+
mpz-garble-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
191+
mpz-hash = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
192+
mpz-ideal-vm = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
193+
mpz-memory-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
194+
mpz-ole = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
195+
mpz-ole-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
196+
mpz-ot = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
197+
mpz-ot-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
198+
mpz-share-conversion = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
199+
mpz-share-conversion-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
200+
mpz-vm-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
201+
mpz-zk = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }
202+
mpz-zk-core = { git = "https://github.com/AdamDawidKrol/mpz", rev = "c0379ef" }

crates/tlsn/src/deps/prover.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,21 @@ impl ProverMpcDeps {
5858
// RCOT only flushes once all its clones reach the flush barrier, but the
5959
// preprocess branches (ke / record_layer / vm) don't all flush together, so a
6060
// shared instance deadlocks. All senders use the same global delta.
61-
let new_send = || {
61+
let id = |n: u128| Block::new(n.to_le_bytes());
62+
let new_send = |instance_id: Block| {
6263
SharedRCOTSender::new(kos::Sender::new(
6364
kos::SenderConfig::default(),
6465
delta.into_inner(),
66+
instance_id,
6567
co::Receiver::default(),
6668
))
6769
};
68-
let new_recv = |rng: &mut rand::rngs::ThreadRng| {
69-
let rcot_recv =
70-
kos::Receiver::new(kos::ReceiverConfig::default(), co::Sender::default());
70+
let new_recv = |rng: &mut rand::rngs::ThreadRng, instance_id: Block| {
71+
let rcot_recv = kos::Receiver::new(
72+
kos::ReceiverConfig::default(),
73+
instance_id,
74+
co::Sender::default(),
75+
);
7176
let rcot_recv = ferret::Receiver::new(
7277
ferret::FerretConfig::builder()
7378
.lpn_type(ferret::LpnType::Regular)
@@ -82,22 +87,22 @@ impl ProverMpcDeps {
8287
let mpc = cfg_select! {
8388
tlsn_insecure => { mpz_ideal_vm::IdealVm::new() }
8489
_ => {
85-
ProverMpc::new(DerandCOTSender::new(new_send()), rng.random(), delta)
90+
ProverMpc::new(DerandCOTSender::new(new_send(id(0))), rng.random(), delta)
8691
}
8792
};
8893

8994
let zk = cfg_select! {
9095
tlsn_insecure => { mpz_ideal_vm::IdealVm::new() }
91-
_ => { ProverZk::new(Default::default(), new_recv(&mut rng)) }
96+
_ => { ProverZk::new(Default::default(), new_recv(&mut rng, id(1))) }
9297
};
9398

9499
let vm = Arc::new(Mutex::new(Deap::new(tlsn_deap::Role::Leader, mpc, zk)));
95100
let mpc_tls = MpcTlsLeader::new(
96101
build_mpc_tls_config(config),
97102
ctx,
98103
vm.clone(),
99-
(new_send(), new_send(), new_send()),
100-
new_recv(&mut rng),
104+
(new_send(id(2)), new_send(id(3)), new_send(id(4))),
105+
new_recv(&mut rng, id(5)),
101106
);
102107

103108
Self {
@@ -150,7 +155,11 @@ impl ProverProxyDeps {
150155
let mut rng = rand::rng();
151156

152157
let base_ot_send = co::Sender::default();
153-
let rcot_recv = kos::Receiver::new(kos::ReceiverConfig::default(), base_ot_send);
158+
let rcot_recv = kos::Receiver::new(
159+
kos::ReceiverConfig::default(),
160+
Block::ZERO,
161+
base_ot_send,
162+
);
154163
let rcot_recv = ferret::Receiver::new(
155164
ferret::FerretConfig::builder()
156165
.lpn_type(ferret::LpnType::Regular)

0 commit comments

Comments
 (0)