From feb560cece4461ecd9918f7228471e8b1e6d2847 Mon Sep 17 00:00:00 2001 From: taskooh Date: Thu, 3 Oct 2024 20:59:53 +0900 Subject: [PATCH] WIP --- Cargo.lock | 342 ++++++++++++++++++++++++++++++++++- mpc-net/Cargo.lock | 414 +++++++++++++++++++++++++++++++++++++++++-- mpc-net/Cargo.toml | 3 + mpc-net/src/lib.rs | 25 ++- mpc-net/src/multi.rs | 199 +++++++++------------ 5 files changed, 839 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4601e8c..1e88f6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.6" @@ -284,13 +299,31 @@ dependencies = [ "rand", ] +[[package]] +name = "async_smux" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0f8695d370a810623d18891f6d4d60149afd8499d7f1e608a7fb1cbf099531" +dependencies = [ + "bytes", + "futures", + "futures-sink", + "log", + "parking_lot", + "pin-project", + "rand", + "thiserror", + "tokio", + "tokio-util", +] + [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -301,12 +334,33 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "blake2" version = "0.9.2" @@ -339,12 +393,27 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cast" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +[[package]] +name = "cc" +version = "1.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +dependencies = [ + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -386,7 +455,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap 0.11.0", "unicode-width", @@ -399,7 +468,7 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "textwrap 0.16.1", @@ -557,6 +626,95 @@ dependencies = [ "termcolor", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -578,6 +736,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "half" version = "2.4.1" @@ -621,6 +785,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" @@ -694,6 +864,16 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.20" @@ -725,6 +905,27 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "mpc-algebra" version = "0.1.0" @@ -757,10 +958,13 @@ name = "mpc-net" version = "0.1.0" dependencies = [ "ark-std", + "async_smux", "lazy_static", "log", "rayon", "serde", + "tokio", + "tokio-util", ] [[package]] @@ -846,6 +1050,15 @@ dependencies = [ "libm", ] +[[package]] +name = "object" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -870,6 +1083,29 @@ version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + [[package]] name = "paste" version = "1.0.14" @@ -886,12 +1122,38 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "pin-project-lite" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "plotters" version = "0.3.5" @@ -1034,6 +1296,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regex" version = "1.10.4" @@ -1063,6 +1334,12 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustc_version" version = "0.3.3" @@ -1164,6 +1441,12 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simba" version = "0.9.0" @@ -1177,6 +1460,31 @@ dependencies = [ "wide", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "strsim" version = "0.8.0" @@ -1289,6 +1597,34 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "tracing" version = "0.1.37" diff --git a/mpc-net/Cargo.lock b/mpc-net/Cargo.lock index 523e335..6df6705 100644 --- a/mpc-net/Cargo.lock +++ b/mpc-net/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -29,6 +44,24 @@ dependencies = [ "rand", ] +[[package]] +name = "async_smux" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0f8695d370a810623d18891f6d4d60149afd8499d7f1e608a7fb1cbf099531" +dependencies = [ + "bytes", + "futures", + "futures-sink", + "log", + "parking_lot", + "pin-project", + "rand", + "thiserror", + "tokio", + "tokio-util", +] + [[package]] name = "atty" version = "0.2.14" @@ -46,6 +79,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -58,6 +106,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cfg-if" version = "1.0.0" @@ -141,6 +195,112 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" + [[package]] name = "heck" version = "0.3.3" @@ -190,9 +350,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linux-raw-sys" @@ -200,6 +360,16 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.20" @@ -221,17 +391,29 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mpc-net" version = "0.1.0" dependencies = [ "ark-std", + "async_smux", "env_logger", "lazy_static", "log", "rayon", "serde", "structopt", + "tokio", + "tokio-util", ] [[package]] @@ -247,6 +429,70 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +dependencies = [ + "memchr", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -301,6 +547,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ + "libc", "rand_chacha", "rand_core", ] @@ -320,6 +567,9 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] [[package]] name = "rayon" @@ -341,6 +591,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags 2.4.1", +] + [[package]] name = "regex" version = "1.10.2" @@ -370,6 +629,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustix" version = "0.38.20" @@ -409,6 +674,21 @@ dependencies = [ "syn 2.0.65", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "strsim" version = "0.8.0" @@ -479,6 +759,50 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +dependencies = [ + "backtrace", + "bytes", + "pin-project-lite", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -509,6 +833,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "winapi" version = "0.3.9" @@ -546,7 +876,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -555,13 +885,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -570,38 +916,86 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/mpc-net/Cargo.toml b/mpc-net/Cargo.toml index 953ab36..d4e0627 100644 --- a/mpc-net/Cargo.toml +++ b/mpc-net/Cargo.toml @@ -7,10 +7,13 @@ edition = "2021" [dependencies] ark-std = { path = "../arkworks/std", version = "0.3.0", features = ["std"] } +async_smux = "0.3.3" lazy_static = "1.4.0" log = "0.4.20" rayon = "1.8.0" serde = { version = "1.0.209", features = ["derive"] } +tokio = { version = "1.40.0", features = ["sync","net"] } +tokio-util = { version = "0.7.12", features = ["codec"] } [dev-dependencies] env_logger = "0.10.0" diff --git a/mpc-net/src/lib.rs b/mpc-net/src/lib.rs index 74cd1e8..d46899e 100644 --- a/mpc-net/src/lib.rs +++ b/mpc-net/src/lib.rs @@ -23,16 +23,15 @@ pub enum MultiplexedStreamID { Two = 2, } -pub trait MpcNet { +pub trait MpcNet: Send + Sync { /// Am I the first party? - #[inline] - fn is_leader() -> bool { - Self::party_id() == 0 + fn is_leader(&self) -> bool { + self.party_id() == 0 } /// How many parties are there? - fn n_parties() -> usize; + fn n_parties(&self) -> usize; /// What is my party number (0 to n-1)? - fn party_id() -> usize; + fn party_id(&self) -> usize; /// Initialize the network layer from a file. /// The file should contain one HOST:PORT setting per line, corresponding to the addresses of /// the parties in increasing order. @@ -40,7 +39,7 @@ pub trait MpcNet { /// Parties are zero-indexed. fn init_from_file(path: &str, party_id: usize); /// Is the network layer initalized? - fn is_init() -> bool; + fn is_init(&self) -> bool; /// Uninitialize the network layer, closing all connections. fn deinit(); /// Set statistics to zero. @@ -48,12 +47,12 @@ pub trait MpcNet { /// Get statistics. fn stats() -> Stats; /// All parties send bytes to each other. - fn broadcast_bytes(bytes: &[u8]) -> Vec>; + fn broadcast_bytes(&self, bytes: &[u8]) -> Vec>; /// All parties send bytes to the king. - fn worker_send_or_leader_receive(bytes: &[u8]) -> Option>>; + fn worker_send_or_leader_receive(&self, bytes: &[u8]) -> Option>>; /// All parties recv bytes from the king. /// Provide bytes iff you're the king! - fn worker_receive_or_leader_send(bytes: Option>>) -> Vec; + fn worker_receive_or_leader_send(&self, bytes: Option>>) -> Vec; /// Everyone sends bytes to the king, who recieves those bytes, runs a computation on them, and /// redistributes the resulting bytes. @@ -61,9 +60,9 @@ pub trait MpcNet { /// The king's computation is given by a function, `f` /// proceeds. #[inline] - fn leader_compute(bytes: &[u8], f: impl Fn(Vec>) -> Vec>) -> Vec { - let king_response = Self::worker_send_or_leader_receive(bytes).map(f); - Self::worker_receive_or_leader_send(king_response) + fn leader_compute(&self, bytes: &[u8], f: impl Fn(Vec>) -> Vec>) -> Vec { + let king_response = self.worker_send_or_leader_receive(bytes).map(f); + self.worker_receive_or_leader_send(king_response) } fn uninit(); diff --git a/mpc-net/src/multi.rs b/mpc-net/src/multi.rs index c7fdd89..801ffad 100644 --- a/mpc-net/src/multi.rs +++ b/mpc-net/src/multi.rs @@ -1,41 +1,42 @@ -use std::{ - fs::File, - io::{BufRead, BufReader, Read, Write}, - net::{SocketAddr, TcpListener, TcpStream}, - sync::Mutex, -}; - use ark_std::{end_timer, perf_trace::TimerInfo, start_timer}; -use lazy_static::lazy_static; -use log::debug; -use rayon::prelude::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; +use async_smux::MuxStream; +use std::collections::HashMap; +use std::fmt::{Debug, Formatter}; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::net::SocketAddr; +use std::sync::atomic::AtomicUsize; +use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::net::{TcpListener, TcpStream}; +use tokio::sync::Mutex as TokioMutex; +use tokio_util::codec::{Framed, LengthDelimitedCodec}; -use crate::MpcNet; +use crate::{MPCNetError, MpcNet}; -lazy_static! { - static ref CONNECTIONS: Mutex = Mutex::new(Connections::default()); -} +pub type WrappedMuxStream = Framed, LengthDelimitedCodec>; -/// Macro for locking the FieldChannel singleton in the current scope. -macro_rules! get_ch { - () => { - CONNECTIONS.lock().expect("Poisoned FieldChannel") - }; +struct Peer { + id: usize, + listen_addr: SocketAddr, + streams: Option>>>, } -#[derive(Debug)] -struct Peer { - id: usize, - addr: SocketAddr, - stream: Option, +impl Debug for Peer { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let mut f = f.debug_struct("Peer"); + f.field("id", &self.id); + f.field("listen_addr", &self.listen_addr); + f.field("streams", &self.streams.is_some()); + f.finish() + } } -impl Default for Peer { - fn default() -> Self { +impl Clone for Peer { + fn clone(&self) -> Self { Self { - id: 0, - addr: "127.0.0.1:8000".parse().unwrap(), - stream: None, + id: self.id, + listen_addr: self.listen_addr, + streams: None, } } } @@ -50,15 +51,26 @@ pub struct Stats { } #[derive(Default, Debug)] -struct Connections { - id: usize, - peers: Vec, - stats: Stats, +struct MPCNetConnection { + pub id: usize, + pub listener: Option, + pub peers: HashMap>, + pub n_parties: usize, + pub upload: AtomicUsize, + pub download: AtomicUsize, } -impl Connections { +impl MPCNetConnection { /// Given a path and the `id` of oneself, initialize the structure - fn init_from_path(&mut self, path: &str, id: usize) { + fn init_from_path(path: &str, id: usize) -> Self { + let mut this = MPCNetConnection { + id: 0, + listener: None, + peers: Default::default(), + n_parties: 0, + upload: AtomicUsize::new(0), + download: AtomicUsize::new(0), + }; let f = BufReader::new(File::open(path).expect("host configuration path")); let mut peer_id = 0; for line in f.lines() { @@ -70,85 +82,36 @@ impl Connections { .unwrap_or_else(|e| panic!("bad socket address: {}:\n{}", trimmed, e)); let peer = Peer { id: peer_id, - addr, - stream: None, + listen_addr: addr, + streams: None, }; - self.peers.push(peer); + this.peers.insert(peer_id, peer); peer_id += 1; } } - assert!(id < self.peers.len()); - self.id = id; + assert!(id < this.peers.len()); + this.id = id; + this.n_parties = this.peers.len(); + this } - fn connect_to_all(&mut self) { - let timer = start_timer!(|| "Connecting"); - let n = self.peers.len(); - for from_id in 0..n { - for to_id in (from_id + 1)..n { - debug!("{} to {}", from_id, to_id); - if self.id == from_id { - let to_addr = self.peers[to_id].addr; - debug!("Contacting {}", to_id); - let stream = loop { - let mut ms_waited = 0; - match TcpStream::connect(to_addr) { - Ok(s) => break s, - Err(e) => match e.kind() { - std::io::ErrorKind::ConnectionRefused - | std::io::ErrorKind::ConnectionReset => { - ms_waited += 10; - std::thread::sleep(std::time::Duration::from_millis(10)); - if ms_waited % 3_000 == 0 { - debug!("Still waiting"); - } else if ms_waited > 30_000 { - panic!("Could not find peer in 30s"); - } - } - _ => { - panic!("Error during FieldChannel::new: {}", e); - } - }, - } - }; - stream.set_nodelay(true).unwrap(); - self.peers[to_id].stream = Some(stream); - } else if self.id == to_id { - debug!("Awaiting {}", from_id); - let listener = TcpListener::bind(self.peers[self.id].addr).unwrap(); - let (stream, _addr) = listener.accept().unwrap(); - stream.set_nodelay(true).unwrap(); - self.peers[from_id].stream = Some(stream); - } - } - // Sender for next round waits for note from this sender to prevent race on receipt. - if from_id + 1 < n { - if self.id == from_id { - self.peers[self.id + 1] - .stream - .as_mut() - .unwrap() - .write_all(&[0u8]) - .unwrap(); - } else if self.id == from_id + 1 { - self.peers[self.id - 1] - .stream - .as_mut() - .unwrap() - .read_exact(&mut [0u8]) - .unwrap(); - } - } - } - // Do a round with the king, to be sure everyone is ready - let from_all = self.send_to_king(&[self.id as u8]); - self.recv_from_king(from_all); - for id in 0..n { - if id != self.id { - assert!(self.peers[id].stream.is_some()); - } - } - end_timer!(timer); + + pub async fn listen(&mut self) -> Result<(), MPCNetError> { + let listen_addr = self.peers.get(&self.id).unwrap().listen_addr; + let listener = TcpListener::bind(listen_addr).await.unwrap(); + self.listener = Some(listener); + Ok(()) } + + async fn connect_to_all(&mut self) { + let n_minus_1 = self.n_parties - 1; + let self_id = self.id; + let peer_addrs = self + .peers + .iter() + .map(|(_, p)| p.listen_addr) + .collect::>(); + } + fn am_king(&self) -> bool { self.id == 0 } @@ -219,7 +182,7 @@ impl Connections { } else { self.stats.bytes_sent += m; self.peers[0] - .stream + .streams .as_mut() .unwrap() .write_all(bytes_out) @@ -251,7 +214,7 @@ impl Connections { end_timer!(timer); bytes_out[own_id].clone() } else { - let stream = self.peers[0].stream.as_mut().unwrap(); + let stream = self.peers[0].streams.as_mut().unwrap(); let mut bytes_size = [0u8; 8]; stream.read_exact(&mut bytes_size).unwrap(); let m = u64::from_le_bytes(bytes_size) as usize; @@ -263,7 +226,7 @@ impl Connections { } fn uninit(&mut self) { for p in &mut self.peers { - p.stream = None; + p.streams = None; } } } @@ -272,24 +235,24 @@ pub struct MpcMultiNet; impl MpcNet for MpcMultiNet { #[inline] - fn party_id() -> usize { + fn party_id(&self) -> usize { get_ch!().id } #[inline] - fn n_parties() -> usize { + fn n_parties(&self) -> usize { get_ch!().peers.len() } #[inline] fn init_from_file(path: &str, party_id: usize) { let mut ch = get_ch!(); - ch.init_from_path(path, party_id); + MPCNetConnection::init_from_path(path, party_id); ch.connect_to_all(); } #[inline] - fn is_init() -> bool { + fn is_init(&self) -> bool { get_ch!() .peers .first() @@ -313,17 +276,17 @@ impl MpcNet for MpcMultiNet { } #[inline] - fn broadcast_bytes(bytes: &[u8]) -> Vec> { + fn broadcast_bytes(&self, bytes: &[u8]) -> Vec> { get_ch!().broadcast(bytes) } #[inline] - fn worker_send_or_leader_receive(bytes: &[u8]) -> Option>> { + fn worker_send_or_leader_receive(&self, bytes: &[u8]) -> Option>> { get_ch!().send_to_king(bytes) } #[inline] - fn worker_receive_or_leader_send(bytes: Option>>) -> Vec { + fn worker_receive_or_leader_send(&self, bytes: Option>>) -> Vec { get_ch!().recv_from_king(bytes) }