Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: tlsn-core #213

Closed
wants to merge 4 commits into from
Closed

Draft: tlsn-core #213

wants to merge 4 commits into from

Conversation

themighty1
Copy link
Member

@themighty1 themighty1 commented Mar 30, 2023

see the test in tlsn-core/src/lib.rs for the API example

tlsn-core/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 99 to 117
/// Verifies the signature over the header against the public key. This is only called when we
/// know that `signature` is Some().
///
/// Returns the verified header
fn verify(&self, pubkey: &PubKey) -> Result<SessionHeader, Error> {
let sig = match &self.signature {
Some(sig) => sig,
_ => return Err(Error::InternalError),
};

match (sig, pubkey) {
// signature and pubkey types must match
(Signature::P256(_), PubKey::P256(_)) => {
pubkey.verify(&self.header, &sig)?;
}
}

Ok(self.header.clone())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be implemented on Signature, eg

struct Signature(..);

impl Signature {
  pub fn verify(&self, key: &PubKey, data: &[u8]) -> Result<(), SignatureError> {
    ..
  }
}

or it can be implemented on PubKey.. might want to look at some other crates to see what pattern they chose

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently it is implemented on Pubkey (line 112). p256 crate also impls it on pubkey

Ok(self.header.clone())
}

/// Returns the session header only if the signature is not present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this method. It's a getter that fails if the signature is None, but it's not clear why

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this method shouldnt be pub, sry for that.)
It is only called internally from SessionHeader::from_msg
It is a safety feature - the caller shouldn't be able to get SessionHeader from SessionHeaderMsg if a signature is present. If it is present, then SessionHeader can only be obtained by calling SessionHeaderMsg::veriffy. This prevents the caller from accidentally skipping verification.

tlsn-core/src/session_header.rs Outdated Show resolved Hide resolved
tlsn-core/src/substrings_opening.rs Outdated Show resolved Hide resolved
tlsn-core/src/substrings_proof.rs Outdated Show resolved Hide resolved
@sinui0 sinui0 changed the title draft Draft: tlsn-core Apr 6, 2023
@themighty1
Copy link
Member Author

closing, superceded by #232

@themighty1 themighty1 closed this May 2, 2023
@sinui0 sinui0 deleted the draft/notarized_session branch July 25, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants