Skip to content

Commit

Permalink
refactor: selective disclosure api (#380)
Browse files Browse the repository at this point in the history
* refactor: selective disclosure api

* remove incomplete substring proof API

* remove unnecessary type annotation

* simplify tests

* switch from unit structs to empty structs

* skip committing empty strings

* fix notary server test

* rename RecordKind to MessageKind

* update json commit error doc

* commits -> commits to

* update commit_array doc

* function argument doc styling

* Update tlsn/tlsn-core/src/proof/substrings.rs

Co-authored-by: dan <[email protected]>

---------

Co-authored-by: dan <[email protected]>
  • Loading branch information
sinui0 and themighty1 authored Feb 8, 2024
1 parent f9f4a08 commit bb50e3d
Show file tree
Hide file tree
Showing 38 changed files with 931 additions and 1,805 deletions.
6 changes: 3 additions & 3 deletions components/aead/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ tracing = [
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 = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

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 = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

# 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 = "ecb8c54" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
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 = "8d8ffe1" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

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

Expand Down
10 changes: 5 additions & 5 deletions components/key-exchange/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ tracing = ["dep:tracing", "tlsn-point-addition/tracing"]
mock = []

[dependencies]
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
tlsn-point-addition = { path = "../point-addition" }
p256 = { version = "0.13", features = ["ecdh"] }
async-trait = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions components/point-addition/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mock = ["dep:mpz-core"]
tracing = ["dep:tracing"]

[dependencies]
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54", optional = true }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778", optional = true }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
p256 = { version = "0.13", features = ["arithmetic"] }
tracing = { version = "0.1", optional = true }
async-trait = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions components/prf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resolver = "2"

[workspace.dependencies]
# tlsn
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }

# async
async-trait = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion components/prf/hmac-sha256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mock = []

[dependencies]
tlsn-hmac-sha256-circuits = { path = "../hmac-sha256-circuits" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }
mpz-garble.workspace = true
mpz-circuits.workspace = true

Expand Down
10 changes: 5 additions & 5 deletions components/tls/tls-mpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ tracing = [
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 = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }

tlsn-block-cipher = { path = "../../cipher/block-cipher" }
tlsn-stream-cipher = { path = "../../cipher/stream-cipher" }
Expand All @@ -42,7 +42,7 @@ 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 = "8d8ffe1" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

p256.workspace = true
rand.workspace = true
Expand All @@ -59,7 +59,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" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
uid-mux = { path = "../../uid-mux" }

tracing-subscriber.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion components/uid-mux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2021"
tracing = ["dep:tracing"]

[dependencies]
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

async-trait = "0.1"
futures = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions components/universal-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ mock = []

[dependencies]
# tlsn
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }

# async
async-trait = "0.1"
Expand Down
8 changes: 4 additions & 4 deletions notary-server/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ async fn test_tcp_prover<S: AsyncWrite + AsyncRead + Send + Unpin + 'static>(

let builder = prover.commitment_builder();

builder.commit_sent(0..sent_len).unwrap();
builder.commit_recv(0..recv_len).unwrap();
builder.commit_sent(&(0..sent_len)).unwrap();
builder.commit_recv(&(0..recv_len)).unwrap();

_ = prover.finalize().await.unwrap();

