Skip to content

Commit 6578386

Browse files
th4ssinui0
andauthored
chore: remove notarize methods for prover and verifier (#952)
* feat: remove notarize methods for prover and verifier * clean up imports * remove remaining notarize methods * clean up imports * remove wasm attestation bindings --------- Co-authored-by: sinu <[email protected]>
1 parent 2f072b2 commit 6578386

File tree

8 files changed

+5
-608
lines changed

8 files changed

+5
-608
lines changed

crates/tlsn/src/prover.rs

Lines changed: 2 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,16 @@ use crate::{
3232
use futures::{AsyncRead, AsyncWrite, TryFutureExt};
3333
use mpc_tls::{LeaderCtrl, MpcTlsLeader, SessionKeys};
3434
use rand::Rng;
35-
use serio::{SinkExt, stream::IoStreamExt};
35+
use serio::SinkExt;
3636
use std::sync::Arc;
3737
use tls_client::{ClientConnection, ServerName as TlsServerName};
3838
use tls_client_async::{TlsConnection, bind_client};
3939
use tls_core::msgs::enums::ContentType;
40-
use tlsn_attestation::{
41-
Attestation, CryptoProvider, Secrets,
42-
request::{Request, RequestConfig},
43-
};
4440
use tlsn_core::{
4541
ProvePayload,
4642
connection::ServerCertData,
4743
hash::{Blake3, HashAlgId, HashAlgorithm, Keccak256, Sha256},
48-
transcript::{Direction, TlsTranscript, Transcript, TranscriptCommitment, TranscriptSecret},
44+
transcript::{TlsTranscript, Transcript, TranscriptCommitment, TranscriptSecret},
4945
};
5046
use tlsn_deap::Deap;
5147
use tokio::sync::Mutex;
@@ -458,118 +454,6 @@ impl Prover<state::Committed> {
458454
Ok(output)
459455
}
460456

461-
/// Requests an attestation from the verifier.
462-
///
463-
/// # Arguments
464-
///
465-
/// * `config` - The attestation request configuration.
466-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
467-
#[deprecated(
468-
note = "attestation functionality will be removed from this API in future releases."
469-
)]
470-
pub async fn notarize(
471-
&mut self,
472-
config: &RequestConfig,
473-
) -> Result<(Attestation, Secrets), ProverError> {
474-
#[allow(deprecated)]
475-
self.notarize_with_provider(config, &CryptoProvider::default())
476-
.await
477-
}
478-
479-
/// Requests an attestation from the verifier.
480-
///
481-
/// # Arguments
482-
///
483-
/// * `config` - The attestation request configuration.
484-
/// * `provider` - Cryptography provider.
485-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
486-
#[deprecated(
487-
note = "attestation functionality will be removed from this API in future releases."
488-
)]
489-
pub async fn notarize_with_provider(
490-
&mut self,
491-
config: &RequestConfig,
492-
provider: &CryptoProvider,
493-
) -> Result<(Attestation, Secrets), ProverError> {
494-
let mut builder = ProveConfig::builder(self.transcript());
495-
496-
if let Some(config) = config.transcript_commit() {
497-
// Temporarily, we reject attestation requests which contain hash commitments to
498-
// subsets of the transcript. We do this because we want to preserve the
499-
// obliviousness of the reference notary, and hash commitments currently leak
500-
// the ranges which are being committed.
501-
for ((direction, idx), _) in config.iter_hash() {
502-
let len = match direction {
503-
Direction::Sent => self.transcript().sent().len(),
504-
Direction::Received => self.transcript().received().len(),
505-
};
506-
507-
if idx.start() > 0 || idx.end() < len || idx.count() != 1 {
508-
return Err(ProverError::attestation(
509-
"hash commitments to subsets of the transcript are currently not supported in attestation requests",
510-
));
511-
}
512-
}
513-
514-
builder.transcript_commit(config.clone());
515-
}
516-
517-
let disclosure_config = builder.build().map_err(ProverError::attestation)?;
518-
519-
let ProverOutput {
520-
transcript_commitments,
521-
transcript_secrets,
522-
..
523-
} = self.prove(&disclosure_config).await?;
524-
525-
let state::Committed {
526-
mux_fut,
527-
ctx,
528-
tls_transcript,
529-
transcript,
530-
..
531-
} = &mut self.state;
532-
533-
let mut builder = Request::builder(config);
534-
535-
builder
536-
.server_name(self.config.server_name().clone())
537-
.server_cert_data(ServerCertData {
538-
certs: tls_transcript
539-
.server_cert_chain()
540-
.expect("server cert chain is present")
541-
.to_vec(),
542-
sig: tls_transcript
543-
.server_signature()
544-
.expect("server signature is present")
545-
.clone(),
546-
handshake: tls_transcript.handshake_data().clone(),
547-
})
548-
.transcript(transcript.clone())
549-
.transcript_commitments(transcript_secrets, transcript_commitments);
550-
551-
let (request, secrets) = builder.build(provider).map_err(ProverError::attestation)?;
552-
553-
let attestation = mux_fut
554-
.poll_with(async {
555-
debug!("sending attestation request");
556-
557-
ctx.io_mut().send(request.clone()).await?;
558-
559-
let attestation: Attestation = ctx.io_mut().expect_next().await?;
560-
561-
Ok::<_, ProverError>(attestation)
562-
})
563-
.await?;
564-
565-
// Check the attestation is consistent with the Prover's view.
566-
request
567-
.validate(&attestation)
568-
.map_err(ProverError::attestation)?;
569-
570-
Ok((attestation, secrets))
571-
}
572-
573457
/// Closes the connection with the verifier.
574458
#[instrument(parent = &self.span, level = "info", skip_all, err)]
575459
pub async fn close(self) -> Result<(), ProverError> {

crates/tlsn/src/prover/error.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ impl ProverError {
4949
{
5050
Self::new(ErrorKind::Commit, source)
5151
}
52-
53-
pub(crate) fn attestation<E>(source: E) -> Self
54-
where
55-
E: Into<Box<dyn Error + Send + Sync + 'static>>,
56-
{
57-
Self::new(ErrorKind::Attestation, source)
58-
}
5952
}
6053

6154
#[derive(Debug)]
@@ -65,7 +58,6 @@ enum ErrorKind {
6558
Zk,
6659
Config,
6760
Commit,
68-
Attestation,
6961
}
7062

7163
impl fmt::Display for ProverError {
@@ -78,7 +70,6 @@ impl fmt::Display for ProverError {
7870
ErrorKind::Zk => f.write_str("zk error")?,
7971
ErrorKind::Config => f.write_str("config error")?,
8072
ErrorKind::Commit => f.write_str("commit error")?,
81-
ErrorKind::Attestation => f.write_str("attestation error")?,
8273
}
8374

8475
if let Some(source) = &self.source {

crates/tlsn/src/verifier.rs

Lines changed: 2 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ use mpz_common::Context;
3030
use mpz_core::Block;
3131
use mpz_garble_core::Delta;
3232
use mpz_vm_core::prelude::*;
33-
use serio::{SinkExt, stream::IoStreamExt};
33+
use serio::stream::IoStreamExt;
3434
use tls_core::{msgs::enums::ContentType, verify::WebPkiVerifier};
35-
use tlsn_attestation::{Attestation, AttestationConfig, CryptoProvider, request::Request};
3635
use tlsn_core::{
3736
ProvePayload,
38-
connection::{ConnectionInfo, ServerName, TranscriptLength},
37+
connection::{ConnectionInfo, ServerName},
3938
transcript::{TlsTranscript, TranscriptCommitment},
4039
};
4140
use tlsn_deap::Deap;
@@ -152,59 +151,6 @@ impl Verifier<state::Initialized> {
152151
})
153152
}
154153

155-
/// Runs the verifier to completion and attests to the TLS session.
156-
///
157-
/// This is a convenience method which runs all the steps needed for
158-
/// notarization.
159-
///
160-
/// # Arguments
161-
///
162-
/// * `socket` - The socket to the prover.
163-
/// * `config` - The attestation configuration.
164-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
165-
#[deprecated(
166-
note = "attestation functionality will be removed from this API in future releases."
167-
)]
168-
pub async fn notarize<S: AsyncWrite + AsyncRead + Send + Unpin + 'static>(
169-
self,
170-
socket: S,
171-
config: &AttestationConfig,
172-
) -> Result<Attestation, VerifierError> {
173-
#[allow(deprecated)]
174-
self.notarize_with_provider(socket, config, &CryptoProvider::default())
175-
.await
176-
}
177-
178-
/// Runs the verifier to completion and attests to the TLS session.
179-
///
180-
/// This is a convenience method which runs all the steps needed for
181-
/// notarization.
182-
///
183-
/// # Arguments
184-
///
185-
/// * `socket` - The socket to the prover.
186-
/// * `config` - The attestation configuration.
187-
/// * `provider` - Cryptography provider.
188-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
189-
#[deprecated(
190-
note = "attestation functionality will be removed from this API in future releases."
191-
)]
192-
pub async fn notarize_with_provider<S: AsyncWrite + AsyncRead + Send + Unpin + 'static>(
193-
self,
194-
socket: S,
195-
config: &AttestationConfig,
196-
provider: &CryptoProvider,
197-
) -> Result<Attestation, VerifierError> {
198-
let mut verifier = self.setup(socket).await?.run().await?;
199-
200-
#[allow(deprecated)]
201-
let attestation = verifier.notarize_with_provider(config, provider).await?;
202-
203-
verifier.close().await?;
204-
205-
Ok(attestation)
206-
}
207-
208154
/// Runs the TLS verifier to completion, verifying the TLS session.
209155
///
210156
/// This is a convenience method which runs all the steps needed for
@@ -472,123 +418,6 @@ impl Verifier<state::Committed> {
472418
})
473419
}
474420

