Skip to content

Commit

Permalink
Modify documentation and add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuroitaki committed Aug 17, 2023
1 parent 03d12f9 commit a9a6ea5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tlsn/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ name = "twitter_dm"
path = "twitter_dm.rs"

[[example]]
name = "notary"
path = "notary.rs"
name = "simple_notary"
path = "simple_notary.rs"
2 changes: 2 additions & 0 deletions tlsn/examples/notary.rs → tlsn/examples/simple_notary.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// This is a simple implementation of the notary server with minimal functionalities (without TLS, does not support WebSocket and configuration etc.)
/// For a more functional notary server implementation, please use https://github.com/tlsnotary/notary-server
use std::env;

use tokio::net::TcpListener;
Expand Down
22 changes: 10 additions & 12 deletions tlsn/examples/twitter_dm.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,26 @@ This involves 3 steps:
In this tlsn/examples folder, create a `.env` file.
Then in that `.env` file, set the values of the following constants by following the format shown in this [example env file](./.env.example).

| Name | Example |
| --------------- | ------------------------------------------------------- |
| CONVERSATION_ID | `20124652-973145016511139841` |
| CLIENT_UUID | `e6f00000-cccc-dddd-bbbb-eeeeeefaaa27` |
| AUTH_TOKEN | `670ccccccbe2bbbbbbbc1025aaaaaafa55555551` |
| ACCESS_TOKEN | `AAAAAAAAAAAAAAAAAAAAANRILgAA...4puTs%3D1Zv7...WjCpTnA` |
| CSRF_TOKEN | `77d8ef46bd57f722ea7e9f...f4235a713040bfcaac1cd6909` |
| Name | Example | Location in Request Headers Section (within Network Tab of Developer Tools) |
| --------------- | ------------------------------------------------------- |---------------------------------------------------------------------------------- |
| CONVERSATION_ID | `20124652-973145016511139841` | Look for `Referer`, then extract the `ID` in `https://twitter.com/messages/<ID>` |
| CLIENT_UUID | `e6f00000-cccc-dddd-bbbb-eeeeeefaaa27` | Look for `X-Client-Uuid`, then copy the entire value |
| AUTH_TOKEN | `670ccccccbe2bbbbbbbc1025aaaaaafa55555551` | Look for `Cookie`, then extract the `token` in `;auth_token=<token>;` |
| ACCESS_TOKEN | `AAAAAAAAAAAAAAAAAAAAANRILgAA...4puTs%3D1Zv7...WjCpTnA` | Look for `Authorization`, then extract the `token` in `Bearer <token>` |
| CSRF_TOKEN | `77d8ef46bd57f722ea7e9f...f4235a713040bfcaac1cd6909` | Look for `X-Csrf-Token`, then copy the entire value |

You can obtain these parameters by opening [Twitter](https://twitter.com/messages/) in your browser and accessing the message history you want to notarize. Please note that notarizing only works for short transcripts at the moment, so choose a contact with a short history. The `CONVERSATION_ID` corresponds to the last part of the URL.
You can obtain these parameters by opening [Twitter](https://twitter.com/messages/) in your browser and accessing the message history you want to notarize. Please note that notarizing only works for short transcripts at the moment, so choose a contact with a short history.

Next, open the **Developer Tools**, go to the **Network** tab, and refresh the page. Then, click on **Search** and type `uuid` as shown in the screenshot below:
Next, open the **Developer Tools**, go to the **Network** tab, and refresh the page. Then, click on **Search** and type `uuid` as shown in the screenshot below — all of these constants should be under the **Request Headers** section. Refer to the table above on where to find each of the constant value.

![Screenshot](twitter_dm_browser.png)

Repeat the process for the other constants.

## Start the notary server

```
git clone https://github.com/tlsnotary/notary-server
cd notary-server
cargo run
cargo run --release
```

The notary server will now be running in the background waiting for connections.
Expand Down
6 changes: 6 additions & 0 deletions tlsn/examples/twitter_dm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// This prover implementation talks to the notary server implemented in https://github.com/tlsnotary/notary-server, instead of the simple_notary.rs in this example directory
use eyre::Result;
use futures::AsyncWriteExt;
use hyper::{body::to_bytes, client::conn::Parts, Body, Request, StatusCode};
Expand All @@ -18,13 +19,17 @@ use tracing::debug;

use tlsn_prover::{bind_prover, ProverConfig};

// Setting of the application server
const SERVER_DOMAIN: &str = "twitter.com";
const ROUTE: &str = "i/api/1.1/dm/conversation";
const USER_AGENT: &str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";

// Setting of the notary server — make sure these are the same with those in the notary-server repository used (https://github.com/tlsnotary/notary-server)
const NOTARY_DOMAIN: &str = "127.0.0.1";
const NOTARY_PORT: u16 = 7047;
const NOTARY_CA_CERT_PATH: &str = "./rootCA.crt";

// Configuration of notarization
const NOTARY_MAX_TRANSCRIPT_SIZE: usize = 16384;

/// Response object of the /session API
Expand Down Expand Up @@ -90,6 +95,7 @@ async fn main() {
.unwrap();

let notary_tls_socket = notary_connector
// Require the domain name of notary server to be the same as that in the server cert
.connect("tlsnotaryserver.io".try_into().unwrap(), notary_socket)
.await
.unwrap();
Expand Down

0 comments on commit a9a6ea5

Please sign in to comment.