Expand Down Expand Up @@ -472,8 +472,8 @@ async fn test_websocket_prover() {

let builder = prover.commitment_builder();

builder.commit_sent(0..sent_len).unwrap();
builder.commit_recv(0..recv_len).unwrap();
builder.commit_sent(&(0..sent_len)).unwrap();
builder.commit_recv(&(0..recv_len)).unwrap();

_ = prover.finalize().await.unwrap();

Expand Down
24 changes: 11 additions & 13 deletions tlsn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"tlsn-common",
"tlsn-verifier",
"tlsn-prover",
# "tlsn-formats",
"tlsn-formats",
"tlsn-server-fixture",
"tests-integration",
"examples",
Expand All @@ -18,8 +18,7 @@ tlsn-common = { path = "tlsn-common" }
tlsn-prover = { path = "tlsn-prover" }
tlsn-verifier = { path = "tlsn-verifier" }
tlsn-server-fixture = { path = "tlsn-server-fixture" }

#tlsn-formats = { path = "tlsn-formats" }
tlsn-formats = { path = "tlsn-formats" }

tlsn-tls-core = { path = "../components/tls/tls-core" }
tlsn-tls-mpc = { path = "../components/tls/tls-mpc" }
Expand All @@ -28,16 +27,16 @@ 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 = "8d8ffe1" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "8d8ffe1" }

mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-garble-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "ecb8c54" }
tlsn-utils = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }
tlsn-utils-aio = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }
spansy = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "33052c6" }

mpz-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-circuits = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble-core = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }
mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "90a3778" }

futures = "0.3"
tokio-util = "0.7"
Expand All @@ -59,7 +58,6 @@ bincode = "1"
hex = "0.4"
bytes = "1.4"
opaque-debug = "0.3"
spansy = { git = "https://github.com/sinui0/spansy", rev = "becb33d" }

