-
Notifications
You must be signed in to change notification settings - Fork 118
feat: added plugin-core crate #1040
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
Open
themighty1
wants to merge
1
commit into
dev
Choose a base branch
from
feat/plugin-core
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [package] | ||
| name = "tlsn-plugin-core" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| tlsn = { workspace = true } | ||
| tlsn-core = { workspace = true } | ||
| tlsn-formats = { workspace = true } | ||
|
|
||
| http-body-util = { workspace = true } | ||
| hyper = { workspace = true, features = ["client", "http1"] } | ||
| rangeset = { workspace = true } | ||
| serde = { workspace = true } | ||
| spansy = { workspace = true } | ||
| thiserror = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| tlsn-data-fixtures = { workspace = true } | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| //! Core types of the prover and verifier plugin. | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
| use tlsn_core::{ | ||
| hash::HashAlgId, | ||
| transcript::{Direction, TranscriptCommitmentKind}, | ||
| }; | ||
|
|
||
| mod prover; | ||
| mod verifier; | ||
|
|
||
| pub use prover::{ | ||
| Config as ProverPluginConfig, ConfigError as ProverPLuginConfigError, | ||
| Output as ProverPluginOutput, | ||
| }; | ||
| pub use verifier::{ | ||
| Config as VerifierPluginConfig, ConfigError as VerifierPluginConfigError, | ||
| Output as VerifierPluginOutput, | ||
| }; | ||
|
|
||
| /// A rule for disclosing HTTP data. | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct DisclosureRule { | ||
| http: HttpHandle, | ||
| policy: DisclosurePolicy, | ||
| } | ||
|
|
||
| /// Handle for a part of an HTTP message. | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct HttpHandle { | ||
| typ: MessageType, | ||
| part: MessagePart, | ||
| } | ||
|
|
||
| #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] | ||
| pub enum MessageType { | ||
| Request, | ||
| Response, | ||
| } | ||
|
|
||
| impl From<&MessageType> for Direction { | ||
| fn from(mt: &MessageType) -> Self { | ||
| match mt { | ||
| MessageType::Request => Direction::Sent, | ||
| MessageType::Response => Direction::Received, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Disclosure policy. | ||
| #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] | ||
| pub enum DisclosurePolicy { | ||
| /// Reveals data. | ||
| Reveal, | ||
| /// Creates a hiding commitment. | ||
| Commit(Alg), | ||
| } | ||
|
|
||
| /// Commitment algorithm. | ||
| #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] | ||
| pub enum Alg { | ||
| EncodingSha256, | ||
| EncodingBlake3, | ||
| EncodingKeccak256, | ||
| Sha256, | ||
| Blake3, | ||
| } | ||
|
|
||
| impl From<&Alg> for TranscriptCommitmentKind { | ||
| fn from(alg: &Alg) -> Self { | ||
| match alg { | ||
| Alg::EncodingSha256 | Alg::EncodingBlake3 | Alg::EncodingKeccak256 => { | ||
| TranscriptCommitmentKind::Encoding | ||
| } | ||
| Alg::Sha256 => TranscriptCommitmentKind::Hash { | ||
| alg: HashAlgId::SHA256, | ||
| }, | ||
| Alg::Blake3 => TranscriptCommitmentKind::Hash { | ||
| alg: HashAlgId::BLAKE3, | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// The part of an HTTP message. | ||
| #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] | ||
| pub enum MessagePart { | ||
| All, | ||
| StartLine, | ||
| Header(HeaderParams), | ||
| Body(BodyParams), | ||
| } | ||
|
|
||
| /// Parameters for an HTTP header. | ||
| #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] | ||
| pub struct HeaderParams { | ||
| pub key: String, | ||
| } | ||
|
|
||
| /// Parameters for a part of an HTTP body. | ||
| #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] | ||
| pub enum BodyParams { | ||
| JsonPath(String), | ||
| XPath(String), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| //! Core types of the prover plugin. | ||
|
|
||
| use crate::HttpHandle; | ||
| use serde::{Deserialize, Serialize}; | ||
| use tlsn_core::ProverOutput; | ||
|
|
||
| mod config; | ||
|
|
||
| pub use config::{Config, ConfigError}; | ||
|
|
||
| /// Output of the prover plugin. | ||
| #[allow(dead_code)] | ||
| pub struct Output { | ||
| output: ProverOutput, | ||
| /// Plaintext exposed to the host. | ||
| plaintext: Vec<(HttpHandle, Vec<u8>)>, | ||
| } | ||
|
|
||
| /// Params for protocol prover. | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct ProverParams { | ||
| max_recv_data: usize, | ||
| max_sent_data: usize, | ||
| prove_server_identity: bool, | ||
| pub server_dns: String, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct HttpRequest { | ||
| url: String, | ||
| method: String, | ||
| body: Option<Vec<u8>>, | ||
| pub headers: Vec<(String, String)>, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this newline on purpose, otherwise content length was incorrect.