From c2f848f65359f92380bf6613ba83fcd25bc9ce0a Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 31 Mar 2023 22:27:19 +1100 Subject: [PATCH 1/4] wip integration tests --- Cargo.lock | 1146 +++++++++++----------------- Cargo.toml | 34 +- Dockerfile | 8 + integration-tests/Cargo.toml | 18 + integration-tests/src/lib.rs | 1 + integration-tests/tests/lib.rs | 206 +++++ mpc-recovery/Cargo.toml | 29 + {src => mpc-recovery/src}/actor.rs | 9 + mpc-recovery/src/lib.rs | 70 ++ mpc-recovery/src/main.rs | 64 ++ {src => mpc-recovery/src}/web.rs | 3 +- src/main.rs | 117 --- 12 files changed, 875 insertions(+), 830 deletions(-) create mode 100644 Dockerfile create mode 100644 integration-tests/Cargo.toml create mode 100644 integration-tests/src/lib.rs create mode 100644 integration-tests/tests/lib.rs create mode 100644 mpc-recovery/Cargo.toml rename {src => mpc-recovery/src}/actor.rs (94%) create mode 100644 mpc-recovery/src/lib.rs create mode 100644 mpc-recovery/src/main.rs rename {src => mpc-recovery/src}/web.rs (93%) delete mode 100644 src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 79358f1de..0b106a261 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.2.6" @@ -75,7 +84,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" dependencies = [ "anstyle", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -92,16 +101,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", + "syn 2.0.12", ] [[package]] @@ -184,32 +184,22 @@ dependencies = [ ] [[package]] -name = "bitflags" -version = "1.3.2" +name = "base64" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] -name = "block-buffer" -version = "0.7.3" +name = "base64" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding 0.1.5", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] -name = "block-buffer" -version = "0.9.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "block-padding 0.2.1", - "generic-array 0.14.7", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" @@ -217,23 +207,47 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] -name = "block-padding" -version = "0.1.5" +name = "bollard" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +checksum = "af254ed2da4936ef73309e9597180558821cb16ae9bba4cb24ce6b612d8d80ed" dependencies = [ - "byte-tools", + "base64 0.21.0", + "bollard-stubs", + "bytes", + "futures-core", + "futures-util", + "hex", + "http", + "hyper", + "hyperlocal", + "log", + "pin-project-lite", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "serde_urlencoded", + "thiserror", + "tokio", + "tokio-util", + "url", + "winapi", ] [[package]] -name = "block-padding" -version = "0.2.1" +name = "bollard-stubs" +version = "1.42.0-rc.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +checksum = "602bda35f33aeb571cef387dcd4042c643a8bf689d8aaac2cc47ea24cb7bc7e0" +dependencies = [ + "serde", + "serde_with", +] [[package]] name = "bumpalo" @@ -241,12 +255,6 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" -[[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" @@ -271,6 +279,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "serde", + "winapi", +] + [[package]] name = "clap" version = "4.2.1" @@ -304,7 +325,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.12", ] [[package]] @@ -314,12 +335,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] -name = "cloudabi" -version = "0.0.3" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "bitflags", + "termcolor", + "unicode-width", ] [[package]] @@ -334,14 +356,14 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" dependencies = [ - "windows-sys 0.45.0", + "windows-sys", ] [[package]] -name = "const-oid" -version = "0.6.2" +name = "core-foundation-sys" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" @@ -358,90 +380,58 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "typenum", ] [[package]] -name = "crypto-mac" -version = "0.11.1" +name = "cxx" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ - "generic-array 0.14.7", - "subtle", + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", ] [[package]] -name = "cryptoxide" -version = "0.1.3" +name = "cxx-build" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35f15e1a0699dd988fed910dd78fdc6407f44654cd12589c91fa44ea67d9159" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.12", +] [[package]] -name = "curv-kzen" -version = "0.9.0" +name = "cxxbridge-flags" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc25c87ebf29b249e801de5eed820f0c9ba001054bf73008df884690a03e6eb" -dependencies = [ - "cryptoxide", - "curve25519-dalek", - "digest 0.9.0", - "ff-zeroize", - "generic-array 0.14.7", - "hex 0.4.3", - "hmac", - "lazy_static", - "merkle-cbt", - "num-bigint 0.4.3", - "num-integer", - "num-traits", - "p256", - "pairing-plus", - "rand 0.6.5", - "rand 0.7.3", - "rust-gmp-kzen", - "secp256k1", - "serde", - "serde_bytes", - "serde_derive", - "sha2 0.8.2", - "sha2 0.9.9", - "sha3", - "thiserror", - "typenum", - "zeroize", -] +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] -name = "curve25519-dalek" -version = "3.2.0" +name = "cxxbridge-macro" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.12", ] [[package]] @@ -457,88 +447,22 @@ dependencies = [ "parking_lot_core", ] -[[package]] -name = "der" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" -dependencies = [ - "const-oid", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "digest" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", ] -[[package]] -name = "ecdsa" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" -dependencies = [ - "der", - "elliptic-curve", - "hmac", - "signature", -] - [[package]] name = "either" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "elliptic-curve" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" -dependencies = [ - "crypto-bigint", - "ff 0.10.1", - "generic-array 0.14.7", - "group 0.10.0", - "pkcs8", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - [[package]] name = "errno" version = "0.3.0" @@ -547,7 +471,7 @@ checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -582,12 +506,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fastrand" version = "1.9.0" @@ -608,49 +526,13 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "ff" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "ff-zeroize" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02169a2e8515aa316ce516eaaf6318a76617839fbf904073284bc2576b029ee" -dependencies = [ - "byteorder", - "ff_derive-zeroize", - "rand_core 0.5.1", - "zeroize", -] - [[package]] name = "ff_derive" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3776aaf60a45037a9c3cabdd8542b38693acaa3e241ff957181b72579d29feb" dependencies = [ - "num-bigint 0.2.6", - "num-integer", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ff_derive-zeroize" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b24d4059bc0d0a0bf26b740aa21af1f96a984f0ab7a21356d00b32475388b53a" -dependencies = [ - "num-bigint 0.2.6", + "num-bigint", "num-integer", "num-traits", "proc-macro2", @@ -679,17 +561,11 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -702,9 +578,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -712,15 +588,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -729,38 +605,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", ] [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -774,15 +650,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -827,20 +694,28 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f15be54742789e36f03307c8fdf0621201e1345e94f1387282024178b5e9ec8c" dependencies = [ - "ff 0.6.0", + "ff", "rand 0.7.3", - "rand_xorshift 0.2.0", + "rand_xorshift", ] [[package]] -name = "group" -version = "0.10.0" +name = "h2" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ - "ff 0.10.1", - "rand_core 0.6.4", - "subtle", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] @@ -870,20 +745,11 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -dependencies = [ - "serde", -] [[package]] name = "hex_fmt" @@ -891,16 +757,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "http" version = "0.2.9" @@ -945,6 +801,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "httparse", @@ -958,14 +815,62 @@ dependencies = [ "want", ] +[[package]] +name = "hyperlocal" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fafdf7b2b2de7c9784f76e02c0935e65a8117ec3b768644379983ab333ac98c" +dependencies = [ + "futures-util", + "hex", + "hyper", + "pin-project", + "tokio", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "716f12fbcfac6ffab0a5e9ec51d0a0ff70503742bb2dc7b99396394c9dc323f0" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "autocfg 1.1.0", + "autocfg", "hashbrown", + "serde", ] [[package]] @@ -985,7 +890,7 @@ checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -996,8 +901,8 @@ checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.5", - "windows-sys 0.45.0", + "rustix", + "windows-sys", ] [[package]] @@ -1024,15 +929,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "keccak" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" -dependencies = [ - "cpufeatures", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1046,16 +942,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] -name = "linux-raw-sys" -version = "0.1.4" +name = "link-cplusplus" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] [[package]] name = "linux-raw-sys" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" [[package]] name = "lock_api" @@ -1063,7 +962,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ - "autocfg 1.1.0", + "autocfg", "scopeguard", ] @@ -1088,15 +987,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "merkle-cbt" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" -dependencies = [ - "cfg-if", -] - [[package]] name = "mime" version = "0.3.17" @@ -1121,7 +1011,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1133,10 +1023,8 @@ dependencies = [ "async-trait", "axum", "clap", - "curv-kzen", "futures", - "hex 0.4.3", - "multi-party-eddsa", + "hex", "ractor", "ractor_cluster", "rand 0.7.3", @@ -1147,17 +1035,20 @@ dependencies = [ ] [[package]] -name = "multi-party-eddsa" -version = "0.3.0" -source = "git+https://github.com/ZenGo-X/multi-party-eddsa.git#f5e825121c7fa2356482070adceda93c8db08ae8" +name = "mpc-recovery-integration-tests" +version = "0.1.0" dependencies = [ - "curv-kzen", - "hex 0.3.2", + "anyhow", + "bollard", + "futures", + "hex", + "hyper", + "mpc-recovery", + "portpicker", "rand 0.8.5", - "serde", - "serde_derive", "serde_json", - "sha2 0.9.9", + "threshold_crypto", + "tokio", ] [[package]] @@ -1172,21 +1063,9 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", - "serde", ] [[package]] @@ -1195,7 +1074,7 @@ version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-traits", ] @@ -1205,7 +1084,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1233,29 +1112,6 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "p256" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d053368e1bae4c8a672953397bd1bd7183dde1c72b0b7612a15719173148d186" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.9.9", -] - [[package]] name = "pairing" version = "0.16.0" @@ -1263,26 +1119,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8290dea210a712682cd65031dc2b34fd132cf2729def3df7ee08f0737ff5ed6" dependencies = [ "byteorder", - "ff 0.6.0", - "group 0.6.0", + "ff", + "group", "rand_core 0.5.1", ] -[[package]] -name = "pairing-plus" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cda4f22e8e6720f3c254049960c8cc4f93cb82b5ade43bddd2622b5f39ea62" -dependencies = [ - "byteorder", - "digest 0.8.1", - "ff-zeroize", - "rand 0.4.6", - "rand_core 0.5.1", - "rand_xorshift 0.2.0", - "zeroize", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -1301,9 +1142,9 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1355,13 +1196,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "pkcs8" -version = "0.7.6" +name = "portpicker" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9" dependencies = [ - "der", - "spki", + "rand 0.8.5", ] [[package]] @@ -1382,9 +1222,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.53" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" dependencies = [ "unicode-ident", ] @@ -1493,7 +1333,7 @@ dependencies = [ "ractor_cluster_derive", "rand 0.8.5", "rustls", - "sha2 0.10.6", + "sha2", "tokio", "tokio-rustls", ] @@ -1508,38 +1348,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift 0.1.1", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -1550,7 +1358,7 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", ] [[package]] @@ -1564,16 +1372,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -1594,21 +1392,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -1627,15 +1410,6 @@ dependencies = [ "getrandom 0.2.8", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -1645,59 +1419,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_xorshift" version = "0.2.0" @@ -1708,19 +1429,19 @@ dependencies = [ ] [[package]] -name = "rdrand" -version = "0.4.0" +name = "redox_syscall" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "rand_core 0.3.1", + "bitflags", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1755,37 +1476,12 @@ dependencies = [ "winapi", ] -[[package]] -name = "rust-gmp-kzen" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e654bb304958a567aefa09e83cc313251388202c40bfc245fac19a0e2dd8d08" -dependencies = [ - "libc", - "num-traits", - "serde", -] - [[package]] name = "rustc-demangle" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" -[[package]] -name = "rustix" -version = "0.36.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" -dependencies = [ - "bitflags", - "errno 0.2.8", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - [[package]] name = "rustix" version = "0.37.5" @@ -1793,11 +1489,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75" dependencies = [ "bitflags", - "errno 0.3.0", + "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.0", - "windows-sys 0.45.0", + "linux-raw-sys", + "windows-sys", ] [[package]] @@ -1830,6 +1526,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" + [[package]] name = "sct" version = "0.7.0" @@ -1840,53 +1542,24 @@ dependencies = [ "untrusted", ] -[[package]] -name = "secp256k1" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" -dependencies = [ - "rand 0.6.5", - "secp256k1-sys", - "serde", -] - -[[package]] -name = "secp256k1-sys" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" -dependencies = [ - "cc", -] - [[package]] name = "serde" -version = "1.0.158" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" dependencies = [ "serde_derive", ] -[[package]] -name = "serde_bytes" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" -version = "1.0.158" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.12", ] [[package]] @@ -1909,6 +1582,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1922,28 +1606,18 @@ dependencies = [ ] [[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.9" +name = "serde_with" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "85456ffac572dc8826334164f2fb6fb40a7c766aebe195a2a21ee69ee2885ecf" dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "base64 0.13.1", + "chrono", + "hex", + "indexmap", + "serde", + "serde_json", + "time", ] [[package]] @@ -1954,19 +1628,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", -] - -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug 0.3.0", + "digest", ] [[package]] @@ -1978,23 +1640,13 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" -dependencies = [ - "digest 0.9.0", - "rand_core 0.6.4", -] - [[package]] name = "slab" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -2019,27 +1671,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[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.109" @@ -2053,9 +1690,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.9" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da4a3c17e109f700685ec577c0f85efd9b19bcf15c913985f14dc1ac01775aa" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" dependencies = [ "proc-macro2", "quote", @@ -2082,15 +1719,24 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", - "rustix 0.36.11", - "windows-sys 0.42.0", + "redox_syscall 0.3.5", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", ] [[package]] @@ -2110,7 +1756,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.12", ] [[package]] @@ -2121,8 +1767,8 @@ checksum = "7f708705bce37e765c37a95a8e0221a327c880d5a5a148d522552e8daa85787a" dependencies = [ "byteorder", "failure", - "ff 0.6.0", - "group 0.6.0", + "ff", + "group", "hex_fmt", "log", "pairing", @@ -2133,6 +1779,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2142,13 +1815,28 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ - "autocfg 1.1.0", + "autocfg", "bytes", "libc", "mio", @@ -2158,7 +1846,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -2169,7 +1857,7 @@ checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.12", ] [[package]] @@ -2183,6 +1871,20 @@ dependencies = [ "webpki", ] +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "tower" version = "0.4.13" @@ -2244,12 +1946,33 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -2262,6 +1985,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -2397,6 +2131,15 @@ 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" @@ -2404,18 +2147,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.42.0" +name = "windows" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "2649ff315bee4c98757f15dac226efe3d81927adbb6e882084bb1ee3e0c330a7" 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-targets 0.47.0", ] [[package]] @@ -2424,7 +2161,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", ] [[package]] @@ -2433,13 +2170,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 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.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f8996d3f43b4b2d44327cd71b7b0efd1284ab60e6e9d0e8b630e18555d87d3e" +dependencies = [ + "windows_aarch64_gnullvm 0.47.0", + "windows_aarch64_msvc 0.47.0", + "windows_i686_gnu 0.47.0", + "windows_i686_msvc 0.47.0", + "windows_x86_64_gnu 0.47.0", + "windows_x86_64_gnullvm 0.47.0", + "windows_x86_64_msvc 0.47.0", ] [[package]] @@ -2448,36 +2200,72 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831d567d53d4f3cb1db332b68e6e2b6260228eb4d99a777d8b2e8ed794027c90" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a42d54a417c60ce4f0e31661eed628f0fa5aca73448c093ec4d45fab4c51cdf" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1925beafdbb22201a53a483db861a5644123157c1c3cee83323a2ed565d71e3" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8ef8f2f1711b223947d9b69b596cf5a4e452c930fb58b6fc3fdae7d0ec6b31" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acaa0c2cf0d2ef99b61c308a0c3dbae430a51b7345dedec470bd8f53f5a3642" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a0628f71be1d11e17ca4a0e9e15b3a5180f6fbf1c2d55e3ba3f850378052c1" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -2485,21 +2273,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] -name = "zeroize" -version = "1.4.3" +name = "windows_x86_64_msvc" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" -dependencies = [ - "zeroize_derive", -] +checksum = "9d6e62c256dc6d40b8c8707df17df8d774e60e39db723675241e7c15e910bce7" [[package]] -name = "zeroize_derive" -version = "1.4.1" +name = "zeroize" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25588073e5216b50bca71d61cb8595cdb9745e87032a58c199730def2862c934" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.9", -] +checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" diff --git a/Cargo.toml b/Cargo.toml index f473d8cd0..d9d8f871e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,29 +1,5 @@ -[package] -name = "mpc-recovery" -version = "0.1.0" -edition = "2021" - -# We have encountered issue with linking GMP on ARM macos machines. This is a temporary fix that -# replaces GMP implementation with num-bigint. -[target.'cfg(macos)'.dependencies] -curv = { package = "curv-kzen", version = "0.9", default-features = false, features = ["num-bigint"] } -multi-party-eddsa = { git = "https://github.com/ZenGo-X/multi-party-eddsa.git", default-features = false } - -[target.'cfg(unix)'.dependencies] -multi-party-eddsa = { git = "https://github.com/ZenGo-X/multi-party-eddsa.git" } - -[dependencies] -anyhow = "1" -async-trait = "0.1" -axum = "0.6" -clap = { version = "4.2", features = ["derive"] } -futures = "0.3" -hex = "0.4" -ractor = { version = "0.7", features = ["cluster"] } -ractor_cluster = "0.7" -actix-rt = "2.8" -threshold_crypto = "0.4.0" -rand = "0.7" -serde = "1" -serde_json = "1" -tokio = { version = "1.0", features = ["full"] } \ No newline at end of file +[workspace] +members = [ + "mpc-recovery", + "integration-tests", +] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2fe926fca --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM rust:latest +WORKDIR /usr/src/app +COPY . . +RUN cargo install --path mpc-recovery/ +RUN mv /usr/local/cargo/bin/mpc-recovery /usr/local/bin/mpc-recovery +WORKDIR /usr/local/bin + +ENTRYPOINT [ "mpc-recovery" ] \ No newline at end of file diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml new file mode 100644 index 000000000..15c8117e1 --- /dev/null +++ b/integration-tests/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "mpc-recovery-integration-tests" +version = "0.1.0" +edition = "2021" +publish = false + +[dev-dependencies] +anyhow = "1.0" +bollard = "0.14" +futures = "0.3" +hex = "0.4" +hyper = { version = "0.14", features = ["full"] } +mpc-recovery = { path = "../mpc-recovery" } +portpicker = "0.1" +rand = "0.8" +serde_json = "1" +threshold_crypto = "0.4.0" +tokio = { version = "1.0", features = ["full"] } diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/integration-tests/src/lib.rs @@ -0,0 +1 @@ + diff --git a/integration-tests/tests/lib.rs b/integration-tests/tests/lib.rs new file mode 100644 index 000000000..90c740841 --- /dev/null +++ b/integration-tests/tests/lib.rs @@ -0,0 +1,206 @@ +use bollard::container::{AttachContainerOptions, AttachContainerResults, Config}; +use bollard::network::CreateNetworkOptions; +use bollard::service::{HostConfig, Ipam}; +use bollard::Docker; +use futures::StreamExt; +use hyper::{body::HttpBody, Body, Client, Method, Request}; +use mpc_recovery; +use rand::{distributions::Alphanumeric, Rng}; +use serde_json::json; +use std::collections::HashMap; +use std::time::Duration; +use threshold_crypto::{serde_impl::SerdeSecret, PublicKeySet, SecretKeyShare, Signature}; +use tokio::io::AsyncWriteExt; +use tokio::spawn; + +async fn continuously_print_docker_output(docker: &Docker, id: &str) -> anyhow::Result<()> { + let AttachContainerResults { mut output, .. } = docker + .attach_container( + &id, + Some(AttachContainerOptions:: { + stdout: Some(true), + stderr: Some(true), + stream: Some(true), + ..Default::default() + }), + ) + .await?; + + // Asynchronous process that pipes docker attach output into stdout. + // Will die automatically once Docker container output is closed. + spawn(async move { + let mut stdout = tokio::io::stdout(); + + while let Some(Ok(output)) = output.next().await { + stdout + .write_all(output.into_bytes().as_ref()) + .await + .unwrap(); + stdout.flush().await.unwrap(); + } + }); + + Ok(()) +} + +async fn start_mpc_node( + docker: &Docker, + node_id: u64, + pk_set: &PublicKeySet, + sk_share: &SecretKeyShare, + actor_address: Option, +) -> anyhow::Result<(String, String, String)> { + let actor_port = portpicker::pick_unused_port().expect("no free ports"); + let web_port = portpicker::pick_unused_port().expect("no free ports"); + + let empty = HashMap::<(), ()>::new(); + let mut exposed_ports = HashMap::new(); + exposed_ports.insert(format!("{web_port}/tcp"), empty); + + let mut cmd = vec![ + "start".to_string(), + node_id.to_string(), + serde_json::to_string(&pk_set)?, + serde_json::to_string(&SerdeSecret(sk_share))?, + actor_port.to_string(), + web_port.to_string(), + ]; + if let Some(actor_address) = actor_address { + cmd.push(actor_address); + } + + let mpc_recovery_config = Config { + image: Some("near/mpc-recovery:latest".to_string()), + tty: Some(true), + attach_stdout: Some(true), + attach_stderr: Some(true), + exposed_ports: Some(exposed_ports), + cmd: Some(cmd), + host_config: Some(HostConfig { + network_mode: Some("mpc_recovery_integration_test_network".to_string()), + ..Default::default() + }), + ..Default::default() + }; + + let id = docker + .create_container::<&str, String>(None, mpc_recovery_config) + .await? + .id; + docker.start_container::(&id, None).await?; + + let network_settings = docker + .inspect_container(&id, None) + .await? + .network_settings + .unwrap(); + let ip_address = network_settings + .networks + .unwrap() + .get("mpc_recovery_integration_test_network") + .cloned() + .unwrap() + .ip_address + .unwrap(); + + println!("{ip_address}"); + + continuously_print_docker_output(&docker, &id).await?; + + Ok(( + id, + format!("{ip_address}:{actor_port}"), + format!("{ip_address}:{web_port}"), + )) +} + +async fn create_network(docker: &Docker) -> anyhow::Result<()> { + let list = docker.list_networks::<&str>(None).await?; + if list + .iter() + .any(|n| n.name == Some("mpc_recovery_integration_test_network".to_string())) + { + return Ok(()); + } + + let create_network_options = CreateNetworkOptions { + name: "mpc_recovery_integration_test_network", + check_duplicate: true, + driver: if cfg!(windows) { + "transparent" + } else { + "bridge" + }, + ipam: Ipam { + config: None, + ..Default::default() + }, + ..Default::default() + }; + let _response = &docker.create_network(create_network_options).await?; + + Ok(()) +} + +#[tokio::test] +async fn test_trio() -> anyhow::Result<()> { + let docker = Docker::connect_with_local_defaults()?; + create_network(&docker).await?; + + // This test creates 4 sk shares with a threshold of 2 (i.e. minimum 3 required to sign), + // but only instantiates 3 nodes. + let (pk_set, sk_shares) = mpc_recovery::generate(4, 3)?; + + let mut actor_addresses = Vec::new(); + let mut web_ports = Vec::new(); + for (i, sk_share) in sk_shares.into_iter().enumerate().take(3) { + let (_id, actor_address, web_port) = start_mpc_node( + &docker, + (i + 1) as u64, + &pk_set, + &sk_share, + actor_addresses.first().cloned(), + ) + .await?; + actor_addresses.push(actor_address); + web_ports.push(web_port); + } + + tokio::time::sleep(Duration::from_millis(10000)).await; + + // Try querying every node's web interface + for web_port in web_ports { + println!("Trying http://{}/submit", web_port); + let payload: String = rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(10) + .map(char::from) + .collect(); + let req = Request::builder() + .method(Method::POST) + .uri(format!("http://{}/submit", web_port)) + .header("content-type", "application/json") + .body(Body::from(json!({ "payload": payload }).to_string()))?; + + let client = Client::new(); + let mut resp = client.request(req).await?; + + assert_eq!(resp.status(), 200); + + let data = resp.body_mut().data().await.expect("no response body")?; + let response_body: String = serde_json::from_slice(&data)?; + let signature = Signature::from_bytes(&hex::decode(&response_body)?.try_into().map_err( + |e: Vec| { + anyhow::anyhow!( + "signature has incorrect length: expected 96 bytes, but got {}", + e.len() + ) + }, + )?) + .map_err(|e| anyhow::anyhow!("malformed signature: {}", e))?; + + assert!(pk_set.public_key().verify(&signature, payload)); + } + + Ok(()) +} diff --git a/mpc-recovery/Cargo.toml b/mpc-recovery/Cargo.toml new file mode 100644 index 000000000..143901b3b --- /dev/null +++ b/mpc-recovery/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "mpc-recovery" +version = "0.1.0" +edition = "2021" + +# We have encountered issue with linking GMP on ARM macos machines. This is a temporary fix that +# replaces GMP implementation with num-bigint. +# [target.'cfg(macos)'.dependencies] +# curv = { package = "curv-kzen", version = "0.9", default-features = false, features = ["num-bigint"] } +# multi-party-eddsa = { git = "https://github.com/ZenGo-X/multi-party-eddsa.git", default-features = false } + +# [target.'cfg(unix)'.dependencies] +# multi-party-eddsa = { git = "https://github.com/ZenGo-X/multi-party-eddsa.git" } + +[dependencies] +anyhow = "1" +async-trait = "0.1" +axum = "0.6" +clap = { version = "4.2", features = ["derive"] } +futures = "0.3" +hex = "0.4" +ractor = { version = "0.7", features = ["cluster"] } +ractor_cluster = "0.7" +actix-rt = "2.8" +threshold_crypto = "0.4.0" +rand = "0.7" +serde = "1" +serde_json = "1" +tokio = { version = "1.0", features = ["full"] } \ No newline at end of file diff --git a/src/actor.rs b/mpc-recovery/src/actor.rs similarity index 94% rename from src/actor.rs rename to mpc-recovery/src/actor.rs index 785949a87..8160527ac 100644 --- a/src/actor.rs +++ b/mpc-recovery/src/actor.rs @@ -89,6 +89,15 @@ impl Actor for NodeActor { message: Self::Msg, state: &mut Self::State, ) -> Result<(), ActorProcessingErr> { + for actor in ractor::pg::get_members(&MPC_RECOVERY_GROUP.to_string()) { + let actor_ref = ActorRef::::from(actor); + println!( + "Has an actor {:?} {:?} {:?}", + actor_ref.get_id(), + actor_ref.get_name(), + actor_ref.get_cell() + ) + } let remote_actors = ractor::pg::get_members(&MPC_RECOVERY_GROUP.to_string()) .into_iter() .filter(|actor| !actor.get_id().is_local()) diff --git a/mpc-recovery/src/lib.rs b/mpc-recovery/src/lib.rs new file mode 100644 index 000000000..94d5b2b21 --- /dev/null +++ b/mpc-recovery/src/lib.rs @@ -0,0 +1,70 @@ +use ractor::Actor; +use ractor_cluster::node::NodeConnectionMode; +use threshold_crypto::{PublicKeySet, SecretKeySet, SecretKeyShare}; + +const COOKIE: &str = "mpc-recovery-cookie"; + +mod actor; +mod web; + +pub async fn start( + node_id: u64, + pk_set: PublicKeySet, + sk_share: SecretKeyShare, + actor_port: u16, + web_port: u16, + remote_addr: Option, +) { + let server = ractor_cluster::NodeServer::new( + actor_port, + COOKIE.to_string(), + format!("mpc-recovery-node-{}", node_id), + "localhost".to_string(), + None, + Some(NodeConnectionMode::Transitive), + ); + + let (actor, handle) = Actor::spawn(None, server, ()) + .await + .expect("Failed to start NodeServer A"); + + let (node_actor, node_handle) = + Actor::spawn(None, actor::NodeActor, (node_id, pk_set.clone(), sk_share)) + .await + .expect("Ping pong actor failed to start up!"); + + if let Some(raddress) = remote_addr { + if let Err(error) = ractor_cluster::node::client::connect(&actor, raddress).await { + eprintln!("Failed to connect with error {error}") + } else { + println!("Client connected to NodeServer"); + } + } + + // start a user-facing web server + web::start(web_port, node_actor.clone()).await; + + // wait for exit + tokio::signal::ctrl_c() + .await + .expect("failed to listen for event"); + + // cleanup + node_actor.stop(None); + node_handle.await.unwrap(); + actor.stop(None); + handle.await.unwrap(); +} + +pub fn generate(n: usize, t: usize) -> anyhow::Result<(PublicKeySet, Vec)> { + let sk_set = SecretKeySet::random(t - 1, &mut rand::thread_rng()); + let pk_set = sk_set.public_keys(); + + let mut sk_shares = Vec::new(); + for i in 1..=n { + let sk_share = sk_set.secret_key_share(i); + sk_shares.push(sk_share); + } + + Ok((pk_set, sk_shares)) +} diff --git a/mpc-recovery/src/main.rs b/mpc-recovery/src/main.rs new file mode 100644 index 000000000..793d527f4 --- /dev/null +++ b/mpc-recovery/src/main.rs @@ -0,0 +1,64 @@ +use clap::Parser; +use threshold_crypto::{serde_impl::SerdeSecret, PublicKeySet, SecretKeyShare}; + +#[derive(Parser, Debug)] +enum Cli { + Generate { + n: usize, + t: usize, + }, + Start { + /// Node ID + node_id: u64, + /// Root public key + pk_set: String, + /// Secret key share + sk_share: String, + /// The actor port for this server + actor_port: u16, + /// The web port for this server + web_port: u16, + /// The remote server address to connect to (if Some) + remote_address: Option, + }, +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + match Cli::parse() { + Cli::Generate { n, t } => { + let (pk_set, sk_shares) = mpc_recovery::generate(n, t)?; + println!("Public key set: {}", serde_json::to_string(&pk_set)?); + for (i, sk_share) in sk_shares.iter().enumerate() { + println!( + "Secret key share {}: {}", + i, + serde_json::to_string(&SerdeSecret(sk_share))? + ); + } + } + Cli::Start { + node_id, + pk_set, + sk_share, + actor_port, + web_port, + remote_address, + } => { + let pk_set: PublicKeySet = serde_json::from_str(&pk_set).unwrap(); + let sk_share: SecretKeyShare = serde_json::from_str(&sk_share).unwrap(); + + mpc_recovery::start( + node_id, + pk_set, + sk_share, + actor_port, + web_port, + remote_address, + ) + .await; + } + } + + Ok(()) +} diff --git a/src/web.rs b/mpc-recovery/src/web.rs similarity index 93% rename from src/web.rs rename to mpc-recovery/src/web.rs index 6d7dd0750..ac248b95f 100644 --- a/src/web.rs +++ b/mpc-recovery/src/web.rs @@ -15,7 +15,8 @@ pub async fn start(port: u16, node_actor: ActorRef) { // run our app with hyper // `axum::Server` is a re-export of `hyper::Server` - let addr = SocketAddr::from(([127, 0, 0, 1], port)); + println!("Starting a web server on port {port}"); + let addr = SocketAddr::from(([0, 0, 0, 0], port)); axum::Server::bind(&addr) .serve(app.into_make_service()) .await diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 107014c7b..000000000 --- a/src/main.rs +++ /dev/null @@ -1,117 +0,0 @@ -use clap::Parser; -use ractor::Actor; -use ractor_cluster::node::NodeConnectionMode; -use threshold_crypto::{serde_impl::SerdeSecret, PublicKeySet, SecretKeySet, SecretKeyShare}; - -mod actor; -mod web; - -const COOKIE: &str = "mpc-recovery-cookie"; - -#[derive(Parser, Debug)] -enum Cli { - Generate { - n: usize, - t: usize, - }, - Start { - /// Node ID - node_id: u64, - /// Root public key - pk_set: String, - /// Secret key share - sk_share: String, - /// The host port for this NodeServer - port: u16, - /// The remote server port to connect to (if Some) - remote_port: Option, - }, -} - -async fn start( - node_id: u64, - pk_set: PublicKeySet, - sk_share: SecretKeyShare, - port: u16, - remote_port: Option, -) { - let server = ractor_cluster::NodeServer::new( - port, - COOKIE.to_string(), - format!("mpc-recovery-node-{}", node_id), - "localhost".to_string(), - None, - Some(NodeConnectionMode::Transitive), - ); - - let (actor, handle) = Actor::spawn(None, server, ()) - .await - .expect("Failed to start NodeServer A"); - - let (node_actor, node_handle) = - Actor::spawn(None, actor::NodeActor, (node_id, pk_set.clone(), sk_share)) - .await - .expect("Ping pong actor failed to start up!"); - - if let Some(rport) = remote_port { - if let Err(error) = - ractor_cluster::node::client::connect(&actor, format!("127.0.0.1:{rport}")).await - { - eprintln!("Failed to connect with error {error}") - } else { - println!("Client connected to NodeServer"); - } - } - - // start a user-facing web server - web::start(3000 + port - 9000, node_actor.clone()).await; - - // wait for exit - tokio::signal::ctrl_c() - .await - .expect("failed to listen for event"); - - // cleanup - node_actor.stop(None); - node_handle.await.unwrap(); - actor.stop(None); - handle.await.unwrap(); -} - -fn generate(n: usize, t: usize) -> anyhow::Result<()> { - let sk_set = SecretKeySet::random(t - 1, &mut rand::thread_rng()); - let pk_set = sk_set.public_keys(); - println!("Public key set: {}", serde_json::to_string(&pk_set)?); - - for i in 1..=n { - let sk_share = SerdeSecret(sk_set.secret_key_share(i)); - println!( - "Secret key share {}: {}", - i, - serde_json::to_string(&sk_share)? - ); - } - - Ok(()) -} - -#[tokio::main] -async fn main() -> anyhow::Result<()> { - match Cli::parse() { - Cli::Generate { n, t } => generate(n, t)?, - Cli::Start { - node_id, - pk_set, - sk_share, - port, - remote_port, - } => { - let pk_set: PublicKeySet = serde_json::from_str(&pk_set).unwrap(); - let sk_share: SecretKeyShare = serde_json::from_str(&sk_share).unwrap(); - - start(node_id, pk_set, sk_share, port, remote_port).await; - } - } - - Ok(()) -} From 66d104f9ce2a65d440aee5166fc6c8c1bf17f214 Mon Sep 17 00:00:00 2001 From: Serhii Volovyk Date: Fri, 31 Mar 2023 17:31:24 +0300 Subject: [PATCH 2/4] clippy suggestions --- integration-tests/tests/lib.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/integration-tests/tests/lib.rs b/integration-tests/tests/lib.rs index 90c740841..cbc59a7a0 100644 --- a/integration-tests/tests/lib.rs +++ b/integration-tests/tests/lib.rs @@ -4,10 +4,10 @@ use bollard::service::{HostConfig, Ipam}; use bollard::Docker; use futures::StreamExt; use hyper::{body::HttpBody, Body, Client, Method, Request}; -use mpc_recovery; use rand::{distributions::Alphanumeric, Rng}; use serde_json::json; use std::collections::HashMap; +use std::convert::TryInto; use std::time::Duration; use threshold_crypto::{serde_impl::SerdeSecret, PublicKeySet, SecretKeyShare, Signature}; use tokio::io::AsyncWriteExt; @@ -16,7 +16,7 @@ use tokio::spawn; async fn continuously_print_docker_output(docker: &Docker, id: &str) -> anyhow::Result<()> { let AttachContainerResults { mut output, .. } = docker .attach_container( - &id, + id, Some(AttachContainerOptions:: { stdout: Some(true), stderr: Some(true), @@ -105,7 +105,7 @@ async fn start_mpc_node( println!("{ip_address}"); - continuously_print_docker_output(&docker, &id).await?; + continuously_print_docker_output(docker, &id).await?; Ok(( id, @@ -189,15 +189,15 @@ async fn test_trio() -> anyhow::Result<()> { let data = resp.body_mut().data().await.expect("no response body")?; let response_body: String = serde_json::from_slice(&data)?; - let signature = Signature::from_bytes(&hex::decode(&response_body)?.try_into().map_err( - |e: Vec| { - anyhow::anyhow!( - "signature has incorrect length: expected 96 bytes, but got {}", - e.len() - ) - }, - )?) - .map_err(|e| anyhow::anyhow!("malformed signature: {}", e))?; + let signature_bytes = hex::decode(response_body)?; + let signature_array: [u8; 96] = signature_bytes.as_slice().try_into().map_err(|_e| { + anyhow::anyhow!( + "signature has incorrect length: expected 96 bytes, but got {}", + signature_bytes.len() + ) + })?; + let signature = Signature::from_bytes(signature_array) + .map_err(|e| anyhow::anyhow!("malformed signature: {}", e))?; assert!(pk_set.public_key().verify(&signature, payload)); } From c2afd4407b5e436a849893ec0bc4ace1e5e94edf Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Mon, 3 Apr 2023 17:20:38 +1000 Subject: [PATCH 3/4] get rid of debug prints and use the leader node --- integration-tests/tests/lib.rs | 67 ++++++++++++++++------------------ mpc-recovery/src/actor.rs | 9 ----- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/integration-tests/tests/lib.rs b/integration-tests/tests/lib.rs index cbc59a7a0..6bbd837a9 100644 --- a/integration-tests/tests/lib.rs +++ b/integration-tests/tests/lib.rs @@ -103,8 +103,6 @@ async fn start_mpc_node( .ip_address .unwrap(); - println!("{ip_address}"); - continuously_print_docker_output(docker, &id).await?; Ok(( @@ -168,39 +166,38 @@ async fn test_trio() -> anyhow::Result<()> { tokio::time::sleep(Duration::from_millis(10000)).await; - // Try querying every node's web interface - for web_port in web_ports { - println!("Trying http://{}/submit", web_port); - let payload: String = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(10) - .map(char::from) - .collect(); - let req = Request::builder() - .method(Method::POST) - .uri(format!("http://{}/submit", web_port)) - .header("content-type", "application/json") - .body(Body::from(json!({ "payload": payload }).to_string()))?; - - let client = Client::new(); - let mut resp = client.request(req).await?; - - assert_eq!(resp.status(), 200); - - let data = resp.body_mut().data().await.expect("no response body")?; - let response_body: String = serde_json::from_slice(&data)?; - let signature_bytes = hex::decode(response_body)?; - let signature_array: [u8; 96] = signature_bytes.as_slice().try_into().map_err(|_e| { - anyhow::anyhow!( - "signature has incorrect length: expected 96 bytes, but got {}", - signature_bytes.len() - ) - })?; - let signature = Signature::from_bytes(signature_array) - .map_err(|e| anyhow::anyhow!("malformed signature: {}", e))?; - - assert!(pk_set.public_key().verify(&signature, payload)); - } + // TODO: only leader node works for now, other nodes struggling to connect to each other + // for some reason. + let web_port = &web_ports[0]; + let payload: String = rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(10) + .map(char::from) + .collect(); + let req = Request::builder() + .method(Method::POST) + .uri(format!("http://{}/submit", web_port)) + .header("content-type", "application/json") + .body(Body::from(json!({ "payload": payload }).to_string()))?; + + let client = Client::new(); + let mut resp = client.request(req).await?; + + assert_eq!(resp.status(), 200); + + let data = resp.body_mut().data().await.expect("no response body")?; + let response_body: String = serde_json::from_slice(&data)?; + let signature_bytes = hex::decode(response_body)?; + let signature_array: [u8; 96] = signature_bytes.as_slice().try_into().map_err(|_e| { + anyhow::anyhow!( + "signature has incorrect length: expected 96 bytes, but got {}", + signature_bytes.len() + ) + })?; + let signature = Signature::from_bytes(signature_array) + .map_err(|e| anyhow::anyhow!("malformed signature: {}", e))?; + + assert!(pk_set.public_key().verify(&signature, payload)); Ok(()) } diff --git a/mpc-recovery/src/actor.rs b/mpc-recovery/src/actor.rs index 8160527ac..785949a87 100644 --- a/mpc-recovery/src/actor.rs +++ b/mpc-recovery/src/actor.rs @@ -89,15 +89,6 @@ impl Actor for NodeActor { message: Self::Msg, state: &mut Self::State, ) -> Result<(), ActorProcessingErr> { - for actor in ractor::pg::get_members(&MPC_RECOVERY_GROUP.to_string()) { - let actor_ref = ActorRef::::from(actor); - println!( - "Has an actor {:?} {:?} {:?}", - actor_ref.get_id(), - actor_ref.get_name(), - actor_ref.get_cell() - ) - } let remote_actors = ractor::pg::get_members(&MPC_RECOVERY_GROUP.to_string()) .into_iter() .filter(|actor| !actor.get_id().is_local()) From 1c477964654ddbf0d8f65c942655d82a8cac32c4 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Mon, 3 Apr 2023 20:55:33 +1000 Subject: [PATCH 4/4] only run unit tests in the Tests workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5784a2674..c49977e32 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - uses: Swatinem/rust-cache@v1 - run: rustup target add wasm32-unknown-unknown - name: Test - run: cargo test --all + run: cargo test -p mpc-recovery lint: name: Clippy and fmt runs-on: ubuntu-latest