From 4396ce4db7c1bec799cc1eb0db1371ad9e0dd8b6 Mon Sep 17 00:00:00 2001 From: Hendrik Eeckhaut Date: Tue, 29 Oct 2024 08:22:31 +0100 Subject: [PATCH] review feedback --- crates/examples/attestation/README.md | 3 ++- crates/examples/attestation/present.rs | 3 ++- crates/examples/interactive/interactive.rs | 15 +++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/examples/attestation/README.md b/crates/examples/attestation/README.md index f87c34c7f6..e4552884df 100644 --- a/crates/examples/attestation/README.md +++ b/crates/examples/attestation/README.md @@ -98,7 +98,8 @@ cargo run --release --example attestation_verify -- html ### Private Data -The examples above demonstrate TLSNotary with public data. TLSNotary can also be used for private data by adding the necessary headers (e.g., an authentication token) or cookies to the request. To run a private data example: +The examples above demonstrate how to use TLSNotary with publicly accessible data. TLSNotary can also be utilized for private data that requires authentication. To access this data, you can add the necessary headers (such as an authentication token) or cookies to your request. To run an example that uses an authentication token, execute the following command: + ```shell # notarize SERVER_PORT=4000 cargo run --release --example attestation_prove -- authenticated diff --git a/crates/examples/attestation/present.rs b/crates/examples/attestation/present.rs index 1087521b64..9b788ef45f 100644 --- a/crates/examples/attestation/present.rs +++ b/crates/examples/attestation/present.rs @@ -45,7 +45,7 @@ async fn create_presentation(example_type: &ExampleType) -> Result<(), Box Result<(), Box { + // For experimentation, reveal the entire response or just a selection let reveal_all = false; if reveal_all { builder.reveal_recv(response)?; diff --git a/crates/examples/interactive/interactive.rs b/crates/examples/interactive/interactive.rs index ef493f6559..7befd4ddda 100644 --- a/crates/examples/interactive/interactive.rs +++ b/crates/examples/interactive/interactive.rs @@ -124,8 +124,8 @@ async fn prover( let mut prover = prover_task.await.unwrap().unwrap().start_prove(); // Reveal parts of the transcript - let idx_sent = redact_ranges_sent(&mut prover); - let idx_recv = redact_ranges_received(&mut prover); + let idx_sent = revealed_ranges_sent(&mut prover); + let idx_recv = revealed_ranges_received(&mut prover); prover.prove_transcript(idx_sent, idx_recv).await.unwrap(); // Finalize. @@ -154,10 +154,9 @@ async fn verifier( let (mut partial_transcript, session_info) = verifier.verify(socket.compat()).await.unwrap(); partial_transcript.set_unauthed(0); - // Check sent data: check host. + // Check sent data: let sent = partial_transcript.sent_unsafe().to_vec(); let sent_data = String::from_utf8(sent.clone()).expect("Verifier expected sent data"); - sent_data .find(SERVER_DOMAIN) .unwrap_or_else(|| panic!("Verification failed: Expected host {}", SERVER_DOMAIN)); @@ -175,8 +174,8 @@ async fn verifier( (sent, received, session_info) } -/// Redacts and reveals received data to the verifier. -fn redact_ranges_received(prover: &mut Prover) -> Idx { +/// Returns the received ranges to be revealed to the verifier. +fn revealed_ranges_received(prover: &mut Prover) -> Idx { let recv_transcript = prover.transcript().received(); let recv_transcript_len = recv_transcript.len(); @@ -191,8 +190,8 @@ fn redact_ranges_received(prover: &mut Prover) -> Idx { Idx::new([0..start, end..recv_transcript_len]) } -/// Redacts and reveals sent data to the verifier. -fn redact_ranges_sent(prover: &mut Prover) -> Idx { +/// Returns the sent ranges to be revealed to the verifier. +fn revealed_ranges_sent(prover: &mut Prover) -> Idx { let sent_transcript = prover.transcript().sent(); let sent_transcript_len = sent_transcript.len();