From 0f9c04fc11dc8d722506f4a9644841b4289b0de3 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 Oct 2025 10:41:45 +0300 Subject: [PATCH] feat: added plugin-core crate --- Cargo.lock | 375 +++++++-------- Cargo.toml | 7 +- crates/core/src/transcript/tls.rs | 5 +- crates/data-fixtures/data/http/response_json | 2 +- crates/plugin-core/Cargo.toml | 22 + crates/plugin-core/src/lib.rs | 105 +++++ crates/plugin-core/src/prover.rs | 34 ++ crates/plugin-core/src/prover/config.rs | 463 +++++++++++++++++++ crates/plugin-core/src/verifier.rs | 20 + crates/plugin-core/src/verifier/config.rs | 56 +++ 10 files changed, 900 insertions(+), 189 deletions(-) create mode 100644 crates/plugin-core/Cargo.toml create mode 100644 crates/plugin-core/src/lib.rs create mode 100644 crates/plugin-core/src/prover.rs create mode 100644 crates/plugin-core/src/prover/config.rs create mode 100644 crates/plugin-core/src/verifier.rs create mode 100644 crates/plugin-core/src/verifier/config.rs diff --git a/Cargo.lock b/Cargo.lock index e0fc69798d..a6859523ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ "acvm_blackbox_solver", "brillig_vm", "fxhash", - "indexmap 2.11.4", + "indexmap 2.12.0", "serde", "thiserror 1.0.69", "tracing", @@ -174,9 +174,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-consensus" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0dd3ed764953a6b20458b2b7abbfdc93d20d14b38babe1a70fe631a443a9f1" +checksum = "b9b151e38e42f1586a01369ec52a6934702731d07e8509a7307331b09f6c46dc" dependencies = [ "alloy-eips", "alloy-primitives", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9556182afa73cddffa91e64a5aa9508d5e8c912b3a15f26998d2388a824d2c7b" +checksum = "6e2d5e8668ef6215efdb7dcca6f22277b4e483a5650e05f5de22b2350971f4b8" dependencies = [ "alloy-consensus", "alloy-eips", @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fa99b538ca7006b0c03cfed24ec6d82beda67aac857ef4714be24231d15e6" +checksum = "e5434834adaf64fa20a6fb90877bc1d33214c41b055cc49f82189c98614368cc" dependencies = [ "alloy-eip2124", "alloy-eip2930", @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91676d242c0ced99c0dd6d0096d7337babe9457cc43407d26aa6367fcf90553" +checksum = "d7c69f6c9c68a1287c9d5ff903d0010726934de0dac10989be37b75a29190d55" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -299,9 +299,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f82150116b30ba92f588b87f08fa97a46a1bd5ffc0d0597efdf0843d36bfda" +checksum = "8eaf2ae05219e73e0979cb2cf55612aafbab191d130f203079805eaf881cca58" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -325,9 +325,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223612259a080160ce839a4e5df0125ca403a1d5e7206cc911cea54af5d769aa" +checksum = "e58f4f345cef483eab7374f2b6056973c7419ffe8ad35e994b7a7f5d8e0c7ba4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -349,7 +349,7 @@ dependencies = [ "derive_more", "foldhash 0.2.0", "hashbrown 0.16.0", - "indexmap 2.11.4", + "indexmap 2.12.0", "itoa", "k256", "keccak-asm", @@ -382,14 +382,14 @@ checksum = "64b728d511962dda67c1bc7ea7c03736ec275ed2cf4c35d9585298ac9ccf3b73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] name = "alloy-rpc-types-any" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cc57ee0c1ac9fb14854195fc249494da7416591dc4a4d981ddfd5dd93b9bce" +checksum = "fbde0801a32d21c5f111f037bee7e22874836fba7add34ed4a6919932dd7cf23" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -398,9 +398,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7d47bca1a2a1541e4404aa38b7e262bb4dffd9ac23b4f178729a4ddc5a5caa" +checksum = "361cd87ead4ba7659bda8127902eda92d17fa7ceb18aba1676f7be10f7222487" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -419,9 +419,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8468f1a7f9ee3bae73c24eead0239abea720dbf7779384b9c7e20d51bfb6b0" +checksum = "64600fc6c312b7e0ba76f73a381059af044f4f21f43e07f51f1fa76c868fe302" dependencies = [ "alloy-primitives", "serde", @@ -430,9 +430,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33387c90b0a5021f45a5a77c2ce6c49b8f6980e66a318181468fb24cea771670" +checksum = "5772858492b26f780468ae693405f895d6a27dea6e3eab2c36b6217de47c2647" dependencies = [ "alloy-primitives", "async-trait", @@ -445,9 +445,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55d9e795c85e36dcea08786d2e7ae9b73cb554b6bea6ac4c212def24e1b4d03" +checksum = "f4195b803d0a992d8dbaab2ca1986fc86533d4bc80967c0cce7668b26ad99ef9" dependencies = [ "alloy-consensus", "alloy-network", @@ -470,7 +470,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -482,11 +482,11 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck 0.5.0", - "indexmap 2.11.4", + "indexmap 2.12.0", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "syn-solidity", "tiny-keccak", ] @@ -503,7 +503,7 @@ dependencies = [ "macro-string", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "syn-solidity", ] @@ -547,15 +547,15 @@ dependencies = [ [[package]] name = "alloy-tx-macros" -version = "1.0.38" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bf39928a5e70c9755d6811a2928131b53ba785ad37c8bf85c90175b5d43b818" +checksum = "f8e52276fdb553d3c11563afad2898f4085165e4093604afe3d78b69afbf408f" dependencies = [ "alloy-primitives", "darling 0.21.3", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -763,7 +763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -801,7 +801,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -909,7 +909,7 @@ checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1136,7 +1136,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1184,7 +1184,7 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1469,7 +1469,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1505,9 +1505,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitmaps" @@ -1627,7 +1627,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1699,7 +1699,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1755,7 +1755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b4a6cae9efc04cc6cbb8faf338d2c497c165c83e74509cf4dbedea948bbf6e5" dependencies = [ "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -1785,9 +1785,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -1968,9 +1968,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" dependencies = [ "clap_builder", "clap_derive", @@ -1978,9 +1978,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" dependencies = [ "anstream", "anstyle", @@ -1997,7 +1997,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2309,21 +2309,21 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" dependencies = [ "csv-core", "itoa", "ryu", - "serde", + "serde_core", ] [[package]] name = "csv-core" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d02f3b0da4c6504f86e9cd789d8dbafab48c2321be74e9987593de5a894d93d" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" dependencies = [ "memchr", ] @@ -2371,7 +2371,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2429,7 +2429,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2444,7 +2444,7 @@ dependencies = [ "quote", "serde", "strsim 0.11.1", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2466,7 +2466,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core 0.20.11", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2477,7 +2477,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core 0.21.3", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2516,7 +2516,7 @@ dependencies = [ "deno_path_util", "deno_unsync", "futures", - "indexmap 2.11.4", + "indexmap 2.12.0", "libc", "parking_lot", "percent-encoding", @@ -2562,7 +2562,7 @@ checksum = "a1ad5ae3ef15db33e917d6ed54b53d0a98d068c4d1217eb35a4997423203c3ef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2571,14 +2571,14 @@ version = "0.224.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55db7994eccbdad457ca5091c545af712234c8f6e4389cadb2a24d2ecbbe7e89" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "proc-macro-rules", "proc-macro2", "quote", "stringcase", "strum 0.27.2", "strum_macros 0.27.2", - "syn 2.0.106", + "syn 2.0.108", "thiserror 2.0.17", ] @@ -2698,7 +2698,7 @@ dependencies = [ "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2728,7 +2728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core 0.20.2", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2748,7 +2748,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "unicode-xid", ] @@ -2787,7 +2787,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2838,7 +2838,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2889,7 +2889,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -2901,7 +2901,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -3040,9 +3040,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" +checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" dependencies = [ "crc32fast", "miniz_oxide", @@ -3170,7 +3170,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -3255,21 +3255,21 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "js-sys", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", "wasm-bindgen", ] @@ -3362,7 +3362,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.3.1", - "indexmap 2.11.4", + "indexmap 2.12.0", "slab", "tokio", "tokio-util", @@ -3494,11 +3494,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3612,7 +3612,7 @@ dependencies = [ "http 1.3.1", "hyper", "hyper-util", - "rustls 0.23.32", + "rustls 0.23.34", "rustls-pki-types", "tokio", "tokio-rustls", @@ -3821,7 +3821,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -3843,9 +3843,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.4" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", "hashbrown 0.16.0", @@ -3910,20 +3910,20 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "iter-extended" @@ -4174,7 +4174,7 @@ checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -4246,13 +4246,13 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", - "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "wasi", + "windows-sys 0.61.2", ] [[package]] @@ -4949,9 +4949,9 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" dependencies = [ "num_enum_derive", "rustversion", @@ -4959,14 +4959,14 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5000,9 +5000,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "oorandom" @@ -5076,7 +5076,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5159,7 +5159,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5179,7 +5179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset", - "indexmap 2.11.4", + "indexmap 2.12.0", ] [[package]] @@ -5190,7 +5190,7 @@ checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" dependencies = [ "fixedbitset", "hashbrown 0.15.5", - "indexmap 2.11.4", + "indexmap 2.12.0", "serde", ] @@ -5221,7 +5221,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5370,7 +5370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5422,7 +5422,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5433,7 +5433,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5445,14 +5445,14 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -5503,7 +5503,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.106", + "syn 2.0.108", "tempfile", ] @@ -5517,7 +5517,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5557,7 +5557,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.32", + "rustls 0.23.34", "socket2", "thiserror 2.0.17", "tokio", @@ -5572,12 +5572,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ "bytes", - "getrandom 0.3.3", + "getrandom 0.3.4", "lru-slab", "rand 0.9.2", "ring 0.17.14", "rustc-hash", - "rustls 0.23.32", + "rustls 0.23.34", "rustls-pki-types", "slab", "thiserror 2.0.17", @@ -5689,7 +5689,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "serde", ] @@ -5772,7 +5772,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -5826,7 +5826,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.32", + "rustls 0.23.34", "rustls-pki-types", "serde", "serde_json", @@ -5995,9 +5995,9 @@ checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rust-embed" -version = "8.7.2" +version = "8.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025908b8682a26ba8d12f6f2d66b987584a4a87bc024abc5bbc12553a8cd178a" +checksum = "fb44e1917075637ee8c7bcb865cf8830e3a92b5b1189e44e3a0ab5a0d5be314b" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -6006,22 +6006,22 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.7.2" +version = "8.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6065f1a4392b71819ec1ea1df1120673418bf386f50de1d6f54204d836d4349c" +checksum = "382499b49db77a7c19abd2a574f85ada7e9dbe125d5d1160fa5cad7c4cf71fc9" dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.106", + "syn 2.0.108", "walkdir", ] [[package]] name = "rust-embed-utils" -version = "8.7.2" +version = "8.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cc0c81648b20b70c491ff8cce00c1c3b223bb8ed2b5d41f0e54c6c4c0a3594" +checksum = "21fcbee55c2458836bcdbfffb6ec9ba74bbc23ca7aa6816015a3dd2c4d8fc185" dependencies = [ "sha2", "walkdir", @@ -6132,9 +6132,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.32" +version = "0.23.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" +checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" dependencies = [ "log", "once_cell", @@ -6432,7 +6432,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6443,7 +6443,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6452,7 +6452,7 @@ version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "itoa", "memchr", "ryu", @@ -6508,15 +6508,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.15.0" +version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" +checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.11.4", + "indexmap 2.12.0", "schemars 0.9.0", "schemars 1.0.4", "serde_core", @@ -6527,14 +6527,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.15.0" +version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e6c180db0816026a61afa1cff5344fb7ebded7e4d3062772179f2501481c27" +checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955" dependencies = [ "darling 0.21.3", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6733,12 +6733,12 @@ dependencies = [ [[package]] name = "smol_str" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9676b89cd56310a87b93dec47b11af744f34d5fc9f367b829474eec0a891350d" +checksum = "3498b0a27f93ef1402f20eefacfaa1691272ac4eca1cdc8c596cb0a245d6cbf5" dependencies = [ "borsh", - "serde", + "serde_core", ] [[package]] @@ -6778,7 +6778,7 @@ dependencies = [ [[package]] name = "spansy" version = "0.1.0" -source = "git+https://github.com/tlsnotary/tlsn-utils?rev=6168663#6168663495281f2c1b2c1734dc276cecc4d36ef1" +source = "git+https://github.com/tlsnotary/tlsn-utils?rev=304b910#304b910520cd914a8dd6a777c6fe329f263cb6b5" dependencies = [ "bytes", "httparse", @@ -6872,7 +6872,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6894,9 +6894,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", @@ -6912,7 +6912,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6932,7 +6932,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6952,7 +6952,7 @@ checksum = "181f22127402abcf8ee5c83ccd5b408933fec36a6095cf82cda545634692657e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -6989,7 +6989,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.2", "windows-sys 0.61.2", @@ -7030,7 +7030,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -7041,7 +7041,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -7367,7 +7367,7 @@ dependencies = [ "anyhow", "futures", "getrandom 0.2.16", - "getrandom 0.3.3", + "getrandom 0.3.4", "gloo-utils", "http-body-util", "hyper", @@ -7528,6 +7528,22 @@ dependencies = [ "web-time 0.2.4", ] +[[package]] +name = "tlsn-plugin-core" +version = "0.1.0" +dependencies = [ + "http-body-util", + "hyper", + "rangeset", + "serde", + "spansy", + "thiserror 1.0.69", + "tlsn", + "tlsn-core", + "tlsn-data-fixtures", + "tlsn-formats", +] + [[package]] name = "tlsn-server-fixture" version = "0.0.0" @@ -7646,7 +7662,7 @@ dependencies = [ "enum-try-as-inner", "futures", "getrandom 0.2.16", - "getrandom 0.3.3", + "getrandom 0.3.4", "http-body-util", "hyper", "js-sys", @@ -7696,7 +7712,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -7705,7 +7721,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ - "rustls 0.23.32", + "rustls 0.23.34", "tokio", ] @@ -7783,7 +7799,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -7796,7 +7812,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -7810,7 +7826,7 @@ version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "toml_datetime 0.7.3", "toml_parser", "winnow 0.7.13", @@ -7923,7 +7939,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -8016,7 +8032,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -8099,9 +8115,9 @@ checksum = "81b79ad29b5e19de4260020f8919b443b2ef0277d242ce532ec7b7a2cc8b6007" [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" [[package]] name = "unicode-width" @@ -8162,7 +8178,7 @@ dependencies = [ "base64 0.22.1", "log", "once_cell", - "rustls 0.23.32", + "rustls 0.23.34", "rustls-pki-types", "url", "webpki-roots 0.26.11", @@ -8303,15 +8319,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" -dependencies = [ - "wasip2", -] - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -8344,7 +8351,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "wasm-bindgen-shared", ] @@ -8379,7 +8386,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8487,7 +8494,7 @@ dependencies = [ [[package]] name = "websocket-relay" version = "0.1.0" -source = "git+https://github.com/tlsnotary/tlsn-utils?rev=6168663#6168663495281f2c1b2c1734dc276cecc4d36ef1" +source = "git+https://github.com/tlsnotary/tlsn-utils?rev=304b910#304b910520cd914a8dd6a777c6fe329f263cb6b5" dependencies = [ "anyhow", "form_urlencoded", @@ -8563,7 +8570,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -8574,7 +8581,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -8983,7 +8990,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "synstructure", ] @@ -9004,7 +9011,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -9024,7 +9031,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", "synstructure", ] @@ -9045,7 +9052,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] @@ -9078,7 +9085,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.108", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 409de0ff54..27a6477410 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "crates/data-fixtures", "crates/examples", "crates/formats", + "crates/plugin-core", "crates/server-fixture/certs", "crates/server-fixture/server", "crates/tls/backend", @@ -53,6 +54,7 @@ tlsn-formats = { path = "crates/formats" } tlsn-hmac-sha256 = { path = "crates/components/hmac-sha256" } tlsn-key-exchange = { path = "crates/components/key-exchange" } tlsn-mpc-tls = { path = "crates/mpc-tls" } +tlsn-plugin-core = { path = "crates/plugin-core" } tlsn-server-fixture = { path = "crates/server-fixture/server" } tlsn-server-fixture-certs = { path = "crates/server-fixture/certs" } tlsn-tls-backend = { path = "crates/tls/backend" } @@ -83,9 +85,10 @@ mpz-ideal-vm = { git = "https://github.com/privacy-ethereum/mpz", tag = "v0.1.0- rangeset = { version = "0.2" } serio = { version = "0.2" } -spansy = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "6168663" } +spansy = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "304b910" } uid-mux = { version = "0.2" } -websocket-relay = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "6168663" } +websocket-relay = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "304b910" } +futures-plex = { git = "https://github.com/tlsnotary/tlsn-utils", rev = "304b910" } aead = { version = "0.4" } aes = { version = "0.8" } diff --git a/crates/core/src/transcript/tls.rs b/crates/core/src/transcript/tls.rs index 0c9028e2ba..ad0f7e68c8 100644 --- a/crates/core/src/transcript/tls.rs +++ b/crates/core/src/transcript/tls.rs @@ -7,6 +7,7 @@ use crate::{ transcript::{Direction, Transcript}, webpki::CertificateDer, }; +use serde::{Deserialize, Serialize}; use tls_core::msgs::{ alert::AlertMessagePayload, codec::{Codec, Reader}, @@ -15,7 +16,7 @@ use tls_core::msgs::{ }; /// A transcript of TLS records sent and received by the prover. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct TlsTranscript { time: u64, version: TlsVersion, @@ -291,7 +292,7 @@ impl TlsTranscript { } /// A TLS record. -#[derive(Clone)] +#[derive(Clone, Serialize, Deserialize)] pub struct Record { /// Sequence number. pub seq: u64, diff --git a/crates/data-fixtures/data/http/response_json b/crates/data-fixtures/data/http/response_json index bd42e134f7..2b20f7906b 100644 --- a/crates/data-fixtures/data/http/response_json +++ b/crates/data-fixtures/data/http/response_json @@ -3,4 +3,4 @@ Cookie: very-secret-cookie Content-Length: 44 Content-Type: application/json -{"foo": "bar", "bazz": 123, "buzz": [1,"5"]} +{"foo": "bar", "bazz": 123, "buzz": [1,"5"]} \ No newline at end of file diff --git a/crates/plugin-core/Cargo.toml b/crates/plugin-core/Cargo.toml new file mode 100644 index 0000000000..0cda5f45a6 --- /dev/null +++ b/crates/plugin-core/Cargo.toml @@ -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 diff --git a/crates/plugin-core/src/lib.rs b/crates/plugin-core/src/lib.rs new file mode 100644 index 0000000000..56c09f2007 --- /dev/null +++ b/crates/plugin-core/src/lib.rs @@ -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), +} diff --git a/crates/plugin-core/src/prover.rs b/crates/plugin-core/src/prover.rs new file mode 100644 index 0000000000..7be5e86485 --- /dev/null +++ b/crates/plugin-core/src/prover.rs @@ -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)>, +} + +/// 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>, + pub headers: Vec<(String, String)>, +} diff --git a/crates/plugin-core/src/prover/config.rs b/crates/plugin-core/src/prover/config.rs new file mode 100644 index 0000000000..614966d936 --- /dev/null +++ b/crates/plugin-core/src/prover/config.rs @@ -0,0 +1,463 @@ +use crate::{ + BodyParams, DisclosurePolicy, DisclosureRule, HttpHandle, MessagePart, MessageType, + prover::{HttpRequest, ProverParams}, +}; + +use crate::prover::Output; +use http_body_util::Full; +use hyper::{Request as HyperRequest, body::Bytes}; +use rangeset::RangeSet; +use serde::{Deserialize, Serialize}; +use tlsn::{ + config::ProtocolConfig, + prover::{ProverConfig, TlsConfig}, +}; +use tlsn_core::{ + ProveConfig, ProveConfigBuilder, ProverOutput, + connection::{DnsName, ServerName}, + transcript::{Transcript, TranscriptCommitConfig, TranscriptCommitConfigBuilder}, + webpki::RootCertStore, +}; +use tlsn_formats::{ + http::{Body, Request, Requests, Response, Responses}, + json::JsonValue, + spansy, + spansy::Spanned, +}; + +/// Prover plugin config. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Config { + pub prover_params: ProverParams, + pub request: HttpRequest, + /// Data which will be disclosed to the verifier. + pub disclose: Vec, + /// Data which will be exposed in the plugin output. + pub expose: Vec, + pub root_store: RootCertStore, + pub verifier_endpoint: String, + /// Proxy endpoint for connecting to the server. + pub proxy_endpoint: Option, +} + +impl Config { + /// Returns the verifier endpoint. + pub fn prover_endpoint(&self) -> &String { + &self.verifier_endpoint + } + + /// Builds and returns [ProverConfig]. + pub fn prover_config(&self) -> Result { + let dns_name: DnsName = self + .prover_params + .server_dns + .clone() + .try_into() + .map_err(|_| ConfigError("prover_config error".to_string()))?; + + let mut builder = TlsConfig::builder(); + builder.root_store(self.root_store.clone()); + let tls_config = builder.build().unwrap(); + + let config = ProverConfig::builder() + .server_name(ServerName::Dns(dns_name)) + .tls_config(tls_config) + .protocol_config( + ProtocolConfig::builder() + .max_sent_data(self.prover_params.max_sent_data) + .max_recv_data(self.prover_params.max_recv_data) + .build() + .unwrap(), + ) + .build() + .unwrap(); + + Ok(config) + } + + /// Returns the HTTP request. + pub fn http_request(&self) -> Result>, ConfigError> { + let mut request = HyperRequest::builder() + .uri(self.request.url.clone()) + .header("Host", self.prover_params.server_dns.clone()); + + for (k, v) in &self.request.headers { + request = request.header(k, v); + } + + request = request.method(self.request.method.as_str()); + let body = match &self.request.body { + Some(data) => Full::::from(data.clone()), + None => Full::::from(vec![]), + }; + + request + .body(body) + .map_err(|_| ConfigError("http_request error".to_string())) + } + + /// Creates a [ProveConfig] for the given `transcript`. + pub fn prove_config(&self, transcript: &Transcript) -> Result { + let mut prove_cfg = ProveConfig::builder(transcript); + let mut commit_cfg = TranscriptCommitConfig::builder(transcript); + + if self.prover_params.prove_server_identity { + prove_cfg.server_identity(); + } + + let reqs = Requests::new_from_slice(transcript.sent()) + .collect::, _>>() + .map_err(|_| ConfigError("prove_config error".to_string()))?; + let resps = Responses::new_from_slice(transcript.received()) + .collect::, _>>() + .map_err(|_| ConfigError("prove_config error".to_string()))?; + + let req = reqs.first().expect("at least one request"); + let resp = resps.first().expect("at least one response"); + + let req_rules = self + .disclose + .iter() + .filter(|h| h.http.typ == MessageType::Request); + let resp_rules = self + .disclose + .iter() + .filter(|h| h.http.typ == MessageType::Response); + + disclose_req(req, req_rules, &mut commit_cfg, &mut prove_cfg); + disclose_resp(resp, resp_rules, &mut commit_cfg, &mut prove_cfg); + + prove_cfg.transcript_commit(commit_cfg.build().unwrap()); + Ok(prove_cfg.build().unwrap()) + } + + /// Returns the output of the plugin. + pub fn output( + &self, + transcript: Transcript, + prover_output: ProverOutput, + ) -> Result { + let reqs = Requests::new_from_slice(transcript.sent()) + .collect::, _>>() + .map_err(|_| ConfigError("output error".to_string()))?; + let resps = Responses::new_from_slice(transcript.received()) + .collect::, _>>() + .map_err(|_| ConfigError("output error".to_string()))?; + + let req = reqs.first().expect("at least one request"); + let resp = resps.first().expect("at least one response"); + + let mut exposed = Vec::new(); + + // Extract the to-be-exposed data from the transcript. + for h in self.expose.iter() { + let range = if h.typ == MessageType::Request { + req_part_range(req, h) + } else { + resp_part_range(resp, h) + }; + + let seq = transcript + .get((&h.typ).into(), &range) + .ok_or(ConfigError("range not found in transcript".to_string()))?; + + exposed.push((h.clone(), seq.data().to_vec())); + } + + Ok(Output { + output: prover_output, + plaintext: exposed, + }) + } +} + +#[derive(Debug, thiserror::Error)] +#[error("config error: {0}")] +pub struct ConfigError(String); + +/// Processes disclosure rules for the request. +fn disclose_req<'a, I>( + req: &Request, + rules: I, + commit_cfg: &mut TranscriptCommitConfigBuilder<'_>, + prove_cfg: &mut ProveConfigBuilder<'_>, +) where + I: Iterator, +{ + for r in rules { + let range = req_part_range(req, &r.http); + + if range.is_empty() { + // TODO: maybe return an error here when the part was not found. + return; + } + + match &r.policy { + DisclosurePolicy::Commit(alg) => { + commit_cfg + .commit_with_kind(&range, (&r.http.typ).into(), alg.into()) + .expect("range is in the transcript"); + } + DisclosurePolicy::Reveal => { + prove_cfg + .reveal_sent(&range) + .expect("range is in the transcript"); + } + } + } +} + +/// Processes disclosure rules for the response. +fn disclose_resp<'a, I>( + resp: &Response, + rules: I, + commit_cfg: &mut TranscriptCommitConfigBuilder<'_>, + prove_cfg: &mut ProveConfigBuilder<'_>, +) where + I: Iterator, +{ + for r in rules { + let range = resp_part_range(resp, &r.http); + + if range.is_empty() { + // TODO: maybe return an error here when the part was not found. + return; + } + + match &r.policy { + DisclosurePolicy::Commit(alg) => { + commit_cfg + .commit_with_kind(&range, (&r.http.typ).into(), alg.into()) + .expect("range is in the transcript"); + } + DisclosurePolicy::Reveal => { + prove_cfg + .reveal_recv(&range) + .expect("range is in the transcript"); + } + } + } +} + +/// Returns the range for the given `part` of the HTTP request, +fn req_part_range(req: &Request, part: &HttpHandle) -> RangeSet { + match &part.part { + MessagePart::All => { + (req.span().indices().min().unwrap()..req.span().indices().end().unwrap()).into() + } + + MessagePart::StartLine => req.request.span().indices().clone(), + + MessagePart::Header(params) => req + .headers_with_name(params.key.as_str()) + .map(|h| h.span().indices()) + .fold(RangeSet::default(), |acc, r| acc | r), + + MessagePart::Body(params) => match &req.body { + Some(body) => { + // Body offset from the start of an HTTP message. + let body_offset = body + .span() + .indices() + .min() + .expect("body span cannot be empty"); + let mut range = body_params_range(body, params); + range.shift_right(&body_offset); + range + } + None => RangeSet::default(), + }, + } +} + +/// Returns the range for the given `part` of the HTTP response, +fn resp_part_range(resp: &Response, part: &HttpHandle) -> RangeSet { + match &part.part { + MessagePart::All => { + (resp.span().indices().min().unwrap()..resp.span().indices().end().unwrap()).into() + } + MessagePart::StartLine => resp.status.span().indices().clone(), + MessagePart::Header(params) => resp + .headers_with_name(params.key.as_str()) + .map(|h| h.span().indices()) + .fold(RangeSet::default(), |acc, r| acc | r), + MessagePart::Body(params) => match &resp.body { + Some(body) => { + // Body offset from the start of an HTTP message. + let body_offset = body.span().indices().min().expect("body cannot be empty"); + let mut range = body_params_range(body, params); + range.shift_right(&body_offset); + range + } + None => RangeSet::default(), + }, + } +} + +/// Returns the byte range of the `params` in the given `body`. +fn body_params_range(body: &Body, params: &BodyParams) -> RangeSet { + match params { + BodyParams::JsonPath(path) => { + // TODO: use a better approach than re-parsing the entire + // json for each path. + match spansy::json::parse(body.as_bytes().to_vec().into()) { + Ok(json) => json_path_range(&json, path), + Err(_) => RangeSet::default(), + } + } + _ => unimplemented!("only json parsing is currently supported"), + } +} + +/// Returns the byte range of the key–value pair corresponding to the given +/// `path` in a JSON value `source`. +/// +/// If the path points to an array element, only the range of the **value** +/// of the element is returned. +fn json_path_range(source: &JsonValue, path: &String) -> RangeSet { + let val = match source.get(path) { + Some(val) => val, + None => return RangeSet::default(), + }; + + let dot = "."; + let last = path.split(dot).last().unwrap(); + // Whether `path` is a top-level key. + let is_top_level = last == path; + + if last.parse::().is_ok() { + // The path points to an array element, so we only need the range of + // the **value**. + val.span().indices().clone() + } else { + let parent_val = if is_top_level { + source + } else { + source + .get(&path[..path.len() - last.len() - dot.len()]) + .expect("path is valid") + }; + let JsonValue::Object(parent_obj) = parent_val else { + unreachable!("parent value is always an object"); + }; + + // We need the range of the **key-value** pair. + let kv = parent_obj + .elems + .iter() + .find(|kv| kv.value == *val) + .expect("element exists"); + + kv.without_separator() + } +} + +#[cfg(test)] +mod tests { + use crate::HeaderParams; + + use super::*; + use spansy::http::parse_response; + use tlsn_data_fixtures::http::{request, response}; + use tlsn_formats::spansy::http::parse_request; + + #[test] + fn test_req_part_range() { + let data = request::POST_JSON; + let req = parse_request(data).unwrap(); + let s = std::str::from_utf8(data).unwrap(); + + //===============All + let part = HttpHandle { + part: MessagePart::All, + typ: MessageType::Request, + }; + let range = req_part_range(&req, &part); + assert_eq!(range, 0..data.len()); + + //===============StartLine + let part = HttpHandle { + part: MessagePart::StartLine, + typ: MessageType::Request, + }; + let range = req_part_range(&req, &part); + let end = s.find("\r\n").unwrap() + 2; + assert_eq!(range, 0..end); + + //===============Header + let part = HttpHandle { + part: MessagePart::Header(HeaderParams { + key: "Content-Length".to_string(), + }), + typ: MessageType::Request, + }; + let range = req_part_range(&req, &part); + + let target: &'static str = "Content-Length: 44"; + let start = s.find(target).unwrap(); + let end = start + target.len() + 2; + assert_eq!(range, start..end); + + //===============Body + let part = HttpHandle { + part: MessagePart::Body(BodyParams::JsonPath("bazz".to_string())), + typ: MessageType::Request, + }; + let range = req_part_range(&req, &part); + + let target: &'static str = "\"bazz\": 123"; + let start = s.find(target).unwrap(); + let end = start + target.len(); + assert_eq!(range, start..end); + } + + #[test] + fn test_resp_part_range() { + let data = response::OK_JSON; + let resp = parse_response(data).unwrap(); + let s = std::str::from_utf8(data).unwrap(); + + //===============All + let part = HttpHandle { + part: MessagePart::All, + typ: MessageType::Response, + }; + let range = resp_part_range(&resp, &part); + assert_eq!(range, 0..data.len()); + + //===============StartLine + let part = HttpHandle { + part: MessagePart::StartLine, + typ: MessageType::Response, + }; + let range = resp_part_range(&resp, &part); + let end = s.find("\r\n").unwrap() + 2; + assert_eq!(range, 0..end); + + //===============Header + let part = HttpHandle { + part: MessagePart::Header(HeaderParams { + key: "Content-Length".to_string(), + }), + typ: MessageType::Response, + }; + let range = resp_part_range(&resp, &part); + + let target: &'static str = "Content-Length: 44"; + let start = s.find(target).unwrap(); + let end = start + target.len() + 2; + assert_eq!(range, start..end); + + //===============Body + let part = HttpHandle { + part: MessagePart::Body(BodyParams::JsonPath("bazz".to_string())), + typ: MessageType::Request, + }; + let range = resp_part_range(&resp, &part); + + let target: &'static str = "\"bazz\": 123"; + let start = s.find(target).unwrap(); + let end = start + target.len(); + assert_eq!(range, start..end); + } +} diff --git a/crates/plugin-core/src/verifier.rs b/crates/plugin-core/src/verifier.rs new file mode 100644 index 0000000000..c4bdfadea4 --- /dev/null +++ b/crates/plugin-core/src/verifier.rs @@ -0,0 +1,20 @@ +//! Core types of the verifier plugin. + +use tlsn_core::VerifierOutput; + +mod config; + +pub use config::{Config, ConfigError}; + +/// Output of the verifier plugin. +#[allow(dead_code)] +pub struct Output { + output: VerifierOutput, +} + +/// Params for protocol verifier. +pub struct VerifierParams { + pub max_sent_data: usize, + pub max_recv_data: usize, + pub prover_endpoint: String, +} diff --git a/crates/plugin-core/src/verifier/config.rs b/crates/plugin-core/src/verifier/config.rs new file mode 100644 index 0000000000..d63db4247a --- /dev/null +++ b/crates/plugin-core/src/verifier/config.rs @@ -0,0 +1,56 @@ +use crate::{ + DisclosureRule, + verifier::{Output, VerifierParams}, +}; +use tlsn::{ + config::{ProtocolConfig, RootCertStore}, + verifier::VerifierConfig, +}; +use tlsn_core::VerifierOutput; + +/// Verifier plugin config. +#[allow(dead_code)] +pub struct Config { + pub verifier_params: VerifierParams, + /// Data which the prover is expected to disclose. + pub disclose: Vec, + pub root_store: RootCertStore, + pub prover_endpoint: String, +} + +impl Config { + /// Returns the prover endpoint. + pub fn prover_endpoint(&self) -> &String { + &self.verifier_params.prover_endpoint + } + + /// Builds and returns [VerifierConfig]. + pub fn verifier_config(&self) -> VerifierConfig { + VerifierConfig::builder() + .root_store(self.root_store.clone()) + .build() + .unwrap() + } + + /// Validates the given protocol `config`. + pub fn validate_protocol_config(&self, config: &ProtocolConfig) -> Result<(), ConfigError> { + if config.max_recv_data() > self.verifier_params.max_recv_data + || config.max_sent_data() > self.verifier_params.max_sent_data + { + Err(ConfigError( + "failed to validate protocol config".to_string(), + )) + } else { + Ok(()) + } + } + + /// Returns verifier plugin output. + pub fn output(&self, output: VerifierOutput) -> Output { + Output { output } + } +} + +#[derive(Debug, thiserror::Error)] +#[error("config error: {0}")] +pub struct ConfigError(String);