Skip to content

Commit

Permalink
refactor(tlsn): mpz upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sinui0 committed Jun 24, 2024
1 parent 58c0322 commit d9bc9e8
Show file tree
Hide file tree
Showing 32 changed files with 848 additions and 1,025 deletions.
10 changes: 5 additions & 5 deletions components/aead/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ mock = ["mpz-common/test-utils", "dep:mpz-ot"]
tlsn-block-cipher = { path = "../cipher/block-cipher" }
tlsn-stream-cipher = { path = "../cipher/stream-cipher" }
tlsn-universal-hash = { path = "../universal-hash" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", optional = true, features = [
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", optional = true, features = [
"ideal",
] }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
serio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
serio = "0.1"

async-trait = "0.1"
derive_builder = "0.12"
Expand Down
6 changes: 3 additions & 3 deletions components/cipher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ resolver = "2"

[workspace.dependencies]
# tlsn
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }

# crypto
aes = "0.8"
Expand Down
8 changes: 4 additions & 4 deletions components/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ lto = true


[dev-dependencies]
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
tlsn-block-cipher = { path = "../cipher/block-cipher" }
tlsn-stream-cipher = { path = "../cipher/stream-cipher" }
tlsn-universal-hash = { path = "../universal-hash" }
tlsn-aead = { path = "../aead" }
tlsn-key-exchange = { path = "../key-exchange" }
tlsn-point-addition = { path = "../point-addition" }
tlsn-hmac-sha256 = { path = "../prf/hmac-sha256" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }

uid-mux = { path = "../uid-mux" }

Expand Down
16 changes: 8 additions & 8 deletions components/key-exchange/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ default = ["mock"]
mock = []

[dependencies]
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", features = [
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", features = [
"ideal",
] }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }

p256 = { version = "0.13", features = ["ecdh", "serde"] }
async-trait = "0.1"
thiserror = "1"
serde = "1"
futures = "0.3"
serio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533" }
serio = "0.1"
derive_builder = "0.12"
tracing = "0.1"
rand = "0.8"

[dev-dependencies]
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", features = [
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", features = [
"ideal",
] }

Expand Down
8 changes: 4 additions & 4 deletions components/prf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ resolver = "2"

[workspace.dependencies]
# tlsn
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }

# async
async-trait = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions components/tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ members = [
resolver = "2"

[patch."https://github.com/tlsnotary/tlsn-utils"]
tlsn-utils-aio = { git = "https://github.com/tlsnotary//tlsn-utils", rev = "f8d4533" }
uid-mux = { git = "https://github.com/tlsnotary//tlsn-utils", rev = "f8d4533" }
serio = { git = "https://github.com/tlsnotary//tlsn-utils", rev = "f8d4533" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary//tlsn-utils", rev = "bb9769d" }
uid-mux = "0.1"
serio = "0.1"

[workspace.dependencies]
# rand
Expand Down
24 changes: 10 additions & 14 deletions components/tls/tls-mpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ default = []
tlsn-tls-core = { path = "../tls-core", features = ["serde"] }
tlsn-tls-backend = { path = "../tls-backend" }

mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-ole = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ole = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }

tlsn-block-cipher = { path = "../../cipher/block-cipher" }
tlsn-stream-cipher = { path = "../../cipher/stream-cipher" }
Expand All @@ -33,10 +33,8 @@ tlsn-aead = { path = "../../aead" }
tlsn-key-exchange = { path = "../../key-exchange" }
tlsn-hmac-sha256 = { path = "../../prf/hmac-sha256" }

tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533" }
uid-mux = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533", features = [
"serio",
] }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }
uid-mux = { version = "0.1", features = ["serio"] }

p256.workspace = true
rand.workspace = true
Expand All @@ -53,9 +51,7 @@ ludi = { git = "https://github.com/sinui0/ludi", rev = "b590de5" }
tlsn-tls-client = { path = "../tls-client" }
tlsn-tls-client-async = { path = "../tls-client-async" }
tls-server-fixture = { path = "../tls-server-fixture" }
serio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "f8d4533", features = [
"compat",
] }
serio = { version = "0.1", features = ["compat"] }

