Skip to content

Commit 853a930

Browse files
committed
add config option to mpc-tls, prover and verifier
1 parent c5d454b commit 853a930

File tree

10 files changed

+23
-14
lines changed

10 files changed

+23
-14
lines changed

crates/benches/binary/src/preprocess.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hmac_sha256::MpcPrf;
1+
use hmac_sha256::{Config, MpcPrf};
22
use mpz_garble::protocol::semihonest::{Evaluator, Garbler};
33
use mpz_ot::ideal::cot::{ideal_cot, IdealCOTReceiver, IdealCOTSender};
44
use mpz_vm_core::memory::{binary::U8, correlated::Delta, Array, MemoryExt};
@@ -8,7 +8,7 @@ pub async fn preprocess_prf_circuits() {
88
let (mut garbler, _) = mock_vm();
99
let pms: Array<U8, 32> = garbler.alloc().unwrap();
1010

11-
let mut prf = MpcPrf::default();
11+
let mut prf = MpcPrf::new(Config::default());
1212
prf.alloc(&mut garbler, pms).unwrap();
1313
}
1414

crates/components/hmac-sha256/benches/prf.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use criterion::{criterion_group, criterion_main, Criterion};
44

5-
use hmac_sha256::MpcPrf;
5+
use hmac_sha256::{Config, MpcPrf};
66
use mpz_common::context::test_mt_context;
77
use mpz_garble::protocol::semihonest::{Evaluator, Garbler};
88
use mpz_ot::ideal::cot::ideal_cot;
@@ -52,8 +52,8 @@ async fn prf() {
5252
follower_vm.assign(follower_pms, pms).unwrap();
5353
follower_vm.commit(follower_pms).unwrap();
5454

55-
let mut leader = MpcPrf::default();
56-
let mut follower = MpcPrf::default();
55+
let mut leader = MpcPrf::new(Config::default());
56+
let mut follower = MpcPrf::new(Config::default());
5757

5858
let leader_output = leader.alloc(&mut leader_vm, leader_pms).unwrap();
5959
let follower_output = follower.alloc(&mut follower_vm, follower_pms).unwrap();

crates/components/hmac-sha256/src/prf/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ pub struct MpcPrf {
2424
circuits: Option<Circuits>,
2525
}
2626

27-
impl Default for MpcPrf {
28-
fn default() -> Self {
29-
let config = Config::default();
30-
Self::new(config)
31-
}
32-
}
33-
3427
impl MpcPrf {
3528
/// Creates a new instance of the PRF.
3629
///

crates/mpc-tls/src/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use derive_builder::Builder;
2+
use hmac_sha256::Config as PrfConfig;
23

34
const MIN_SENT: usize = 32;
45
const MIN_SENT_RECORDS: usize = 8;
@@ -30,6 +31,8 @@ pub struct Config {
3031
/// Maximum number of received bytes.
3132
#[allow(unused)]
3233
pub(crate) max_recv: usize,
34+
/// Configuration options for the PRF.
35+
pub(crate) prf: PrfConfig,
3336
}
3437

3538
impl Config {
@@ -76,6 +79,7 @@ impl ConfigBuilder {
7679
max_recv_records,
7780
max_recv_online,
7881
max_recv,
82+
prf: self.prf.unwrap_or_default(),
7983
})
8084
}
8185
}

crates/mpc-tls/src/follower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl MpcTlsFollower {
6363
)),
6464
)) as Box<dyn KeyExchange + Send + Sync>;
6565

66-
let prf = MpcPrf::default();
66+
let prf = MpcPrf::new(config.prf);
6767

6868
let encrypter = MpcAesGcm::new(
6969
ShareConversionReceiver::new(OLEReceiver::new(AnyReceiver::new(

crates/mpc-tls/src/leader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl MpcTlsLeader {
8787
))),
8888
)) as Box<dyn KeyExchange + Send + Sync>;
8989

90-
let prf = MpcPrf::default();
90+
let prf = MpcPrf::new(config.prf);
9191

9292
let encrypter = MpcAesGcm::new(
9393
ShareConversionSender::new(OLESender::new(

crates/prover/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tlsn-tls-client = { workspace = true }
2121
tlsn-tls-client-async = { workspace = true }
2222
tlsn-tls-core = { workspace = true }
2323
tlsn-mpc-tls = { workspace = true }
24+
tlsn-hmac-sha256 = { workspace = true }
2425

2526
serio = { workspace = true, features = ["compat"] }
2627
uid-mux = { workspace = true, features = ["serio"] }

crates/prover/src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use hmac_sha256::Config as PrfConfig;
34
use mpc_tls::Config;
45
use tlsn_common::config::ProtocolConfig;
56
use tlsn_core::{connection::ServerName, CryptoProvider};
@@ -19,6 +20,9 @@ pub struct ProverConfig {
1920
/// Cryptography provider.
2021
#[builder(default, setter(into))]
2122
crypto_provider: Arc<CryptoProvider>,
23+
/// Configuration options for the PRF.
24+
#[builder(default)]
25+
prf: PrfConfig,
2226
}
2327

2428
impl ProverConfig {
@@ -54,6 +58,7 @@ impl ProverConfig {
5458
.max_sent(self.protocol_config.max_sent_data())
5559
.max_recv_online(self.protocol_config.max_recv_data_online())
5660
.max_recv(self.protocol_config.max_recv_data())
61+
.prf(self.prf)
5762
.build()
5863
.unwrap()
5964
}

crates/verifier/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ tlsn-core = { workspace = true }
1919
tlsn-deap = { workspace = true }
2020
tlsn-mpc-tls = { workspace = true }
2121
tlsn-tls-core = { workspace = true }
22+
tlsn-hmac-sha256 = { workspace = true }
2223

2324
serio = { workspace = true, features = ["compat"] }
2425
uid-mux = { workspace = true, features = ["serio"] }

crates/verifier/src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{
33
sync::Arc,
44
};
55

6+
use hmac_sha256::Config as PrfConfig;
67
use mpc_tls::Config;
78
use tlsn_common::config::{ProtocolConfig, ProtocolConfigValidator};
89
use tlsn_core::CryptoProvider;
@@ -16,6 +17,9 @@ pub struct VerifierConfig {
1617
/// Cryptography provider.
1718
#[builder(default, setter(into))]
1819
crypto_provider: Arc<CryptoProvider>,
20+
/// Configuration options for the PRF.
21+
#[builder(default)]
22+
prf: PrfConfig,
1923
}
2024

2125
impl Debug for VerifierConfig {
@@ -47,6 +51,7 @@ impl VerifierConfig {
4751
.max_sent(protocol_config.max_sent_data())
4852
.max_recv_online(protocol_config.max_recv_data_online())
4953
.max_recv(protocol_config.max_recv_data())
54+
.prf(self.prf)
5055
.build()
5156
.unwrap()
5257
}

0 commit comments

Comments
 (0)