From facfa81eb94ca64826050181497bea3dfb2ef50b Mon Sep 17 00:00:00 2001 From: th4s Date: Tue, 5 Sep 2023 16:20:50 +0200 Subject: [PATCH] Add spansy and start with assertion on `VerifiedTranscript` --- tlsn/Cargo.toml | 1 + tlsn/tlsn-verifier/Cargo.toml | 2 ++ tlsn/tlsn-verifier/src/assert.rs | 3 +++ tlsn/tlsn-verifier/src/lib.rs | 15 +++++++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tlsn/tlsn-verifier/src/assert.rs diff --git a/tlsn/Cargo.toml b/tlsn/Cargo.toml index 7fbcc2f537..43639469f8 100644 --- a/tlsn/Cargo.toml +++ b/tlsn/Cargo.toml @@ -31,6 +31,7 @@ mpz-garble = { git = "https://github.com/privacy-scaling-explorations/mpz", rev mpz-ot = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "a98fd8a" } mpz-share-conversion = { git = "https://github.com/privacy-scaling-explorations/mpz", rev = "a98fd8a" } +spansy = {git = "https://github.com/sinui0/spansy", rev = "23a6b0a"} futures = "0.3" tokio-util = "0.7" diff --git a/tlsn/tlsn-verifier/Cargo.toml b/tlsn/tlsn-verifier/Cargo.toml index d7e05333a8..2728e2be7a 100644 --- a/tlsn/tlsn-verifier/Cargo.toml +++ b/tlsn/tlsn-verifier/Cargo.toml @@ -17,6 +17,8 @@ tlsn-utils.workspace = true mpz-core.workspace = true +spansy.workspace = true + webpki-roots.workspace = true p256.workspace = true thiserror.workspace = true diff --git a/tlsn/tlsn-verifier/src/assert.rs b/tlsn/tlsn-verifier/src/assert.rs new file mode 100644 index 0000000000..f3ec2c7caa --- /dev/null +++ b/tlsn/tlsn-verifier/src/assert.rs @@ -0,0 +1,3 @@ +pub struct VerifiedTranscript { + pub(crate) data: Vec, +} diff --git a/tlsn/tlsn-verifier/src/lib.rs b/tlsn/tlsn-verifier/src/lib.rs index c4b7c36936..26071f371b 100644 --- a/tlsn/tlsn-verifier/src/lib.rs +++ b/tlsn/tlsn-verifier/src/lib.rs @@ -34,6 +34,9 @@ use tlsn_core::{ }; use utils::invert_range::invert_range; +mod assert; +use assert::VerifiedTranscript; + /// Valid characters for redacted parts in transcripts pub const VALID_REDACTMENT_CHARS: &[u8] = b"x"; @@ -75,7 +78,7 @@ impl Verifier { /// Sets a new session proof and verifies it. pub fn set_session_proof(&mut self, session_proof: SessionProof) -> Result<(), VerifierError> { self.session_proof = Some(session_proof); - let verify_result = self.verify(); + let verify_result = self.verify_session_proof(); if verify_result.is_err() { self.session_proof = None; @@ -95,7 +98,7 @@ impl Verifier { proof: SubstringsProof, transcript: Transcript, direction: Direction, - ) -> Result<(), VerifierError> { + ) -> Result { let header = self .session_proof .as_ref() @@ -142,10 +145,14 @@ impl Verifier { return Err(VerifierError::InvalidRedactedTranscript); } - Ok(()) + let verified_transcript = VerifiedTranscript { + data: transcript.data().to_vec(), + }; + + Ok(verified_transcript) } - fn verify(&self) -> Result<(), VerifierError> { + fn verify_session_proof(&self) -> Result<(), VerifierError> { if let Some(notary_pk) = self.notary_pubkey { self.verify_notary_signature(notary_pk)?; }