Skip to content

Commit

Permalink
Add spansy and start with assertion on VerifiedTranscript
Browse files Browse the repository at this point in the history
  • Loading branch information
th4s committed Sep 12, 2023
1 parent 8759c2d commit facfa81
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions tlsn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tlsn/tlsn-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tlsn/tlsn-verifier/src/assert.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub struct VerifiedTranscript {
pub(crate) data: Vec<u8>,
}
15 changes: 11 additions & 4 deletions tlsn/tlsn-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand All @@ -95,7 +98,7 @@ impl Verifier {
proof: SubstringsProof,
transcript: Transcript,
direction: Direction,
) -> Result<(), VerifierError> {
) -> Result<VerifiedTranscript, VerifierError> {
let header = self
.session_proof
.as_ref()
Expand Down Expand Up @@ -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)?;
}
Expand Down

0 comments on commit facfa81

Please sign in to comment.