475-
/// Attests to the TLS session.
476-
///
477-
/// # Arguments
478-
///
479-
/// * `config` - Attestation configuration.
480-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
481-
#[deprecated(
482-
note = "attestation functionality will be removed from this API in future releases."
483-
)]
484-
pub async fn notarize(
485-
&mut self,
486-
config: &AttestationConfig,
487-
) -> Result<Attestation, VerifierError> {
488-
#[allow(deprecated)]
489-
self.notarize_with_provider(config, &CryptoProvider::default())
490-
.await
491-
}
492-
493-
/// Attests to the TLS session.
494-
///
495-
/// # Arguments
496-
///
497-
/// * `config` - Attestation configuration.
498-
/// * `provider` - Cryptography provider.
499-
#[instrument(parent = &self.span, level = "info", skip_all, err)]
500-
#[deprecated(
501-
note = "attestation functionality will be removed from this API in future releases."
502-
)]
503-
pub async fn notarize_with_provider(
504-
&mut self,
505-
config: &AttestationConfig,
506-
provider: &CryptoProvider,
507-
) -> Result<Attestation, VerifierError> {
508-
let VerifierOutput {
509-
server_name,
510-
transcript,
511-
transcript_commitments,
512-
} = self.verify(&VerifyConfig::default()).await?;
513-
514-
if server_name.is_some() {
515-
return Err(VerifierError::attestation(
516-
"server name can not be revealed to a verifier",
517-
));
518-
} else if transcript.is_some() {
519-
return Err(VerifierError::attestation(
520-
"transcript data can not be revealed to a verifier",
521-
));
522-
}
523-
524-
let state::Committed {
525-
mux_fut,
526-
ctx,
527-
tls_transcript,
528-
..
529-
} = &mut self.state;
530-
531-
let sent_len = tls_transcript
532-
.sent()
533-
.iter()
534-
.filter_map(|record| {
535-
if let ContentType::ApplicationData = record.typ {
536-
Some(record.ciphertext.len())
537-
} else {
538-
None
539-
}
540-
})
541-
.sum::<usize>();
542-
543-
let recv_len = tls_transcript
544-
.recv()
545-
.iter()
546-
.filter_map(|record| {
547-
if let ContentType::ApplicationData = record.typ {
548-
Some(record.ciphertext.len())
549-
} else {
550-
None
551-
}
552-
})
553-
.sum::<usize>();
554-
555-
let request: Request = mux_fut
556-
.poll_with(ctx.io_mut().expect_next().map_err(VerifierError::from))
557-
.await?;
558-
559-
let mut builder = Attestation::builder(config)
560-
.accept_request(request)
561-
.map_err(VerifierError::attestation)?;
562-
563-
builder
564-
.connection_info(ConnectionInfo {
565-
time: tls_transcript.time(),
566-
version: (*tls_transcript.version()),
567-
transcript_length: TranscriptLength {
568-
sent: sent_len as u32,
569-
received: recv_len as u32,
570-
},
571-
})
572-
.server_ephemeral_key(tls_transcript.server_ephemeral_key().clone())
573-
.transcript_commitments(transcript_commitments);
574-
575-
let attestation = builder
576-
.build(provider)
577-
.map_err(VerifierError::attestation)?;
578-
579-
mux_fut
580-
.poll_with(
581-
ctx.io_mut()
582-
.send(attestation.clone())
583-
.map_err(VerifierError::from),
584-
)
585-
.await?;
586-
587-
info!("Sent attestation");
588-
589-
Ok(attestation)
590-
}
591-
592421
/// Closes the connection with the prover.
593422
#[instrument(parent = &self.span, level = "info", skip_all, err)]
594423
pub async fn close(self) -> Result<(), VerifierError> {

0 commit comments

Comments
 (0)