tracing-subscriber.workspace = true
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] }
Expand Down
14 changes: 7 additions & 7 deletions components/universal-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ ideal = ["dep:ghash_rc"]

[dependencies]
# tlsn
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", features = [
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", features = [
"ideal",
] }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c" }
mpz-fields = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }

ghash_rc = { package = "ghash", version = "0.5", optional = true }

Expand All @@ -39,10 +39,10 @@ tracing = "0.1"
derive_builder = "0.12"

[dev-dependencies]
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", features = [
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", features = [
"test-utils",
] }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "544cf5c", features = [
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e", features = [
"ideal",
] }

Expand Down
8 changes: 5 additions & 3 deletions notary-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ futures-util = "0.3.28"
http = "1.1"
http-body-util = "0.1"
hyper = { version = "1.1", features = ["client", "http1", "server"] }
hyper-util = {version = "0.1", features = ["full"]}
notify = { version = "6.1.1", default-features = false, features = ["macos_kqueue"] }
hyper-util = { version = "0.1", features = ["full"] }
notify = { version = "6.1.1", default-features = false, features = [
"macos_kqueue",
] }
opentelemetry = { version = "0.19" }
p256 = "0.13"
rstest = "0.18"
Expand All @@ -31,7 +33,7 @@ serde_yaml = "0.9.21"
sha1 = "0.10"
structopt = "0.3.26"
thiserror = "1"
tlsn-verifier = { path = "../tlsn/tlsn-verifier", features = ["tracing"] }
tlsn-verifier = { path = "../tlsn/tlsn-verifier" }
tokio = { version = "1", features = ["full"] }
tokio-rustls = { version = "0.24.1" }
tokio-util = { version = "0.7", features = ["compat"] }
Expand Down
23 changes: 13 additions & 10 deletions tlsn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ tlsn-tls-mpc = { path = "../components/tls/tls-mpc" }
tlsn-tls-client = { path = "../components/tls/tls-client" }
tlsn-tls-client-async = { path = "../components/tls/tls-client-async" }
tls-server-fixture = { path = "../components/tls/tls-server-fixture" }
uid-mux = { path = "../components/uid-mux" }

tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "51f313d" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "51f313d" }
spansy = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "51f313d" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }
spansy = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "bb9769d" }
serio = "0.1"
uid-mux = { version = "0.1", features = ["serio"] }

mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-garble-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "477448c " }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-common = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-garble-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-ole = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "435526e" }

futures = "0.3"
tokio-util = "0.7"
Expand Down
28 changes: 14 additions & 14 deletions tlsn/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ version = "0.0.0"

[dependencies]
mpz-core.workspace = true
notary-server = {path = "../../notary-server"}
notary-server = { path = "../../notary-server" }
tlsn-core.workspace = true
tlsn-prover = {workspace = true, features = ["tracing"]}
tlsn-prover.workspace = true
tlsn-tls-client.workspace = true
tlsn-tls-core.workspace = true
tlsn-utils.workspace = true
tlsn-verifier.workspace = true

elliptic-curve = {version = "0.13.5", features = ["pkcs8"]}
p256 = {workspace = true, features = ["ecdsa"]}
elliptic-curve = { version = "0.13.5", features = ["pkcs8"] }
p256 = { workspace = true, features = ["ecdsa"] }
webpki-roots.workspace = true

async-tls = {version = "0.12", default-features = false, features = [
async-tls = { version = "0.12", default-features = false, features = [
"client",
]}
] }
chrono = "0.4"
futures.workspace = true
http-body-util = "0.1"
hyper = {version = "1.1", features = ["client", "http1"]}
hyper-util = {version = "0.1", features = ["full"]}
rustls = {version = "0.21"}
rustls-pemfile = {version = "1.0.2"}
tokio = {workspace = true, features = [
hyper = { version = "1.1", features = ["client", "http1"] }
hyper-util = { version = "0.1", features = ["full"] }
rustls = { version = "0.21" }
rustls-pemfile = { version = "1.0.2" }
tokio = { workspace = true, features = [
"rt",
"rt-multi-thread",
"macros",
"net",
"io-std",
"fs",
]}
tokio-rustls = {version = "0.24.1"}
] }
tokio-rustls = { version = "0.24.1" }
tokio-util.workspace = true