tracing = "0.1"
tracing-subscriber = "0.3"
Expand Down
10 changes: 5 additions & 5 deletions tlsn/examples/discord/discord_dm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ async fn main() {
let mut commitment_ids = public_ranges
.iter()
.chain(private_ranges.iter())
.map(|range| builder.commit_sent(range.clone()).unwrap())
.map(|range| builder.commit_sent(range).unwrap())
.collect::<Vec<_>>();

// Commit to the full received transcript in one shot, as we don't need to redact anything
commitment_ids.push(builder.commit_recv(0..recv_len).unwrap());
commitment_ids.push(builder.commit_recv(&(0..recv_len)).unwrap());

// Finalize, returning the notarized session
let notarized_session = prover.finalize().await.unwrap();
Expand All @@ -173,9 +173,9 @@ async fn main() {
let mut proof_builder = notarized_session.data().build_substrings_proof();

// Reveal everything but the auth token (which was assigned commitment id 2)
proof_builder.reveal(commitment_ids[0]).unwrap();
proof_builder.reveal(commitment_ids[1]).unwrap();
proof_builder.reveal(commitment_ids[3]).unwrap();
proof_builder.reveal_by_id(commitment_ids[0]).unwrap();
proof_builder.reveal_by_id(commitment_ids[1]).unwrap();
proof_builder.reveal_by_id(commitment_ids[3]).unwrap();

let substrings_proof = proof_builder.build().unwrap();

Expand Down
16 changes: 8 additions & 8 deletions tlsn/examples/simple/simple_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ async fn build_proof_without_redactions(mut prover: Prover<Notarize>) -> TlsProo
let recv_len = prover.recv_transcript().data().len();

let builder = prover.commitment_builder();
let sent_commitment = builder.commit_sent(0..sent_len).unwrap();
let recv_commitment = builder.commit_recv(0..recv_len).unwrap();
let sent_commitment = builder.commit_sent(&(0..sent_len)).unwrap();
let recv_commitment = builder.commit_recv(&(0..recv_len)).unwrap();

// Finalize, returning the notarized session
let notarized_session = prover.finalize().await.unwrap();
Expand All @@ -162,8 +162,8 @@ async fn build_proof_without_redactions(mut prover: Prover<Notarize>) -> TlsProo
let mut proof_builder = notarized_session.data().build_substrings_proof();

// Reveal all the public ranges
proof_builder.reveal(sent_commitment).unwrap();
proof_builder.reveal(recv_commitment).unwrap();
proof_builder.reveal_by_id(sent_commitment).unwrap();
proof_builder.reveal_by_id(recv_commitment).unwrap();

let substrings_proof = proof_builder.build().unwrap();

Expand Down Expand Up @@ -197,12 +197,12 @@ async fn build_proof_with_redactions(mut prover: Prover<Notarize>) -> TlsProof {
// Commit to each range of the public outbound data which we want to disclose
let sent_commitments: Vec<_> = sent_public_ranges
.iter()
.map(|r| builder.commit_sent(r.clone()).unwrap())
.map(|range| builder.commit_sent(range).unwrap())
.collect();
// Commit to each range of the public inbound data which we want to disclose
let recv_commitments: Vec<_> = recv_public_ranges
.iter()
.map(|r| builder.commit_recv(r.clone()).unwrap())
.map(|range| builder.commit_recv(range).unwrap())
.collect();

// Finalize, returning the notarized session
Expand All @@ -213,10 +213,10 @@ async fn build_proof_with_redactions(mut prover: Prover<Notarize>) -> TlsProof {

// Reveal all the public ranges
for commitment_id in sent_commitments {
proof_builder.reveal(commitment_id).unwrap();
proof_builder.reveal_by_id(commitment_id).unwrap();
}
for commitment_id in recv_commitments {
proof_builder.reveal(commitment_id).unwrap();
proof_builder.reveal_by_id(commitment_id).unwrap();
}

let substrings_proof = proof_builder.build().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions tlsn/examples/twitter/twitter_dm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ async fn main() {
// Commit to send public data and collect commitment ids for the outbound transcript
let mut commitment_ids = public_ranges
.iter()
.map(|range| builder.commit_sent(range.clone()).unwrap())
.map(|range| builder.commit_sent(range).unwrap())
.collect::<Vec<_>>();
// Commit to private data. This is not needed for proof creation but ensures the data
// is in the notarized session file for optional future disclosure.
private_ranges.iter().for_each(|range| {
builder.commit_sent(range.clone()).unwrap();
builder.commit_sent(range).unwrap();
});
// Commit to the received (public) data.
commitment_ids.push(builder.commit_recv(0..recv_len).unwrap());
commitment_ids.push(builder.commit_recv(&(0..recv_len)).unwrap());

// Finalize, returning the notarized session
let notarized_session = prover.finalize().await.unwrap();
Expand All @@ -192,7 +192,7 @@ async fn main() {

let mut proof_builder = notarized_session.data().build_substrings_proof();
for commitment_id in commitment_ids {
proof_builder.reveal(commitment_id).unwrap();
proof_builder.reveal_by_id(commitment_id).unwrap();
}
let substrings_proof = proof_builder.build().unwrap();

Expand Down
4 changes: 2 additions & 2 deletions tlsn/tests-integration/tests/defer_decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ async fn prover<T: AsyncWrite + AsyncRead + Send + Unpin + 'static>(notary_socke
let builder = prover.commitment_builder();

// Commit to everything
builder.commit_sent(0..sent_tx_len).unwrap();
builder.commit_recv(0..recv_tx_len).unwrap();
builder.commit_sent(&(0..sent_tx_len)).unwrap();
builder.commit_recv(&(0..recv_tx_len)).unwrap();

let _notarized_session = prover.finalize().await.unwrap();
}
Expand Down
6 changes: 3 additions & 3 deletions tlsn/tests-integration/tests/notarize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ async fn prover<T: AsyncWrite + AsyncRead + Send + Unpin + 'static>(notary_socke
let builder = prover.commitment_builder();

// Commit to everything
builder.commit_sent(0..sent_tx_len).unwrap();
builder.commit_recv(0..recv_tx_len).unwrap();
builder.commit_sent(&(0..sent_tx_len)).unwrap();
builder.commit_recv(&(0..recv_tx_len)).unwrap();

let _notarized_session = prover.finalize().await.unwrap();
prover.finalize().await.unwrap();
}

#[instrument(skip(socket))]
Expand Down
Loading

0 comments on commit bb50e3d

Please sign in to comment.