Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
heeckhau committed Oct 29, 2024
1 parent a80dbba commit 4396ce4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion crates/examples/attestation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/examples/attestation/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn create_presentation(example_type: &ExampleType) -> Result<(), Box<dyn s
builder.reveal_sent(&request.without_data())?;
// Reveal the request target.
builder.reveal_sent(&request.request.target)?;
// Reveal all headers except the value of the User-Agent header.
// Reveal all headers except the values of the User-Agent and Authorization.
for header in &request.headers {
if !(header
.name
Expand All @@ -72,6 +72,7 @@ async fn create_presentation(example_type: &ExampleType) -> Result<(), Box<dyn s
let content = &response.body.as_ref().unwrap().content;
match content {
tlsn_formats::http::BodyContent::Json(json) => {
// For experimentation, reveal the entire response or just a selection
let reveal_all = false;
if reveal_all {
builder.reveal_recv(response)?;
Expand Down
15 changes: 7 additions & 8 deletions crates/examples/interactive/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ async fn prover<T: AsyncWrite + AsyncRead + Send + Unpin + 'static>(
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.
Expand Down Expand Up @@ -154,10 +154,9 @@ async fn verifier<T: AsyncWrite + AsyncRead + Send + Sync + Unpin + 'static>(
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));
Expand All @@ -175,8 +174,8 @@ async fn verifier<T: AsyncWrite + AsyncRead + Send + Sync + Unpin + 'static>(
(sent, received, session_info)
}

/// Redacts and reveals received data to the verifier.
fn redact_ranges_received(prover: &mut Prover<Prove>) -> Idx {
/// Returns the received ranges to be revealed to the verifier.
fn revealed_ranges_received(prover: &mut Prover<Prove>) -> Idx {
let recv_transcript = prover.transcript().received();
let recv_transcript_len = recv_transcript.len();

Expand All @@ -191,8 +190,8 @@ fn redact_ranges_received(prover: &mut Prover<Prove>) -> Idx {
Idx::new([0..start, end..recv_transcript_len])
}

/// Redacts and reveals sent data to the verifier.
fn redact_ranges_sent(prover: &mut Prover<Prove>) -> Idx {
/// Returns the sent ranges to be revealed to the verifier.
fn revealed_ranges_sent(prover: &mut Prover<Prove>) -> Idx {
let sent_transcript = prover.transcript().sent();
let sent_transcript_len = sent_transcript.len();

Expand Down

0 comments on commit 4396ce4

Please sign in to comment.