Skip to content

Commit

Permalink
feat: Dynamic Manifests (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattes authored Feb 11, 2025
1 parent 1266e7e commit 8769a82
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/staging-deploy/notary.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ User=notary
Group=notary
# TODO once web-prover-circuits paths is a config, change this
WorkingDirectory=/opt/notary/bin
ExecStart=/opt/notary/bin/notary --config /opt/notary/etc/notary-config.toml --manifest /opt/notary/etc/fixture/notary.origo_tcp_local.json
ExecStart=/opt/notary/bin/notary --config /opt/notary/etc/notary-config.toml
Restart=always
Environment="RUST_LOG=info"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_client_native_origo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run: |
export RUST_LOG=DEBUG
./target/release/notary --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json &
./target/release/notary --config ./fixture/notary-config.toml &
sleep 10
./target/release/client --config ./fixture/client.origo_tcp_local.json
2 changes: 1 addition & 1 deletion .github/workflows/test_client_native_tlsn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run: |
export RUST_LOG=DEBUG
./target/release/notary --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json &
./target/release/notary --config ./fixture/notary-config.toml &
sleep 10
./target/release/client --config ./fixture/client.tlsn_tcp_local.json
2 changes: 1 addition & 1 deletion .github/workflows/test_client_wasm_origo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- run: |
export RUST_LOG=DEBUG
./target/release/notary --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json &
./target/release/notary --config ./fixture/notary-config.toml &
sleep 10
# symlink proofs/web_proof_circuits
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ COPY --from=rust-builder /app/proofs /app/proofs
EXPOSE 7443
WORKDIR /app
ENV RUST_LOG=info
CMD ["./notary", "--config", "./fixture/notary-config.toml", "--manifest", "./fixture/notary.origo_tcp_local.json"]
CMD ["./notary", "--config", "./fixture/notary-config.toml"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ check-llvm:
exit 1; \
fi

wasm: check-llvm artifacts
wasm: artifacts
@# NOTE: This build depends on RUSTFLAGS in the client_wasm/.cargo/config.toml
-cargo install wasm-pack
-cd client_wasm/demo/static && rm -f build && ln -s ../../../proofs/web_proof_circuits build && cd ../../..
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Documentation is evolving throughout the repository as the pipeline becomes more
```
make wasm
make ios
cargo run --release -p notary -- --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json
cargo run --release -p notary -- --config ./fixture/notary-config.toml
cargo run --release -p client -- --config ./fixture/client.tlsn_tcp_local.json
cargo run --release --bin mock_server
```

## WASM Demo

```
cargo run --release -p notary -- --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json
cargo run --release -p notary -- --config ./fixture/notary-config.toml
make wasm
make wasm-demo
open https://localhost:8090
Expand All @@ -39,7 +39,7 @@ open https://localhost:8090
## Native Client Demo

```
cargo run --release -p notary -- --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json
cargo run --release -p notary -- --config ./fixture/notary-config.toml
# TLSNotary flow
cargo run --release -p client -- --config ./fixture/client.tlsn_tcp_local.json
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name ="client"
version="0.2.0"
version="0.3.0"
edition="2021"
build ="build.rs"
publish=false
Expand Down
3 changes: 3 additions & 0 deletions client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub enum ClientErrors {

#[error(transparent)]
Canceled(#[from] futures::channel::oneshot::Canceled),

#[error("Manifest missing")]
ManifestMissingError,
}

#[cfg(target_arch = "wasm32")]
Expand Down
6 changes: 5 additions & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ pub async fn prover_inner_origo(

let proof = origo::proxy_and_sign_and_generate_proof(config.clone(), proving_params).await?;

let manifest =
config.proving.manifest.clone().ok_or(errors::ClientErrors::ManifestMissingError)?;

debug!("sending proof to proxy for verification");
let verify_response =
origo::verify(config, origo::VerifyBody { session_id, origo_proof: proof.clone() }).await?;
origo::verify(config, origo::VerifyBody { session_id, origo_proof: proof.clone(), manifest })
.await?;

if !verify_response.valid {
Err(ProofError::VerifyFailed().into())
Expand Down
1 change: 1 addition & 0 deletions client/src/origo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct SignBody {
pub struct VerifyBody {
pub session_id: String,
pub origo_proof: OrigoProof,
pub manifest: Manifest,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion client_ios/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name ="client_ios"
version="0.2.0"
version="0.3.0"
edition="2021"
build ="build.rs"
publish=false
Expand Down
2 changes: 1 addition & 1 deletion client_wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name ="client_wasm"
version="0.2.0"
version="0.3.0"
edition="2021"
build ="build.rs"
publish=false
Expand Down
41 changes: 0 additions & 41 deletions fixture/notary.origo_tcp_local.json

This file was deleted.

2 changes: 1 addition & 1 deletion notary/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name ="notary"
version="0.2.0"
version="0.3.0"
edition="2021"
build ="build.rs"

Expand Down
12 changes: 0 additions & 12 deletions notary/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ use crate::errors::NotaryServerError;
struct Args {
#[arg(short, long, default_value = "config.toml")]
config: String,

#[arg(short, long, default_value = "manifest.json")]
manifest: String,
}

#[derive(Debug, Default, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -62,12 +59,3 @@ pub fn read_config() -> Config {
let c: Config = builder.build().unwrap().try_deserialize().unwrap();
c
}

pub fn read_manifest() -> Result<Manifest, NotaryServerError> {
let args = Args::parse();

let manifest_json = std::fs::read_to_string(args.manifest)?;
let manifest: Manifest = serde_json::from_str(&manifest_json)?;

Ok(manifest)
}
14 changes: 4 additions & 10 deletions notary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use hyper::{body::Incoming, server::conn::http1};
use hyper_util::rt::TokioIo;
use k256::ecdsa::SigningKey as Secp256k1SigningKey;
use p256::{ecdsa::SigningKey, pkcs8::DecodePrivateKey};
use proofs::program::manifest::Manifest;
use rustls::{
pki_types::{CertificateDer, PrivateKeyDer},
ServerConfig,
Expand Down Expand Up @@ -50,7 +49,6 @@ struct SharedState {
origo_sessions: Arc<Mutex<HashMap<String, tls_parser::Transcript<tls_parser::Raw>>>>,
verifier_sessions: Arc<Mutex<HashMap<String, origo::VerifierInputs>>>,
verifier: verifier::Verifier,
manifest: Manifest,
}

/// Main entry point for the notary server application.
Expand Down Expand Up @@ -96,22 +94,18 @@ async fn main() -> Result<(), NotaryServerError> {
let _ = rustls::crypto::ring::default_provider().install_default();

let c = config::read_config();
let manifest = config::read_manifest()?;

let listener = TcpListener::bind(&c.listen).await?;
info!("Listening on https://{}", &c.listen);

let shared_state = Arc::new(SharedState {
notary_signing_key: load_notary_signing_key(&c.notary_signing_key),
origo_signing_key: load_origo_signing_key(&c.origo_signing_key),
origo_signing_key: load_origo_signing_key(&c.origo_signing_key),
tlsn_max_sent_data: c.tlsn_max_sent_data,
tlsn_max_recv_data: c.tlsn_max_recv_data,
origo_sessions: Default::default(),
verifier_sessions: Default::default(),
verifier: verifier::initialize_verifier().unwrap(),
// TODO: This is obviously not sufficient, we need richer logic
// for informing the notary of a valid manifest.
manifest,
origo_sessions: Default::default(),
verifier_sessions: Default::default(),
verifier: verifier::initialize_verifier().unwrap(),
});

let router = Router::new()
Expand Down
2 changes: 1 addition & 1 deletion notary/src/origo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub async fn verify(
let verifier = &state.verifier;

let InitialNIVCInputs { initial_nivc_input, .. } =
state.manifest.initial_inputs::<MAX_STACK_HEIGHT, CIRCUIT_SIZE_512>(
payload.manifest.initial_inputs::<MAX_STACK_HEIGHT, CIRCUIT_SIZE_512>(
&verifier_inputs.request_messages,
&verifier_inputs.response_messages,
)?;
Expand Down
2 changes: 1 addition & 1 deletion proofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To generate witness using wasm binary, just modify these keys in [setup](./setup

- run notary:
```
RUST_LOG=debug cargo run --release -p notary -- --config ./fixture/notary-config.toml --manifest ./fixture/notary.origo_tcp_local.json
RUST_LOG=debug cargo run --release -p notary -- --config ./fixture/notary-config.toml
```

- run `make wasm` or `make wasm-debug` (for better stacktraces in wasm (really necessary to debug))
Expand Down

0 comments on commit 8769a82

Please sign in to comment.