mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-08 21:08:04 -05:00
circuit implementation
This commit is contained in:
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1 +1,14 @@
|
||||
/target
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
694
Cargo.lock
generated
694
Cargo.lock
generated
@@ -11,295 +11,28 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||
|
||||
[[package]]
|
||||
name = "base_conversion"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/GaloisInc/swanky.git#4455754abadee07f168079ac45ef33535b0df27d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"byte-tools",
|
||||
"byteorder",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "517358c28fcef6607bf6f76108e02afad7e82297d132a6b846dcc1fc3efcd153"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ct-logs"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "362b2bf41dd138704dd7e4f253ecc5026287b0626a29fecbcbcd26cec8130e7d"
|
||||
dependencies = [
|
||||
"sct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"digest",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
|
||||
[[package]]
|
||||
name = "fancy-garbling"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/GaloisInc/swanky.git#4455754abadee07f168079ac45ef33535b0df27d"
|
||||
dependencies = [
|
||||
"base_conversion",
|
||||
"itertools",
|
||||
"ocelot",
|
||||
"rand",
|
||||
"regex",
|
||||
"scuttlebutt",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.16"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.112"
|
||||
version = "0.2.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
@@ -308,68 +41,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
|
||||
name = "pop-mpc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"miow",
|
||||
"ntapi",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miow"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ocelot"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/GaloisInc/swanky.git#4455754abadee07f168079ac45ef33535b0df27d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"curve25519-dalek",
|
||||
"libc",
|
||||
"rand",
|
||||
"scuttlebutt",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
name = "pop-tls"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
@@ -377,69 +58,12 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proof_of_provenance"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"ct-logs",
|
||||
"env_logger",
|
||||
"fancy-garbling",
|
||||
"mio",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
@@ -448,9 +72,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
@@ -458,18 +82,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
@@ -491,288 +115,8 @@ version = "0.6.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"sct",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9"
|
||||
dependencies = [
|
||||
"base64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scuttlebutt"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/GaloisInc/swanky.git#4455754abadee07f168079ac45ef33535b0df27d"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"rand",
|
||||
"rand_core",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.133"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest",
|
||||
"fake-simd",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.22.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449"
|
||||
dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
22
Cargo.toml
22
Cargo.toml
@@ -1,17 +1,5 @@
|
||||
[package]
|
||||
name = "proof_of_provenance"
|
||||
authors = ["sinuio <sinuio.eth>"]
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rustls = "0.20"
|
||||
rustls-pemfile = "0.2.1"
|
||||
webpki-roots = "0.22"
|
||||
ct-logs = "0.9"
|
||||
clap = { version = "3.0.7", features = ["derive"] }
|
||||
env_logger = "0.9.0"
|
||||
mio = { version = "0.8", features = ["net", "os-poll"] }
|
||||
fancy-garbling = { git = "https://github.com/GaloisInc/swanky.git" }
|
||||
[workspace]
|
||||
members = [
|
||||
"pop-tls",
|
||||
"pop-mpc",
|
||||
]
|
||||
10
pop-mpc/Cargo.toml
Normal file
10
pop-mpc/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "pop-mpc"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.4"
|
||||
regex = "1.5.4"
|
||||
382
pop-mpc/circuits/adder64.txt
Normal file
382
pop-mpc/circuits/adder64.txt
Normal file
@@ -0,0 +1,382 @@
|
||||
376 504
|
||||
2 64 64
|
||||
1 64
|
||||
|
||||
2 1 63 127 376 XOR
|
||||
2 1 62 126 375 XOR
|
||||
2 1 61 125 374 XOR
|
||||
2 1 60 124 373 XOR
|
||||
2 1 59 123 372 XOR
|
||||
2 1 58 122 371 XOR
|
||||
2 1 57 121 370 XOR
|
||||
2 1 56 120 369 XOR
|
||||
2 1 55 119 368 XOR
|
||||
2 1 54 118 367 XOR
|
||||
2 1 53 117 366 XOR
|
||||
2 1 52 116 365 XOR
|
||||
2 1 51 115 364 XOR
|
||||
2 1 50 114 363 XOR
|
||||
2 1 49 113 362 XOR
|
||||
2 1 48 112 361 XOR
|
||||
2 1 47 111 360 XOR
|
||||
2 1 46 110 359 XOR
|
||||
2 1 45 109 358 XOR
|
||||
2 1 44 108 357 XOR
|
||||
2 1 43 107 356 XOR
|
||||
2 1 42 106 355 XOR
|
||||
2 1 41 105 354 XOR
|
||||
2 1 40 104 353 XOR
|
||||
2 1 39 103 352 XOR
|
||||
2 1 38 102 351 XOR
|
||||
2 1 37 101 350 XOR
|
||||
2 1 36 100 349 XOR
|
||||
2 1 35 99 348 XOR
|
||||
2 1 34 98 347 XOR
|
||||
2 1 33 97 346 XOR
|
||||
2 1 32 96 345 XOR
|
||||
2 1 31 95 344 XOR
|
||||
2 1 30 94 343 XOR
|
||||
2 1 29 93 342 XOR
|
||||
2 1 28 92 341 XOR
|
||||
2 1 27 91 340 XOR
|
||||
2 1 26 90 339 XOR
|
||||
2 1 25 89 338 XOR
|
||||
2 1 24 88 337 XOR
|
||||
2 1 23 87 336 XOR
|
||||
2 1 22 86 335 XOR
|
||||
2 1 21 85 334 XOR
|
||||
2 1 20 84 333 XOR
|
||||
2 1 19 83 332 XOR
|
||||
2 1 18 82 331 XOR
|
||||
2 1 17 81 330 XOR
|
||||
2 1 16 80 329 XOR
|
||||
2 1 15 79 328 XOR
|
||||
2 1 14 78 327 XOR
|
||||
2 1 13 77 326 XOR
|
||||
2 1 12 76 325 XOR
|
||||
2 1 11 75 324 XOR
|
||||
2 1 10 74 323 XOR
|
||||
2 1 9 73 322 XOR
|
||||
2 1 8 72 321 XOR
|
||||
2 1 7 71 320 XOR
|
||||
2 1 6 70 319 XOR
|
||||
2 1 5 69 318 XOR
|
||||
2 1 4 68 317 XOR
|
||||
2 1 3 67 316 XOR
|
||||
2 1 2 66 315 XOR
|
||||
2 1 1 65 314 XOR
|
||||
2 1 0 64 440 XOR
|
||||
2 1 0 64 377 AND
|
||||
2 1 65 377 129 XOR
|
||||
2 1 1 377 128 XOR
|
||||
2 1 128 129 130 AND
|
||||
2 1 130 377 378 XOR
|
||||
2 1 66 378 132 XOR
|
||||
2 1 2 378 131 XOR
|
||||
2 1 131 132 133 AND
|
||||
2 1 133 378 379 XOR
|
||||
2 1 67 379 135 XOR
|
||||
2 1 3 379 134 XOR
|
||||
2 1 134 135 136 AND
|
||||
2 1 136 379 380 XOR
|
||||
2 1 68 380 138 XOR
|
||||
2 1 4 380 137 XOR
|
||||
2 1 137 138 139 AND
|
||||
2 1 139 380 381 XOR
|
||||
2 1 69 381 141 XOR
|
||||
2 1 5 381 140 XOR
|
||||
2 1 140 141 142 AND
|
||||
2 1 142 381 382 XOR
|
||||
2 1 70 382 144 XOR
|
||||
2 1 6 382 143 XOR
|
||||
2 1 143 144 145 AND
|
||||
2 1 145 382 383 XOR
|
||||
2 1 71 383 147 XOR
|
||||
2 1 7 383 146 XOR
|
||||
2 1 146 147 148 AND
|
||||
2 1 148 383 384 XOR
|
||||
2 1 72 384 150 XOR
|
||||
2 1 8 384 149 XOR
|
||||
2 1 149 150 151 AND
|
||||
2 1 151 384 385 XOR
|
||||
2 1 73 385 153 XOR
|
||||
2 1 9 385 152 XOR
|
||||
2 1 152 153 154 AND
|
||||
2 1 154 385 386 XOR
|
||||
2 1 74 386 156 XOR
|
||||
2 1 10 386 155 XOR
|
||||
2 1 155 156 157 AND
|
||||
2 1 157 386 387 XOR
|
||||
2 1 75 387 159 XOR
|
||||
2 1 11 387 158 XOR
|
||||
2 1 158 159 160 AND
|
||||
2 1 160 387 388 XOR
|
||||
2 1 76 388 162 XOR
|
||||
2 1 12 388 161 XOR
|
||||
2 1 161 162 163 AND
|
||||
2 1 163 388 389 XOR
|
||||
2 1 77 389 165 XOR
|
||||
2 1 13 389 164 XOR
|
||||
2 1 164 165 166 AND
|
||||
2 1 166 389 390 XOR
|
||||
2 1 78 390 168 XOR
|
||||
2 1 14 390 167 XOR
|
||||
2 1 167 168 169 AND
|
||||
2 1 169 390 391 XOR
|
||||
2 1 79 391 171 XOR
|
||||
2 1 15 391 170 XOR
|
||||
2 1 170 171 172 AND
|
||||
2 1 172 391 392 XOR
|
||||
2 1 80 392 174 XOR
|
||||
2 1 16 392 173 XOR
|
||||
2 1 173 174 175 AND
|
||||
2 1 175 392 393 XOR
|
||||
2 1 81 393 177 XOR
|
||||
2 1 17 393 176 XOR
|
||||
2 1 176 177 178 AND
|
||||
2 1 178 393 394 XOR
|
||||
2 1 82 394 180 XOR
|
||||
2 1 18 394 179 XOR
|
||||
2 1 179 180 181 AND
|
||||
2 1 181 394 395 XOR
|
||||
2 1 83 395 183 XOR
|
||||
2 1 19 395 182 XOR
|
||||
2 1 182 183 184 AND
|
||||
2 1 184 395 396 XOR
|
||||
2 1 84 396 186 XOR
|
||||
2 1 20 396 185 XOR
|
||||
2 1 185 186 187 AND
|
||||
2 1 187 396 397 XOR
|
||||
2 1 85 397 189 XOR
|
||||
2 1 21 397 188 XOR
|
||||
2 1 188 189 190 AND
|
||||
2 1 190 397 398 XOR
|
||||
2 1 86 398 192 XOR
|
||||
2 1 22 398 191 XOR
|
||||
2 1 191 192 193 AND
|
||||
2 1 193 398 399 XOR
|
||||
2 1 87 399 195 XOR
|
||||
2 1 23 399 194 XOR
|
||||
2 1 194 195 196 AND
|
||||
2 1 196 399 400 XOR
|
||||
2 1 88 400 198 XOR
|
||||
2 1 24 400 197 XOR
|
||||
2 1 197 198 199 AND
|
||||
2 1 199 400 401 XOR
|
||||
2 1 89 401 201 XOR
|
||||
2 1 25 401 200 XOR
|
||||
2 1 200 201 202 AND
|
||||
2 1 202 401 402 XOR
|
||||
2 1 90 402 204 XOR
|
||||
2 1 26 402 203 XOR
|
||||
2 1 203 204 205 AND
|
||||
2 1 205 402 403 XOR
|
||||
2 1 91 403 207 XOR
|
||||
2 1 27 403 206 XOR
|
||||
2 1 206 207 208 AND
|
||||
2 1 208 403 404 XOR
|
||||
2 1 341 404 468 XOR
|
||||
2 1 92 404 210 XOR
|
||||
2 1 28 404 209 XOR
|
||||
2 1 209 210 211 AND
|
||||
2 1 211 404 405 XOR
|
||||
2 1 342 405 469 XOR
|
||||
2 1 340 403 467 XOR
|
||||
2 1 93 405 213 XOR
|
||||
2 1 29 405 212 XOR
|
||||
2 1 212 213 214 AND
|
||||
2 1 214 405 406 XOR
|
||||
2 1 343 406 470 XOR
|
||||
2 1 339 402 466 XOR
|
||||
2 1 94 406 216 XOR
|
||||
2 1 30 406 215 XOR
|
||||
2 1 215 216 217 AND
|
||||
2 1 217 406 407 XOR
|
||||
2 1 338 401 465 XOR
|
||||
2 1 31 407 218 XOR
|
||||
2 1 344 407 471 XOR
|
||||
2 1 337 400 464 XOR
|
||||
2 1 95 407 219 XOR
|
||||
2 1 218 219 220 AND
|
||||
2 1 220 407 408 XOR
|
||||
2 1 345 408 472 XOR
|
||||
2 1 336 399 463 XOR
|
||||
2 1 96 408 222 XOR
|
||||
2 1 32 408 221 XOR
|
||||
2 1 221 222 223 AND
|
||||
2 1 223 408 409 XOR
|
||||
2 1 346 409 473 XOR
|
||||
2 1 335 398 462 XOR
|
||||
2 1 97 409 225 XOR
|
||||
2 1 33 409 224 XOR
|
||||
2 1 224 225 226 AND
|
||||
2 1 226 409 410 XOR
|
||||
2 1 347 410 474 XOR
|
||||
2 1 334 397 461 XOR
|
||||
2 1 98 410 228 XOR
|
||||
2 1 34 410 227 XOR
|
||||
2 1 227 228 229 AND
|
||||
2 1 229 410 411 XOR
|
||||
2 1 333 396 460 XOR
|
||||
2 1 35 411 230 XOR
|
||||
2 1 348 411 475 XOR
|
||||
2 1 332 395 459 XOR
|
||||
2 1 99 411 231 XOR
|
||||
2 1 230 231 232 AND
|
||||
2 1 232 411 412 XOR
|
||||
2 1 349 412 476 XOR
|
||||
2 1 331 394 458 XOR
|
||||
2 1 100 412 234 XOR
|
||||
2 1 36 412 233 XOR
|
||||
2 1 233 234 235 AND
|
||||
2 1 235 412 413 XOR
|
||||
2 1 350 413 477 XOR
|
||||
2 1 330 393 457 XOR
|
||||
2 1 101 413 237 XOR
|
||||
2 1 37 413 236 XOR
|
||||
2 1 236 237 238 AND
|
||||
2 1 238 413 414 XOR
|
||||
2 1 351 414 478 XOR
|
||||
2 1 329 392 456 XOR
|
||||
2 1 102 414 240 XOR
|
||||
2 1 38 414 239 XOR
|
||||
2 1 239 240 241 AND
|
||||
2 1 241 414 415 XOR
|
||||
2 1 328 391 455 XOR
|
||||
2 1 39 415 242 XOR
|
||||
2 1 352 415 479 XOR
|
||||
2 1 327 390 454 XOR
|
||||
2 1 103 415 243 XOR
|
||||
2 1 242 243 244 AND
|
||||
2 1 244 415 416 XOR
|
||||
2 1 353 416 480 XOR
|
||||
2 1 326 389 453 XOR
|
||||
2 1 104 416 246 XOR
|
||||
2 1 40 416 245 XOR
|
||||
2 1 245 246 247 AND
|
||||
2 1 247 416 417 XOR
|
||||
2 1 354 417 481 XOR
|
||||
2 1 325 388 452 XOR
|
||||
2 1 105 417 249 XOR
|
||||
2 1 41 417 248 XOR
|
||||
2 1 248 249 250 AND
|
||||
2 1 250 417 418 XOR
|
||||
2 1 355 418 482 XOR
|
||||
2 1 324 387 451 XOR
|
||||
2 1 106 418 252 XOR
|
||||
2 1 42 418 251 XOR
|
||||
2 1 251 252 253 AND
|
||||
2 1 253 418 419 XOR
|
||||
2 1 323 386 450 XOR
|
||||
2 1 43 419 254 XOR
|
||||
2 1 356 419 483 XOR
|
||||
2 1 322 385 449 XOR
|
||||
2 1 107 419 255 XOR
|
||||
2 1 254 255 256 AND
|
||||
2 1 256 419 420 XOR
|
||||
2 1 357 420 484 XOR
|
||||
2 1 321 384 448 XOR
|
||||
2 1 108 420 258 XOR
|
||||
2 1 44 420 257 XOR
|
||||
2 1 257 258 259 AND
|
||||
2 1 259 420 421 XOR
|
||||
2 1 358 421 485 XOR
|
||||
2 1 320 383 447 XOR
|
||||
2 1 109 421 261 XOR
|
||||
2 1 45 421 260 XOR
|
||||
2 1 260 261 262 AND
|
||||
2 1 262 421 422 XOR
|
||||
2 1 359 422 486 XOR
|
||||
2 1 319 382 446 XOR
|
||||
2 1 110 422 264 XOR
|
||||
2 1 46 422 263 XOR
|
||||
2 1 263 264 265 AND
|
||||
2 1 265 422 423 XOR
|
||||
2 1 318 381 445 XOR
|
||||
2 1 47 423 266 XOR
|
||||
2 1 360 423 487 XOR
|
||||
2 1 317 380 444 XOR
|
||||
2 1 111 423 267 XOR
|
||||
2 1 266 267 268 AND
|
||||
2 1 268 423 424 XOR
|
||||
2 1 361 424 488 XOR
|
||||
2 1 316 379 443 XOR
|
||||
2 1 112 424 270 XOR
|
||||
2 1 48 424 269 XOR
|
||||
2 1 269 270 271 AND
|
||||
2 1 271 424 425 XOR
|
||||
2 1 362 425 489 XOR
|
||||
2 1 315 378 442 XOR
|
||||
2 1 113 425 273 XOR
|
||||
2 1 49 425 272 XOR
|
||||
2 1 272 273 274 AND
|
||||
2 1 274 425 426 XOR
|
||||
2 1 363 426 490 XOR
|
||||
2 1 314 377 441 XOR
|
||||
2 1 114 426 276 XOR
|
||||
2 1 50 426 275 XOR
|
||||
2 1 275 276 277 AND
|
||||
2 1 277 426 427 XOR
|
||||
2 1 115 427 279 XOR
|
||||
2 1 51 427 278 XOR
|
||||
2 1 278 279 280 AND
|
||||
2 1 280 427 428 XOR
|
||||
2 1 116 428 282 XOR
|
||||
2 1 52 428 281 XOR
|
||||
2 1 281 282 283 AND
|
||||
2 1 283 428 429 XOR
|
||||
2 1 117 429 285 XOR
|
||||
2 1 53 429 284 XOR
|
||||
2 1 284 285 286 AND
|
||||
2 1 286 429 430 XOR
|
||||
2 1 118 430 288 XOR
|
||||
2 1 54 430 287 XOR
|
||||
2 1 287 288 289 AND
|
||||
2 1 289 430 431 XOR
|
||||
2 1 119 431 291 XOR
|
||||
2 1 55 431 290 XOR
|
||||
2 1 290 291 292 AND
|
||||
2 1 292 431 432 XOR
|
||||
2 1 120 432 294 XOR
|
||||
2 1 56 432 293 XOR
|
||||
2 1 293 294 295 AND
|
||||
2 1 295 432 433 XOR
|
||||
2 1 370 433 497 XOR
|
||||
2 1 121 433 297 XOR
|
||||
2 1 57 433 296 XOR
|
||||
2 1 296 297 298 AND
|
||||
2 1 298 433 434 XOR
|
||||
2 1 371 434 498 XOR
|
||||
2 1 369 432 496 XOR
|
||||
2 1 122 434 300 XOR
|
||||
2 1 58 434 299 XOR
|
||||
2 1 299 300 301 AND
|
||||
2 1 301 434 435 XOR
|
||||
2 1 372 435 499 XOR
|
||||
2 1 368 431 495 XOR
|
||||
2 1 123 435 303 XOR
|
||||
2 1 59 435 302 XOR
|
||||
2 1 302 303 304 AND
|
||||
2 1 304 435 436 XOR
|
||||
2 1 367 430 494 XOR
|
||||
2 1 60 436 305 XOR
|
||||
2 1 373 436 500 XOR
|
||||
2 1 366 429 493 XOR
|
||||
2 1 124 436 306 XOR
|
||||
2 1 305 306 307 AND
|
||||
2 1 307 436 437 XOR
|
||||
2 1 374 437 501 XOR
|
||||
2 1 365 428 492 XOR
|
||||
2 1 125 437 309 XOR
|
||||
2 1 61 437 308 XOR
|
||||
2 1 308 309 310 AND
|
||||
2 1 310 437 438 XOR
|
||||
2 1 375 438 502 XOR
|
||||
2 1 364 427 491 XOR
|
||||
2 1 126 438 312 XOR
|
||||
2 1 62 438 311 XOR
|
||||
2 1 311 312 313 AND
|
||||
2 1 313 438 439 XOR
|
||||
2 1 376 439 503 XOR
|
||||
|
||||
|
||||
33621
pop-mpc/circuits/aes_128.txt
Normal file
33621
pop-mpc/circuits/aes_128.txt
Normal file
File diff suppressed because it is too large
Load Diff
36669
pop-mpc/circuits/aes_128_reverse.txt
Normal file
36669
pop-mpc/circuits/aes_128_reverse.txt
Normal file
File diff suppressed because it is too large
Load Diff
91
pop-mpc/src/circuit/mod.rs
Normal file
91
pop-mpc/src/circuit/mod.rs
Normal file
@@ -0,0 +1,91 @@
|
||||
pub mod parse;
|
||||
|
||||
use crate::element::GateOps;
|
||||
use crate::errors::CircuitEvalError;
|
||||
use crate::gate::Gate;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Circuit {
|
||||
/// Number of gates in the circuit
|
||||
pub(crate) ngates: usize,
|
||||
/// Number of wires in the circuit
|
||||
pub(crate) nwires: usize,
|
||||
/// Number of inputs to the circuit
|
||||
pub(crate) ninputs: usize,
|
||||
/// Number of wires for each input to the circuit
|
||||
pub(crate) input_nwires: Vec<usize>,
|
||||
/// Total number of input wires
|
||||
pub(crate) ninput_wires: usize,
|
||||
/// Total number of output wires
|
||||
pub(crate) noutput_wires: usize,
|
||||
/// All gates in the circuit
|
||||
pub(crate) gates: Vec<Gate>,
|
||||
}
|
||||
|
||||
impl Circuit {
|
||||
pub fn new(
|
||||
ngates: usize,
|
||||
nwires: usize,
|
||||
ninputs: usize,
|
||||
input_nwires: Vec<usize>,
|
||||
ninput_wires: usize,
|
||||
noutput_wires: usize,
|
||||
) -> Self {
|
||||
Circuit {
|
||||
ngates,
|
||||
nwires,
|
||||
ninputs,
|
||||
input_nwires,
|
||||
ninput_wires,
|
||||
noutput_wires,
|
||||
gates: Vec::with_capacity(ngates),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn eval<E: GateOps>(&self, inputs: Vec<Vec<E>>) -> Result<Vec<E>, CircuitEvalError> {
|
||||
let mut wires: Vec<Option<E>> = vec![None; self.nwires];
|
||||
let inputs = inputs.concat();
|
||||
for (i, input) in inputs.into_iter().enumerate() {
|
||||
wires[i] = Some(input);
|
||||
}
|
||||
|
||||
for (i, gate) in self.gates.iter().enumerate() {
|
||||
let (zref, val) = match *gate {
|
||||
Gate::Xor {
|
||||
xref, yref, zref, ..
|
||||
} => {
|
||||
let x =
|
||||
wires[xref].ok_or_else(|| CircuitEvalError::UninitializedValue(xref))?;
|
||||
let y =
|
||||
wires[yref].ok_or_else(|| CircuitEvalError::UninitializedValue(yref))?;
|
||||
let val = x.xor(&y)?;
|
||||
(zref, val)
|
||||
}
|
||||
Gate::And {
|
||||
xref, yref, zref, ..
|
||||
} => {
|
||||
let x =
|
||||
wires[xref].ok_or_else(|| CircuitEvalError::UninitializedValue(xref))?;
|
||||
let y =
|
||||
wires[yref].ok_or_else(|| CircuitEvalError::UninitializedValue(yref))?;
|
||||
let val = x.and(&y)?;
|
||||
(zref, val)
|
||||
}
|
||||
Gate::Inv { xref, zref, .. } => {
|
||||
let x =
|
||||
wires[xref].ok_or_else(|| CircuitEvalError::UninitializedValue(xref))?;
|
||||
let val = x.inv()?;
|
||||
(zref, val)
|
||||
}
|
||||
};
|
||||
wires[zref] = Some(val);
|
||||
}
|
||||
|
||||
let outputs = wires[(self.nwires - self.noutput_wires)..]
|
||||
.to_vec()
|
||||
.iter()
|
||||
.map(|w| w.unwrap())
|
||||
.collect();
|
||||
Ok(outputs)
|
||||
}
|
||||
}
|
||||
358
pop-mpc/src/circuit/parse.rs
Normal file
358
pop-mpc/src/circuit/parse.rs
Normal file
@@ -0,0 +1,358 @@
|
||||
use super::Circuit;
|
||||
use crate::errors::CircuitParserError;
|
||||
use crate::gate::Gate;
|
||||
use regex::{Captures, Regex};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
/// Parses captures into a Vec for convenience
|
||||
fn line2vec<'a>(re: &Regex, line: &'a str) -> Result<Vec<&'a str>, CircuitParserError> {
|
||||
let v: Vec<&'a str> = re
|
||||
.captures_iter(line)
|
||||
.map(|cap| {
|
||||
let s = cap.get(1).unwrap().as_str();
|
||||
s
|
||||
})
|
||||
.collect();
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
impl Circuit {
|
||||
/// Parses circuit files in Bristol Fashion format as specified here:
|
||||
/// https://homes.esat.kuleuven.be/~nsmart/MPC/
|
||||
pub fn parse(filename: &str) -> Result<Self, CircuitParserError> {
|
||||
let f = File::open(filename)?;
|
||||
let mut reader = BufReader::new(f);
|
||||
|
||||
// Parse first line: ngates nwires\n
|
||||
let mut line = String::new();
|
||||
let _ = reader.read_line(&mut line)?;
|
||||
let re = Regex::new(r"(\d+)")?;
|
||||
let line_1 = line2vec(&re, &line)?;
|
||||
|
||||
// Check that first line has 2 values: ngates, nwires
|
||||
if line_1.len() != 2 {
|
||||
return Err(CircuitParserError::ParseLineError(line));
|
||||
}
|
||||
|
||||
let ngates: usize = line_1[0].parse()?;
|
||||
let nwires: usize = line_1[1].parse()?;
|
||||
|
||||
// Parse second line: ninputs input_0_nwires input_1_nwires...
|
||||
let mut line = String::new();
|
||||
let _ = reader.read_line(&mut line)?;
|
||||
let re = Regex::new(r"(\d+)\s*")?;
|
||||
let line_2 = line2vec(&re, &line)?;
|
||||
|
||||
let ninputs: usize = line_2[0].parse()?; // Number of circuit inputs
|
||||
let input_nwires: Vec<usize> = line_2[1..]
|
||||
.iter()
|
||||
.map(|nwires| {
|
||||
let nwires: usize = nwires.parse().unwrap();
|
||||
nwires
|
||||
})
|
||||
.collect();
|
||||
let ninput_wires: usize = input_nwires.iter().sum();
|
||||
|
||||
// Check that nwires is specified for every input
|
||||
if input_nwires.len() != ninputs {
|
||||
return Err(CircuitParserError::ParseLineError(line));
|
||||
}
|
||||
|
||||
// Parse third line: noutputs output_0_nwires output_1_nwires...
|
||||
let mut line = String::new();
|
||||
let _ = reader.read_line(&mut line)?;
|
||||
let re = Regex::new(r"(\d+)\s*")?;
|
||||
let line_3 = line2vec(&re, &line)?;
|
||||
|
||||
let noutputs: usize = line_3[0].parse()?; // Number of circuit outputs
|
||||
let output_nwires: Vec<usize> = line_3[1..]
|
||||
.iter()
|
||||
.map(|nwires| {
|
||||
let nwires: usize = nwires.parse().unwrap();
|
||||
nwires
|
||||
})
|
||||
.collect();
|
||||
let noutput_wires: usize = output_nwires.iter().sum();
|
||||
|
||||
// Check that nwires is specified for every output
|
||||
if output_nwires.len() != noutputs {
|
||||
return Err(CircuitParserError::ParseLineError(line));
|
||||
}
|
||||
|
||||
let mut circ = Self::new(
|
||||
ngates,
|
||||
nwires,
|
||||
ninputs,
|
||||
input_nwires.clone(),
|
||||
ninput_wires,
|
||||
noutput_wires,
|
||||
);
|
||||
|
||||
let re = Regex::new(r"(\d+|\S+)\s*")?;
|
||||
|
||||
let mut id = 0;
|
||||
|
||||
// Process gates
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let gate_vals = line2vec(&re, &line)?;
|
||||
let typ = gate_vals.last().unwrap();
|
||||
let gate = match *typ {
|
||||
"INV" => {
|
||||
let xref: usize = gate_vals[2].parse()?;
|
||||
let zref: usize = gate_vals[3].parse()?;
|
||||
Gate::Inv { id, xref, zref }
|
||||
}
|
||||
"AND" => {
|
||||
let xref: usize = gate_vals[2].parse()?;
|
||||
let yref: usize = gate_vals[3].parse()?;
|
||||
let zref: usize = gate_vals[4].parse()?;
|
||||
Gate::And {
|
||||
id,
|
||||
xref,
|
||||
yref,
|
||||
zref,
|
||||
}
|
||||
}
|
||||
"XOR" => {
|
||||
let xref: usize = gate_vals[2].parse()?;
|
||||
let yref: usize = gate_vals[3].parse()?;
|
||||
let zref: usize = gate_vals[4].parse()?;
|
||||
Gate::Xor {
|
||||
id,
|
||||
xref,
|
||||
yref,
|
||||
zref,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(CircuitParserError::ParseGateError(line.to_string()));
|
||||
}
|
||||
};
|
||||
circ.gates.push(gate);
|
||||
id += 1;
|
||||
}
|
||||
if id != ngates {
|
||||
return Err(CircuitParserError::ParseGateError(format!(
|
||||
"expecting {ngates} gates, parsed {id}"
|
||||
)));
|
||||
}
|
||||
Ok(circ)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
#[test]
|
||||
fn test_parse_adder64() {
|
||||
let circ = Circuit::parse("circuits/adder64.txt").unwrap();
|
||||
|
||||
assert_eq!(circ.ninput_wires, 128);
|
||||
assert_eq!(circ.noutput_wires, 64);
|
||||
|
||||
let a = vec![0u8; 64];
|
||||
let b = vec![0u8; 64];
|
||||
let output = circ.eval(vec![a, b]).unwrap();
|
||||
assert_eq!(
|
||||
output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
|
||||
let mut a = vec![0u8; 64];
|
||||
a[63] = 1;
|
||||
a.reverse();
|
||||
let b = vec![0u8; 64];
|
||||
let mut output = circ.eval(vec![a, b]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(
|
||||
output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"0000000000000000000000000000000000000000000000000000000000000001"
|
||||
);
|
||||
|
||||
let a = vec![0u8; 64];
|
||||
let mut b = vec![0u8; 64];
|
||||
b[63] = 1;
|
||||
b.reverse();
|
||||
let mut output = circ.eval(vec![a, b]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(
|
||||
output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"0000000000000000000000000000000000000000000000000000000000000001"
|
||||
);
|
||||
|
||||
let mut a = vec![0u8; 64];
|
||||
a[63] = 1;
|
||||
a.reverse();
|
||||
let mut b = vec![0u8; 64];
|
||||
b[63] = 1;
|
||||
b.reverse();
|
||||
let mut output = circ.eval(vec![a, b]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(
|
||||
output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"0000000000000000000000000000000000000000000000000000000000000010"
|
||||
);
|
||||
|
||||
let a = vec![1u8; 64];
|
||||
let mut b = vec![0u8; 64];
|
||||
b[63] = 1;
|
||||
b.reverse();
|
||||
let mut output = circ.eval(vec![a, b]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(
|
||||
output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aes_reverse() {
|
||||
let circ = Circuit::parse("circuits/aes_128_reverse.txt").unwrap();
|
||||
|
||||
assert_eq!(circ.ninput_wires, 256);
|
||||
assert_eq!(circ.noutput_wires, 128);
|
||||
|
||||
let mut key = vec![0u8; 128];
|
||||
let mut pt = vec![0u8; 128];
|
||||
let mut output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"01100110111010010100101111010100111011111000101000101100001110111000100001001100111110100101100111001010001101000010101100101110");
|
||||
|
||||
key = vec![1u8; 128];
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10100001111101100010010110001100100001110111110101011111110011011000100101100100010010000100010100111000101111111100100100101100");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
key[7] = 1;
|
||||
key.reverse();
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"11011100000011101101100001011101111110010110000100011010101110110111001001001001110011011101000101101000110001010100011001111110");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
for i in 0..8 {
|
||||
key[127 - i] = 1;
|
||||
}
|
||||
key.reverse();
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"11010101110010011000110001001000001001010101111101111000110011000100011111100001010010011110010101011100111111000011111111111101");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
for i in 0..8 {
|
||||
key[127 - i] = 1;
|
||||
}
|
||||
key.reverse();
|
||||
pt = vec![0u8; 128];
|
||||
pt.splice(
|
||||
..64,
|
||||
[
|
||||
0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0,
|
||||
0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1,
|
||||
0, 1, 1, 0, 1, 1, 0, 1,
|
||||
],
|
||||
);
|
||||
pt.reverse();
|
||||
output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10001010010011010111111100000011011000110101001101101001101011100001101111001110101010001010101010000000100010000001000101010111");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
|
||||
for i in 0..8 {
|
||||
key[i] = 1;
|
||||
}
|
||||
|
||||
key.reverse();
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![key, pt]).unwrap();
|
||||
output.reverse();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10110001110101110101100000100101011010110010100011111101100001010000101011010100100101000100001000001000110011110001000101010101");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aes_old() {
|
||||
let circ = Circuit::parse("circuits/aes_128.txt").unwrap();
|
||||
|
||||
assert_eq!(circ.ninput_wires, 256);
|
||||
assert_eq!(circ.noutput_wires, 128);
|
||||
|
||||
let mut key = vec![0u8; 128];
|
||||
let mut pt = vec![0u8; 128];
|
||||
let mut output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"01100110111010010100101111010100111011111000101000101100001110111000100001001100111110100101100111001010001101000010101100101110");
|
||||
|
||||
key = vec![1u8; 128];
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10100001111101100010010110001100100001110111110101011111110011011000100101100100010010000100010100111000101111111100100100101100");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
key[7] = 1;
|
||||
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"11011100000011101101100001011101111110010110000100011010101110110111001001001001110011011101000101101000110001010100011001111110");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
for i in 0..8 {
|
||||
key[127 - i] = 1;
|
||||
}
|
||||
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"11010101110010011000110001001000001001010101111101111000110011000100011111100001010010011110010101011100111111000011111111111101");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
for i in 0..8 {
|
||||
key[127 - i] = 1;
|
||||
}
|
||||
pt = vec![0u8; 128];
|
||||
pt.splice(
|
||||
..64,
|
||||
[
|
||||
0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0,
|
||||
0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1,
|
||||
0, 1, 1, 0, 1, 1, 0, 1,
|
||||
],
|
||||
);
|
||||
output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10001010010011010111111100000011011000110101001101101001101011100001101111001110101010001010101010000000100010000001000101010111");
|
||||
|
||||
key = vec![0u8; 128];
|
||||
|
||||
for i in 0..8 {
|
||||
key[i] = 1;
|
||||
}
|
||||
|
||||
pt = vec![0u8; 128];
|
||||
output = circ.eval(vec![pt, key]).unwrap();
|
||||
assert_eq!(output.iter().map(|i| i.to_string()).collect::<String>(),
|
||||
"10110001110101110101100000100101011010110010100011111101100001010000101011010100100101000100001000001000110011110001000101010101");
|
||||
}
|
||||
}
|
||||
68
pop-mpc/src/element/boolean.rs
Normal file
68
pop-mpc/src/element/boolean.rs
Normal file
@@ -0,0 +1,68 @@
|
||||
use super::GateOps;
|
||||
use crate::errors::GateOpsError;
|
||||
|
||||
pub type Bool = u8;
|
||||
|
||||
impl GateOps for Bool {
|
||||
/// XOR `self` and `x`
|
||||
fn xor(&self, x: &Bool) -> Result<Bool, GateOpsError> {
|
||||
Ok((self + x) % 2)
|
||||
}
|
||||
|
||||
/// INV `self`
|
||||
fn inv(&self) -> Result<Bool, GateOpsError> {
|
||||
Ok((1 + self) % 2)
|
||||
}
|
||||
|
||||
/// AND `self` and `x`
|
||||
fn and(&self, x: &Bool) -> Result<Bool, GateOpsError> {
|
||||
Ok(self * x)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_xor() {
|
||||
let a: Bool = 1u8;
|
||||
let b: Bool = 1u8;
|
||||
assert_eq!(a.xor(&b).unwrap(), 0u8);
|
||||
|
||||
let a: Bool = 0u8;
|
||||
let b: Bool = 1u8;
|
||||
assert_eq!(a.xor(&b).unwrap(), 1u8);
|
||||
|
||||
let a: Bool = 0u8;
|
||||
let b: Bool = 0u8;
|
||||
assert_eq!(a.xor(&b).unwrap(), 0u8);
|
||||
|
||||
let a: Bool = 1u8;
|
||||
let b: Bool = 0u8;
|
||||
assert_eq!(a.xor(&b).unwrap(), 1u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inv() {
|
||||
let a: Bool = 1u8;
|
||||
assert_eq!(a.inv().unwrap(), 0u8);
|
||||
|
||||
let a: Bool = 0u8;
|
||||
assert_eq!(a.inv().unwrap(), 1u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_and() {
|
||||
let a: Bool = 1u8;
|
||||
let b: Bool = 1u8;
|
||||
assert_eq!(a.and(&b).unwrap(), 1u8);
|
||||
|
||||
let a: Bool = 0u8;
|
||||
let b: Bool = 1u8;
|
||||
assert_eq!(a.and(&b).unwrap(), 0u8);
|
||||
|
||||
let a: Bool = 0u8;
|
||||
let b: Bool = 0u8;
|
||||
assert_eq!(a.and(&b).unwrap(), 0u8);
|
||||
|
||||
let a: Bool = 1;
|
||||
let b: Bool = 0u8;
|
||||
assert_eq!(a.and(&b).unwrap(), 0u8);
|
||||
}
|
||||
12
pop-mpc/src/element/gate_ops.rs
Normal file
12
pop-mpc/src/element/gate_ops.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use crate::errors::GateOpsError;
|
||||
|
||||
pub trait GateOps: Clone + Copy {
|
||||
/// XOR `self` and `x`
|
||||
fn xor(&self, x: &Self) -> Result<Self, GateOpsError>;
|
||||
|
||||
/// INV `self`
|
||||
fn inv(&self) -> Result<Self, GateOpsError>;
|
||||
|
||||
/// AND `self` and `x`
|
||||
fn and(&self, x: &Self) -> Result<Self, GateOpsError>;
|
||||
}
|
||||
11
pop-mpc/src/element/mod.rs
Normal file
11
pop-mpc/src/element/mod.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
mod boolean;
|
||||
mod gate_ops;
|
||||
|
||||
pub use boolean::Bool;
|
||||
pub use gate_ops::GateOps;
|
||||
|
||||
/// An element that has some modulus
|
||||
pub trait HasModulus {
|
||||
/// The modulus of the wire.
|
||||
fn modulus(&self) -> u16;
|
||||
}
|
||||
94
pop-mpc/src/errors.rs
Normal file
94
pop-mpc/src/errors.rs
Normal file
@@ -0,0 +1,94 @@
|
||||
use regex;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
/// Errors that may occur when using the `GateOps` trait.
|
||||
#[derive(Debug)]
|
||||
pub enum GateOpsError {
|
||||
/// Operation not implemented
|
||||
OperationNotImplemented,
|
||||
}
|
||||
|
||||
impl Display for GateOpsError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
match self {
|
||||
GateOpsError::OperationNotImplemented => "operation not implemented".fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// CircuitEval
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CircuitEvalError {
|
||||
UninitializedValue(usize),
|
||||
GateOpsError(GateOpsError),
|
||||
}
|
||||
|
||||
impl From<GateOpsError> for CircuitEvalError {
|
||||
fn from(error: GateOpsError) -> Self {
|
||||
CircuitEvalError::GateOpsError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for CircuitEvalError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CircuitEvalError::UninitializedValue(wire) => {
|
||||
write!(f, "Uninitialized value, wire {}", wire)
|
||||
}
|
||||
CircuitEvalError::GateOpsError(err) => write!(f, "Gate operation error: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Circuit Parser
|
||||
|
||||
/// Errors emitted by the circuit parser.
|
||||
#[derive(Debug)]
|
||||
pub enum CircuitParserError {
|
||||
/// An I/O error occurred.
|
||||
IoError(std::io::Error),
|
||||
/// A regular expression parsing error occurred.
|
||||
RegexError(regex::Error),
|
||||
/// An error occurred parsing an integer.
|
||||
ParseIntError,
|
||||
/// An error occurred parsing a line.
|
||||
ParseLineError(String),
|
||||
/// An error occurred parsing a gate type.
|
||||
ParseGateError(String),
|
||||
/// An error occurred due to invalid garbler/evaluator inputs.
|
||||
InputError(),
|
||||
}
|
||||
|
||||
impl Display for CircuitParserError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CircuitParserError::IoError(e) => write!(f, "io error: {}", e),
|
||||
CircuitParserError::RegexError(e) => write!(f, "regex error: {}", e),
|
||||
CircuitParserError::ParseIntError => write!(f, "unable to parse integer"),
|
||||
CircuitParserError::ParseLineError(s) => write!(f, "unable to parse line '{}'", s),
|
||||
CircuitParserError::ParseGateError(s) => write!(f, "unable to parse gate '{}'", s),
|
||||
CircuitParserError::InputError() => write!(f, "invalid circuit inputs"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for CircuitParserError {
|
||||
fn from(e: std::io::Error) -> CircuitParserError {
|
||||
CircuitParserError::IoError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<regex::Error> for CircuitParserError {
|
||||
fn from(e: regex::Error) -> CircuitParserError {
|
||||
CircuitParserError::RegexError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::num::ParseIntError> for CircuitParserError {
|
||||
fn from(_: std::num::ParseIntError) -> CircuitParserError {
|
||||
CircuitParserError::ParseIntError
|
||||
}
|
||||
}
|
||||
25
pop-mpc/src/gate.rs
Normal file
25
pop-mpc/src/gate.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
/// Basic components of a circuit.
|
||||
///
|
||||
/// `id` represents the gate id.
|
||||
/// `xref` and `yref` are the wire ids of the gate inputs
|
||||
/// `zref` is the wire id of the gate output
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) enum Gate {
|
||||
Xor {
|
||||
id: usize,
|
||||
xref: usize,
|
||||
yref: usize,
|
||||
zref: usize,
|
||||
},
|
||||
And {
|
||||
id: usize,
|
||||
xref: usize,
|
||||
yref: usize,
|
||||
zref: usize,
|
||||
},
|
||||
Inv {
|
||||
id: usize,
|
||||
xref: usize,
|
||||
zref: usize,
|
||||
},
|
||||
}
|
||||
8
pop-mpc/src/lib.rs
Normal file
8
pop-mpc/src/lib.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
mod circuit;
|
||||
mod element;
|
||||
mod errors;
|
||||
mod gate;
|
||||
8
pop-tls/Cargo.toml
Normal file
8
pop-tls/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "pop-tls"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
3
pop-tls/src/main.rs
Normal file
3
pop-tls/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
465
src/main.rs
465
src/main.rs
@@ -1,465 +0,0 @@
|
||||
use std::process;
|
||||
use std::sync::{Arc};
|
||||
|
||||
use mio::net::TcpStream;
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::{BufReader, Read, Write};
|
||||
use std::net::SocketAddr;
|
||||
use std::str;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use rustls::{OwnedTrustAnchor, RootCertStore};
|
||||
|
||||
const CLIENT: mio::Token = mio::Token(0);
|
||||
|
||||
/// This encapsulates the TCP-level connection, some connection
|
||||
/// state, and the underlying TLS-level session.
|
||||
struct TlsClient {
|
||||
socket: TcpStream,
|
||||
closing: bool,
|
||||
clean_closure: bool,
|
||||
tls_conn: rustls::ClientConnection,
|
||||
}
|
||||
|
||||
impl TlsClient {
|
||||
fn new(
|
||||
sock: TcpStream,
|
||||
server_name: rustls::ServerName,
|
||||
cfg: Arc<rustls::ClientConfig>,
|
||||
) -> TlsClient {
|
||||
TlsClient {
|
||||
socket: sock,
|
||||
closing: false,
|
||||
clean_closure: false,
|
||||
tls_conn: rustls::ClientConnection::new(cfg, server_name).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles events sent to the TlsClient by mio::Poll
|
||||
fn ready(&mut self, ev: &mio::event::Event) {
|
||||
assert_eq!(ev.token(), CLIENT);
|
||||
|
||||
if ev.is_readable() {
|
||||
self.do_read();
|
||||
}
|
||||
|
||||
if ev.is_writable() {
|
||||
self.do_write();
|
||||
}
|
||||
|
||||
if self.is_closed() {
|
||||
println!("Connection closed");
|
||||
process::exit(if self.clean_closure { 0 } else { 1 });
|
||||
}
|
||||
}
|
||||
|
||||
fn read_source_to_end(&mut self, rd: &mut dyn io::Read) -> io::Result<usize> {
|
||||
let mut buf = Vec::new();
|
||||
let len = rd.read_to_end(&mut buf)?;
|
||||
self.tls_conn
|
||||
.writer()
|
||||
.write_all(&buf)
|
||||
.unwrap();
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
/// We're ready to do a read.
|
||||
fn do_read(&mut self) {
|
||||
// Read TLS data. This fails if the underlying TCP connection
|
||||
// is broken.
|
||||
match self.tls_conn.read_tls(&mut self.socket) {
|
||||
Err(error) => {
|
||||
if error.kind() == io::ErrorKind::WouldBlock {
|
||||
return;
|
||||
}
|
||||
println!("TLS read error: {:?}", error);
|
||||
self.closing = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're ready but there's no data: EOF.
|
||||
Ok(0) => {
|
||||
println!("EOF");
|
||||
self.closing = true;
|
||||
self.clean_closure = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Ok(_) => {}
|
||||
};
|
||||
|
||||
// Reading some TLS data might have yielded new TLS
|
||||
// messages to process. Errors from this indicate
|
||||
// TLS protocol problems and are fatal.
|
||||
let io_state = match self.tls_conn.process_new_packets() {
|
||||
Ok(io_state) => io_state,
|
||||
Err(err) => {
|
||||
println!("TLS error: {:?}", err);
|
||||
self.closing = true;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Having read some TLS data, and processed any new messages,
|
||||
// we might have new plaintext as a result.
|
||||
//
|
||||
// Read it and then write it to stdout.
|
||||
if io_state.plaintext_bytes_to_read() > 0 {
|
||||
let mut plaintext = Vec::new();
|
||||
plaintext.resize(io_state.plaintext_bytes_to_read(), 0u8);
|
||||
self.tls_conn
|
||||
.reader()
|
||||
.read_exact(&mut plaintext)
|
||||
.unwrap();
|
||||
io::stdout()
|
||||
.write_all(&plaintext)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// If wethat fails, the peer might have started a clean TLS-level
|
||||
// session closure.
|
||||
if io_state.peer_has_closed() {
|
||||
self.clean_closure = true;
|
||||
self.closing = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn do_write(&mut self) {
|
||||
self.tls_conn
|
||||
.write_tls(&mut self.socket)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// Registers self as a 'listener' in mio::Registry
|
||||
fn register(&mut self, registry: &mio::Registry) {
|
||||
let interest = self.event_set();
|
||||
registry
|
||||
.register(&mut self.socket, CLIENT, interest)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// Reregisters self as a 'listener' in mio::Registry.
|
||||
fn reregister(&mut self, registry: &mio::Registry) {
|
||||
let interest = self.event_set();
|
||||
registry
|
||||
.reregister(&mut self.socket, CLIENT, interest)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// Use wants_read/wants_write to register for different mio-level
|
||||
/// IO readiness events.
|
||||
fn event_set(&self) -> mio::Interest {
|
||||
let rd = self.tls_conn.wants_read();
|
||||
let wr = self.tls_conn.wants_write();
|
||||
|
||||
if rd && wr {
|
||||
mio::Interest::READABLE | mio::Interest::WRITABLE
|
||||
} else if wr {
|
||||
mio::Interest::WRITABLE
|
||||
} else {
|
||||
mio::Interest::READABLE
|
||||
}
|
||||
}
|
||||
|
||||
fn is_closed(&self) -> bool {
|
||||
self.closing
|
||||
}
|
||||
}
|
||||
impl io::Write for TlsClient {
|
||||
fn write(&mut self, bytes: &[u8]) -> io::Result<usize> {
|
||||
self.tls_conn.writer().write(bytes)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
self.tls_conn.writer().flush()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Read for TlsClient {
|
||||
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
|
||||
self.tls_conn.reader().read(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
const LONG_ABOUT: &str = "
|
||||
Connects to the TLS server at hostname:PORT. The default PORT
|
||||
is 443. By default, this reads a request from stdin (to EOF)
|
||||
before making the connection. --http replaces this with a
|
||||
basic HTTP GET request for /.
|
||||
|
||||
If --cafile is not supplied, a built-in set of CA certificates
|
||||
are used from the webpki-roots crate.
|
||||
";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(about = "Connects to the TLS server at hostname:PORT", long_about = LONG_ABOUT)]
|
||||
struct Args {
|
||||
#[clap(short, long, help = "Connect to PORT")]
|
||||
port: Option<u16>,
|
||||
|
||||
#[clap(long, help = "Send a basic HTTP GET request for /")]
|
||||
http: bool,
|
||||
|
||||
#[clap(long, help = "Emit log output")]
|
||||
verbose: bool,
|
||||
|
||||
#[clap(long, help = "Disable default TLS version list, and use VERSION instead. May be used multiple times")]
|
||||
protover: Vec<String>,
|
||||
|
||||
#[clap(long, help = "Disable default cipher suite list, and use SUITE instead. May be used multiple times")]
|
||||
suite: Vec<String>,
|
||||
|
||||
#[clap(long, help = "Send ALPN extension containing PROTOCOL. May be used multiple times to offer several protocols")]
|
||||
proto: Vec<String>,
|
||||
|
||||
#[clap(long, help = "Limit outgoing messages to M bytes")]
|
||||
max_frag_size: Option<usize>,
|
||||
|
||||
#[clap(long, help = "Read root certificates from CAFILE")]
|
||||
cafile: Option<String>,
|
||||
|
||||
#[clap(long, help = "Disable server name indication support")]
|
||||
no_sni: bool,
|
||||
|
||||
#[clap(long, help = "Disable certificate verification")]
|
||||
insecure: bool,
|
||||
|
||||
#[clap(long, help = "Read client authentication key from KEY")]
|
||||
auth_key: Option<String>,
|
||||
|
||||
#[clap(long, help = "Read client authentication certificates from CERTS. CERTS must match up with KEY")]
|
||||
auth_certs: Option<String>,
|
||||
|
||||
#[clap()]
|
||||
arg_hostname: String,
|
||||
}
|
||||
|
||||
// TODO: um, well, it turns out that openssl s_client/s_server
|
||||
// that we use for testing doesn't do ipv6. So we can't actually
|
||||
// test ipv6 and hence kill this.
|
||||
fn lookup_ipv4(host: &str, port: u16) -> SocketAddr {
|
||||
use std::net::ToSocketAddrs;
|
||||
|
||||
let addrs = (host, port).to_socket_addrs().unwrap();
|
||||
for addr in addrs {
|
||||
if let SocketAddr::V4(_) = addr {
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
unreachable!("Cannot lookup address");
|
||||
}
|
||||
|
||||
/// Make a vector of protocol versions named in `versions`
|
||||
fn lookup_versions(versions: &[String]) -> Vec<&'static rustls::SupportedProtocolVersion> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
for vname in versions {
|
||||
let version = match vname.as_ref() {
|
||||
"1.2" => &rustls::version::TLS12,
|
||||
"1.3" => &rustls::version::TLS13,
|
||||
_ => panic!(
|
||||
"cannot look up version '{}', valid are '1.2' and '1.3'",
|
||||
vname
|
||||
),
|
||||
};
|
||||
out.push(version);
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
fn load_certs(filename: &str) -> Vec<rustls::Certificate> {
|
||||
let certfile = fs::File::open(filename).expect("cannot open certificate file");
|
||||
let mut reader = BufReader::new(certfile);
|
||||
rustls_pemfile::certs(&mut reader)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|v| rustls::Certificate(v.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn load_private_key(filename: &str) -> rustls::PrivateKey {
|
||||
let keyfile = fs::File::open(filename).expect("cannot open private key file");
|
||||
let mut reader = BufReader::new(keyfile);
|
||||
|
||||
loop {
|
||||
match rustls_pemfile::read_one(&mut reader).expect("cannot parse private key .pem file") {
|
||||
Some(rustls_pemfile::Item::RSAKey(key)) => return rustls::PrivateKey(key),
|
||||
Some(rustls_pemfile::Item::PKCS8Key(key)) => return rustls::PrivateKey(key),
|
||||
None => break,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
panic!(
|
||||
"no keys found in {:?} (encrypted keys not supported)",
|
||||
filename
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dangerous_configuration")]
|
||||
mod danger {
|
||||
pub struct NoCertificateVerification {}
|
||||
|
||||
impl rustls::client::ServerCertVerifier for NoCertificateVerification {
|
||||
fn verify_server_cert(
|
||||
&self,
|
||||
_end_entity: &rustls::Certificate,
|
||||
_intermediates: &[rustls::Certificate],
|
||||
_server_name: &rustls::ServerName,
|
||||
_scts: &mut dyn Iterator<Item = &[u8]>,
|
||||
_ocsp: &[u8],
|
||||
_now: std::time::SystemTime,
|
||||
) -> Result<rustls::client::ServerCertVerified, rustls::Error> {
|
||||
Ok(rustls::client::ServerCertVerified::assertion())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dangerous_configuration")]
|
||||
fn apply_dangerous_options(args: &Args, cfg: &mut rustls::ClientConfig) {
|
||||
if args.insecure {
|
||||
cfg.dangerous()
|
||||
.set_certificate_verifier(Arc::new(danger::NoCertificateVerification {}));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "dangerous_configuration"))]
|
||||
fn apply_dangerous_options(args: &Args, _: &mut rustls::ClientConfig) {
|
||||
if args.insecure {
|
||||
panic!("This build does not support --insecure.");
|
||||
}
|
||||
}
|
||||
|
||||
/// Build a `ClientConfig` from our arguments
|
||||
fn make_config(args: &Args) -> Arc<rustls::ClientConfig> {
|
||||
let mut root_store = RootCertStore::empty();
|
||||
|
||||
if args.cafile.is_some() {
|
||||
let cafile = args.cafile.as_ref().unwrap();
|
||||
|
||||
let certfile = fs::File::open(&cafile).expect("Cannot open CA file");
|
||||
let mut reader = BufReader::new(certfile);
|
||||
root_store.add_parsable_certificates(&rustls_pemfile::certs(&mut reader).unwrap());
|
||||
} else {
|
||||
root_store.add_server_trust_anchors(
|
||||
webpki_roots::TLS_SERVER_ROOTS
|
||||
.0
|
||||
.iter()
|
||||
.map(|ta| {
|
||||
OwnedTrustAnchor::from_subject_spki_name_constraints(
|
||||
ta.subject,
|
||||
ta.spki,
|
||||
ta.name_constraints,
|
||||
)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
let suites = &[
|
||||
rustls::cipher_suite::TLS13_AES_128_GCM_SHA256
|
||||
].to_vec();
|
||||
|
||||
let versions = if !args.protover.is_empty() {
|
||||
lookup_versions(&args.protover)
|
||||
} else {
|
||||
rustls::DEFAULT_VERSIONS.to_vec()
|
||||
};
|
||||
|
||||
let config = rustls::ClientConfig::builder()
|
||||
.with_cipher_suites(&suites)
|
||||
.with_safe_default_kx_groups()
|
||||
.with_protocol_versions(&versions)
|
||||
.expect("inconsistent cipher-suite/versions selected")
|
||||
.with_root_certificates(root_store);
|
||||
|
||||
let mut config = match (&args.auth_key, &args.auth_certs) {
|
||||
(Some(key_file), Some(certs_file)) => {
|
||||
let certs = load_certs(certs_file);
|
||||
let key = load_private_key(key_file);
|
||||
config
|
||||
.with_single_cert(certs, key)
|
||||
.expect("invalid client auth certs/key")
|
||||
}
|
||||
(None, None) => config.with_no_client_auth(),
|
||||
(_, _) => {
|
||||
panic!("must provide --auth-certs and --auth-key together");
|
||||
}
|
||||
};
|
||||
|
||||
config.key_log = Arc::new(rustls::KeyLogFile::new());
|
||||
|
||||
config.enable_tickets = false;
|
||||
|
||||
if args.no_sni {
|
||||
config.enable_sni = false;
|
||||
}
|
||||
|
||||
config.alpn_protocols = args
|
||||
.proto
|
||||
.iter()
|
||||
.map(|proto| proto.as_bytes().to_vec())
|
||||
.collect();
|
||||
config.max_fragment_size = args.max_frag_size;
|
||||
|
||||
apply_dangerous_options(args, &mut config);
|
||||
|
||||
Arc::new(config)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
if args.verbose {
|
||||
env_logger::Builder::new()
|
||||
.parse_filters("trace")
|
||||
.init();
|
||||
}
|
||||
|
||||
let port = args.port.unwrap_or(443);
|
||||
let addr = lookup_ipv4(args.arg_hostname.as_str(), port);
|
||||
|
||||
let config = make_config(&args);
|
||||
|
||||
let sock = TcpStream::connect(addr).unwrap();
|
||||
let server_name = args
|
||||
.arg_hostname
|
||||
.as_str()
|
||||
.try_into()
|
||||
.expect("invalid DNS name");
|
||||
let mut tlsclient = TlsClient::new(sock, server_name, config);
|
||||
|
||||
if args.http {
|
||||
let httpreq = format!(
|
||||
"GET / HTTP/1.0\r\nHost: {}\r\nConnection: \
|
||||
close\r\nAccept-Encoding: identity\r\n\r\n",
|
||||
args.arg_hostname
|
||||
);
|
||||
tlsclient
|
||||
.write_all(httpreq.as_bytes())
|
||||
.unwrap();
|
||||
} else {
|
||||
let mut stdin = io::stdin();
|
||||
tlsclient
|
||||
.read_source_to_end(&mut stdin)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let mut poll = mio::Poll::new().unwrap();
|
||||
let mut events = mio::Events::with_capacity(32);
|
||||
tlsclient.register(poll.registry());
|
||||
|
||||
loop {
|
||||
poll.poll(&mut events, None).unwrap();
|
||||
|
||||
for ev in events.iter() {
|
||||
tlsclient.ready(ev);
|
||||
tlsclient.reregister(poll.registry());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user