Skip to content

Commit 92d7b59

Browse files
authored
doc(example): add minor comments (#761)
* Add comments. * Remove commented leftover. * Remove example tweak. * fmt. --------- Co-authored-by: yuroitaki <>
1 parent c8e9cb3 commit 92d7b59

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

crates/examples/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ notary-client = { workspace = true }
99
tlsn-common = { workspace = true }
1010
tlsn-core = { workspace = true }
1111
tlsn-prover = { workspace = true }
12-
tlsn-utils = { workspace = true }
1312
tlsn-verifier = { workspace = true }
1413
tlsn-formats = { workspace = true }
1514
tlsn-tls-core = { workspace = true }

crates/examples/attestation/present.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ async fn create_presentation(example_type: &ExampleType) -> Result<(), Box<dyn s
4040
// Build a transcript proof.
4141
let mut builder = secrets.transcript_proof_builder();
4242

43+
// Here is where we reveal all or some of the parts we committed in `prove.rs`
44+
// previously.
4345
let request = &transcript.requests[0];
4446
// Reveal the structure of the request without the headers or body.
4547
builder.reveal_sent(&request.without_data())?;
4648
// Reveal the request target.
4749
builder.reveal_sent(&request.request.target)?;
48-
// Reveal all headers except the values of User-Agent and Authorization.
50+
// Reveal all request headers except the values of User-Agent and Authorization.
4951
for header in &request.headers {
5052
if !(header
5153
.name
@@ -64,7 +66,9 @@ async fn create_presentation(example_type: &ExampleType) -> Result<(), Box<dyn s
6466

6567
// Reveal only parts of the response
6668
let response = &transcript.responses[0];
69+
// Reveal the structure of the response without the headers or body.
6770
builder.reveal_recv(&response.without_data())?;
71+
// Reveal all response headers.
6872
for header in &response.headers {
6973
builder.reveal_recv(header)?;
7074
}

crates/examples/attestation/prove.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ async fn notarize(
164164

165165
// Parse the HTTP transcript.
166166
let transcript = HttpTranscript::parse(prover.transcript())?;
167-
// dbg!(&transcript);
168167

169168
let body_content = &transcript.responses[0].body.as_ref().unwrap().content;
170169
let body = String::from_utf8_lossy(body_content.span().as_bytes());
@@ -183,6 +182,9 @@ async fn notarize(
183182
// Commit to the transcript.
184183
let mut builder = TranscriptCommitConfig::builder(prover.transcript());
185184

185+
// This commits to various parts of the transcript separately (e.g. request
186+
// headers, response headers, response body and more). See https://docs.tlsnotary.org//protocol/commit_strategy.html
187+
// for other strategies that can be used to generate commitments.
186188
DefaultHttpCommitter::default().commit_transcript(&mut builder, &transcript)?;
187189

188190
prover.transcript_commit(builder.build()?);

0 commit comments

Comments
 (0)