dotenv = "0.15.0"
eyre = "0.6.8"
serde = {version = "1.0.147", features = ["derive"]}
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0"
tracing-subscriber.workspace = true
tracing.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions tlsn/tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ publish = false
[dev-dependencies]
tlsn-core.workspace = true
tlsn-tls-core.workspace = true
tlsn-prover = { workspace = true, features = ["tracing"] }
tlsn-verifier = { workspace = true, features = ["tracing"] }
tlsn-prover.workspace = true
tlsn-verifier.workspace = true
tlsn-server-fixture.workspace = true
tlsn-utils.workspace = true

Expand Down
15 changes: 11 additions & 4 deletions tlsn/tlsn-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ version = "0.1.0-alpha.5"
edition = "2021"

[features]
default = ["tracing"]
tracing = ["uid-mux/tracing"]
default = []

[dependencies]
tlsn-utils-aio.workspace = true
mpz-share-conversion.workspace = true
mpz-garble.workspace = true
mpz-garble-core.workspace = true
mpz-ot.workspace = true
mpz-ole.workspace = true
mpz-core.workspace = true
mpz-common.workspace = true

futures.workspace = true
uid-mux.workspace = true
serio = { workspace = true, features = ["codec", "bincode"] }
uid-mux = { workspace = true, features = ["serio"] }
tracing.workspace = true
18 changes: 4 additions & 14 deletions tlsn/tlsn-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ pub const DEFAULT_MAX_SENT_LIMIT: usize = 1 << 12;
/// Default for the maximum number of bytes that can be received (16Kb).
pub const DEFAULT_MAX_RECV_LIMIT: usize = 1 << 14;

// Determined experimentally, will be subject to change if underlying protocols are modified.
const KE_OTS: usize = 3360;
// Secret-sharing the GHASH blocks.
const GHASH_OTS: usize = 65664 * 2;
// Extra cushion room, eg. for sharing J0 blocks.
const EXTRA_OTS: usize = 16384;
const OTS_PER_BYTE_SENT: usize = 8;
Expand All @@ -20,12 +16,9 @@ const OTS_PER_BYTE_RECV: usize = 16;
/// Returns an estimate of the number of OTs that will be sent.
pub fn ot_send_estimate(role: Role, max_sent_data: usize, max_recv_data: usize) -> usize {
match role {
Role::Prover => KE_OTS + GHASH_OTS + EXTRA_OTS,
Role::Prover => EXTRA_OTS,
Role::Verifier => {
KE_OTS
+ EXTRA_OTS
+ (max_sent_data * OTS_PER_BYTE_SENT)
+ (max_recv_data * OTS_PER_BYTE_RECV)
EXTRA_OTS + (max_sent_data * OTS_PER_BYTE_SENT) + (max_recv_data * OTS_PER_BYTE_RECV)
}
}
}
Expand All @@ -34,11 +27,8 @@ pub fn ot_send_estimate(role: Role, max_sent_data: usize, max_recv_data: usize)
pub fn ot_recv_estimate(role: Role, max_sent_data: usize, max_recv_data: usize) -> usize {
match role {
Role::Prover => {
KE_OTS
+ EXTRA_OTS
+ (max_sent_data * OTS_PER_BYTE_SENT)
+ (max_recv_data * OTS_PER_BYTE_RECV)
EXTRA_OTS + (max_sent_data * OTS_PER_BYTE_SENT) + (max_recv_data * OTS_PER_BYTE_RECV)
}
Role::Verifier => KE_OTS + GHASH_OTS + EXTRA_OTS,
Role::Verifier => EXTRA_OTS,
}
}
Loading

0 comments on commit d9bc9e8

Please sign in to comment.