You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(examples): fix examples for alpha.7 release (#603)
* doc: Fix examples for alpha7 release
+ Use secp256k1 key for notary server fixture
+ fix tower issue
+ Fixed doctes issues (Avoid doc test failures when ignored tests are run)
+ Run wasm tests in incognitto mode to avoid chromiumoxide ws errors
* Added comment
* minor improvements
* formatting
* polish attestation example
* use shorthand fs write
* clean
* simplify discord example
---------
Co-authored-by: sinu <[email protected]>
Copy file name to clipboardExpand all lines: crates/examples/attestation/README.md
+31-46Lines changed: 31 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,16 @@
1
-
## Simple Example: Notarize Public Data from example.com (Rust) <aname="rust-simple"></a>
1
+
## Simple Attestation Example: Notarize Public Data from example.com (Rust) <aname="rust-simple"></a>
2
2
3
3
This example demonstrates the simplest possible use case for TLSNotary:
4
-
1. Notarize: Fetch <https://example.com/> and create a proof of its content.
5
-
2. Verify the proof.
6
-
7
-
Next, we will redact the content and verify it again:
8
-
1. Redact the `USER_AGENT` and titles.
9
-
2. Verify the redacted proof.
4
+
1. Fetch <https://example.com/> and acquire an attestation of its content.
5
+
2. Create a verifiable presentation using the attestation, while redacting the value of a header.
6
+
3. Verify the presentation.
10
7
11
8
### 1. Notarize <https://example.com/>
12
9
13
-
Run a simple prover:
10
+
Run the `prove` binary.
14
11
15
12
```shell
16
-
cargo run --release --example simple_prover
13
+
cargo run --release --example attestation_prove
17
14
```
18
15
19
16
If the notarization was successful, you should see this output in the console:
@@ -22,66 +19,54 @@ If the notarization was successful, you should see this output in the console:
22
19
Starting an MPC TLS connection with the server
23
20
Got a response from the server
24
21
Notarization completed successfully!
25
-
The proof has been written to `simple_proof.json`
22
+
The attestation has been written to `example.attestation.tlsn` and the corresponding secrets to `example.secrets.tlsn`.
26
23
```
27
24
28
-
⚠️ In this simple example the `Notary` server is automatically started in the background. Note that this is for demonstration purposes only. In a real work example, the notary should be run by a neutral party or the verifier of the proofs. Consult the [Notary Server Docs](https://docs.tlsnotary.org/developers/notary_server.html) for more details on how to run a notary server.
25
+
⚠️ In this simple example the `Notary` server is automatically started in the background. Note that this is for demonstration purposes only. In a real world example, the notary should be run by a trusted party. Consult the [Notary Server Docs](https://docs.tlsnotary.org/developers/notary_server.html) for more details on how to run a notary server.
26
+
27
+
### 2. Build a verifiable presentation
29
28
30
-
### 2. Verify the Proof
29
+
This will build a verifiable presentation with the `User-Agent` header redacted from the request. This presentation can be shared with any verifier you wish to present the data to.
31
30
32
-
When you open `simple_proof.json` in an editor, you will see a JSON file with lots of non-human-readable byte arrays. You can decode this file by running:
31
+
Run the `present` binary.
33
32
34
33
```shell
35
-
cargo run --release --example simple_verifier
34
+
cargo run --release --example attestation_present
36
35
```
37
36
38
-
This will output the TLS-transaction in clear text:
37
+
If successful, you should see this output in the console:
39
38
40
39
```log
41
-
Successfully verified that the bytes below came from a session with Dns("example.com") at 2023-11-03 08:48:20 UTC.
42
-
Note that the bytes which the Prover chose not to disclose are shown as X.
43
-
44
-
Bytes sent:
45
-
...
46
-
```
47
-
48
-
### 3. Redact Information
49
-
50
-
Open `simple_prover.rs` and locate the line with:
51
-
52
-
```rust
53
-
letredact=false;
40
+
Presentation built successfully!
41
+
The presentation has been written to `example.presentation.tlsn`.
54
42
```
55
43
56
-
and change it to:
44
+
### 3. Verify the presentation
57
45
58
-
```rust
59
-
letredact=true;
60
-
```
46
+
This will read the presentation from the previous step, verify it, and print the disclosed data to console.
61
47
62
-
Next, if you run the `simple_prover` and `simple_verifier` again, you'll notice redacted `X`'s in the output:
48
+
Run the `verify` binary.
63
49
64
50
```shell
65
-
cargo run --release --example simple_prover
66
-
cargo run --release --example simple_verifier
51
+
cargo run --release --example attestation_verify
67
52
```
68
53
54
+
If successful, you should see this output in the console:
You can also use <https://explorer.tlsnotary.org/> to inspect your proofs. Simply drag and drop `simple_proof.json` from your file explorer into the drop zone. Redacted bytes are marked with X characters. [Notary public key](../../notary/server/fixture/notary/notary.pub)
Successfully verified that the data below came from a session with example.com at 2024-10-03 03:01:40 UTC.
63
+
Note that the data which the Prover chose not to disclose are shown as X.
80
64
81
-
Feel free to try these extra challenges:
65
+
Data sent:
66
+
...
67
+
```
82
68
83
-
-[ ] Modify the `server_name` (or any other data) in `simple_proof.json` and verify that the proof is no longer valid.
84
-
-[ ] Modify the `build_proof_with_redactions` function in `simple_prover.rs` to redact more or different data.
69
+
⚠️ Notice that the presentation comes with a "verifying key". This is the key the Notary used when issuing the attestation that the presentation was built from. If you trust the Notary, or more specifically the verifying key, then you can trust that the presented data is authentic.
0 commit comments