diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3945372ff..d346df6296 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,12 +9,14 @@ on: - 'gateway/**' - 'integrations/**' - 'mixnode/**' + - 'sdk/lib/socks5-listener/**' - 'sdk/rust/nym-sdk/**' - 'service-providers/**' - 'nym-api/**' - 'nym-outfox/**' - 'tools/nym-cli/**' - 'tools/ts-rs-cli/**' + - 'Cargo.toml' pull_request: paths: - 'clients/**' @@ -23,12 +25,14 @@ on: - 'gateway/**' - 'integrations/**' - 'mixnode/**' + - 'sdk/lib/socks5-listener/**' - 'sdk/rust/nym-sdk/**' - 'service-providers/**' - 'nym-api/**' - 'nym-outfox/**' - 'tools/nym-cli/**' - 'tools/ts-rs-cli/**' + - 'Cargo.toml' jobs: build: diff --git a/.gitignore b/.gitignore index c42461127a..21ea8966e7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ storybook-static envs/qwerty.env .parcel-cache **/.DS_Store -cpu-cycles/libcpucycles/build \ No newline at end of file +cpu-cycles/libcpucycles/build +foxyfox.env \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9e3c4e110a..c78bff3d99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,221 +8,12 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "actix-codec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-sink", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "actix-http" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "ahash 0.8.3", - "base64 0.21.0", - "bitflags", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand 0.8.5", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", - "zstd", -] - -[[package]] -name = "actix-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "actix-router" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" -dependencies = [ - "bytestring", - "http", - "regex", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "num_cpus", - "socket2", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" -dependencies = [ - "futures-core", - "paste", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] - -[[package]] -name = "actix-web" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" -dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "actix-web-codegen", - "ahash 0.7.6", - "bytes", - "bytestring", - "cfg-if", - "cookie", - "derive_more", - "encoding_rs", - "futures-core", - "futures-util", - "http", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2", - "time 0.3.20", - "url", -] - -[[package]] -name = "actix-web-codegen" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" -dependencies = [ - "actix-router", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", -] - [[package]] name = "aead" version = "0.5.2" @@ -233,17 +24,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - [[package]] name = "aes" version = "0.7.5" @@ -268,54 +48,20 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "aes-gcm" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", - "subtle 2.4.1", -] - [[package]] name = "aes-gcm" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" dependencies = [ - "aead 0.5.2", + "aead", "aes 0.8.2", "cipher 0.4.4", "ctr 0.9.2", - "ghash 0.5.0", + "ghash", "subtle 2.4.1", ] -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -334,7 +80,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.9", "once_cell", "version_check", ] @@ -349,18 +94,21 @@ dependencies = [ ] [[package]] -name = "alloc-no-stdlib" -version = "2.0.4" +name = "android_log-sys" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" +checksum = "27f0fc03f560e1aebde41c2398b691cb98b5ea5996a6184a7a67bbbb77448969" [[package]] -name = "alloc-stdlib" -version = "0.2.2" +name = "android_logger" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +checksum = "3fa490e751f3878eb9accb9f18988eca52c2337ce000a8bf31ef50d4c723ca9e" dependencies = [ - "alloc-no-stdlib", + "android_log-sys", + "env_logger 0.10.0", + "log", + "once_cell", ] [[package]] @@ -432,15 +180,6 @@ name = "anyhow" version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" -dependencies = [ - "backtrace", -] - -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "argon2" @@ -453,12 +192,6 @@ dependencies = [ "password-hash", ] -[[package]] -name = "array-bytes" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" - [[package]] name = "arrayref" version = "0.3.7" @@ -471,79 +204,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "asn1-rs" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.20", -] - -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive 0.4.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.20", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - [[package]] name = "async-file-watcher" version = "0.1.0" @@ -554,35 +214,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg 1.1.0", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" -dependencies = [ - "event-listener", -] - [[package]] name = "async-stream" version = "0.3.5" @@ -602,7 +233,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -613,20 +244,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "asynchronous-codec" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" -dependencies = [ - "bytes", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite", + "syn 2.0.16", ] [[package]] @@ -649,18 +267,9 @@ dependencies = [ [[package]] name = "atomic" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" [[package]] name = "atty" @@ -733,27 +342,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide 0.6.2", - "object", - "rustc-demangle", -] - -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "base16ct" version = "0.1.1" @@ -790,49 +378,20 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" -dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 1.0.109", -] - [[package]] name = "bip32" -version = "0.4.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30ed1d6f8437a487a266c8293aeb95b61a23261273e3e02912cdb8b68bf798b" +checksum = "873faa4363bfc54c36a48321da034c92a0645a363eed34d948683ffc1706e37f" dependencies = [ "bs58", - "hmac 0.12.1", + "hmac 0.11.0", "k256", "once_cell", "pbkdf2", "rand_core 0.6.4", - "ripemd", - "sha2 0.10.6", + "ripemd160", + "sha2 0.9.9", "subtle 2.4.1", "zeroize", ] @@ -916,6 +475,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ + "block-padding", "generic-array 0.14.7", ] @@ -928,16 +488,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding", - "cipher 0.2.5", -] - [[package]] name = "block-padding" version = "0.2.1" @@ -972,27 +522,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "brotli" -version = "3.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - [[package]] name = "bs58" version = "0.4.0" @@ -1004,9 +533,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "byte-tools" @@ -1025,29 +554,6 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] - -[[package]] -name = "bytestring" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" -dependencies = [ - "bytes", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] [[package]] name = "cast" @@ -1065,24 +571,10 @@ dependencies = [ ] [[package]] -name = "ccm" -version = "0.3.0" +name = "cesu8" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle 2.4.1", -] - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" @@ -1100,18 +592,6 @@ dependencies = [ "keystream", ] -[[package]] -name = "chacha20" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "zeroize", -] - [[package]] name = "chacha20" version = "0.9.1" @@ -1123,29 +603,16 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "chacha20poly1305" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" -dependencies = [ - "aead 0.4.3", - "chacha20 0.8.2", - "cipher 0.3.0", - "poly1305 0.7.2", - "zeroize", -] - [[package]] name = "chacha20poly1305" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.5.2", - "chacha20 0.9.1", + "aead", + "chacha20", "cipher 0.4.4", - "poly1305 0.8.0", + "poly1305", "zeroize", ] @@ -1167,9 +634,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -1178,29 +645,20 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "cipher" version = "0.3.0" @@ -1221,17 +679,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "3.2.25" @@ -1271,9 +718,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.2.1" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a19591b2ab0e3c04b588a0e04ddde7b9eaa423646d1b4a8092879216bf47473" +checksum = "1594fe2312ec4abf402076e407628f5c313e54c32ade058521df4ee34ecac8a8" dependencies = [ "clap 4.2.7", ] @@ -1297,7 +744,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1324,16 +771,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "colorchoice" version = "1.0.0" @@ -1351,6 +788,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "comfy-table" version = "6.1.4" @@ -1363,34 +810,11 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "concurrent-queue" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "config" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" -dependencies = [ - "async-trait", - "lazy_static", - "nom", - "pathdiff", - "serde", - "toml 0.5.11", -] - [[package]] name = "console-api" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57ff02e8ad8e06ab9731d5dc72dc23bef9200778eae1a89d555d8c42e5d4a86" +checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" dependencies = [ "prost 0.11.9", "prost-types 0.11.9", @@ -1400,9 +824,9 @@ dependencies = [ [[package]] name = "console-subscriber" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a3a81dfaf6b66bce5d159eddae701e3a002f194d378cbf7be5f053c281d9be" +checksum = "57ab2224a0311582eb03adba4caaf18644f7b1f10a760803a803b9b605187fc7" dependencies = [ "console-api", "crossbeam-channel", @@ -1424,9 +848,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "constant_time_eq" @@ -1434,19 +858,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "cookie" version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ - "aes-gcm 0.10.1", + "aes-gcm", "base64 0.20.0", "hkdf 0.12.3", "hmac 0.12.1", @@ -1454,7 +872,7 @@ dependencies = [ "rand 0.8.5", "sha2 0.10.6", "subtle 2.4.1", - "time 0.3.20", + "time 0.3.21", "version_check", ] @@ -1474,20 +892,10 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" -[[package]] -name = "core2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" -dependencies = [ - "memchr", -] - [[package]] name = "cosmos-sdk-proto" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb61f3d2224c90ea78e1fa7444787761a549170c46b6b0ed09b93f9b7e4076a" +version = "0.12.3" +source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d" dependencies = [ "prost 0.10.4", "prost-types 0.10.1", @@ -1496,9 +904,8 @@ dependencies = [ [[package]] name = "cosmrs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20d5890dac07a62337e5841adb8f2074a66a962a098a48df9460f64d483beaf4" +version = "0.7.1" +source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d" dependencies = [ "bip32", "cosmos-sdk-proto", @@ -1519,11 +926,11 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75836a10cb9654c54e77ee56da94d592923092a10b369cdb0dbd56acefc16340" +checksum = "970d1d705862179b5d7a233ae36f02f21c4ec1b8075fe60c77fc5b43471331fa" dependencies = [ - "digest 0.10.6", + "digest 0.9.0", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -1532,53 +939,26 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9f7f0e51bfc7295f7b2664fe8513c966428642aa765dad8a74acdab5e0c773" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cosmwasm-schema" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f00b363610218eea83f24bbab09e1a7c3920b79f068334fdfcc62f6129ef9fc" -dependencies = [ - "cosmwasm-schema-derive", - "schemars", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cosmwasm-schema-derive" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae38f909b2822d32b275c9e2db9728497aa33ffe67dd463bc67c6a3b7092785c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49b85345e811c8e80ec55d0d091e4fcb4f00f97ab058f9be5f614c444a730cb" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" dependencies = [ "base64 0.13.1", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", "forward_ref", - "hex", "schemars", "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "serde-json-wasm", "thiserror", "uint", ] @@ -1705,7 +1085,7 @@ dependencies = [ "autocfg 1.1.0", "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset", "scopeguard", ] @@ -1761,9 +1141,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", @@ -1811,6 +1191,16 @@ dependencies = [ "sct 0.6.1", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "ctr" version = "0.8.0" @@ -1853,40 +1243,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "curve25519-dalek" -version = "4.0.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" -dependencies = [ - "cfg-if", - "fiat-crypto", - "packed_simd_2", - "platforms", - "subtle 2.4.1", - "zeroize", -] - -[[package]] -name = "cw-controllers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91440ce8ec4f0642798bc8c8cb6b9b53c1926c6dadaf0eed267a5145cd529071" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw-storage-plus" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a5083c258acd68386734f428a5a171b29f7d733151ae83090c6fcc9417ffa" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" dependencies = [ "cosmwasm-std", "schemars", @@ -1895,152 +1256,60 @@ dependencies = [ [[package]] name = "cw-utils" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" +checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", - "cw2", "schemars", - "semver 1.0.17", "serde", "thiserror", ] [[package]] name = "cw2" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb70cee2cf0b4a8ff7253e6bc6647107905e8eb37208f87d54f67810faa62f8" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "schemars", "serde", ] -[[package]] -name = "cw20" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91666da6c7b40c8dd5ff94df655a28114efc10c79b70b4d06f13c31e37d60609" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils", - "schemars", - "serde", -] - [[package]] name = "cw3" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe0b587008aa221cd2a2579a21990a28c4347dc53ad43167c68ad765f5b6efa" +checksum = "fe19462a7f644ba60c19d3443cb90d00c50d9b6b3b0a3a7fca93df8261af979b" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-utils", - "cw20", "schemars", "serde", - "thiserror", -] - -[[package]] -name = "cw3-fixed-multisig" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e2415adb201e5e89dab34edf59d7dc166bc558526de009a49ae66276c9119a" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw3", - "schemars", - "serde", - "thiserror", ] [[package]] name = "cw4" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c236e0bae02ce97e89235a681dd0e07d099524b369f1ef908d704db3e6b049b" +checksum = "0acc3549d5ce11c6901b3a676f2e2628684722197054d97cd0101ea174ed5cbd" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "schemars", "serde", ] -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.15", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", -] - [[package]] name = "darling" version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" dependencies = [ - "darling_core 0.13.4", - "darling_macro 0.13.4", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", + "darling_core", + "darling_macro", ] [[package]] @@ -2057,38 +1326,13 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ - "darling_core 0.13.4", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", + "darling_core", "quote", "syn 1.0.109", ] @@ -2116,124 +1360,13 @@ dependencies = [ "parking_lot_core 0.9.7", ] -[[package]] -name = "data-encoding" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" - -[[package]] -name = "data-encoding-macro" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" -dependencies = [ - "data-encoding", - "data-encoding-macro-internal", -] - -[[package]] -name = "data-encoding-macro-internal" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" -dependencies = [ - "data-encoding", - "syn 1.0.109", -] - [[package]] name = "der" -version = "0.6.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "der-parser" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" -dependencies = [ - "asn1-rs 0.3.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs 0.5.2", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling 0.14.4", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version 0.4.0", - "syn 1.0.109", ] [[package]] @@ -2304,16 +1437,7 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "dirs-sys 0.3.7", -] - -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys 0.4.1", + "dirs-sys", ] [[package]] @@ -2327,29 +1451,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", -] - [[package]] name = "doc-comment" version = "0.3.3" @@ -2368,12 +1469,6 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" -[[package]] -name = "dtoa" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" - [[package]] name = "dyn-clone" version = "1.0.11" @@ -2382,9 +1477,9 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" dependencies = [ "der", "elliptic-curve", @@ -2408,7 +1503,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek", "ed25519", "rand 0.7.3", "serde", @@ -2423,7 +1518,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek", "hashbrown 0.12.3", "hex", "rand_core 0.6.4", @@ -2440,20 +1535,16 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.6", - "ff 0.12.1", + "ff 0.11.1", "generic-array 0.14.7", - "group 0.12.1", - "hkdf 0.12.3", - "pem-rfc7468", - "pkcs8", + "group 0.11.0", "rand_core 0.6.4", "sec1", "subtle 2.4.1", @@ -2469,18 +1560,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-as-inner" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "enum-iterator" version = "1.1.3" @@ -2498,7 +1577,7 @@ checksum = "eecf8589574ce9b895052fa12d69af7a233f99e6107f5cb8dd1044f2a17bfdcb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -2515,49 +1594,13 @@ dependencies = [ ] [[package]] -name = "ephemera" -version = "0.1.0" +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "actix-web", - "anyhow", - "array-bytes", - "assert_matches", - "async-trait", - "asynchronous-codec", - "blake2 0.10.6", - "bs58", - "bytes", - "cfg-if", - "chrono", - "clap 4.2.7", - "config", - "digest 0.10.6", - "dirs 5.0.1", - "futures", - "futures-util", - "lazy_static", - "libp2p", - "libp2p-identity", "log", - "lru", - "pretty_env_logger", - "rand 0.8.5", - "refinery", - "reqwest", - "rocksdb", - "rusqlite", - "serde", - "serde_derive", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite 0.18.0", - "tokio-util", - "toml 0.7.4", - "unsigned-varint", - "utoipa", - "utoipa-swagger-ui", - "uuid 1.3.2", + "regex", ] [[package]] @@ -2621,6 +1664,35 @@ dependencies = [ "tokio", ] +[[package]] +name = "ext-trait" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d772df1c1a777963712fb68e014235e80863d6a91a85c4e06ba2d16243a310e5" +dependencies = [ + "ext-trait-proc_macros", +] + +[[package]] +name = "ext-trait-proc_macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab7934152eaf26aa5aa9f7371408ad5af4c31357073c9e84c3b9d7f11ad639a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "extension-traits" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a296e5a895621edf9fa8329c83aa1cb69a964643e36cf54d8d7a69b789089537" +dependencies = [ + "ext-trait", +] + [[package]] name = "eyre" version = "0.6.8" @@ -2631,18 +1703,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fallible-streaming-iterator" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" - [[package]] name = "fastrand" version = "1.9.0" @@ -2672,22 +1732,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle 2.4.1", -] - -[[package]] -name = "fiat-crypto" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" - [[package]] name = "figment" version = "0.10.8" @@ -2697,7 +1741,7 @@ dependencies = [ "atomic", "pear", "serde", - "toml 0.5.11", + "toml", "uncased", "version_check", ] @@ -2721,7 +1765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2843,7 +1887,6 @@ dependencies = [ "futures-core", "futures-task", "futures-util", - "num_cpus", ] [[package]] @@ -2863,21 +1906,6 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.28" @@ -2886,18 +1914,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "futures-rustls" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" -dependencies = [ - "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "syn 2.0.16", ] [[package]] @@ -2912,12 +1929,6 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - [[package]] name = "futures-util" version = "0.3.28" @@ -2952,7 +1963,7 @@ dependencies = [ "libc", "log", "rustversion", - "windows 0.48.0", + "windows", ] [[package]] @@ -3014,16 +2025,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ghash" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.5.3", -] - [[package]] name = "ghash" version = "0.5.0" @@ -3031,14 +2032,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval", ] [[package]] -name = "gimli" -version = "0.27.2" +name = "ghost" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "e77ac7b51b8e6313251737fcef4b1c01a2ea102bde68415b62c0ee9268fec357" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] [[package]] name = "git2" @@ -3095,22 +2101,11 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle 2.4.1", -] - [[package]] name = "h2" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -3183,11 +2178,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +checksum = "0761a1b9491c4f2e3d66aa0f62d0fba0af9a0e2852e4d48ea506632a4b56e6aa" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -3282,12 +2277,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hex_fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" - [[package]] name = "hidapi" version = "1.5.0" @@ -3338,17 +2327,6 @@ dependencies = [ "digest 0.10.6", ] -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi", -] - [[package]] name = "http" version = "0.2.9" @@ -3505,17 +2483,16 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows 0.48.0", + "windows", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -3545,35 +2522,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "if-addrs" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "if-watch" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" -dependencies = [ - "async-io", - "core-foundation", - "fnv", - "futures", - "if-addrs", - "ipnet", - "log", - "rtnetlink", - "system-configuration", - "tokio", - "windows 0.34.0", -] - [[package]] name = "indenter" version = "0.3.3" @@ -3588,7 +2536,7 @@ checksum = "bfbcff6ae46750b15cc594bfd277b188cbddcfdc1817848f97f03f26f8625b9e" dependencies = [ "cfg-if", "js-sys", - "uuid 1.3.2", + "uuid 1.3.3", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -3662,22 +2610,25 @@ dependencies = [ ] [[package]] -name = "interceptor" -version = "0.8.2" +name = "inventory" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" +checksum = "f0eb5160c60ba1e809707918ee329adb99d222888155835c6feedba19f6c3fd4" dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", + "ctor", + "ghost", + "inventory-impl", +] + +[[package]] +name = "inventory-impl" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e41b53715c6f0c4be49510bb82dee2c1e51c8586d885abe65396e82ed518548" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -3691,18 +2642,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "ipconfig" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" -dependencies = [ - "socket2", - "widestring", - "winapi", - "winreg", -] - [[package]] name = "ipnet" version = "2.7.2" @@ -3764,6 +2703,28 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.26" @@ -3784,14 +2745,15 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sec1", + "sha2 0.9.9", "sha3", ] @@ -3830,24 +2792,12 @@ dependencies = [ "libc", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "ledger" version = "0.1.0" @@ -3898,9 +2848,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.142" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libgit2-sys" @@ -3914,428 +2864,11 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - [[package]] name = "libm" -version = "0.1.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - -[[package]] -name = "libm" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" - -[[package]] -name = "libp2p" -version = "0.51.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "getrandom 0.2.9", - "instant", - "libp2p-allow-block-list", - "libp2p-connection-limits", - "libp2p-core", - "libp2p-dns", - "libp2p-gossipsub", - "libp2p-identity", - "libp2p-kad", - "libp2p-mdns", - "libp2p-metrics", - "libp2p-noise", - "libp2p-quic", - "libp2p-request-response", - "libp2p-swarm", - "libp2p-tcp", - "libp2p-webrtc", - "libp2p-yamux", - "multiaddr", - "pin-project", -] - -[[package]] -name = "libp2p-allow-block-list" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - -[[package]] -name = "libp2p-connection-limits" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - -[[package]] -name = "libp2p-core" -version = "0.39.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-identity", - "log", - "multiaddr", - "multihash", - "multistream-select", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "quick-protobuf", - "rand 0.8.5", - "rw-stream-sink", - "serde", - "smallvec", - "thiserror", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-dns" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" -dependencies = [ - "futures", - "libp2p-core", - "log", - "parking_lot 0.12.1", - "smallvec", - "trust-dns-resolver", -] - -[[package]] -name = "libp2p-gossipsub" -version = "0.44.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70b34b6da8165c0bde35c82db8efda39b824776537e73973549e76cadb3a77c5" -dependencies = [ - "asynchronous-codec", - "base64 0.21.0", - "byteorder", - "bytes", - "either", - "fnv", - "futures", - "hex_fmt", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "prometheus-client", - "quick-protobuf", - "quick-protobuf-codec", - "rand 0.8.5", - "regex", - "serde", - "sha2 0.10.6", - "smallvec", - "thiserror", - "unsigned-varint", - "void", - "wasm-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libp2p-identity" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" -dependencies = [ - "bs58", - "ed25519-dalek", - "log", - "multiaddr", - "multihash", - "quick-protobuf", - "rand 0.8.5", - "serde", - "sha2 0.10.6", - "thiserror", - "zeroize", -] - -[[package]] -name = "libp2p-kad" -version = "0.43.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" -dependencies = [ - "arrayvec", - "asynchronous-codec", - "bytes", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "quick-protobuf", - "rand 0.8.5", - "serde", - "sha2 0.10.6", - "smallvec", - "thiserror", - "uint", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-mdns" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" -dependencies = [ - "data-encoding", - "futures", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "rand 0.8.5", - "smallvec", - "socket2", - "tokio", - "trust-dns-proto", - "void", -] - -[[package]] -name = "libp2p-metrics" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" -dependencies = [ - "libp2p-core", - "libp2p-gossipsub", - "libp2p-kad", - "libp2p-swarm", - "prometheus-client", -] - -[[package]] -name = "libp2p-noise" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" -dependencies = [ - "bytes", - "curve25519-dalek 3.2.0", - "futures", - "libp2p-core", - "libp2p-identity", - "log", - "once_cell", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.6", - "snow", - "static_assertions", - "thiserror", - "x25519-dalek 1.1.1", - "zeroize", -] - -[[package]] -name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-tls", - "log", - "parking_lot 0.12.1", - "quinn-proto", - "rand 0.8.5", - "rustls 0.20.8", - "thiserror", - "tokio", -] - -[[package]] -name = "libp2p-request-response" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" -dependencies = [ - "async-trait", - "futures", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "rand 0.8.5", - "smallvec", -] - -[[package]] -name = "libp2p-swarm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm-derive", - "log", - "rand 0.8.5", - "smallvec", - "tokio", - "void", -] - -[[package]] -name = "libp2p-swarm-derive" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" -dependencies = [ - "heck 0.4.1", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "libp2p-tcp" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" -dependencies = [ - "futures", - "futures-timer", - "if-watch", - "libc", - "libp2p-core", - "log", - "socket2", - "tokio", -] - -[[package]] -name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core", - "libp2p-identity", - "rcgen 0.10.0", - "ring", - "rustls 0.20.8", - "thiserror", - "webpki 0.22.0", - "x509-parser 0.14.0", - "yasna", -] - -[[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" -dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", - "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-noise", - "log", - "multihash", - "quick-protobuf", - "quick-protobuf-codec", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", -] - -[[package]] -name = "libp2p-yamux" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" -dependencies = [ - "futures", - "libp2p-core", - "log", - "thiserror", - "yamux", -] - -[[package]] -name = "librocksdb-sys" -version = "0.10.0+7.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" -dependencies = [ - "bindgen", - "bzip2-sys", - "cc", - "glob", - "libc", - "libz-sys", - "lz4-sys", - "zstd-sys", -] +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libsqlite3-sys" @@ -4360,21 +2893,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.3.7" @@ -4393,24 +2911,6 @@ dependencies = [ "keystream", ] -[[package]] -name = "local-channel" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" -dependencies = [ - "futures-core", - "futures-sink", - "futures-util", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" - [[package]] name = "lock_api" version = "0.4.9" @@ -4446,38 +2946,20 @@ dependencies = [ ] [[package]] -name = "lru" -version = "0.10.0" +name = "macro_rules_attribute" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +checksum = "cf0c9b980bf4f3a37fd7b1c066941dd1b1d0152ce6ee6e8fe8c49b9f6810d862" dependencies = [ - "hashbrown 0.13.2", + "macro_rules_attribute-proc_macro", + "paste", ] [[package]] -name = "lru-cache" -version = "0.1.2" +name = "macro_rules_attribute-proc_macro" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "lz4-sys" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +checksum = "58093314a45e00c77d5c508f76e77c3396afbbc0d01506e7fae47b018bac2b1d" [[package]] name = "matchers" @@ -4512,30 +2994,12 @@ dependencies = [ "serde", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest 0.10.6", -] - [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "memoffset" version = "0.8.0" @@ -4551,31 +3015,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -4617,79 +3062,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "multiaddr" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "log", - "multibase", - "multihash", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - -[[package]] -name = "multibase" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" -dependencies = [ - "base-x", - "data-encoding", - "data-encoding-macro", -] - -[[package]] -name = "multihash" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" -dependencies = [ - "core2", - "digest 0.10.6", - "multihash-derive", - "serde", - "serde-big-array", - "sha2 0.10.6", - "unsigned-varint", -] - -[[package]] -name = "multihash-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "multistream-select" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" -dependencies = [ - "bytes", - "futures", - "log", - "pin-project", - "smallvec", - "unsigned-varint", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -4708,96 +3080,12 @@ dependencies = [ "tempfile", ] -[[package]] -name = "netlink-packet-core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" -dependencies = [ - "anyhow", - "byteorder", - "libc", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-route" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" -dependencies = [ - "anyhow", - "bitflags", - "byteorder", - "libc", - "netlink-packet-core", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-utils" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" -dependencies = [ - "anyhow", - "byteorder", - "paste", - "thiserror", -] - -[[package]] -name = "netlink-proto" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" -dependencies = [ - "bytes", - "futures", - "log", - "netlink-packet-core", - "netlink-sys", - "thiserror", - "tokio", -] - -[[package]] -name = "netlink-sys" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" -dependencies = [ - "bytes", - "futures", - "libc", - "log", - "tokio", -] - -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "no-std-compat" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" -[[package]] -name = "nohash-hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" - [[package]] name = "nom" version = "7.1.3" @@ -4810,9 +3098,9 @@ dependencies = [ [[package]] name = "notify" -version = "5.1.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9" +checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" dependencies = [ "bitflags", "crossbeam-channel", @@ -4823,7 +3111,7 @@ dependencies = [ "libc", "mio", "walkdir", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -4845,17 +3133,6 @@ dependencies = [ "winapi", ] -[[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", - "num-integer", - "num-traits", -] - [[package]] name = "num-derive" version = "0.3.3" @@ -4884,7 +3161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg 1.1.0", - "libm 0.2.6", + "libm", ] [[package]] @@ -4912,8 +3189,7 @@ dependencies = [ "cw-utils", "cw3", "cw4", - "dirs 4.0.0", - "ephemera", + "dirs", "futures", "getset", "humantime-serde", @@ -4960,7 +3236,7 @@ dependencies = [ "sqlx 0.6.3", "tap", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "tokio-stream", "ts-rs", @@ -5080,6 +3356,7 @@ dependencies = [ "nym-crypto", "nym-mixnet-contract-common", "nym-multisig-contract-common", + "nym-name-service-common", "nym-network-defaults", "nym-service-provider-directory-common", "nym-validator-client", @@ -5089,8 +3366,8 @@ dependencies = [ "serde_json", "tap", "thiserror", - "time 0.3.20", - "toml 0.5.11", + "time 0.3.21", + "toml", "url", ] @@ -5099,7 +3376,7 @@ name = "nym-client" version = "1.1.19" dependencies = [ "clap 4.2.7", - "dirs 4.0.0", + "dirs", "futures", "lazy_static", "log", @@ -5136,7 +3413,7 @@ version = "1.1.14" dependencies = [ "async-trait", "dashmap 5.4.0", - "dirs 4.0.0", + "dirs", "futures", "gloo-timers", "humantime-serde", @@ -5161,7 +3438,7 @@ dependencies = [ "tap", "tempfile", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "tokio-stream", "tokio-tungstenite 0.14.0", @@ -5169,7 +3446,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-timer 0.2.5 (git+https://github.com/mmsinclair/wasm-timer?rev=b9d1a54ad514c2f230a026afe0dde341e98cd7b6)", + "wasm-timer", "wasm-utils", "zeroize", ] @@ -5248,7 +3525,7 @@ dependencies = [ "log", "nym-network-defaults", "serde", - "toml 0.5.11", + "toml", "url", ] @@ -5330,7 +3607,7 @@ dependencies = [ "serde_bytes", "subtle-encoding", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] @@ -5377,7 +3654,7 @@ dependencies = [ "clap 4.2.7", "colored", "dashmap 4.0.2", - "dirs 4.0.0", + "dirs", "dotenvy", "futures", "humantime-serde", @@ -5442,7 +3719,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-timer 0.2.5 (git+https://github.com/mmsinclair/wasm-timer?rev=b9d1a54ad514c2f230a026afe0dde341e98cd7b6)", + "wasm-timer", "wasm-utils", ] @@ -5471,8 +3748,6 @@ dependencies = [ name = "nym-group-contract-common" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cw-controllers", "cw4", "schemars", "serde", @@ -5511,10 +3786,10 @@ dependencies = [ "rand_chacha 0.3.1", "schemars", "serde", - "serde-json-wasm 0.4.1", + "serde-json-wasm", "serde_repr", "thiserror", - "time 0.3.20", + "time 0.3.21", "ts-rs", ] @@ -5529,7 +3804,7 @@ dependencies = [ "colored", "cpu-cycles", "cupid", - "dirs 4.0.0", + "dirs", "futures", "humantime-serde", "lazy_static", @@ -5558,7 +3833,7 @@ dependencies = [ "sysinfo", "tokio", "tokio-util", - "toml 0.5.11", + "toml", "tracing", "url", ] @@ -5597,12 +3872,9 @@ dependencies = [ name = "nym-multisig-contract-common" version = "0.1.0" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", "cw-utils", "cw3", - "cw3-fixed-multisig", "cw4", "schemars", "serde", @@ -5638,7 +3910,7 @@ dependencies = [ "async-file-watcher", "async-trait", "clap 4.2.7", - "dirs 4.0.0", + "dirs", "futures", "humantime-serde", "ipnetwork 0.20.0", @@ -5677,7 +3949,7 @@ dependencies = [ name = "nym-network-statistics" version = "1.1.19" dependencies = [ - "dirs 4.0.0", + "dirs", "log", "nym-bin-common", "nym-statistics-common", @@ -5698,6 +3970,7 @@ dependencies = [ "log", "nym-crypto", "nym-sphinx", + "nym-sphinx-params", "nym-task", "nym-topology", "rand 0.7.3", @@ -5717,7 +3990,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "wasm-timer 0.2.5 (git+https://github.com/mmsinclair/wasm-timer?rev=b9d1a54ad514c2f230a026afe0dde341e98cd7b6)", + "wasm-timer", ] [[package]] @@ -5733,14 +4006,16 @@ name = "nym-outfox" version = "0.1.0" dependencies = [ "blake3", - "chacha20 0.9.1", - "chacha20poly1305 0.10.1", + "chacha20", + "chacha20poly1305", "criterion", - "curve25519-dalek 3.2.0", + "curve25519-dalek", "fastrand", "getrandom 0.2.9", + "log", + "rand 0.7.3", "rayon", - "sphinx-packet 0.1.0 (git+https://github.com/nymtech/sphinx.git)", + "sphinx-packet", "thiserror", "zeroize", ] @@ -5749,7 +4024,7 @@ dependencies = [ name = "nym-pemstore" version = "0.2.0" dependencies = [ - "pem 0.8.3", + "pem", ] [[package]] @@ -5779,7 +4054,7 @@ dependencies = [ "tap", "thiserror", "tokio", - "toml 0.5.11", + "toml", "url", ] @@ -5842,7 +4117,7 @@ dependencies = [ name = "nym-socks5-client-core" version = "0.1.0" dependencies = [ - "dirs 4.0.0", + "dirs", "futures", "log", "nym-bandwidth-controller", @@ -5864,6 +4139,28 @@ dependencies = [ "tokio", ] +[[package]] +name = "nym-socks5-listener" +version = "0.1.0" +dependencies = [ + "android_logger", + "anyhow", + "futures", + "jni", + "lazy_static", + "log", + "nym-bin-common", + "nym-client-core", + "nym-config", + "nym-credential-storage", + "nym-crypto", + "nym-socks5-client-core", + "openssl", + "rand 0.7.3", + "safer-ffi", + "tokio", +] + [[package]] name = "nym-socks5-proxy-helpers" version = "0.1.0" @@ -5897,7 +4194,6 @@ dependencies = [ "log", "nym-crypto", "nym-mixnet-contract-common", - "nym-outfox", "nym-sphinx-acknowledgements", "nym-sphinx-addressing", "nym-sphinx-anonymous-replies", @@ -5996,6 +4292,7 @@ dependencies = [ "nym-sphinx-addressing", "nym-sphinx-params", "nym-sphinx-types", + "thiserror", ] [[package]] @@ -6032,7 +4329,9 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "sphinx-packet 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nym-outfox", + "sphinx-packet", + "thiserror", ] [[package]] @@ -6053,7 +4352,7 @@ dependencies = [ name = "nym-store-cipher" version = "0.1.0" dependencies = [ - "aes-gcm 0.10.1", + "aes-gcm", "argon2", "generic-array 0.14.7", "getrandom 0.2.9", @@ -6212,33 +4511,6 @@ dependencies = [ "ts-rs", ] -[[package]] -name = "object" -version = "0.30.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" -dependencies = [ - "memchr", -] - -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - [[package]] name = "okapi" version = "0.7.0-rc.1" @@ -6298,7 +4570,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -6307,6 +4579,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.25.3+1.1.1t" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924757a6a226bf60da5f7dd0311a34d2b52283dd82ddeb103208ddc66362f80c" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.87" @@ -6315,6 +4596,7 @@ checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -6362,12 +4644,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "os_str_bytes" version = "6.5.0" @@ -6380,38 +4656,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - [[package]] name = "pairing" version = "0.20.0" @@ -6430,12 +4674,6 @@ dependencies = [ "group 0.11.0", ] -[[package]] -name = "parking" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - [[package]] name = "parking_lot" version = "0.11.2" @@ -6501,19 +4739,13 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" -[[package]] -name = "pathdiff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" - [[package]] name = "pbkdf2" -version = "0.11.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" dependencies = [ - "digest 0.10.6", + "crypto-mac 0.11.1", ] [[package]] @@ -6536,15 +4768,9 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics 0.10.0", "quote", - "syn 2.0.15", + "syn 2.0.16", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "peg" version = "0.7.0" @@ -6583,24 +4809,6 @@ dependencies = [ "regex", ] -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.2.0" @@ -6637,7 +4845,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -6653,22 +4861,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] @@ -6685,12 +4893,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", + "zeroize", ] [[package]] @@ -6699,12 +4908,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" -[[package]] -name = "platforms" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" - [[package]] name = "plotters" version = "0.3.4" @@ -6733,33 +4936,6 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg 1.1.0", - "bitflags", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - -[[package]] -name = "poly1305" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" -dependencies = [ - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - [[package]] name = "poly1305" version = "0.8.0" @@ -6768,19 +4944,7 @@ checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.5.0", -] - -[[package]] -name = "polyval" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash", ] [[package]] @@ -6792,7 +4956,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.5.0", + "universal-hash", ] [[package]] @@ -6807,18 +4971,18 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" dependencies = [ - "env_logger", + "env_logger 0.7.1", "log", ] [[package]] -name = "proc-macro-crate" -version = "1.1.3" +name = "prettyplease" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "thiserror", - "toml 0.5.11", + "proc-macro2", + "syn 1.0.109", ] [[package]] @@ -6847,9 +5011,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" dependencies = [ "unicode-ident", ] @@ -6875,34 +5039,11 @@ checksum = "606c4ba35817e2922a308af55ad51bab3645b59eae5c570d4a6cf07e36bd493b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", "version_check", "yansi", ] -[[package]] -name = "prometheus-client" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" -dependencies = [ - "dtoa", - "itoa", - "parking_lot 0.12.1", - "prometheus-client-derive-encode", -] - -[[package]] -name = "prometheus-client-derive-encode" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "prost" version = "0.10.4" @@ -6991,51 +5132,11 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - -[[package]] -name = "quick-protobuf-codec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" -dependencies = [ - "asynchronous-codec", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint", -] - -[[package]] -name = "quinn-proto" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" -dependencies = [ - "bytes", - "rand 0.8.5", - "ring", - "rustc-hash", - "rustls 0.20.8", - "slab", - "thiserror", - "tinyvec", - "tracing", - "webpki 0.22.0", -] - [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -7273,31 +5374,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem 1.1.1", - "ring", - "time 0.3.20", - "x509-parser 0.13.2", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" -dependencies = [ - "pem 1.1.1", - "ring", - "time 0.3.20", - "yasna", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -7353,51 +5429,7 @@ checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "refinery" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb0436d0dd7bd8d4fce1e828751fa79742b08e35f27cfea7546f8a322b5ef24" -dependencies = [ - "refinery-core", - "refinery-macros", -] - -[[package]] -name = "refinery-core" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19206547cd047e8f4dfa6b20c30d3ecaf24be05841b6aa0aa926a47a3d0662bb" -dependencies = [ - "async-trait", - "cfg-if", - "lazy_static", - "log", - "regex", - "rusqlite", - "serde", - "siphasher", - "thiserror", - "time 0.3.20", - "toml 0.7.4", - "url", - "walkdir", -] - -[[package]] -name = "refinery-macros" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d94d4b9241859ba19eaa5c04c86e782eb3aa0aae2c5868e0cfa90c856e58a174" -dependencies = [ - "proc-macro2", - "quote", - "refinery-core", - "regex", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -7434,9 +5466,9 @@ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "reqwest" -version = "0.11.17" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64 0.21.0", "bytes", @@ -7470,24 +5502,14 @@ dependencies = [ "winreg", ] -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error 1.2.3", -] - [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" dependencies = [ "crypto-bigint", - "hmac 0.12.1", + "hmac 0.11.0", "zeroize", ] @@ -7506,15 +5528,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.6", -] - [[package]] name = "ripemd160" version = "0.9.1" @@ -7556,7 +5569,7 @@ dependencies = [ "serde_json", "state", "tempfile", - "time 0.3.20", + "time 0.3.21", "tokio", "tokio-stream", "tokio-util", @@ -7618,7 +5631,7 @@ dependencies = [ "smallvec", "stable-pattern", "state", - "time 0.3.20", + "time 0.3.21", "tokio", "uncased", ] @@ -7645,125 +5658,13 @@ version = "0.8.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54f94d1ffe41472e08463d7a2674f1db04dc4df745285e8369b33d3cfd6b0308" dependencies = [ - "darling 0.13.4", + "darling", "proc-macro2", "quote", "rocket_http", "syn 1.0.109", ] -[[package]] -name = "rocksdb" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" -dependencies = [ - "libc", - "librocksdb-sys", -] - -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - -[[package]] -name = "rtnetlink" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" -dependencies = [ - "futures", - "log", - "netlink-packet-route", - "netlink-proto", - "nix", - "thiserror", - "tokio", -] - -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - -[[package]] -name = "rusqlite" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a" -dependencies = [ - "bitflags", - "fallible-iterator", - "fallible-streaming-iterator", - "hashlink 0.7.0", - "libsqlite3-sys", - "memchr", - "smallvec", -] - -[[package]] -name = "rust-embed" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b68543d5527e158213414a92832d2aab11a84d2571a5eb021ebe22c43aab066" -dependencies = [ - "rust-embed-impl", - "rust-embed-utils", - "walkdir", -] - -[[package]] -name = "rust-embed-impl" -version = "6.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4e0f0ced47ded9a68374ac145edd65a6c1fa13a96447b873660b2a568a0fd7" -dependencies = [ - "proc-macro2", - "quote", - "rust-embed-utils", - "shellexpand", - "syn 1.0.109", - "walkdir", -] - -[[package]] -name = "rust-embed-utils" -version = "7.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512b0ab6853f7e14e3c8754acb43d6f748bb9ced66aa5915a6553ac8213f7731" -dependencies = [ - "sha2 0.10.6", - "walkdir", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.2.3" @@ -7782,15 +5683,6 @@ dependencies = [ "semver 1.0.17", ] -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - [[package]] name = "rustix" version = "0.37.19" @@ -7857,23 +5749,42 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" -[[package]] -name = "rw-stream-sink" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" -dependencies = [ - "futures", - "pin-project", - "static_assertions", -] - [[package]] name = "ryu" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "safer-ffi" +version = "0.1.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7270b08a2af50909969cfc28a239cfdda9ab1b3df74749b265c46956183e5bf7" +dependencies = [ + "inventory", + "libc", + "macro_rules_attribute", + "paste", + "safer_ffi-proc_macros", + "scopeguard", + "uninit", + "unwind_safe", + "with_builtin_macros", +] + +[[package]] +name = "safer_ffi-proc_macros" +version = "0.1.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1438fb328c52f5148ea02a317603efd802f2cd6eb9e721adfd51b94bb55d9ddb" +dependencies = [ + "macro_rules_attribute", + "prettyplease", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "same-file" version = "1.0.6" @@ -7929,12 +5840,6 @@ 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.6.1" @@ -7955,25 +5860,12 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", -] - [[package]] name = "sec1" -version = "0.3.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" dependencies = [ - "base16ct", "der", "generic-array 0.14.7", "pkcs8", @@ -7983,9 +5875,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +checksum = "ca2855b3715770894e67cbfa3df957790aa0c9edc3bf06efa1a84d77fa0839d1" dependencies = [ "bitflags", "core-foundation", @@ -7996,9 +5888,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -8045,22 +5937,13 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.162" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] -[[package]] -name = "serde-big-array" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd31f59f6fe2b0c055371bb2f16d7f0aa7d8881676c04a55b1596d1a17cd10a4" -dependencies = [ - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.4.1" @@ -8070,15 +5953,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde-json-wasm" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" -dependencies = [ - "serde", -] - [[package]] name = "serde-wasm-bindgen" version = "0.5.0" @@ -8101,13 +5975,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.162" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -8140,16 +6014,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "serde_spanned" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" -dependencies = [ - "serde", + "syn 2.0.16", ] [[package]] @@ -8225,12 +6090,14 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.8" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" dependencies = [ - "digest 0.10.6", + "block-buffer 0.9.0", + "digest 0.9.0", "keccak", + "opaque-debug 0.3.0", ] [[package]] @@ -8242,21 +6109,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shellexpand" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" -dependencies = [ - "dirs 4.0.0", -] - -[[package]] -name = "shlex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" - [[package]] name = "signal-hook" version = "0.3.15" @@ -8289,20 +6141,14 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" dependencies = [ - "digest 0.10.6", + "digest 0.9.0", "rand_core 0.6.4", ] -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - [[package]] name = "slab" version = "0.4.8" @@ -8340,23 +6186,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "snow" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" -dependencies = [ - "aes-gcm 0.9.4", - "blake2 0.10.6", - "chacha20poly1305 0.9.1", - "curve25519-dalek 4.0.0-rc.1", - "rand_core 0.6.4", - "ring", - "rustc_version 0.4.0", - "sha2 0.10.6", - "subtle 2.4.1", -] - [[package]] name = "socket2" version = "0.4.9" @@ -8379,30 +6208,7 @@ dependencies = [ "bs58", "byteorder", "chacha", - "curve25519-dalek 3.2.0", - "digest 0.9.0", - "hkdf 0.11.0", - "hmac 0.11.0", - "lioness", - "log", - "rand 0.7.3", - "rand_distr", - "sha2 0.9.9", - "subtle 2.4.1", -] - -[[package]] -name = "sphinx-packet" -version = "0.1.0" -source = "git+https://github.com/nymtech/sphinx.git#ca107d94360cdf8bbfbdb12fe5320ed74f80e40c" -dependencies = [ - "aes 0.7.5", - "arrayref", - "blake2 0.8.1", - "bs58", - "byteorder", - "chacha", - "curve25519-dalek 3.2.0", + "curve25519-dalek", "digest 0.9.0", "hkdf 0.11.0", "hmac 0.11.0", @@ -8431,9 +6237,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.6.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", "der", @@ -8550,7 +6356,7 @@ dependencies = [ "futures-executor", "futures-intrusive", "futures-util", - "hashlink 0.8.1", + "hashlink 0.8.2", "hex", "indexmap", "itoa", @@ -8715,34 +6521,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc 3.0.1", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring", - "subtle 2.4.1", - "thiserror", - "tokio", - "url", - "webrtc-util", -] - -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "subtle" version = "1.0.0" @@ -8777,9 +6555,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -8792,18 +6570,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "sysinfo" version = "0.27.8" @@ -8819,27 +6585,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -8861,9 +6606,9 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a199518e0366ba0aeb0d0e0a59dbd99ea0bdc14280f414ecc758c9228a454ad8" +checksum = "3ca881fa4dedd2b46334f13be7fbc8cc1549ba4be5a833fe4e73d1a1baaf7949" dependencies = [ "async-trait", "bytes", @@ -8886,29 +6631,29 @@ dependencies = [ "subtle 2.4.1", "subtle-encoding", "tendermint-proto", - "time 0.3.20", + "time 0.3.21", "zeroize", ] [[package]] name = "tendermint-config" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d8f6a64ae3b59ea3c73efad727271ee085b544b817d7f46901817ca6bb1773" +checksum = "f6c56ee93f4e9b7e7daba86d171f44572e91b741084384d0ae00df7991873dfd" dependencies = [ "flex-error", "serde", "serde_json", "tendermint", - "toml 0.5.11", + "toml", "url", ] [[package]] name = "tendermint-proto" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b303d6387aaea38cea7ef924476d1f798573044e7b4f6ddd1166ac5184b2281" +checksum = "b71f925d74903f4abbdc4af0110635a307b3cb05b175fdff4a7247c14a4d0874" dependencies = [ "bytes", "flex-error", @@ -8919,14 +6664,14 @@ dependencies = [ "serde", "serde_bytes", "subtle-encoding", - "time 0.3.20", + "time 0.3.21", ] [[package]] name = "tendermint-rpc" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3036f0b65baa11e767dabd22a0663e842b595b0a1903f149b7b8b1e09b2b443d" +checksum = "a13e63f57ee05a1e927887191c76d1b139de9fa40c180b9f8727ee44377242a6" dependencies = [ "async-trait", "bytes", @@ -8947,7 +6692,7 @@ dependencies = [ "tendermint-config", "tendermint-proto", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "tracing", "url", @@ -8987,7 +6732,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -9013,9 +6758,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "js-sys", @@ -9026,15 +6771,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -9066,9 +6811,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg 1.1.0", "bytes", @@ -9102,7 +6847,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -9199,18 +6944,6 @@ dependencies = [ "tungstenite 0.17.3", ] -[[package]] -name = "tokio-tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.18.0", -] - [[package]] name = "tokio-util" version = "0.7.8" @@ -9219,10 +6952,7 @@ checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", - "futures-io", "futures-sink", - "futures-util", - "hashbrown 0.12.3", "pin-project-lite", "slab", "tokio", @@ -9238,50 +6968,15 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.19.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d964908cec0d030b812013af25a0e57fddfadb1e066ecc6681d86253129d4f" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tonic" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ - "async-stream", "async-trait", "axum", - "base64 0.13.1", + "base64 0.21.0", "bytes", "futures-core", "futures-util", @@ -9293,15 +6988,12 @@ dependencies = [ "percent-encoding", "pin-project", "prost 0.11.9", - "prost-derive 0.11.9", "tokio", "tokio-stream", - "tokio-util", "tower", "tower-layer", "tower-service", "tracing", - "tracing-futures", ] [[package]] @@ -9343,7 +7035,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -9356,7 +7047,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time 0.3.20", + "time 0.3.21", "tracing-subscriber", ] @@ -9368,29 +7059,19 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.1.3" @@ -9433,52 +7114,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "trust-dns-proto" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" -dependencies = [ - "async-trait", - "cfg-if", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "rand 0.8.5", - "smallvec", - "socket2", - "thiserror", - "tinyvec", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lazy_static", - "lru-cache", - "parking_lot 0.12.1", - "resolv-conf", - "smallvec", - "thiserror", - "tokio", - "tracing", - "trust-dns-proto", -] - [[package]] name = "try-lock" version = "0.2.4" @@ -9562,44 +7197,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - [[package]] name = "typenum" version = "1.16.0" @@ -9635,9 +7232,9 @@ dependencies = [ [[package]] name = "uncased" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b01702b0fd0b3fadcf98e098780badda8742d4f4a7676615cad90e8ac73622" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" dependencies = [ "serde", "version_check", @@ -9708,13 +7305,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] -name = "universal-hash" -version = "0.4.1" +name = "uninit" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "3e130f2ed46ca5d8ec13c7ff95836827f92f5f5f37fd2b2bf16f33c408d98bb6" dependencies = [ - "generic-array 0.14.7", - "subtle 2.4.1", + "extension-traits", ] [[package]] @@ -9727,22 +7323,18 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "unsigned-varint" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" -dependencies = [ - "asynchronous-codec", - "bytes", -] - [[package]] name = "untrusted" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "unwind_safe" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0976c77def3f1f75c4ef892a292c31c0bbe9e3d0702c63044d7c76db298171a3" + [[package]] name = "url" version = "2.3.1" @@ -9773,48 +7365,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "utoipa" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ae74ef183fae36d650f063ae7bde1cacbe1cd7e72b617cbe1e985551878b98" -dependencies = [ - "indexmap", - "serde", - "serde_json", - "utoipa-gen", -] - -[[package]] -name = "utoipa-gen" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea8ac818da7e746a63285594cce8a96f5e00ee31994e655bd827569cb8b137b" -dependencies = [ - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "regex", - "syn 2.0.15", -] - -[[package]] -name = "utoipa-swagger-ui" -version = "3.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062bba5a3568e126ac72049a63254f4cb1da2eb713db0c1ab2a4c76be191db8c" -dependencies = [ - "actix-web", - "mime_guess", - "regex", - "rust-embed", - "serde", - "serde_json", - "utoipa", - "zip", -] - [[package]] name = "uuid" version = "0.8.2" @@ -9823,9 +7373,9 @@ checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "uuid" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ "getrandom 0.2.9", "wasm-bindgen", @@ -9857,7 +7407,7 @@ dependencies = [ "rustc_version 0.4.0", "rustversion", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -9866,27 +7416,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" version = "2.3.3" @@ -9991,21 +7520,6 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasm-timer" version = "0.2.5" @@ -10086,221 +7600,6 @@ dependencies = [ "webpki 0.22.0", ] -[[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.6", - "stun", - "thiserror", - "time 0.3.20", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.1", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.2.0", - "elliptic-curve", - "hkdf 0.12.3", - "hmac 0.12.1", - "log", - "oid-registry 0.6.1", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", - "rustls 0.19.1", - "sec1", - "serde", - "sha1", - "sha2 0.10.6", - "signature", - "subtle 2.4.1", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0-pre.1", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc 3.0.1", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid 1.3.2", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" -dependencies = [ - "byteorder", - "bytes", - "rand 0.8.5", - "rtp", - "thiserror", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc 3.0.1", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1 0.9.8", - "subtle 2.4.1", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-util" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" -dependencies = [ - "async-trait", - "bitflags", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", -] - -[[package]] -name = "widestring" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" - [[package]] name = "winapi" version = "0.3.9" @@ -10332,19 +7631,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" -dependencies = [ - "windows_aarch64_msvc 0.34.0", - "windows_i686_gnu 0.34.0", - "windows_i686_msvc 0.34.0", - "windows_x86_64_gnu 0.34.0", - "windows_x86_64_msvc 0.34.0", -] - [[package]] name = "windows" version = "0.48.0" @@ -10429,12 +7715,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -10447,12 +7727,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -10465,12 +7739,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -10483,12 +7751,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -10513,12 +7775,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -10531,15 +7787,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" -[[package]] -name = "winnow" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" -dependencies = [ - "memchr", -] - [[package]] name = "winreg" version = "0.10.1" @@ -10549,6 +7796,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "with_builtin_macros" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a59d55032495429b87f9d69954c6c8602e4d3f3e0a747a12dea6b0b23de685da" +dependencies = [ + "with_builtin_macros-proc_macros", +] + +[[package]] +name = "with_builtin_macros-proc_macros" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bd7679c15e22924f53aee34d4e448c45b674feb6129689af88593e129f8f42" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "wyz" version = "0.5.1" @@ -10564,89 +7831,18 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek", "rand_core 0.5.1", "serde", "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.6.4", - "zeroize", -] - -[[package]] -name = "x509-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" -dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", - "data-encoding", - "der-parser 7.0.0", - "lazy_static", - "nom", - "oid-registry 0.4.0", - "ring", - "rusticata-macros", - "thiserror", - "time 0.3.20", -] - -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs 0.5.2", - "base64 0.13.1", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time 0.3.20", -] - -[[package]] -name = "yamux" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" -dependencies = [ - "futures", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "static_assertions", -] - [[package]] name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -[[package]] -name = "yasna" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" -dependencies = [ - "time 0.3.20", -] - [[package]] name = "zeroize" version = "1.6.0" @@ -10664,47 +7860,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", -] - -[[package]] -name = "zstd" -version = "0.12.3+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "6.0.5+zstd.1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" -dependencies = [ - "cc", - "libc", - "pkg-config", + "syn 2.0.16", ] diff --git a/Cargo.toml b/Cargo.toml index 6d44e25991..04a11ae06b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,6 +78,7 @@ members = [ "gateway/gateway-requests", "integrations/bity", "mixnode", + "sdk/lib/socks5-listener", "sdk/rust/nym-sdk", "service-providers/common", "service-providers/network-requester", diff --git a/README.md b/README.md index fda3d28163..93c976e7ba 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ For Typescript components, please see [ts-packages](./ts-packages). ### Developer chat -You can chat to us in [Keybase](https://keybase.io). Download their chat app, then click **Teams -> Join a team**. Type **nymtech.friends** into the team name and hit **continue**. For general chat, hang out in the **#general** channel. Our development takes places in the **#dev** channel. Node operators should be in the **#node-operators** channel. +You can chat with us in [Keybase](https://keybase.io). Download their chat app, then click **Teams -> Join a team**. Type **nymtech.friends** into the team name and hit **continue**. For general chat, hang out in the **#general** channel. Our development takes place in the **#dev** channel. Node operators should be in the **#node-operators** channel. ### Rewards @@ -46,7 +46,7 @@ Node, node operator and delegator rewards are determined according to the princi ||ratio of stake operator has pledged to their node to the token circulating supply. ||fraction of total effort undertaken by node `i`, set to `1/k`. ||number of nodes stakeholders are incentivised to create, set by the validators, a matter of governance. Currently determined by the `reward set` size, and set to 720 in testnet Sandbox. -||Sybil attack resistance parameter - the higher this parameter is set the stronger the reduction in competitivness gets for a Sybil attacker. +||Sybil attack resistance parameter - the higher this parameter is set the stronger the reduction in competitiveness gets for a Sybil attacker. ||declared profit margin of operator `i`, defaults to 10% in. ||uptime of node `i`, scaled to 0 - 1, for the rewarding epoch ||cost of operating node `i` for the duration of the rewarding epoch, set to 40 NYMT. @@ -70,7 +70,7 @@ Operator of node `i` is credited with the following amount: -Delegate with stake `s` recieves: +Delegate with stake `s` receives: diff --git a/clients/native/src/client/mod.rs b/clients/native/src/client/mod.rs index 57d77a1d4d..5c612f8fdf 100644 --- a/clients/native/src/client/mod.rs +++ b/clients/native/src/client/mod.rs @@ -20,6 +20,7 @@ use nym_client_core::client::received_buffer::{ use nym_client_core::config::persistence::key_pathfinder::ClientKeyPathfinder; use nym_credential_storage::persistent_storage::PersistentStorage; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; +use nym_sphinx::params::PacketType; use nym_task::connections::TransmissionLane; use nym_task::TaskManager; use nym_validator_client::nyxd::QueryNyxdClient; @@ -63,6 +64,7 @@ impl SocketClient { client_state: ClientState, self_address: &Recipient, shutdown: nym_task::TaskClient, + packet_type: PacketType, ) { info!("Starting websocket listener..."); @@ -88,6 +90,7 @@ impl SocketClient { self_address, shared_lane_queue_lengths, reply_controller_sender, + Some(packet_type), ); websocket::Listener::new(config.get_listening_ip(), config.get_listening_port()) @@ -137,7 +140,8 @@ impl SocketClient { } let base_builder = self.create_base_client_builder().await?; - let mut started_client = base_builder.start_base().await?; + let packet_type = self.config.get_base().get_packet_type(); + let mut started_client = base_builder.start_base(packet_type).await?; let self_address = started_client.address; let client_input = started_client.client_input.register_producer(); let client_output = started_client.client_output.register_consumer(); @@ -150,6 +154,7 @@ impl SocketClient { client_state, &self_address, started_client.task_manager.subscribe(), + packet_type, ); info!("Client startup finished!"); @@ -164,7 +169,8 @@ impl SocketClient { } let base_builder = self.create_base_client_builder().await?; - let mut started_client = base_builder.start_base().await?; + let packet_type = self.config.get_base().get_packet_type(); + let mut started_client = base_builder.start_base(packet_type).await?; let address = started_client.address; let client_input = started_client.client_input.register_producer(); let client_output = started_client.client_output.register_consumer(); @@ -186,6 +192,7 @@ impl SocketClient { reconstructed_receiver, address, shutdown_notifier: started_client.task_manager, + packet_type, }) } } @@ -199,6 +206,7 @@ pub struct DirectClient { // we need to keep reference to this guy otherwise things will start dropping shutdown_notifier: TaskManager, + packet_type: PacketType, } impl DirectClient { @@ -219,7 +227,7 @@ impl DirectClient { /// well enough in local tests) pub async fn send_regular_message(&mut self, recipient: Recipient, message: Vec) { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_regular(recipient, message, lane); + let input_msg = InputMessage::new_regular(recipient, message, lane, Some(self.packet_type)); self.client_input .input_sender @@ -238,7 +246,13 @@ impl DirectClient { reply_surbs: u32, ) { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_anonymous(recipient, message, reply_surbs, lane); + let input_msg = InputMessage::new_anonymous( + recipient, + message, + reply_surbs, + lane, + Some(self.packet_type), + ); self.client_input .input_sender @@ -252,7 +266,8 @@ impl DirectClient { /// well enough in local tests) pub async fn send_reply(&mut self, recipient_tag: AnonymousSenderTag, message: Vec) { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_reply(recipient_tag, message, lane); + let input_msg = + InputMessage::new_reply(recipient_tag, message, lane, Some(self.packet_type)); self.client_input .input_sender diff --git a/clients/native/src/websocket/handler.rs b/clients/native/src/websocket/handler.rs index a0eebbf9be..3830a31894 100644 --- a/clients/native/src/websocket/handler.rs +++ b/clients/native/src/websocket/handler.rs @@ -14,6 +14,7 @@ use nym_client_core::client::{ use nym_client_websocket_requests::{requests::ClientRequest, responses::ServerResponse}; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; +use nym_sphinx::params::PacketType; use nym_sphinx::receiver::ReconstructedMessage; use nym_task::connections::{ ConnectionCommand, ConnectionCommandSender, ConnectionId, LaneQueueLengths, TransmissionLane, @@ -41,6 +42,7 @@ pub(crate) struct HandlerBuilder { self_full_address: Recipient, lane_queue_lengths: LaneQueueLengths, reply_controller_sender: ReplyControllerSender, + packet_type: Option, } impl HandlerBuilder { @@ -51,6 +53,7 @@ impl HandlerBuilder { self_full_address: &Recipient, lane_queue_lengths: LaneQueueLengths, reply_controller_sender: ReplyControllerSender, + packet_type: Option, ) -> Self { Self { msg_input, @@ -59,6 +62,7 @@ impl HandlerBuilder { self_full_address: *self_full_address, lane_queue_lengths, reply_controller_sender, + packet_type, } } @@ -73,6 +77,7 @@ impl HandlerBuilder { received_response_type: Default::default(), lane_queue_lengths: self.lane_queue_lengths.clone(), reply_controller_sender: self.reply_controller_sender.clone(), + packet_type: self.packet_type, } } } @@ -86,6 +91,7 @@ pub(crate) struct Handler { received_response_type: ReceivedResponseType, lane_queue_lengths: LaneQueueLengths, reply_controller_sender: ReplyControllerSender, + packet_type: Option, } impl Drop for Handler { @@ -160,7 +166,7 @@ impl Handler { }); // the ack control is now responsible for chunking, etc. - let input_msg = InputMessage::new_regular(recipient, message, lane); + let input_msg = InputMessage::new_regular(recipient, message, lane, self.packet_type); self.msg_input .send(input_msg) .await @@ -191,7 +197,8 @@ impl Handler { TransmissionLane::ConnectionId(id) }); - let input_msg = InputMessage::new_anonymous(recipient, message, reply_surbs, lane); + let input_msg = + InputMessage::new_anonymous(recipient, message, reply_surbs, lane, self.packet_type); self.msg_input .send(input_msg) .await @@ -218,7 +225,7 @@ impl Handler { TransmissionLane::ConnectionId(id) }); - let input_msg = InputMessage::new_reply(recipient_tag, message, lane); + let input_msg = InputMessage::new_reply(recipient_tag, message, lane, self.packet_type); self.msg_input .send(input_msg) .await diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 9009578f3c..3b4eb2cf11 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -91,6 +91,7 @@ impl From for OverrideConfig { no_cover: init_config.no_cover, nyxd_urls: init_config.nyxd_urls, enabled_credentials_mode: init_config.enabled_credentials_mode, + outfox: false, } } } diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index e792b842f3..2100e9915f 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -10,6 +10,7 @@ use nym_bin_common::completions::{fig_generate, ArgShell}; use nym_config::{NymConfig, OptionalSet}; use nym_socks5_client_core::config::old_config_v1_1_13::OldConfigV1_1_13; use nym_socks5_client_core::config::{BaseConfig, Config}; +use nym_sphinx::params::PacketType; use std::error::Error; pub mod init; @@ -64,6 +65,7 @@ pub(crate) struct OverrideConfig { no_cover: bool, nyxd_urls: Option>, enabled_credentials_mode: Option, + outfox: bool, } pub(crate) async fn execute(args: &Cli) -> Result<(), Box> { @@ -80,9 +82,15 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box Config { + let packet_type = if args.outfox { + PacketType::Outfox + } else { + PacketType::Mix + }; config .with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode) .with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover) + .with_base(BaseConfig::with_packet_type, packet_type) .with_optional(Config::with_anonymous_replies, args.use_anonymous_replies) .with_optional(Config::with_port, args.port) .with_optional_custom_env_ext( diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index dc2b5648a3..09264adc58 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -9,6 +9,7 @@ use crate::{ use clap::Args; use log::*; use nym_bin_common::version_checker::is_minor_version_compatible; +use nym_client_core::client::base_client::storage::OnDiskPersistent; use nym_config::NymConfig; use nym_crypto::asymmetric::identity; use nym_socks5_client_core::{config::Config, NymClient}; @@ -67,6 +68,9 @@ pub(crate) struct Run { /// with bandwidth credential requirement. #[clap(long, hide = true)] enabled_credentials_mode: Option, + + #[clap(long, hide = true, action)] + outfox: bool, } impl From for OverrideConfig { @@ -79,6 +83,7 @@ impl From for OverrideConfig { no_cover: run_config.no_cover, nyxd_urls: run_config.nyxd_urls, enabled_credentials_mode: run_config.enabled_credentials_mode, + outfox: run_config.outfox, } } } @@ -138,5 +143,6 @@ pub(crate) async fn execute(args: &Run) -> Result<(), Box, pub(crate) debug: ConfigDebug, + + pub(crate) packet_type: PacketType, } #[wasm_bindgen] @@ -42,9 +44,18 @@ impl Config { pub fn new( id: String, validator_server: String, + packet_type: Option, gateway: Option, debug: Option, ) -> Self { + let packet_type = if let Some(packet_type) = packet_type { + match packet_type.as_str() { + "outfox" => PacketType::Outfox, + _ => PacketType::Mix, + } + } else { + PacketType::Mix + }; Config { id, nym_api_url: Some( @@ -55,6 +66,7 @@ impl Config { disabled_credentials_mode: true, gateway, debug: debug.map(Into::into).unwrap_or_default(), + packet_type, } } } @@ -97,6 +109,7 @@ impl From for ConfigTraffic { .disable_main_poisson_packet_distribution, primary_packet_size: PacketSize::RegularPacket, secondary_packet_size: use_extended_packet_size, + packet_type: None, } } } diff --git a/clients/webassembly/src/client/mod.rs b/clients/webassembly/src/client/mod.rs index 52b47ee796..baf72a7c85 100644 --- a/clients/webassembly/src/client/mod.rs +++ b/clients/webassembly/src/client/mod.rs @@ -23,6 +23,7 @@ use nym_client_core::client::inbound_messages::InputMessage; use nym_client_core::client::replies::reply_storage::browser_backend; use nym_client_core::config::{CoverTraffic, DebugConfig, Topology, Traffic}; use nym_credential_storage::ephemeral_storage::EphemeralStorage; +use nym_sphinx::params::PacketType; use nym_task::connections::TransmissionLane; use nym_task::TaskManager; use nym_topology::provider_trait::{HardcodedTopologyProvider, TopologyProvider}; @@ -52,6 +53,7 @@ pub struct NymClient { // even though we don't use graceful shutdowns, other components rely on existence of this struct // and if it's dropped, everything will start going offline _task_manager: TaskManager, + packet_type: Option, } #[wasm_bindgen] @@ -68,6 +70,7 @@ pub struct NymClientBuilder { bandwidth_controller: Option, EphemeralStorage>>, disabled_credentials: bool, + packet_type: Option, } #[wasm_bindgen] @@ -86,6 +89,7 @@ impl NymClientBuilder { on_message, bandwidth_controller: None, disabled_credentials: true, + packet_type: None, } } @@ -124,6 +128,7 @@ impl NymClientBuilder { }, ..Default::default() }, + packet_type: PacketType::Mix, }; NymClientBuilder { @@ -136,6 +141,7 @@ impl NymClientBuilder { bandwidth_controller: None, disabled_credentials: true, storage_passphrase: None, + packet_type: None, } } @@ -143,7 +149,7 @@ impl NymClientBuilder { ResponsePusher::new(client_output, on_message).start() } - fn topology_provider(&mut self) -> Option> { + fn topology_provider(&mut self) -> Option> { if let Some(hardcoded_topology) = self.custom_topology.take() { Some(Box::new(HardcodedTopologyProvider::new(hardcoded_topology))) } else { @@ -202,7 +208,8 @@ impl NymClientBuilder { base_builder = base_builder.with_topology_provider(topology_provider); } - let mut started_client = base_builder.start_base().await?; + let packet_type = self.config.packet_type; + let mut started_client = base_builder.start_base(packet_type).await?; let self_address = started_client.address.to_string(); let client_input = started_client.client_input.register_producer(); @@ -216,6 +223,7 @@ impl NymClientBuilder { client_state: Arc::new(started_client.client_state), _full_topology: None, _task_manager: started_client.task_manager, + packet_type: self.packet_type, }) } @@ -291,7 +299,7 @@ impl NymClient { let input_msgs = request .test_msgs .into_iter() - .map(|p| InputMessage::new_regular(recipient, p, lane)) + .map(|p| InputMessage::new_regular(recipient, p, lane, None)) .collect(); self.client_input.send_messages(input_msgs) @@ -311,7 +319,7 @@ impl NymClient { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_regular(recipient, message, lane); + let input_msg = InputMessage::new_regular(recipient, message, lane, self.packet_type); self.client_input.send_message(input_msg) } @@ -338,7 +346,8 @@ impl NymClient { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_anonymous(recipient, message, reply_surbs, lane); + let input_msg = + InputMessage::new_anonymous(recipient, message, reply_surbs, lane, self.packet_type); self.client_input.send_message(input_msg) } @@ -356,7 +365,7 @@ impl NymClient { let lane = TransmissionLane::General; - let input_msg = InputMessage::new_reply(sender_tag, message, lane); + let input_msg = InputMessage::new_reply(sender_tag, message, lane, self.packet_type); self.client_input.send_message(input_msg) } } diff --git a/clients/webassembly/src/storage/mod.rs b/clients/webassembly/src/storage/mod.rs index 46e7feb627..f372e723ee 100644 --- a/clients/webassembly/src/storage/mod.rs +++ b/clients/webassembly/src/storage/mod.rs @@ -31,7 +31,7 @@ mod v1 { pub const GATEWAY_CONFIG: &str = "gateway_config"; pub const ED25519_IDENTITY_KEYPAIR: &str = "ed25519_identity_keypair"; - pub const X25519_ENCRYPTION_KEYPAIR: &str = "x25519_encryption_key"; + pub const X25519_ENCRYPTION_KEYPAIR: &str = "x25519_encryption_keypair"; // TODO: for those we could actually use the subtle crypto storage pub const AES128CTR_ACK_KEY: &str = "aes128ctr_ack_key"; diff --git a/common/async-file-watcher/src/lib.rs b/common/async-file-watcher/src/lib.rs index dea2cfd335..73faaa3dfa 100644 --- a/common/async-file-watcher/src/lib.rs +++ b/common/async-file-watcher/src/lib.rs @@ -130,7 +130,7 @@ impl AsyncFileWatcher { Ok(event) => { let now = Instant::now(); if self.should_propagate(&event, now) { - self.last_received.insert(event.kind.clone(), now); + self.last_received.insert(event.kind, now); if let Err(_err) = self.event_sender.unbounded_send(event) { log::error!("the file watcher receiver has been dropped!"); } diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index e804c1fccf..bf4803140a 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -37,17 +37,19 @@ use nym_gateway_client::{ use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::addressing::nodes::NodeIdentity; +use nym_sphinx::params::PacketType; use nym_sphinx::receiver::{ReconstructedMessage, SphinxMessageReceiver}; use nym_task::connections::{ConnectionCommandReceiver, ConnectionCommandSender, LaneQueueLengths}; use nym_task::{TaskClient, TaskManager}; use nym_topology::provider_trait::TopologyProvider; -use rand::thread_rng; +use rand::rngs::OsRng; use std::sync::Arc; use tap::TapFallible; use url::Url; #[cfg(target_arch = "wasm32")] use nym_bandwidth_controller::wasm_mockups::DkgQueryClient; + #[cfg(not(target_arch = "wasm32"))] use nym_validator_client::nyxd::traits::DkgQueryClient; @@ -163,7 +165,7 @@ pub struct BaseClientBuilder<'a, C, S: MixnetClientStorage> { reply_storage_backend: S::ReplyStore, key_store: S::KeyStore, - custom_topology_provider: Option>, + custom_topology_provider: Option>, bandwidth_controller: Option>, managed_keys: ManagedKeys, } @@ -216,7 +218,10 @@ where } } - pub fn with_topology_provider(mut self, provider: Box) -> Self { + pub fn with_topology_provider( + mut self, + provider: Box, + ) -> Self { self.custom_topology_provider = Some(provider); self } @@ -271,6 +276,7 @@ where lane_queue_lengths: LaneQueueLengths, client_connection_rx: ConnectionCommandReceiver, shutdown: TaskClient, + packet_type: PacketType, ) { info!("Starting real traffic stream..."); @@ -286,7 +292,7 @@ where lane_queue_lengths, client_connection_rx, ) - .start_with_shutdown(shutdown); + .start_with_shutdown(shutdown, packet_type); } // buffer controlling all messages fetched from provider @@ -367,9 +373,9 @@ where } fn setup_topology_provider( - custom_provider: Option>, + custom_provider: Option>, nym_api_urls: Vec, - ) -> Box { + ) -> Box { // if no custom provider was ... provided ..., create one using nym-api custom_provider.unwrap_or_else(|| { Box::new(NymApiTopologyProvider::new( @@ -382,7 +388,7 @@ where // future responsible for periodically polling directory server and updating // the current global view of topology async fn start_topology_refresher( - topology_provider: Box, + topology_provider: Box, topology_config: config::Topology, topology_accessor: TopologyAccessor, mut shutdown: TaskClient, @@ -422,7 +428,7 @@ where Ok(()) } - // controller for sending sphinx packets to mixnet (either real traffic or cover traffic) + // controller for sending packets to mixnet (either real traffic or cover traffic) // TODO: if we want to send control messages to gateway_client, this CAN'T take the ownership // over it. Perhaps GatewayClient needs to be thread-shareable or have some channel for // requests? @@ -469,11 +475,14 @@ where async fn initial_key_setup(&mut self) { assert!(!self.managed_keys.is_valid()); - let mut rng = thread_rng(); + let mut rng = OsRng; self.managed_keys = ManagedKeys::load_or_generate(&mut rng, &self.key_store).await; } - pub async fn start_base(mut self) -> Result + pub async fn start_base( + mut self, + packet_type: PacketType, + ) -> Result where ::StorageError: Sync + Send, S::ReplyStore: Send + Sync, @@ -544,11 +553,11 @@ where task_manager.subscribe(), ); - // The sphinx_message_sender is the transmitter for any component generating sphinx packets + // The message_sender is the transmitter for any component generating sphinx packets // that are to be sent to the mixnet. They are used by cover traffic stream and real // traffic stream. // The MixTrafficController then sends the actual traffic - let sphinx_message_sender = + let message_sender = Self::start_mix_traffic_controller(gateway_client, task_manager.subscribe()); // Channels that the websocket listener can use to signal downstream to the real traffic @@ -570,13 +579,14 @@ where shared_topology_accessor.clone(), ack_receiver, input_receiver, - sphinx_message_sender.clone(), + message_sender.clone(), reply_storage, reply_controller_sender.clone(), reply_controller_receiver, shared_lane_queue_lengths.clone(), client_connection_rx, task_manager.subscribe(), + packet_type, ); if !self @@ -589,7 +599,7 @@ where self.managed_keys.ack_key(), self_address, shared_topology_accessor.clone(), - sphinx_message_sender, + message_sender, task_manager.subscribe(), ); } diff --git a/common/client-core/src/client/base_client/storage/mod.rs b/common/client-core/src/client/base_client/storage/mod.rs index e83efeee27..b9029d0850 100644 --- a/common/client-core/src/client/base_client/storage/mod.rs +++ b/common/client-core/src/client/base_client/storage/mod.rs @@ -12,10 +12,15 @@ use nym_credential_storage::ephemeral_storage::{ }; use nym_credential_storage::storage::Storage as CredentialStorage; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] +use crate::client::base_client::non_wasm_helpers; +#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] use crate::client::key_manager::persistence::OnDiskKeys; - -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] +use crate::config::{persistence::key_pathfinder::ClientKeyPathfinder, Config}; +#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] +use crate::error::ClientCoreError; +#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] use nym_credential_storage::persistent_storage::PersistentStorage as PersistentCredentialStorage; #[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] @@ -89,6 +94,26 @@ impl OnDiskPersistent { credential_store, } } + + pub async fn from_config(config: &Config) -> Result { + let pathfinder = ClientKeyPathfinder::new_from_config(config); + let key_store = OnDiskKeys::new(pathfinder); + + let reply_store = non_wasm_helpers::setup_fs_reply_surb_backend( + config.get_reply_surb_database_path(), + &config.get_debug_config().reply_surbs, + ) + .await?; + + let credential_store = + nym_credential_storage::initialise_persistent_storage(config.get_database_path()).await; + + Ok(OnDiskPersistent { + key_store, + reply_store, + credential_store, + }) + } } #[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))] diff --git a/common/client-core/src/client/cover_traffic_stream.rs b/common/client-core/src/client/cover_traffic_stream.rs index 41048a1461..19f549a52f 100644 --- a/common/client-core/src/client/cover_traffic_stream.rs +++ b/common/client-core/src/client/cover_traffic_stream.rs @@ -45,7 +45,7 @@ where #[cfg(target_arch = "wasm32")] next_delay: Pin>, - /// Channel used for sending prepared sphinx packets to `MixTrafficController` that sends them + /// Channel used for sending prepared nym packets to `MixTrafficController` that sends them /// out to the network without any further delays. mix_tx: BatchMixMessageSender, @@ -194,6 +194,7 @@ impl LoopCoverTrafficStream { self.average_ack_delay, self.cover_traffic.loop_cover_traffic_average_delay, cover_traffic_packet_size, + nym_sphinx::params::PacketType::Mix, ) .expect("Somehow failed to generate a loop cover message with a valid topology"); diff --git a/common/client-core/src/client/inbound_messages.rs b/common/client-core/src/client/inbound_messages.rs index 0a1e93c435..1530073d3f 100644 --- a/common/client-core/src/client/inbound_messages.rs +++ b/common/client-core/src/client/inbound_messages.rs @@ -4,6 +4,7 @@ use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; use nym_sphinx::forwarding::packet::MixPacket; +use nym_sphinx::params::PacketType; use nym_task::connections::TransmissionLane; pub type InputMessageSender = tokio::sync::mpsc::Sender; @@ -53,18 +54,49 @@ pub enum InputMessage { data: Vec, lane: TransmissionLane, }, + + MessageWrapper { + message: Box, + packet_type: PacketType, + }, } impl InputMessage { - pub fn new_premade(msgs: Vec, lane: TransmissionLane) -> Self { - InputMessage::Premade { msgs, lane } + pub fn new_premade( + msgs: Vec, + lane: TransmissionLane, + packet_type: PacketType, + ) -> Self { + let message = InputMessage::Premade { msgs, lane }; + if packet_type == PacketType::Mix { + message + } else { + InputMessage::new_wrapper(message, packet_type) + } } - pub fn new_regular(recipient: Recipient, data: Vec, lane: TransmissionLane) -> Self { - InputMessage::Regular { + pub fn new_wrapper(message: InputMessage, packet_type: PacketType) -> Self { + InputMessage::MessageWrapper { + message: Box::new(message), + packet_type, + } + } + + pub fn new_regular( + recipient: Recipient, + data: Vec, + lane: TransmissionLane, + packet_type: Option, + ) -> Self { + let message = InputMessage::Regular { recipient, data, lane, + }; + if let Some(packet_type) = packet_type { + InputMessage::new_wrapper(message, packet_type) + } else { + message } } @@ -73,12 +105,18 @@ impl InputMessage { data: Vec, reply_surbs: u32, lane: TransmissionLane, + packet_type: Option, ) -> Self { - InputMessage::Anonymous { + let message = InputMessage::Anonymous { recipient, data, reply_surbs, lane, + }; + if let Some(packet_type) = packet_type { + InputMessage::new_wrapper(message, packet_type) + } else { + message } } @@ -86,11 +124,17 @@ impl InputMessage { recipient_tag: AnonymousSenderTag, data: Vec, lane: TransmissionLane, + packet_type: Option, ) -> Self { - InputMessage::Reply { + let message = InputMessage::Reply { recipient_tag, data, lane, + }; + if let Some(packet_type) = packet_type { + InputMessage::new_wrapper(message, packet_type) + } else { + message } } @@ -100,6 +144,7 @@ impl InputMessage { | InputMessage::Anonymous { lane, .. } | InputMessage::Reply { lane, .. } | InputMessage::Premade { lane, .. } => lane, + InputMessage::MessageWrapper { message, .. } => message.lane(), } } } diff --git a/common/client-core/src/client/mix_traffic.rs b/common/client-core/src/client/mix_traffic.rs index 882b26684b..8e7f7ce2fb 100644 --- a/common/client-core/src/client/mix_traffic.rs +++ b/common/client-core/src/client/mix_traffic.rs @@ -40,15 +40,15 @@ where pub fn new( gateway_client: GatewayClient, ) -> (MixTrafficController, BatchMixMessageSender) { - let (sphinx_message_sender, sphinx_message_receiver) = + let (message_sender, message_receiver) = tokio::sync::mpsc::channel(MIX_MESSAGE_RECEIVER_BUFFER_SIZE); ( MixTrafficController { gateway_client, - mix_rx: sphinx_message_receiver, + mix_rx: message_receiver, consecutive_gateway_failure_count: 0, }, - sphinx_message_sender, + message_sender, ) } diff --git a/common/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs b/common/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs index 0034e00567..18d2959181 100644 --- a/common/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs +++ b/common/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs @@ -71,7 +71,7 @@ impl AcknowledgementListener { while !shutdown.is_shutdown() { tokio::select! { acks = self.ack_receiver.next() => match acks { - Some(acks) => self.handle_ack_receiver_item(acks).await, + Some(acks) => {self.handle_ack_receiver_item(acks).await} None => { log::trace!("AcknowledgementListener: Stopping since channel closed"); break; diff --git a/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs b/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs index 76f8918981..ab2eda1637 100644 --- a/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs +++ b/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs @@ -9,6 +9,7 @@ use log::*; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; use nym_sphinx::forwarding::packet::MixPacket; +use nym_sphinx::params::PacketType; use nym_task::connections::TransmissionLane; use rand::{CryptoRng, Rng}; @@ -71,10 +72,11 @@ where recipient: Recipient, content: Vec, lane: TransmissionLane, + packet_type: PacketType, ) { if let Err(err) = self .message_handler - .try_send_plain_message(recipient, content, lane) + .try_send_plain_message(recipient, content, lane, packet_type) .await { warn!("failed to send a plain message - {err}") @@ -87,10 +89,11 @@ where content: Vec, reply_surbs: u32, lane: TransmissionLane, + packet_type: PacketType, ) { if let Err(err) = self .message_handler - .try_send_message_with_reply_surbs(recipient, content, reply_surbs, lane) + .try_send_message_with_reply_surbs(recipient, content, reply_surbs, lane, packet_type) .await { warn!("failed to send a repliable message - {err}") @@ -103,14 +106,17 @@ where recipient, data, lane, - } => self.handle_plain_message(recipient, data, lane).await, + } => { + self.handle_plain_message(recipient, data, lane, PacketType::Mix) + .await + } InputMessage::Anonymous { recipient, data, reply_surbs, lane, } => { - self.handle_repliable_message(recipient, data, reply_surbs, lane) + self.handle_repliable_message(recipient, data, reply_surbs, lane, PacketType::Mix) .await } InputMessage::Reply { @@ -121,6 +127,40 @@ where self.handle_reply(recipient_tag, data, lane).await; } InputMessage::Premade { msgs, lane } => self.handle_premade_packets(msgs, lane).await, + InputMessage::MessageWrapper { + message, + packet_type, + } => match *message { + InputMessage::Regular { + recipient, + data, + lane, + } => { + self.handle_plain_message(recipient, data, lane, packet_type) + .await + } + InputMessage::Anonymous { + recipient, + data, + reply_surbs, + lane, + } => { + self.handle_repliable_message(recipient, data, reply_surbs, lane, packet_type) + .await + } + InputMessage::Reply { + recipient_tag, + data, + lane, + } => { + self.handle_reply(recipient_tag, data, lane).await; + } + InputMessage::Premade { msgs, lane } => { + self.handle_premade_packets(msgs, lane).await + } + // MessageWrappers can't be nested + InputMessage::MessageWrapper { .. } => unimplemented!(), + }, }; } diff --git a/common/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs b/common/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs index 1572465ed2..5f2bf6f80d 100644 --- a/common/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs +++ b/common/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs @@ -16,7 +16,7 @@ use futures::channel::mpsc; use log::*; use nym_gateway_client::AcknowledgementReceiver; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; -use nym_sphinx::params::PacketSize; +use nym_sphinx::params::{PacketSize, PacketType}; use nym_sphinx::{ acknowledgements::AckKey, addressing::clients::Recipient, @@ -249,7 +249,11 @@ where } } - pub(super) fn start_with_shutdown(self, shutdown: nym_task::TaskClient) { + pub(super) fn start_with_shutdown( + self, + shutdown: nym_task::TaskClient, + packet_type: PacketType, + ) { let mut acknowledgement_listener = self.acknowledgement_listener; let mut input_message_listener = self.input_message_listener; let mut retransmission_request_listener = self.retransmission_request_listener; @@ -275,7 +279,7 @@ where let shutdown_handle = shutdown.clone(); spawn_future(async move { retransmission_request_listener - .run_with_shutdown(shutdown_handle) + .run_with_shutdown(shutdown_handle, packet_type) .await; debug!("The retransmission request listener has finished execution!"); }); diff --git a/common/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs b/common/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs index 966130d1cb..abe1751284 100644 --- a/common/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs +++ b/common/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs @@ -11,9 +11,9 @@ use crate::client::real_messages_control::real_traffic_stream::RealMessage; use crate::client::replies::reply_controller::ReplyControllerSender; use futures::StreamExt; use log::*; -use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::chunking::fragment::Fragment; use nym_sphinx::preparer::PreparedFragment; +use nym_sphinx::{addressing::clients::Recipient, params::PacketType}; use nym_task::connections::TransmissionLane; use rand::{CryptoRng, Rng}; use std::sync::{Arc, Weak}; @@ -48,17 +48,20 @@ where &mut self, packet_recipient: Recipient, chunk_data: Fragment, + packet_type: PacketType, ) -> Result { debug!("retransmitting normal packet..."); + // TODO: Figure out retransmission packet type signaling self.message_handler - .try_prepare_single_chunk_for_sending(packet_recipient, chunk_data) + .try_prepare_single_chunk_for_sending(packet_recipient, chunk_data, packet_type) .await } async fn on_retransmission_request( &mut self, weak_timed_out_ack: Weak, + packet_type: PacketType, ) { let timed_out_ack = match weak_timed_out_ack.upgrade() { Some(timed_out_ack) => timed_out_ack, @@ -85,6 +88,7 @@ where self.prepare_normal_retransmission_chunk( **recipient, timed_out_ack.message_chunk.clone(), + packet_type, ) .await } @@ -140,13 +144,17 @@ where .await } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { + pub(super) async fn run_with_shutdown( + &mut self, + mut shutdown: nym_task::TaskClient, + packet_type: PacketType, + ) { debug!("Started RetransmissionRequestListener with graceful shutdown support"); while !shutdown.is_shutdown() { tokio::select! { timed_out_ack = self.request_receiver.next() => match timed_out_ack { - Some(timed_out_ack) => self.on_retransmission_request(timed_out_ack).await, + Some(timed_out_ack) => self.on_retransmission_request(timed_out_ack, packet_type).await, None => { log::trace!("RetransmissionRequestListener: Stopping since channel closed"); break; diff --git a/common/client-core/src/client/real_messages_control/message_handler.rs b/common/client-core/src/client/real_messages_control/message_handler.rs index 7658016017..a92ae58e90 100644 --- a/common/client-core/src/client/real_messages_control/message_handler.rs +++ b/common/client-core/src/client/real_messages_control/message_handler.rs @@ -15,7 +15,7 @@ use nym_sphinx::anonymous_replies::requests::{AnonymousSenderTag, RepliableMessa use nym_sphinx::anonymous_replies::{ReplySurb, SurbEncryptionKey}; use nym_sphinx::chunking::fragment::{Fragment, FragmentIdentifier}; use nym_sphinx::message::NymMessage; -use nym_sphinx::params::{PacketSize, DEFAULT_NUM_MIX_HOPS}; +use nym_sphinx::params::{PacketSize, PacketType, DEFAULT_NUM_MIX_HOPS}; use nym_sphinx::preparer::{MessagePreparer, PreparedFragment}; use nym_sphinx::Delay; use nym_task::connections::TransmissionLane; @@ -27,7 +27,7 @@ use std::time::Duration; use thiserror::Error; // TODO: move that error elsewhere since it seems to be contaminating different files -#[derive(Debug, Clone, Error)] +#[derive(Debug, Error)] pub enum PreparationError { #[error(transparent)] NymTopologyError(#[from] NymTopologyError), @@ -417,9 +417,10 @@ where recipient: Recipient, message: Vec, lane: TransmissionLane, + packet_type: PacketType, ) -> Result<(), PreparationError> { let message = NymMessage::new_plain(message); - self.try_split_and_send_non_reply_message(message, recipient, lane) + self.try_split_and_send_non_reply_message(message, recipient, lane, packet_type) .await } @@ -428,7 +429,9 @@ where message: NymMessage, recipient: Recipient, lane: TransmissionLane, + packet_type: PacketType, ) -> Result<(), PreparationError> { + debug!("Sending non-reply message with packet type {packet_type}"); // TODO: I really dislike existence of this assertion, it implies code has to be re-organised debug_assert!(!matches!(message, NymMessage::Reply(_))); @@ -436,7 +439,11 @@ where let topology_permit = self.topology_access.get_read_permit().await; let topology = self.get_topology(&topology_permit)?; - let packet_size = self.optimal_packet_size(&message); + let packet_size = if packet_type == PacketType::Outfox { + PacketSize::OutfoxRegularPacket + } else { + self.optimal_packet_size(&message) + }; debug!("Using {packet_size} packets for {message}"); let fragments = self .message_preparer @@ -453,6 +460,7 @@ where topology, &self.config.ack_key, &recipient, + packet_type, )?; let real_message = RealMessage::new( @@ -476,7 +484,9 @@ where &mut self, recipient: Recipient, amount: u32, + packet_type: PacketType, ) -> Result<(), PreparationError> { + debug!("Sending additional reply SURBs with packet type {packet_type}"); let sender_tag = self.get_or_create_sender_tag(&recipient); let (reply_surbs, reply_keys) = self.generate_reply_surbs_with_keys(amount as usize).await?; @@ -490,6 +500,7 @@ where message, recipient, TransmissionLane::AdditionalReplySurbs, + packet_type, ) .await?; @@ -505,7 +516,9 @@ where message: Vec, num_reply_surbs: u32, lane: TransmissionLane, + packet_type: PacketType, ) -> Result<(), SurbWrappedPreparationError> { + debug!("Sending message with reply SURBs with packet type {packet_type}"); let sender_tag = self.get_or_create_sender_tag(&recipient); let (reply_surbs, reply_keys) = self .generate_reply_surbs_with_keys(num_reply_surbs as usize) @@ -514,7 +527,7 @@ where let message = NymMessage::new_repliable(RepliableMessage::new_data(message, sender_tag, reply_surbs)); - self.try_split_and_send_non_reply_message(message, recipient, lane) + self.try_split_and_send_non_reply_message(message, recipient, lane, packet_type) .await?; log::trace!("storing {} reply keys", reply_keys.len()); @@ -527,13 +540,21 @@ where &mut self, recipient: Recipient, chunk: Fragment, + packet_type: PacketType, ) -> Result { + debug!("Sending single chunk with packet type {packet_type}"); let topology_permit = self.topology_access.get_read_permit().await; let topology = self.get_topology(&topology_permit)?; let prepared_fragment = self .message_preparer - .prepare_chunk_for_sending(chunk, topology, &self.config.ack_key, &recipient) + .prepare_chunk_for_sending( + chunk, + topology, + &self.config.ack_key, + &recipient, + packet_type, + ) .unwrap(); Ok(prepared_fragment) @@ -569,6 +590,7 @@ where topology, &self.config.ack_key, reply_surb, + PacketType::Mix, ) .unwrap() }) @@ -588,7 +610,13 @@ where let prepared_fragment = self .message_preparer - .prepare_reply_chunk_for_sending(chunk, topology, &self.config.ack_key, reply_surb) + .prepare_reply_chunk_for_sending( + chunk, + topology, + &self.config.ack_key, + reply_surb, + PacketType::Mix, + ) .unwrap(); Ok(prepared_fragment) diff --git a/common/client-core/src/client/real_messages_control/mod.rs b/common/client-core/src/client/real_messages_control/mod.rs index bfb3c0e1fc..32c913006d 100644 --- a/common/client-core/src/client/real_messages_control/mod.rs +++ b/common/client-core/src/client/real_messages_control/mod.rs @@ -26,6 +26,7 @@ use log::*; use nym_gateway_client::AcknowledgementReceiver; use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::addressing::clients::Recipient; +use nym_sphinx::params::PacketType; use nym_task::connections::{ConnectionCommandReceiver, LaneQueueLengths}; use rand::{rngs::OsRng, CryptoRng, Rng}; use std::sync::Arc; @@ -207,7 +208,7 @@ impl RealMessagesController { } } - pub fn start_with_shutdown(self, shutdown: nym_task::TaskClient) { + pub fn start_with_shutdown(self, shutdown: nym_task::TaskClient, packet_type: PacketType) { let mut out_queue_control = self.out_queue_control; let ack_control = self.ack_control; let mut reply_control = self.reply_control; @@ -223,6 +224,6 @@ impl RealMessagesController { debug!("The reply controller has finished execution!"); }); - ack_control.start_with_shutdown(shutdown); + ack_control.start_with_shutdown(shutdown, packet_type); } } diff --git a/common/client-core/src/client/real_messages_control/real_traffic_stream.rs b/common/client-core/src/client/real_messages_control/real_traffic_stream.rs index c7e5c80dfe..c0f9cce6aa 100644 --- a/common/client-core/src/client/real_messages_control/real_traffic_stream.rs +++ b/common/client-core/src/client/real_messages_control/real_traffic_stream.rs @@ -92,7 +92,7 @@ where // messages. sending_delay_controller: SendingDelayController, - /// Channel used for sending prepared sphinx packets to `MixTrafficController` that sends them + /// Channel used for sending prepared packets to `MixTrafficController` that sends them /// out to the network without any further delays. mix_tx: BatchMixMessageSender, @@ -136,7 +136,7 @@ impl From for RealMessage { impl RealMessage { pub(crate) fn packet_size(&self) -> usize { - self.mix_packet.sphinx_packet().len() + self.mix_packet.packet().len() } pub(crate) fn new(mix_packet: MixPacket, fragment_id: Option) -> Self { @@ -247,6 +247,7 @@ where self.config.average_ack_delay, self.config.traffic.average_packet_delay, cover_traffic_packet_size, + self.config.traffic.packet_type.unwrap_or_default(), ) .expect( "Somehow failed to generate a loop cover message with a valid topology", @@ -386,7 +387,7 @@ where // On every iteration we get new messages from upstream. Given that these come bunched // in `Vec`, this ensures that on average we will fetch messages faster than we can - // send, which is a condition for being able to multiplex sphinx packets from multiple + // send, which is a condition for being able to multiplex packets from multiple // data streams. match Pin::new(&mut self.real_receiver).poll_recv(cx) { // in the case our real message channel stream was closed, we should also indicate we are closed diff --git a/common/client-core/src/client/replies/reply_controller/mod.rs b/common/client-core/src/client/replies/reply_controller/mod.rs index 21e1f5a9d1..0e5a5a0ae9 100644 --- a/common/client-core/src/client/replies/reply_controller/mod.rs +++ b/common/client-core/src/client/replies/reply_controller/mod.rs @@ -512,7 +512,11 @@ where let to_send = min(remaining, 100); if let Err(err) = self .message_handler - .try_send_additional_reply_surbs(recipient, to_send) + .try_send_additional_reply_surbs( + recipient, + to_send, + nym_sphinx::params::PacketType::Mix, + ) .await { warn!("failed to send additional surbs to {recipient} - {err}"); diff --git a/common/client-core/src/client/topology_control/mod.rs b/common/client-core/src/client/topology_control/mod.rs index 168767cd3e..0fef523b1e 100644 --- a/common/client-core/src/client/topology_control/mod.rs +++ b/common/client-core/src/client/topology_control/mod.rs @@ -26,7 +26,7 @@ impl TopologyRefresherConfig { } pub struct TopologyRefresher { - topology_provider: Box, + topology_provider: Box, topology_accessor: TopologyAccessor, refresh_rate: Duration, @@ -37,7 +37,7 @@ impl TopologyRefresher { pub fn new( cfg: TopologyRefresherConfig, topology_accessor: TopologyAccessor, - topology_provider: Box, + topology_provider: Box, ) -> Self { TopologyRefresher { topology_provider, @@ -47,7 +47,7 @@ impl TopologyRefresher { } } - pub fn change_topology_provider(&mut self, provider: Box) { + pub fn change_topology_provider(&mut self, provider: Box) { self.topology_provider = provider; } diff --git a/common/client-core/src/client/transmission_buffer.rs b/common/client-core/src/client/transmission_buffer.rs index 5423cc57a6..65c0e23976 100644 --- a/common/client-core/src/client/transmission_buffer.rs +++ b/common/client-core/src/client/transmission_buffer.rs @@ -28,7 +28,7 @@ impl SizedData for RealMessage { impl SizedData for Fragment { fn data_size(&self) -> usize { - // note that raw `Fragment` is smaller than sphinx packet payload + // note that raw `Fragment` is smaller than packet payload // as it doesn't include surb-ack or the [shared] key materials self.payload_size() } diff --git a/common/client-core/src/config/mod.rs b/common/client-core/src/config/mod.rs index d1ee728a26..bd919d3a37 100644 --- a/common/client-core/src/config/mod.rs +++ b/common/client-core/src/config/mod.rs @@ -4,10 +4,10 @@ use nym_config::defaults::NymNetworkDetails; use nym_config::{NymConfig, OptionalSet, CRED_DB_FILE_NAME}; use nym_crypto::asymmetric::identity; -use nym_sphinx::params::PacketSize; +use nym_sphinx::params::{PacketSize, PacketType}; use serde::{Deserialize, Serialize}; use std::marker::PhantomData; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::Duration; use url::Url; @@ -18,6 +18,15 @@ use wasm_bindgen::prelude::*; pub mod old_config_v1_1_13; pub mod persistence; +pub const DEFAULT_PRIVATE_IDENTITY_KEY_FILENAME: &str = "private_identity.pem"; +pub const DEFAULT_PUBLIC_IDENTITY_KEY_FILENAME: &str = "public_identity.pem"; +pub const DEFAULT_PRIVATE_ENCRYPTION_KEY_FILENAME: &str = "private_encryption.pem"; +pub const DEFAULT_PUBLIC_ENCRYPTION_KEY_FILENAME: &str = "public_encryption.pem"; +pub const DEFAULT_GATEWAY_KEYS_FILENAME: &str = "gateway_shared.pem"; +pub const DEFAULT_ACK_KEY_FILENAME: &str = "ack_key.pem"; +pub const DEFAULT_REPLY_STORE_FILENAME: &str = "persistent_reply_store.sqlite"; +pub const DEFAULT_CREDENTIAL_STORE_FILENAME: &str = CRED_DB_FILE_NAME; + pub const MISSING_VALUE: &str = "MISSING VALUE"; // 'DEBUG' @@ -109,6 +118,37 @@ impl Config { self } + #[must_use] + #[doc(hidden)] + // TODO: this totally contradicts our trait... we REALLY have to refactor it... + pub fn reset_data_directory>(mut self, dir: P) -> Self { + self.client.private_identity_key_file = + dir.as_ref().join(DEFAULT_PRIVATE_IDENTITY_KEY_FILENAME); + self.client.public_identity_key_file = + dir.as_ref().join(DEFAULT_PUBLIC_IDENTITY_KEY_FILENAME); + self.client.private_encryption_key_file = + dir.as_ref().join(DEFAULT_PRIVATE_ENCRYPTION_KEY_FILENAME); + self.client.public_encryption_key_file = + dir.as_ref().join(DEFAULT_PUBLIC_ENCRYPTION_KEY_FILENAME); + self.client.gateway_shared_key_file = dir.as_ref().join(DEFAULT_GATEWAY_KEYS_FILENAME); + self.client.ack_key_file = dir.as_ref().join(DEFAULT_ACK_KEY_FILENAME); + self.client.reply_surb_database_path = dir.as_ref().join(DEFAULT_REPLY_STORE_FILENAME); + self.client.database_path = dir.as_ref().join(DEFAULT_CREDENTIAL_STORE_FILENAME); + + self + } + + #[must_use] + #[doc(hidden)] + // TODO: this totally contradicts our trait... we REALLY have to refactor it... + pub fn reset_nym_root_directory>(mut self, dir: P) -> Self + where + T: NymConfig, + { + self.client.nym_root_directory = dir.as_ref().to_owned(); + self + } + pub fn set_empty_fields_to_defaults(&mut self) -> bool where T: NymConfig, @@ -219,6 +259,11 @@ impl Config { self } + pub fn with_packet_type(mut self, packet_type: PacketType) -> Self { + self.client.packet_type = Some(packet_type); + self + } + pub fn set_high_default_traffic_volume(&mut self) { self.debug.traffic.average_packet_delay = Duration::from_millis(10); // basically don't really send cover messages @@ -406,6 +451,10 @@ impl Config { pub fn get_maximum_reply_key_age(&self) -> Duration { self.debug.reply_surbs.maximum_reply_key_age } + + pub fn get_packet_type(&self) -> PacketType { + self.client.packet_type.unwrap_or(PacketType::Mix) + } } impl Default for Config { @@ -528,6 +577,8 @@ pub struct Client { #[serde(skip)] pub super_struct: PhantomData, + + pub packet_type: Option, } impl Default for Client { @@ -566,6 +617,7 @@ impl Default for Client { reply_surb_database_path: Default::default(), nym_root_directory: T::default_root_directory(), super_struct: Default::default(), + packet_type: Default::default(), } } } @@ -637,6 +689,8 @@ pub struct Traffic { /// Note that its use decreases overall anonymity. /// Do not set it it unless you understand the consequences of that change. pub secondary_packet_size: Option, + + pub packet_type: Option, } impl Traffic { @@ -660,6 +714,7 @@ impl Default for Traffic { disable_main_poisson_packet_distribution: false, primary_packet_size: PacketSize::RegularPacket, secondary_packet_size: None, + packet_type: None, } } } diff --git a/common/client-core/src/config/old_config_v1_1_13.rs b/common/client-core/src/config/old_config_v1_1_13.rs index ee01616564..9c06f885b0 100644 --- a/common/client-core/src/config/old_config_v1_1_13.rs +++ b/common/client-core/src/config/old_config_v1_1_13.rs @@ -125,6 +125,7 @@ impl From for DebugConfig { .disable_main_poisson_packet_distribution, primary_packet_size: PacketSize::RegularPacket, secondary_packet_size: value.use_extended_packet_size.map(Into::into), + packet_type: None, }, cover_traffic: CoverTraffic { loop_cover_traffic_average_delay: value.loop_cover_traffic_average_delay, @@ -210,8 +211,8 @@ impl From> for Config { database_path: value.client.database_path, reply_surb_database_path: value.client.reply_surb_database_path, nym_root_directory: value.client.nym_root_directory, - super_struct: PhantomData, + packet_type: Some(nym_sphinx::params::PacketType::Mix), }, logging: value.logging, debug: value.debug.into(), diff --git a/common/client-core/src/config/persistence/key_pathfinder.rs b/common/client-core/src/config/persistence/key_pathfinder.rs index fc2db82522..135b8f61da 100644 --- a/common/client-core/src/config/persistence/key_pathfinder.rs +++ b/common/client-core/src/config/persistence/key_pathfinder.rs @@ -40,11 +40,17 @@ impl ClientKeyPathfinder { } pub fn identity_key_pair_path(&self) -> nym_pemstore::KeyPairPath { - nym_pemstore::KeyPairPath::new(self.private_identity_key(), self.public_identity_key()) + nym_pemstore::KeyPairPath::new( + self.private_identity_key().to_path_buf(), + self.public_identity_key().to_path_buf(), + ) } pub fn encryption_key_pair_path(&self) -> nym_pemstore::KeyPairPath { - nym_pemstore::KeyPairPath::new(self.private_encryption_key(), self.public_encryption_key()) + nym_pemstore::KeyPairPath::new( + self.private_encryption_key().to_path_buf(), + self.public_encryption_key().to_path_buf(), + ) } pub fn any_file_exists(&self) -> bool { diff --git a/common/client-core/src/init/mod.rs b/common/client-core/src/init/mod.rs index 028dd2388e..27cab34fb4 100644 --- a/common/client-core/src/init/mod.rs +++ b/common/client-core/src/init/mod.rs @@ -19,9 +19,8 @@ use nym_crypto::asymmetric::{encryption, identity}; use nym_sphinx::addressing::{clients::Recipient, nodes::NodeIdentity}; use nym_validator_client::client::IdentityKey; use rand::rngs::OsRng; -use rand::thread_rng; use serde::Serialize; -use std::fmt::Display; +use std::fmt::{Debug, Display}; use tap::TapFallible; use url::Url; @@ -85,7 +84,7 @@ impl GatewaySetup { ) -> Result { match self { GatewaySetup::New { by_latency } => { - let mut rng = thread_rng(); + let mut rng = OsRng; let gateways = current_gateways(&mut rng, validator_servers).await?; if by_latency { choose_gateway_by_latency(&mut rng, gateways).await @@ -98,7 +97,7 @@ impl GatewaySetup { let user_gateway = identity::PublicKey::from_base58_string(&gateway_identity) .map_err(ClientCoreError::UnableToCreatePublicKeyFromGatewayId)?; - let mut rng = thread_rng(); + let mut rng = OsRng; let gateways = current_gateways(&mut rng, validator_servers).await?; gateways .into_iter() @@ -161,7 +160,7 @@ where S: MixnetClientStorage, ::StorageError: Send + Sync + 'static, { - let mut rng = rand::thread_rng(); + let mut rng = OsRng; // try load keys let mut managed_keys = match ManagedKeys::try_load(key_store).await { diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index c964dbe2d2..2baf5718c0 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -571,7 +571,7 @@ impl GatewayClient { fn estimate_required_bandwidth(&self, packets: &[MixPacket]) -> i64 { packets .iter() - .map(|packet| packet.sphinx_packet().len()) + .map(|packet| packet.packet().len()) .sum::() as i64 } @@ -579,6 +579,8 @@ impl GatewayClient { &mut self, packets: Vec, ) -> Result<(), GatewayClientError> { + debug!("Sending {} mix packets", packets.len()); + if !self.authenticated { return Err(GatewayClientError::NotAuthenticated); } @@ -623,9 +625,10 @@ impl GatewayClient { ) -> Result<(), GatewayClientError> { if let Err(err) = self.send_websocket_message_without_response(msg).await { if err.is_closed_connection() && self.should_reconnect_on_failure { - info!("Going to attempt a reconnection"); + debug!("Going to attempt a reconnection"); self.attempt_reconnection().await } else { + warn!("{err}"); Err(err) } } else { @@ -652,9 +655,9 @@ impl GatewayClient { if !self.authenticated { return Err(GatewayClientError::NotAuthenticated); } - if (mix_packet.sphinx_packet().len() as i64) > self.bandwidth_remaining { + if (mix_packet.packet().len() as i64) > self.bandwidth_remaining { return Err(GatewayClientError::NotEnoughBandwidth( - mix_packet.sphinx_packet().len() as i64, + mix_packet.packet().len() as i64, self.bandwidth_remaining, )); } diff --git a/common/client-libs/gateway-client/src/packet_router.rs b/common/client-libs/gateway-client/src/packet_router.rs index c758abcc19..0b4a99f1c2 100644 --- a/common/client-libs/gateway-client/src/packet_router.rs +++ b/common/client-libs/gateway-client/src/packet_router.rs @@ -50,10 +50,15 @@ impl PacketRouter { let ack_overhead = PacketSize::AckPacket.size() + MAX_NODE_ADDRESS_UNPADDED_LEN; for received_packet in unwrapped_packets { - if received_packet.len() == PacketSize::AckPacket.plaintext_size() { + if received_packet.len() == PacketSize::AckPacket.plaintext_size() + || received_packet.len() == PacketSize::OutfoxAckPacket.plaintext_size() + { received_acks.push(received_packet); } else if received_packet.len() == PacketSize::RegularPacket.plaintext_size() - ack_overhead + || received_packet.len() + == PacketSize::OutfoxRegularPacket.plaintext_size() - ack_overhead + || received_packet.len() == PacketSize::OutfoxRegularPacket.size() - 6 { trace!("routing regular packet"); received_messages.push(received_packet); diff --git a/common/client-libs/mixnet-client/src/client.rs b/common/client-libs/mixnet-client/src/client.rs index 62e37bca90..4da308144f 100644 --- a/common/client-libs/mixnet-client/src/client.rs +++ b/common/client-libs/mixnet-client/src/client.rs @@ -4,10 +4,11 @@ use futures::channel::mpsc; use futures::StreamExt; use log::*; -use nym_sphinx::framing::codec::SphinxCodec; -use nym_sphinx::framing::packet::FramedSphinxPacket; -use nym_sphinx::params::PacketMode; -use nym_sphinx::{addressing::nodes::NymNodeRoutingAddress, SphinxPacket}; +use nym_sphinx::addressing::nodes::NymNodeRoutingAddress; +use nym_sphinx::framing::codec::NymCodec; +use nym_sphinx::framing::packet::FramedNymPacket; +use nym_sphinx::params::PacketType; +use nym_sphinx::NymPacket; use std::collections::HashMap; use std::io; use std::net::SocketAddr; @@ -50,8 +51,8 @@ pub trait SendWithoutResponse { fn send_without_response( &mut self, address: NymNodeRoutingAddress, - packet: SphinxPacket, - packet_mode: PacketMode, + packet: NymPacket, + packet_type: PacketType, ) -> io::Result<()>; } @@ -61,12 +62,12 @@ pub struct Client { } struct ConnectionSender { - channel: mpsc::Sender, + channel: mpsc::Sender, current_reconnection_attempt: Arc, } impl ConnectionSender { - fn new(channel: mpsc::Sender) -> Self { + fn new(channel: mpsc::Sender) -> Self { ConnectionSender { channel, current_reconnection_attempt: Arc::new(AtomicU32::new(0)), @@ -84,7 +85,7 @@ impl Client { async fn manage_connection( address: SocketAddr, - receiver: mpsc::Receiver, + receiver: mpsc::Receiver, connection_timeout: Duration, current_reconnection: &AtomicU32, ) { @@ -96,7 +97,7 @@ impl Client { debug!("Managed to establish connection to {}", address); // if we managed to connect, reset the reconnection count (whatever it might have been) current_reconnection.store(0, Ordering::Release); - Framed::new(stream, SphinxCodec) + Framed::new(stream, NymCodec) } Err(err) => { debug!( @@ -148,11 +149,7 @@ impl Client { } } - fn make_connection( - &mut self, - address: NymNodeRoutingAddress, - pending_packet: FramedSphinxPacket, - ) { + fn make_connection(&mut self, address: NymNodeRoutingAddress, pending_packet: FramedNymPacket) { let (mut sender, receiver) = mpsc::channel(self.config.maximum_connection_buffer_size); // this CAN'T fail because we just created the channel which has a non-zero capacity @@ -200,12 +197,12 @@ impl SendWithoutResponse for Client { fn send_without_response( &mut self, address: NymNodeRoutingAddress, - packet: SphinxPacket, - packet_mode: PacketMode, + packet: NymPacket, + packet_type: PacketType, ) -> io::Result<()> { trace!("Sending packet to {:?}", address); let framed_packet = - FramedSphinxPacket::new(packet, packet_mode, self.config.use_legacy_version); + FramedNymPacket::new(packet, packet_type, self.config.use_legacy_version); if let Some(sender) = self.conn_new.get_mut(&address) { if let Err(err) = sender.channel.try_send(framed_packet) { diff --git a/common/client-libs/mixnet-client/src/forwarder.rs b/common/client-libs/mixnet-client/src/forwarder.rs index cefae1fc30..8bbf5a47f6 100644 --- a/common/client-libs/mixnet-client/src/forwarder.rs +++ b/common/client-libs/mixnet-client/src/forwarder.rs @@ -59,14 +59,14 @@ impl PacketForwarder { trace!("Going to forward packet to {:?}", mix_packet.next_hop()); let next_hop = mix_packet.next_hop(); - let packet_mode = mix_packet.packet_mode(); - let sphinx_packet = mix_packet.into_sphinx_packet(); + let packet_type = mix_packet.packet_type(); + let packet = mix_packet.into_packet(); // we don't care about responses, we just want to fire packets // as quickly as possible if let Err(err) = self.mixnet_client - .send_without_response(next_hop, sphinx_packet, packet_mode) + .send_without_response(next_hop, packet, packet_type) { debug!("failed to forward the packet - {err}") } diff --git a/common/client-libs/validator-client/src/nym_api/mod.rs b/common/client-libs/validator-client/src/nym_api/mod.rs index a98ce62754..283f12d4a7 100644 --- a/common/client-libs/validator-client/src/nym_api/mod.rs +++ b/common/client-libs/validator-client/src/nym_api/mod.rs @@ -15,7 +15,8 @@ use nym_api_requests::models::{ }; use nym_mixnet_contract_common::mixnode::MixNodeDetails; use nym_mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixId}; -use nym_service_provider_directory_common::ServiceInfo; +use nym_name_service_common::response::NamesListResponse; +use nym_service_provider_directory_common::response::ServicesListResponse; use reqwest::{Response, StatusCode}; use serde::{Deserialize, Serialize}; use url::Url; @@ -484,10 +485,18 @@ impl Client { .await } - pub async fn get_service_providers(&self) -> Result, NymAPIError> { + pub async fn get_service_providers(&self) -> Result { + log::trace!("Getting service providers"); self.query_nym_api(&[routes::API_VERSION, routes::SERVICE_PROVIDERS], NO_PARAMS) .await } + + //pub async fn get_registered_names(&self) -> Result, NymAPIError> { + pub async fn get_registered_names(&self) -> Result { + log::trace!("Getting registered names"); + self.query_nym_api(&[routes::API_VERSION, routes::REGISTERED_NAMES], NO_PARAMS) + .await + } } // utility function that should solve the double slash problem in validator API forever. diff --git a/common/client-libs/validator-client/src/nym_api/routes.rs b/common/client-libs/validator-client/src/nym_api/routes.rs index 12722757dc..fd97047b6a 100644 --- a/common/client-libs/validator-client/src/nym_api/routes.rs +++ b/common/client-libs/validator-client/src/nym_api/routes.rs @@ -33,4 +33,5 @@ pub const AVG_UPTIME: &str = "avg_uptime"; pub const STAKE_SATURATION: &str = "stake-saturation"; pub const INCLUSION_CHANCE: &str = "inclusion-probability"; -pub const SERVICE_PROVIDERS: &str = "service-providers"; +pub const SERVICE_PROVIDERS: &str = "services"; +pub const REGISTERED_NAMES: &str = "names"; diff --git a/common/client-libs/validator-client/src/nyxd/mod.rs b/common/client-libs/validator-client/src/nyxd/mod.rs index 14445f9951..0d90eb2387 100644 --- a/common/client-libs/validator-client/src/nyxd/mod.rs +++ b/common/client-libs/validator-client/src/nyxd/mod.rs @@ -16,7 +16,7 @@ use cosmrs::rpc::query::Query; use cosmrs::rpc::Error as TendermintRpcError; use cosmrs::rpc::HttpClientUrl; use cosmrs::tx::Msg; -use log::debug; +use log::{debug, trace}; use nym_network_defaults::{ChainDetails, NymNetworkDetails}; use serde::{Deserialize, Serialize}; use std::convert::TryInto; @@ -79,8 +79,8 @@ impl Config { expected_prefix: &str, ) -> Result, NyxdError> { if let Some(address) = raw { - debug!("Raw address:{:?}", raw); - debug!("Expected prefix:{:?}", expected_prefix); + trace!("Raw address:{:?}", raw); + trace!("Expected prefix:{:?}", expected_prefix); let parsed: AccountId = address .parse() .map_err(|_| NyxdError::MalformedAccountAddress(address.clone()))?; diff --git a/common/commands/Cargo.toml b/common/commands/Cargo.toml index 573be92526..baf6016df3 100644 --- a/common/commands/Cargo.toml +++ b/common/commands/Cargo.toml @@ -39,3 +39,4 @@ nym-coconut-bandwidth-contract-common = { path = "../cosmwasm-smart-contracts/co nym-coconut-dkg-common = { path = "../cosmwasm-smart-contracts/coconut-dkg" } nym-multisig-contract-common = { path = "../cosmwasm-smart-contracts/multisig-contract" } nym-service-provider-directory-common = { path = "../cosmwasm-smart-contracts/service-provider-directory" } +nym-name-service-common = { path = "../cosmwasm-smart-contracts/name-service" } diff --git a/common/commands/src/validator/mixnet/operators/mod.rs b/common/commands/src/validator/mixnet/operators/mod.rs index aa8af7d314..fa92fb5518 100644 --- a/common/commands/src/validator/mixnet/operators/mod.rs +++ b/common/commands/src/validator/mixnet/operators/mod.rs @@ -5,6 +5,7 @@ use clap::{Args, Subcommand}; pub mod gateway; pub mod mixnode; +pub mod name; pub mod service; #[derive(Debug, Args)] @@ -22,4 +23,6 @@ pub enum MixnetOperatorsCommands { Gateway(gateway::MixnetOperatorsGateway), /// Manage your service ServiceProvider(service::MixnetOperatorsService), + /// Manage your registered name + Name(name::MixnetOperatorsName), } diff --git a/common/commands/src/validator/mixnet/operators/name/delete.rs b/common/commands/src/validator/mixnet/operators/name/delete.rs new file mode 100644 index 0000000000..558dbf190c --- /dev/null +++ b/common/commands/src/validator/mixnet/operators/name/delete.rs @@ -0,0 +1,25 @@ +use clap::Parser; +use log::{error, info}; +use nym_name_service_common::NameId; +use nym_validator_client::nyxd::{error::NyxdError, traits::NameServiceSigningClient}; +use tap::TapFallible; + +use crate::context::SigningClient; + +#[derive(Debug, Parser)] +pub struct Args { + #[clap(long)] + pub id: NameId, +} + +pub async fn delete(args: Args, client: SigningClient) -> Result<(), NyxdError> { + info!("Deleting registered name alias with id {}", args.id); + + let res = client + .delete_name_by_id(args.id, None) + .await + .tap_err(|err| error!("Failed to delete name: {err:#?}"))?; + + info!("Deleted: {res:?}"); + Ok(()) +} diff --git a/common/commands/src/validator/mixnet/operators/name/mod.rs b/common/commands/src/validator/mixnet/operators/name/mod.rs new file mode 100644 index 0000000000..a1e2733ac5 --- /dev/null +++ b/common/commands/src/validator/mixnet/operators/name/mod.rs @@ -0,0 +1,19 @@ +use clap::{Args, Subcommand}; + +pub mod delete; +pub mod register; + +#[derive(Debug, Args)] +#[clap(args_conflicts_with_subcommands = true, subcommand_required = true)] +pub struct MixnetOperatorsName { + #[clap(subcommand)] + pub command: MixnetOperatorsNameCommands, +} + +#[derive(Debug, Subcommand)] +pub enum MixnetOperatorsNameCommands { + /// Register a name alias for a nym address + Register(register::Args), + /// Delete name alias for a nym address + Delete(delete::Args), +} diff --git a/common/commands/src/validator/mixnet/operators/name/register.rs b/common/commands/src/validator/mixnet/operators/name/register.rs new file mode 100644 index 0000000000..6458faf8a6 --- /dev/null +++ b/common/commands/src/validator/mixnet/operators/name/register.rs @@ -0,0 +1,43 @@ +use clap::Parser; +use log::{error, info}; +use nym_name_service_common::{Address, Coin, NymName}; +use nym_validator_client::nyxd::{error::NyxdError, traits::NameServiceSigningClient}; +use tap::TapFallible; + +use crate::context::SigningClient; + +#[derive(Debug, Parser)] +pub struct Args { + /// Name alias + #[clap(long)] + pub name: String, + + /// Nym address that the alias is pointing to + #[clap(long)] + pub nym_address: String, + + /// Deposit to be made to the service provider directory, in curent DENOMINATION (e.g. 'unym') + #[clap(long)] + pub deposit: u128, +} + +pub async fn register(args: Args, client: SigningClient) -> Result<(), NyxdError> { + info!( + "Registering name alias '{}' for nym address '{}'", + args.name, args.nym_address + ); + + let name = NymName::new(&args.name).expect("invalid name"); + let address = Address::new(&args.nym_address); + + let denom = client.current_chain_details().mix_denom.base.as_str(); + let deposit = Coin::new(args.deposit, denom); + + let res = client + .register_name(name, address, deposit.into(), None) + .await + .tap_err(|err| error!("Failed to register name: {err:#?}"))?; + + info!("Registered name: {res:?}"); + Ok(()) +} diff --git a/common/commands/src/validator/mixnet/query/mod.rs b/common/commands/src/validator/mixnet/query/mod.rs index 79481a728a..2a6c04c312 100644 --- a/common/commands/src/validator/mixnet/query/mod.rs +++ b/common/commands/src/validator/mixnet/query/mod.rs @@ -5,6 +5,7 @@ use clap::{Args, Subcommand}; pub mod query_all_gateways; pub mod query_all_mixnodes; +pub mod query_all_names; pub mod query_all_service_providers; #[derive(Debug, Args)] @@ -22,4 +23,6 @@ pub enum MixnetQueryCommands { Gateways(query_all_gateways::Args), /// Query announced service-providers ServiceProviders(query_all_service_providers::Args), + /// Query registed names + Names(query_all_names::Args), } diff --git a/common/commands/src/validator/mixnet/query/query_all_names.rs b/common/commands/src/validator/mixnet/query/query_all_names.rs new file mode 100644 index 0000000000..e3bb24ebae --- /dev/null +++ b/common/commands/src/validator/mixnet/query/query_all_names.rs @@ -0,0 +1,53 @@ +// Copyright 2023 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use clap::Parser; +use comfy_table::Table; +use nym_validator_client::nym_api::error::NymAPIError; + +use crate::context::QueryClientWithNyxd; +use crate::utils::show_error; + +#[derive(Debug, Parser)] +pub struct Args { + #[clap(value_parser)] + #[clap(help = "Optionally, the registered name to display")] + pub name: Option, +} + +pub async fn query(args: Args, client: &QueryClientWithNyxd) { + log::trace!("Querying all registered names"); + + match client.nym_api.get_registered_names().await { + Ok(res) => { + if let Some(name) = args.name { + let name = res.names.iter().find(|name_entry| { + name_entry.name.name.to_string().eq_ignore_ascii_case(&name) + }); + println!( + "{}", + ::serde_json::to_string_pretty(&name).expect("json formatting error") + ); + } else { + let mut table = Table::new(); + + table.set_header(vec!["Name Id", "Owner", "Nym Address", "Name"]); + for name_entry in res.names { + table.add_row(vec![ + name_entry.name_id.to_string(), + name_entry.name.owner.to_string(), + name_entry.name.address.to_string(), + name_entry.name.name.to_string(), + ]); + } + + println!("The registered names in the directory are:"); + println!("{table}"); + } + } + Err(NymAPIError::NotFound) => { + println!("nym-api reports no name endpoint available"); + } + Err(e) => show_error(e), + } +} diff --git a/common/commands/src/validator/mixnet/query/query_all_service_providers.rs b/common/commands/src/validator/mixnet/query/query_all_service_providers.rs index d3cb805d38..f803078eb8 100644 --- a/common/commands/src/validator/mixnet/query/query_all_service_providers.rs +++ b/common/commands/src/validator/mixnet/query/query_all_service_providers.rs @@ -19,7 +19,7 @@ pub async fn query(args: Args, client: &QueryClientWithNyxd) { match client.nym_api.get_service_providers().await { Ok(res) => { if let Some(nym_address) = args.nym_address { - let service = res.iter().find(|service| { + let service = res.services.iter().find(|service| { service .service .nym_address @@ -33,8 +33,8 @@ pub async fn query(args: Args, client: &QueryClientWithNyxd) { } else { let mut table = Table::new(); - table.set_header(vec!["Service Id", "Announcer", "Nym Address"]); - for service in res { + table.set_header(vec!["Service Id", "Announcer", "Type", "Nym Address"]); + for service in res.services { table.add_row(vec![ service.service_id.to_string(), service.service.announcer.to_string(), diff --git a/common/config/src/lib.rs b/common/config/src/lib.rs index 4d38e55467..030a991bfc 100644 --- a/common/config/src/lib.rs +++ b/common/config/src/lib.rs @@ -10,7 +10,7 @@ use std::any::type_name; use std::fmt::Debug; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::str::FromStr; use std::{fs, io}; @@ -31,17 +31,29 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned { // default, most probable, implementations; can be easily overridden where required fn default_config_directory(id: &str) -> PathBuf { - Self::default_root_directory().join(id).join(CONFIG_DIR) + Self::default_config_directory_with_root(Self::default_root_directory(), id) + } + + fn default_config_directory_with_root>(root: P, id: &str) -> PathBuf { + root.as_ref().join(id).join(CONFIG_DIR) } fn default_data_directory(id: &str) -> PathBuf { - Self::default_root_directory().join(id).join(DATA_DIR) + Self::default_data_directory_with_root(Self::default_root_directory(), id) + } + + fn default_data_directory_with_root>(root: P, id: &str) -> PathBuf { + root.as_ref().join(id).join(DATA_DIR) } fn default_config_file_path(id: &str) -> PathBuf { Self::default_config_directory(id).join(Self::config_file_name()) } + fn default_config_file_path_with_root>(root: P, id: &str) -> PathBuf { + Self::default_config_directory_with_root(root, id).join(Self::config_file_name()) + } + // We provide a second set of functions that tries to not panic. fn try_default_root_directory() -> Option; @@ -99,8 +111,12 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned { fn load_from_file(id: &str) -> io::Result { let file = Self::default_config_file_path(id); - log::trace!("Loading from file: {:#?}", file); - let config_contents = fs::read_to_string(file)?; + Self::load_from_filepath(file) + } + + fn load_from_filepath>(filepath: P) -> io::Result { + log::trace!("Loading from file: {:#?}", filepath.as_ref().to_owned()); + let config_contents = fs::read_to_string(filepath)?; toml::from_str(&config_contents) .map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err)) diff --git a/common/cosmwasm-smart-contracts/multisig-contract/Cargo.toml b/common/cosmwasm-smart-contracts/multisig-contract/Cargo.toml index a9b038530e..2a6753267e 100644 --- a/common/cosmwasm-smart-contracts/multisig-contract/Cargo.toml +++ b/common/cosmwasm-smart-contracts/multisig-contract/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" [dependencies] cw-utils = { workspace = true } cw3 = { workspace = true } -cw3-fixed-multisig = { workspace = true, features = ["library"] } cw4 = { workspace= true } cw-storage-plus = { workspace = true } cosmwasm-schema = { workspace = true } diff --git a/common/cosmwasm-smart-contracts/name-service/src/lib.rs b/common/cosmwasm-smart-contracts/name-service/src/lib.rs index f456db01aa..4609473c60 100644 --- a/common/cosmwasm-smart-contracts/name-service/src/lib.rs +++ b/common/cosmwasm-smart-contracts/name-service/src/lib.rs @@ -5,3 +5,5 @@ pub mod types; // Re-export all types at the top-level pub use types::*; + +pub use cosmwasm_std::{Addr, Coin, Decimal, Fraction}; diff --git a/common/mixnode-common/src/packet_processor/error.rs b/common/mixnode-common/src/packet_processor/error.rs index 99d3a2d2f2..9c0c1e5ab0 100644 --- a/common/mixnode-common/src/packet_processor/error.rs +++ b/common/mixnode-common/src/packet_processor/error.rs @@ -3,12 +3,15 @@ use nym_sphinx_acknowledgements::surb_ack::SurbAckRecoveryError; use nym_sphinx_addressing::nodes::NymNodeRoutingAddressError; -use nym_sphinx_types::Error as SphinxError; +use nym_sphinx_types::{NymPacketError, SphinxError}; use thiserror::Error; #[derive(Error, Debug)] pub enum MixProcessingError { #[error("failed to process received packet: {0}")] + NymPacketProcessingError(#[from] NymPacketError), + + #[error("failed to process received sphinx packet: {0}")] SphinxProcessingError(#[from] SphinxError), #[error("the forward hop address was malformed: {0}")] diff --git a/common/mixnode-common/src/packet_processor/processor.rs b/common/mixnode-common/src/packet_processor/processor.rs index 98847d8983..8acbc9d90b 100644 --- a/common/mixnode-common/src/packet_processor/processor.rs +++ b/common/mixnode-common/src/packet_processor/processor.rs @@ -7,11 +7,11 @@ use log::*; use nym_sphinx_acknowledgements::surb_ack::SurbAck; use nym_sphinx_addressing::nodes::NymNodeRoutingAddress; use nym_sphinx_forwarding::packet::MixPacket; -use nym_sphinx_framing::packet::FramedSphinxPacket; -use nym_sphinx_params::{PacketMode, PacketSize}; +use nym_sphinx_framing::packet::FramedNymPacket; +use nym_sphinx_params::{PacketSize, PacketType}; use nym_sphinx_types::{ - Delay as SphinxDelay, DestinationAddressBytes, NodeAddressBytes, Payload, PrivateKey, - ProcessedPacket, SphinxPacket, + Delay as SphinxDelay, DestinationAddressBytes, NodeAddressBytes, NymPacket, NymProcessedPacket, + PrivateKey, ProcessedPacket, }; use std::convert::TryFrom; use std::sync::Arc; @@ -53,14 +53,14 @@ impl SphinxPacketProcessor { feature = "cpucycles", instrument(skip(self, packet), fields(cpucycles)) )] - fn perform_initial_sphinx_packet_processing( + fn perform_initial_packet_processing( &self, - packet: SphinxPacket, - ) -> Result { + packet: NymPacket, + ) -> Result { measure!({ packet.process(&self.sphinx_key).map_err(|err| { - debug!("Failed to unwrap Sphinx packet: {err}"); - MixProcessingError::SphinxProcessingError(err) + debug!("Failed to unwrap NymPacket packet: {err}"); + MixProcessingError::NymPacketProcessingError(err) }) }) } @@ -72,17 +72,12 @@ impl SphinxPacketProcessor { )] fn perform_initial_unwrapping( &self, - received: FramedSphinxPacket, - ) -> Result { + received: FramedNymPacket, + ) -> Result { measure!({ - let packet_mode = received.packet_mode(); - let sphinx_packet = received.into_inner(); + let packet = received.into_inner(); - if packet_mode.is_old_vpn() { - return Err(MixProcessingError::ReceivedOldTypeVpnPacket); - } - - self.perform_initial_sphinx_packet_processing(sphinx_packet) + self.perform_initial_packet_processing(packet) }) } @@ -90,14 +85,14 @@ impl SphinxPacketProcessor { /// and packs all the data in a way that can be easily sent to the next hop. fn process_forward_hop( &self, - packet: SphinxPacket, + packet: NymPacket, forward_address: NodeAddressBytes, delay: SphinxDelay, - packet_mode: PacketMode, + packet_type: PacketType, ) -> Result { let next_hop_address = NymNodeRoutingAddress::try_from(forward_address)?; - let mix_packet = MixPacket::new(next_hop_address, packet, packet_mode); + let mix_packet = MixPacket::new(next_hop_address, packet, packet_type); Ok(MixProcessingResult::ForwardHop(mix_packet, Some(delay))) } @@ -106,14 +101,17 @@ impl SphinxPacketProcessor { fn split_hop_data_into_ack_and_message( &self, mut extracted_data: Vec, + packet_type: PacketType, ) -> Result<(Vec, Vec), MixProcessingError> { + let ack_len = SurbAck::len(Some(packet_type)); + // in theory it's impossible for this to fail since it managed to go into correct `match` // branch at the caller - if extracted_data.len() < SurbAck::len() { + if extracted_data.len() < ack_len { return Err(MixProcessingError::NoSurbAckInFinalHop); } - let message = extracted_data.split_off(SurbAck::len()); + let message = extracted_data.split_off(ack_len); let ack_data = extracted_data; Ok((ack_data, message)) } @@ -124,21 +122,30 @@ impl SphinxPacketProcessor { &self, data: Vec, packet_size: PacketSize, - packet_mode: PacketMode, + packet_type: PacketType, ) -> Result<(Option, Vec), MixProcessingError> { match packet_size { - PacketSize::AckPacket => { + PacketSize::AckPacket | PacketSize::OutfoxAckPacket => { trace!("received an ack packet!"); Ok((None, data)) } PacketSize::RegularPacket | PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 - | PacketSize::ExtendedPacket32 => { + | PacketSize::ExtendedPacket32 + | PacketSize::OutfoxRegularPacket => { trace!("received a normal packet!"); - let (ack_data, message) = self.split_hop_data_into_ack_and_message(data)?; - let (ack_first_hop, ack_packet) = SurbAck::try_recover_first_hop_packet(&ack_data)?; - let forward_ack = MixPacket::new(ack_first_hop, ack_packet, packet_mode); + let (ack_data, message) = + self.split_hop_data_into_ack_and_message(data, packet_type)?; + let (ack_first_hop, ack_packet) = + match SurbAck::try_recover_first_hop_packet(&ack_data, packet_type) { + Ok((first_hop, packet)) => (first_hop, packet), + Err(err) => { + debug!("Failed to recover first hop from ack data: {err}"); + return Err(err.into()); + } + }; + let forward_ack = MixPacket::new(ack_first_hop, ack_packet, packet_type); Ok((Some(forward_ack), message)) } } @@ -150,14 +157,12 @@ impl SphinxPacketProcessor { fn process_final_hop( &self, destination: DestinationAddressBytes, - payload: Payload, + payload: Vec, packet_size: PacketSize, - packet_mode: PacketMode, + packet_type: PacketType, ) -> Result { - let packet_message = payload.recover_plaintext()?; - let (forward_ack, message) = - self.split_into_ack_and_message(packet_message, packet_size, packet_mode)?; + self.split_into_ack_and_message(payload, packet_size, packet_type)?; Ok(MixProcessingResult::FinalHop(ProcessedFinalHop { destination, @@ -170,18 +175,48 @@ impl SphinxPacketProcessor { /// or a final hop. fn perform_final_processing( &self, - packet: ProcessedPacket, + packet: NymProcessedPacket, packet_size: PacketSize, - packet_mode: PacketMode, + packet_type: PacketType, ) -> Result { match packet { - ProcessedPacket::ForwardHop(packet, address, delay) => { - self.process_forward_hop(*packet, address, delay, packet_mode) + NymProcessedPacket::Sphinx(packet) => { + match packet { + ProcessedPacket::ForwardHop(packet, address, delay) => self + .process_forward_hop( + NymPacket::Sphinx(*packet), + address, + delay, + packet_type, + ), + // right now there's no use for the surb_id included in the header - probably it should get removed from the + // sphinx all together? + ProcessedPacket::FinalHop(destination, _, payload) => self.process_final_hop( + destination, + payload.recover_plaintext()?, + packet_size, + packet_type, + ), + } } - // right now there's no use for the surb_id included in the header - probably it should get removed from the - // sphinx all together? - ProcessedPacket::FinalHop(destination, _, payload) => { - self.process_final_hop(destination, payload, packet_size, packet_mode) + NymProcessedPacket::Outfox(packet) => { + let next_address = *packet.next_address(); + let packet = packet.into_packet(); + if packet.is_final_hop() { + self.process_final_hop( + DestinationAddressBytes::from_bytes(next_address), + packet.recover_plaintext().to_vec(), + packet_size, + packet_type, + ) + } else { + let mix_packet = MixPacket::new( + NymNodeRoutingAddress::try_from_bytes(&next_address)?, + NymPacket::Outfox(packet), + PacketType::Outfox, + ); + Ok(MixProcessingResult::ForwardHop(mix_packet, None)) + } } } } @@ -192,19 +227,19 @@ impl SphinxPacketProcessor { )] pub fn process_received( &self, - received: FramedSphinxPacket, + received: FramedNymPacket, ) -> Result { // explicit packet size will help to correctly parse final hop measure!({ let packet_size = received.packet_size(); - let packet_mode = received.packet_mode(); + let packet_type = received.packet_type(); // unwrap the sphinx packet and if possible and appropriate, cache keys let processed_packet = self.perform_initial_unwrapping(received)?; // for forward packets, extract next hop and set delay (but do NOT delay here) // for final packets, extract SURBAck - self.perform_final_processing(processed_packet, packet_size, packet_mode) + self.perform_final_processing(processed_packet, packet_size, packet_type) }) } } @@ -226,31 +261,71 @@ mod tests { let short_data = vec![42u8]; assert!(processor - .split_hop_data_into_ack_and_message(short_data) + .split_hop_data_into_ack_and_message(short_data, PacketType::Mix) .is_err()); - let sufficient_data = vec![42u8; SurbAck::len()]; + let sufficient_data = vec![42u8; SurbAck::len(Some(PacketType::Mix))]; let (ack, data) = processor - .split_hop_data_into_ack_and_message(sufficient_data.clone()) + .split_hop_data_into_ack_and_message(sufficient_data.clone(), PacketType::Mix) .unwrap(); assert_eq!(sufficient_data, ack); assert!(data.is_empty()); - let long_data = vec![42u8; SurbAck::len() * 5]; + let long_data = vec![42u8; SurbAck::len(Some(PacketType::Mix)) * 5]; let (ack, data) = processor - .split_hop_data_into_ack_and_message(long_data) + .split_hop_data_into_ack_and_message(long_data, PacketType::Mix) .unwrap(); - assert_eq!(ack.len(), SurbAck::len()); - assert_eq!(data.len(), SurbAck::len() * 4) + assert_eq!(ack.len(), SurbAck::len(Some(PacketType::Mix))); + assert_eq!(data.len(), SurbAck::len(Some(PacketType::Mix)) * 4) + } + + #[tokio::test] + async fn splitting_hop_data_works_for_sufficiently_long_payload_outfox() { + let processor = fixture(); + + let short_data = vec![42u8]; + assert!(processor + .split_hop_data_into_ack_and_message(short_data, PacketType::Outfox) + .is_err()); + + let sufficient_data = vec![42u8; SurbAck::len(Some(PacketType::Outfox))]; + let (ack, data) = processor + .split_hop_data_into_ack_and_message(sufficient_data.clone(), PacketType::Outfox) + .unwrap(); + assert_eq!(sufficient_data, ack); + assert!(data.is_empty()); + + let long_data = vec![42u8; SurbAck::len(Some(PacketType::Outfox)) * 5]; + let (ack, data) = processor + .split_hop_data_into_ack_and_message(long_data, PacketType::Outfox) + .unwrap(); + assert_eq!(ack.len(), SurbAck::len(Some(PacketType::Outfox))); + assert_eq!(data.len(), SurbAck::len(Some(PacketType::Outfox)) * 4) } #[tokio::test] async fn splitting_into_ack_and_message_returns_whole_data_for_ack() { let processor = fixture(); - let data = vec![42u8; SurbAck::len() + 10]; + let data = vec![42u8; SurbAck::len(Some(PacketType::Mix)) + 10]; let (ack, message) = processor - .split_into_ack_and_message(data.clone(), PacketSize::AckPacket, Default::default()) + .split_into_ack_and_message(data.clone(), PacketSize::AckPacket, PacketType::Mix) + .unwrap(); + assert!(ack.is_none()); + assert_eq!(data, message) + } + + #[tokio::test] + async fn splitting_into_ack_and_message_returns_whole_data_for_ack_outfox() { + let processor = fixture(); + + let data = vec![42u8; SurbAck::len(Some(PacketType::Outfox)) + 10]; + let (ack, message) = processor + .split_into_ack_and_message( + data.clone(), + PacketSize::OutfoxAckPacket, + PacketType::Outfox, + ) .unwrap(); assert!(ack.is_none()); assert_eq!(data, message) diff --git a/common/node-tester-utils/Cargo.toml b/common/node-tester-utils/Cargo.toml index eea8d1b21b..39a93d4a9f 100644 --- a/common/node-tester-utils/Cargo.toml +++ b/common/node-tester-utils/Cargo.toml @@ -17,6 +17,7 @@ tokio = { workspace = true, features = ["macros"]} nym-crypto = { path = "../crypto", features = ["asymmetric"] } nym-task = { path = "../task" } nym-topology = { path = "../topology" } +nym-sphinx-params = { path = "../nymsphinx/params" } # TODO: do we need the whole nymsphinx? nym-sphinx = { path = "../nymsphinx" } diff --git a/common/node-tester-utils/src/tester.rs b/common/node-tester-utils/src/tester.rs index 052f919ffe..0b807c54f2 100644 --- a/common/node-tester-utils/src/tester.rs +++ b/common/node-tester-utils/src/tester.rs @@ -10,6 +10,7 @@ use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::message::NymMessage; use nym_sphinx::params::{PacketSize, DEFAULT_NUM_MIX_HOPS}; use nym_sphinx::preparer::{FragmentPreparer, PreparedFragment}; +use nym_sphinx_params::PacketType; use nym_topology::{gateway, mix, NymTopology}; use rand::{CryptoRng, Rng}; use serde::Serialize; @@ -243,7 +244,14 @@ where // TODO: can we avoid this arc clone? let ack_key = Arc::clone(&self.ack_key); - Ok(self.prepare_chunk_for_sending(fragment, topology, &ack_key, &address, &address)?) + Ok(self.prepare_chunk_for_sending( + fragment, + topology, + &ack_key, + &address, + &address, + PacketType::Mix, + )?) } pub fn create_test_packet( diff --git a/common/nymsphinx/Cargo.toml b/common/nymsphinx/Cargo.toml index d229adfa75..dba8e6f265 100644 --- a/common/nymsphinx/Cargo.toml +++ b/common/nymsphinx/Cargo.toml @@ -28,9 +28,6 @@ nym-sphinx-types = { path = "types" } nym-crypto = { path = "../crypto", version = "0.3.0" } nym-topology = { path = "../topology" } -# outfox -nym-outfox = { path = "../../nym-outfox" } - [dev-dependencies] nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" } nym-crypto = { path = "../crypto", version = "0.3.0", features = ["asymmetric"] } diff --git a/common/nymsphinx/acknowledgements/src/identifier.rs b/common/nymsphinx/acknowledgements/src/identifier.rs index 9f6ffb49be..aab5a96146 100644 --- a/common/nymsphinx/acknowledgements/src/identifier.rs +++ b/common/nymsphinx/acknowledgements/src/identifier.rs @@ -3,9 +3,7 @@ use crate::AckKey; use nym_crypto::symmetric::stream_cipher::{self, encrypt, iv_from_slice, random_iv, IvSizeUser}; -use nym_sphinx_params::{ - packet_sizes::PacketSize, AckEncryptionAlgorithm, SerializedFragmentIdentifier, FRAG_ID_LEN, -}; +use nym_sphinx_params::{AckEncryptionAlgorithm, SerializedFragmentIdentifier, FRAG_ID_LEN}; use rand::{CryptoRng, RngCore}; // TODO: should those functions even exist in this file? @@ -26,12 +24,6 @@ pub fn recover_identifier( key: &AckKey, iv_id_ciphertext: &[u8], ) -> Option { - // The content of an 'ACK' packet consists of AckEncryptionAlgorithm::IV followed by - // serialized FragmentIdentifier - if iv_id_ciphertext.len() != PacketSize::AckPacket.plaintext_size() { - return None; - } - let iv_size = AckEncryptionAlgorithm::iv_size(); let iv = iv_from_slice::(&iv_id_ciphertext[..iv_size]); diff --git a/common/nymsphinx/acknowledgements/src/surb_ack.rs b/common/nymsphinx/acknowledgements/src/surb_ack.rs index 5df36e1f0b..b303aa2e8b 100644 --- a/common/nymsphinx/acknowledgements/src/surb_ack.rs +++ b/common/nymsphinx/acknowledgements/src/surb_ack.rs @@ -8,21 +8,18 @@ use nym_sphinx_addressing::nodes::{ NymNodeRoutingAddress, NymNodeRoutingAddressError, MAX_NODE_ADDRESS_UNPADDED_LEN, }; use nym_sphinx_params::packet_sizes::PacketSize; -use nym_sphinx_params::DEFAULT_NUM_MIX_HOPS; -use nym_sphinx_types::builder::SphinxPacketBuilder; -use nym_sphinx_types::Error as SphinxError; -use nym_sphinx_types::{ - delays::{self, Delay}, - SphinxPacket, -}; +use nym_sphinx_params::{PacketType, DEFAULT_NUM_MIX_HOPS}; +use nym_sphinx_types::delays::{self, Delay}; +use nym_sphinx_types::{NymPacket, NymPacketError, MIN_PACKET_SIZE}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; use std::convert::TryFrom; use std::time; use thiserror::Error; +#[derive(Debug)] pub struct SurbAck { - surb_ack_packet: SphinxPacket, + surb_ack_packet: NymPacket, first_hop_address: NymNodeRoutingAddress, expected_total_delay: Delay, } @@ -35,8 +32,8 @@ pub enum SurbAckRecoveryError { #[error("could not extract first hop address information - {0}")] InvalidAddress(#[from] NymNodeRoutingAddressError), - #[error("the contained sphinx packet was not correctly formed - {0}")] - InvalidSphinxPacket(#[from] SphinxError), + #[error("packet: {0}")] + NymPacket(#[from] NymPacketError), } impl SurbAck { @@ -47,6 +44,7 @@ impl SurbAck { marshaled_fragment_id: [u8; 5], average_delay: time::Duration, topology: &NymTopology, + packet_type: PacketType, ) -> Result where R: RngCore + CryptoRng, @@ -57,11 +55,34 @@ impl SurbAck { let destination = recipient.as_sphinx_destination(); let surb_ack_payload = prepare_identifier(rng, ack_key, marshaled_fragment_id); + let packet_size = match packet_type { + PacketType::Outfox => surb_ack_payload.len().max(MIN_PACKET_SIZE), + PacketType::Mix => PacketSize::AckPacket.payload_size(), + PacketType::Vpn => PacketSize::AckPacket.payload_size(), + }; - let surb_ack_packet = SphinxPacketBuilder::new() - .with_payload_size(PacketSize::AckPacket.payload_size()) - .build_packet(surb_ack_payload, &route, &destination, &delays) - .unwrap(); + let surb_ack_packet = match packet_type { + PacketType::Outfox => NymPacket::outfox_build( + surb_ack_payload, + route.as_slice(), + &destination, + Some(packet_size), + )?, + PacketType::Mix => NymPacket::sphinx_build( + packet_size, + surb_ack_payload, + &route, + &destination, + &delays, + )?, + PacketType::Vpn => NymPacket::sphinx_build( + packet_size, + surb_ack_payload, + &route, + &destination, + &delays, + )?, + }; // in our case, the last hop is a gateway that does NOT do any delays let expected_total_delay = delays.iter().take(delays.len() - 1).sum(); @@ -75,45 +96,50 @@ impl SurbAck { }) } - pub fn len() -> usize { + pub fn len(packet_type: Option) -> usize { // TODO: this will be variable once/if we decide to introduce optimization described // in common/nymsphinx/chunking/src/lib.rs:available_plaintext_size() - PacketSize::AckPacket.size() + MAX_NODE_ADDRESS_UNPADDED_LEN + let packet_type = packet_type.unwrap_or(PacketType::Mix); + match packet_type { + PacketType::Outfox => { + PacketSize::OutfoxAckPacket.size() + MAX_NODE_ADDRESS_UNPADDED_LEN + } + PacketType::Mix => PacketSize::AckPacket.size() + MAX_NODE_ADDRESS_UNPADDED_LEN, + PacketType::Vpn => PacketSize::AckPacket.size() + MAX_NODE_ADDRESS_UNPADDED_LEN, + } } pub fn expected_total_delay(&self) -> Delay { self.expected_total_delay } - pub fn prepare_for_sending(self) -> (Delay, Vec) { + pub fn prepare_for_sending(self) -> Result<(Delay, Vec), SurbAckRecoveryError> { // SURB_FIRST_HOP || SURB_ACK let surb_bytes: Vec<_> = self .first_hop_address .as_zero_padded_bytes(MAX_NODE_ADDRESS_UNPADDED_LEN) .into_iter() - .chain(self.surb_ack_packet.to_bytes().into_iter()) + .chain(self.surb_ack_packet.to_bytes()?.into_iter()) .collect(); - (self.expected_total_delay, surb_bytes) + Ok((self.expected_total_delay, surb_bytes)) } // partial reciprocal of `prepare_for_sending` performed by the gateway pub fn try_recover_first_hop_packet( b: &[u8], - ) -> Result<(NymNodeRoutingAddress, SphinxPacket), SurbAckRecoveryError> { - if b.len() != Self::len() { - Err(SurbAckRecoveryError::InvalidPacketSize { - received: b.len(), - expected: Self::len(), - }) - } else { - let address = NymNodeRoutingAddress::try_from_bytes(b)?; + packet_type: PacketType, + ) -> Result<(NymNodeRoutingAddress, NymPacket), SurbAckRecoveryError> { + let address = NymNodeRoutingAddress::try_from_bytes(b)?; - // TODO: this will be variable once/if we decide to introduce optimization described - // in common/nymsphinx/chunking/src/lib.rs:available_plaintext_size() - let address_offset = MAX_NODE_ADDRESS_UNPADDED_LEN; - let packet = SphinxPacket::from_bytes(&b[address_offset..])?; + // TODO: this will be variable once/if we decide to introduce optimization described + // in common/nymsphinx/chunking/src/lib.rs:available_plaintext_size() + let address_offset = MAX_NODE_ADDRESS_UNPADDED_LEN; + let packet = match packet_type { + PacketType::Outfox => NymPacket::outfox_from_bytes(&b[address_offset..])?, + PacketType::Mix => NymPacket::sphinx_from_bytes(&b[address_offset..])?, + PacketType::Vpn => NymPacket::sphinx_from_bytes(&b[address_offset..])?, + }; - Ok((address, packet)) - } + Ok((address, packet)) } } diff --git a/common/nymsphinx/anonymous-replies/src/reply_surb.rs b/common/nymsphinx/anonymous-replies/src/reply_surb.rs index 66642720e5..82fc8ea573 100644 --- a/common/nymsphinx/anonymous-replies/src/reply_surb.rs +++ b/common/nymsphinx/anonymous-replies/src/reply_surb.rs @@ -6,8 +6,8 @@ use nym_crypto::{generic_array::typenum::Unsigned, Digest}; use nym_sphinx_addressing::clients::Recipient; use nym_sphinx_addressing::nodes::{NymNodeRoutingAddress, MAX_NODE_ADDRESS_UNPADDED_LEN}; use nym_sphinx_params::packet_sizes::PacketSize; -use nym_sphinx_params::{ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; -use nym_sphinx_types::{delays, Error as SphinxError, SURBMaterial, SphinxPacket, SURB}; +use nym_sphinx_params::{PacketType, ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; +use nym_sphinx_types::{delays, NymPacket, SURBMaterial, SphinxError, SURB}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; use serde::de::{Error as SerdeError, Visitor}; @@ -173,7 +173,8 @@ impl ReplySurb { self, message: M, packet_size: PacketSize, - ) -> Result<(SphinxPacket, NymNodeRoutingAddress), ReplySurbError> { + _packet_type: PacketType, + ) -> Result<(NymPacket, NymNodeRoutingAddress), ReplySurbError> { let message_bytes = message.as_ref(); if message_bytes.len() != packet_size.plaintext_size() { return Err(ReplySurbError::UnpaddedMessageError); @@ -187,6 +188,6 @@ impl ReplySurb { let first_hop_address = NymNodeRoutingAddress::try_from(first_hop).unwrap(); - Ok((packet, first_hop_address)) + Ok((NymPacket::Sphinx(packet), first_hop_address)) } } diff --git a/common/nymsphinx/cover/src/lib.rs b/common/nymsphinx/cover/src/lib.rs index 19e6e96e09..cdc216f1d8 100644 --- a/common/nymsphinx/cover/src/lib.rs +++ b/common/nymsphinx/cover/src/lib.rs @@ -3,7 +3,7 @@ use nym_crypto::shared_key::new_ephemeral_shared_key; use nym_crypto::symmetric::stream_cipher; -use nym_sphinx_acknowledgements::surb_ack::SurbAck; +use nym_sphinx_acknowledgements::surb_ack::{SurbAck, SurbAckRecoveryError}; use nym_sphinx_acknowledgements::AckKey; use nym_sphinx_addressing::clients::Recipient; use nym_sphinx_addressing::nodes::NymNodeRoutingAddress; @@ -11,10 +11,9 @@ use nym_sphinx_chunking::fragment::COVER_FRAG_ID; use nym_sphinx_forwarding::packet::MixPacket; use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::{ - PacketEncryptionAlgorithm, PacketHkdfAlgorithm, PacketMode, DEFAULT_NUM_MIX_HOPS, + PacketEncryptionAlgorithm, PacketHkdfAlgorithm, PacketType, DEFAULT_NUM_MIX_HOPS, }; -use nym_sphinx_types::builder::SphinxPacketBuilder; -use nym_sphinx_types::{delays, Error as SphinxError}; +use nym_sphinx_types::{delays, NymPacket}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; use std::convert::TryFrom; @@ -28,8 +27,11 @@ pub enum CoverMessageError { #[error("Could not construct cover message due to invalid topology - {0}")] InvalidTopologyError(#[from] NymTopologyError), - #[error("Could not construct a valid sphinx packet - {0}")] - SphinxError(#[from] SphinxError), + #[error("SurbAck: {0}")] + SurbAck(#[from] SurbAckRecoveryError), + + #[error("NymPacket: {0}")] + NymPacket(#[from] nym_sphinx_types::NymPacketError), } pub fn generate_loop_cover_surb_ack( @@ -38,6 +40,7 @@ pub fn generate_loop_cover_surb_ack( ack_key: &AckKey, full_address: &Recipient, average_ack_delay: time::Duration, + packet_type: PacketType, ) -> Result where R: RngCore + CryptoRng, @@ -49,9 +52,11 @@ where COVER_FRAG_ID.to_bytes(), average_ack_delay, topology, + packet_type, )?) } +#[allow(clippy::too_many_arguments)] pub fn generate_loop_cover_packet( rng: &mut R, topology: &NymTopology, @@ -60,14 +65,21 @@ pub fn generate_loop_cover_packet( average_ack_delay: time::Duration, average_packet_delay: time::Duration, packet_size: PacketSize, + packet_type: PacketType, ) -> Result where R: RngCore + CryptoRng, { // we don't care about total ack delay - we will not be retransmitting it anyway - let (_, ack_bytes) = - generate_loop_cover_surb_ack(rng, topology, ack_key, full_address, average_ack_delay)? - .prepare_for_sending(); + let (_, ack_bytes) = generate_loop_cover_surb_ack( + rng, + topology, + ack_key, + full_address, + average_ack_delay, + packet_type, + )? + .prepare_for_sending()?; // cover message can't be distinguishable from a normal traffic so we have to go through // all the effort of key generation, encryption, etc. Note here we are generating shared key @@ -111,15 +123,18 @@ where let destination = full_address.as_sphinx_destination(); // once merged, that's an easy rng injection point for sphinx packets : ) - let packet = SphinxPacketBuilder::new() - .with_payload_size(packet_size.payload_size()) - .build_packet(packet_payload, &route, &destination, &delays) - .unwrap(); + let packet = NymPacket::sphinx_build( + packet_size.payload_size(), + packet_payload, + &route, + &destination, + &delays, + )?; let first_hop_address = NymNodeRoutingAddress::try_from(route.first().unwrap().address).unwrap(); - Ok(MixPacket::new(first_hop_address, packet, PacketMode::Mix)) + Ok(MixPacket::new(first_hop_address, packet, PacketType::Mix)) } /// Helper function used to determine if given message represents a loop cover message. diff --git a/common/nymsphinx/forwarding/Cargo.toml b/common/nymsphinx/forwarding/Cargo.toml index df071403a6..6509098398 100644 --- a/common/nymsphinx/forwarding/Cargo.toml +++ b/common/nymsphinx/forwarding/Cargo.toml @@ -12,3 +12,4 @@ nym-sphinx-addressing = { path = "../addressing" } nym-sphinx-params = { path = "../params" } nym-sphinx-types = { path = "../types" } nym-outfox = { path = "../../../nym-outfox" } +thiserror = "1" diff --git a/common/nymsphinx/forwarding/src/packet.rs b/common/nymsphinx/forwarding/src/packet.rs index 024b80b005..2276e9a5cd 100644 --- a/common/nymsphinx/forwarding/src/packet.rs +++ b/common/nymsphinx/forwarding/src/packet.rs @@ -2,42 +2,28 @@ // SPDX-License-Identifier: Apache-2.0 use nym_sphinx_addressing::nodes::{NymNodeRoutingAddress, NymNodeRoutingAddressError}; -use nym_sphinx_params::{PacketMode, PacketSize}; -use nym_sphinx_types::SphinxPacket; +use nym_sphinx_params::{PacketSize, PacketType}; +use nym_sphinx_types::{NymPacket, NymPacketError}; use std::convert::TryFrom; -use std::fmt::{self, Debug, Display, Formatter}; +use std::fmt::{self, Debug, Formatter}; +use thiserror::Error; -#[derive(Debug)] +#[derive(Debug, Error)] pub enum MixPacketFormattingError { + #[error("too few bytes provided to recover from bytes")] TooFewBytesProvided, - InvalidPacketMode, + #[error("provided packet mode is invalid")] + InvalidPacketType, + #[error("received request had invalid size - received {0}")] InvalidPacketSize(usize), + #[error("address field was incorrectly encoded")] InvalidAddress, + #[error("received sphinx packet was malformed")] MalformedSphinxPacket, + #[error("Packet: {0}")] + Packet(#[from] NymPacketError), } -impl Display for MixPacketFormattingError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - use MixPacketFormattingError::*; - match self { - TooFewBytesProvided => write!(f, "Too few bytes provided to recover from bytes"), - InvalidAddress => write!(f, "address field was incorrectly encoded"), - InvalidPacketSize(actual) => - write!( - f, - "received request had invalid size. (actual: {}, but expected one of: {} (ACK), {} (REGULAR), {}, {}, {} (EXTENDED))", - actual, PacketSize::AckPacket.size(), PacketSize::RegularPacket.size(), - PacketSize::ExtendedPacket8.size(), PacketSize::ExtendedPacket16.size(), - PacketSize::ExtendedPacket32.size() - ), - MalformedSphinxPacket => write!(f, "received sphinx packet was malformed"), - InvalidPacketMode => write!(f, "provided packet mode is invalid") - } - } -} - -impl std::error::Error for MixPacketFormattingError {} - impl From for MixPacketFormattingError { fn from(_: NymNodeRoutingAddressError) -> Self { MixPacketFormattingError::InvalidAddress @@ -46,19 +32,16 @@ impl From for MixPacketFormattingError { pub struct MixPacket { next_hop: NymNodeRoutingAddress, - sphinx_packet: SphinxPacket, - packet_mode: PacketMode, + packet: NymPacket, + packet_type: PacketType, } impl Debug for MixPacket { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!( f, - "MixPacket to {:?} with packet_mode {:?}. Sphinx header: {:?}, payload length: {}", - self.next_hop, - self.packet_mode, - self.sphinx_packet.header, - self.sphinx_packet.payload.len() + "MixPacket to {:?} with packet_type {:?}. Packet {:?}", + self.next_hop, self.packet_type, self.packet ) } } @@ -66,13 +49,13 @@ impl Debug for MixPacket { impl MixPacket { pub fn new( next_hop: NymNodeRoutingAddress, - sphinx_packet: SphinxPacket, - packet_mode: PacketMode, + packet: NymPacket, + packet_type: PacketType, ) -> Self { MixPacket { next_hop, - sphinx_packet, - packet_mode, + packet, + packet_type, } } @@ -80,52 +63,52 @@ impl MixPacket { self.next_hop } - pub fn sphinx_packet(&self) -> &SphinxPacket { - &self.sphinx_packet + pub fn packet(&self) -> &NymPacket { + &self.packet } - pub fn into_sphinx_packet(self) -> SphinxPacket { - self.sphinx_packet + pub fn into_packet(self) -> NymPacket { + self.packet } - pub fn packet_mode(&self) -> PacketMode { - self.packet_mode + pub fn packet_type(&self) -> PacketType { + self.packet_type } // the message is formatted as follows: - // PACKET_MODE || FIRST_HOP || SPHINX_PACKET + // packet_type || FIRST_HOP || packet pub fn try_from_bytes(b: &[u8]) -> Result { - let packet_mode = match PacketMode::try_from(b[0]) { + let packet_type = match PacketType::try_from(b[0]) { Ok(mode) => mode, - Err(_) => return Err(MixPacketFormattingError::InvalidPacketMode), + Err(_) => return Err(MixPacketFormattingError::InvalidPacketType), }; let next_hop = NymNodeRoutingAddress::try_from_bytes(&b[1..])?; let addr_offset = next_hop.bytes_min_len(); - let sphinx_packet_data = &b[addr_offset + 1..]; - let packet_size = sphinx_packet_data.len(); + let packet_data = &b[addr_offset + 1..]; + let packet_size = packet_data.len(); if PacketSize::get_type(packet_size).is_err() { Err(MixPacketFormattingError::InvalidPacketSize(packet_size)) } else { - let sphinx_packet = match SphinxPacket::from_bytes(sphinx_packet_data) { - Ok(packet) => packet, - Err(_) => return Err(MixPacketFormattingError::MalformedSphinxPacket), + let packet = match packet_type { + PacketType::Outfox => NymPacket::outfox_from_bytes(packet_data)?, + _ => NymPacket::sphinx_from_bytes(packet_data)?, }; Ok(MixPacket { next_hop, - sphinx_packet, - packet_mode, + packet, + packet_type, }) } } - pub fn into_bytes(self) -> Vec { - std::iter::once(self.packet_mode as u8) + pub fn into_bytes(self) -> Result, MixPacketFormattingError> { + Ok(std::iter::once(self.packet_type as u8) .chain(self.next_hop.as_bytes().into_iter()) - .chain(self.sphinx_packet.to_bytes().into_iter()) - .collect() + .chain(self.packet.to_bytes()?.into_iter()) + .collect()) } } diff --git a/common/nymsphinx/framing/src/codec.rs b/common/nymsphinx/framing/src/codec.rs index 1f427dc0d1..76b241cf11 100644 --- a/common/nymsphinx/framing/src/codec.rs +++ b/common/nymsphinx/framing/src/codec.rs @@ -1,65 +1,56 @@ // Copyright 2021-2022 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::packet::{FramedSphinxPacket, Header}; +use crate::packet::{FramedNymPacket, Header}; use bytes::{Buf, BufMut, BytesMut}; -use nym_sphinx_params::packet_modes::InvalidPacketMode; use nym_sphinx_params::packet_sizes::{InvalidPacketSize, PacketSize}; -use nym_sphinx_types::Error as SphinxError; -use nym_sphinx_types::SphinxPacket; +use nym_sphinx_params::packet_types::InvalidPacketType; +use nym_sphinx_params::PacketType; +use nym_sphinx_types::{NymPacket, NymPacketError}; use std::io; use thiserror::Error; use tokio_util::codec::{Decoder, Encoder}; #[derive(Error, Debug)] -pub enum SphinxCodecError { +pub enum NymCodecError { #[error("the packet size information was malformed - {0}")] InvalidPacketSize(#[from] InvalidPacketSize), #[error("the packet mode information was malformed - {0}")] - InvalidPacketMode(#[from] InvalidPacketMode), - - #[error("the actual sphinx packet was malformed - {0}")] - MalformedSphinxPacket(#[from] SphinxError), + InvalidPacketType(#[from] InvalidPacketType), #[error("encountered an IO error - {0}")] IoError(#[from] io::Error), -} -impl From for io::Error { - fn from(err: SphinxCodecError) -> Self { - match err { - SphinxCodecError::InvalidPacketSize(source) => { - io::Error::new(io::ErrorKind::InvalidInput, source) - } - SphinxCodecError::InvalidPacketMode(source) => { - io::Error::new(io::ErrorKind::InvalidInput, source) - } - SphinxCodecError::MalformedSphinxPacket(source) => { - io::Error::new(io::ErrorKind::InvalidData, source) - } - SphinxCodecError::IoError(err) => err, - } - } + #[error("encountered a packet error - {0}")] + NymPacket(#[from] NymPacketError), + + #[error("could not convert to bytes")] + ToBytes, + + #[error("could not convert to bytes")] + FromBytes, } // TODO: in the future it could be extended to have state containing symmetric encryption key // so that all data could be encrypted easily (alternatively we could just slap TLS) -pub struct SphinxCodec; +pub struct NymCodec; -impl Encoder for SphinxCodec { - type Error = SphinxCodecError; +impl Encoder for NymCodec { + type Error = NymCodecError; - fn encode(&mut self, item: FramedSphinxPacket, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, item: FramedNymPacket, dst: &mut BytesMut) -> Result<(), Self::Error> { item.header.encode(dst); - dst.put(item.packet.to_bytes().as_ref()); + let packet_bytes = item.packet.to_bytes()?; + let encoded = packet_bytes.as_slice(); + dst.put(encoded); Ok(()) } } -impl Decoder for SphinxCodec { - type Item = FramedSphinxPacket; - type Error = SphinxCodecError; +impl Decoder for NymCodec { + type Item = FramedNymPacket; + type Error = NymCodecError; fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { if src.is_empty() { @@ -76,23 +67,32 @@ impl Decoder for SphinxCodec { None => return Ok(None), // we have some data but not enough to get header back }; - let sphinx_packet_size = header.packet_size.size(); - let frame_len = header.size() + sphinx_packet_size; + let packet_size = header.packet_size.size(); + let frame_len = header.size() + packet_size; if src.len() < frame_len { // we don't have enough bytes to read the rest of frame - src.reserve(sphinx_packet_size); + src.reserve(packet_size); return Ok(None); } // advance buffer past the header - at this point we have enough bytes src.advance(header.size()); - let sphinx_packet_bytes = src.split_to(sphinx_packet_size); + let packet_bytes = src.split_to(packet_size); + let packet = if let Some(slice) = packet_bytes.get(..) { + // here it could be debatable whether stream is corrupt or not, + // but let's go with the safer approach and assume it is. + match header.packet_type { + PacketType::Outfox => NymPacket::outfox_from_bytes(slice)?, + PacketType::Mix => NymPacket::sphinx_from_bytes(slice)?, + PacketType::Vpn => NymPacket::sphinx_from_bytes(slice)?, + } + } else { + return Ok(None); + }; - // here it could be debatable whether stream is corrupt or not, - // but let's go with the safer approach and assume it is. - let packet = SphinxPacket::from_bytes(&sphinx_packet_bytes)?; - let nymsphinx_packet = FramedSphinxPacket { header, packet }; + // let packet = SphinxPacket::from_bytes(&sphinx_packet_bytes)?; + let nymsphinx_packet = FramedNymPacket { header, packet }; // As per docs: // Before returning from the function, implementations should ensure that the buffer @@ -104,6 +104,7 @@ impl Decoder for SphinxCodec { // reserve for that. // we also assume the next packet coming from the same client will use exactly the same versioning // as the current packet + let mut allocate_for_next_packet = header.size() + PacketSize::AckPacket.size(); if !src.is_empty() { match Header::decode(src) { @@ -120,7 +121,6 @@ impl Decoder for SphinxCodec { }; } src.reserve(allocate_for_next_packet); - Ok(Some(nymsphinx_packet)) } } @@ -128,13 +128,47 @@ impl Decoder for SphinxCodec { #[cfg(test)] mod packet_encoding { use super::*; - use nym_sphinx_types::builder::SphinxPacketBuilder; use nym_sphinx_types::{ crypto, Delay as SphinxDelay, Destination, DestinationAddressBytes, Node, NodeAddressBytes, DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, NODE_ADDRESS_LENGTH, }; - fn make_valid_sphinx_packet(size: PacketSize) -> SphinxPacket { + fn make_valid_outfox_packet(size: PacketSize) -> NymPacket { + let (_, node1_pk) = crypto::keygen(); + let node1 = Node::new( + NodeAddressBytes::from_bytes([5u8; NODE_ADDRESS_LENGTH]), + node1_pk, + ); + let (_, node2_pk) = crypto::keygen(); + let node2 = Node::new( + NodeAddressBytes::from_bytes([4u8; NODE_ADDRESS_LENGTH]), + node2_pk, + ); + let (_, node3_pk) = crypto::keygen(); + let node3 = Node::new( + NodeAddressBytes::from_bytes([2u8; NODE_ADDRESS_LENGTH]), + node3_pk, + ); + + let (_, node4_pk) = crypto::keygen(); + let node4 = Node::new( + NodeAddressBytes::from_bytes([2u8; NODE_ADDRESS_LENGTH]), + node4_pk, + ); + + let destination = Destination::new( + DestinationAddressBytes::from_bytes([3u8; DESTINATION_ADDRESS_LENGTH]), + [4u8; IDENTIFIER_LENGTH], + ); + + let route = &[node1, node2, node3, node4]; + + let payload = vec![1; 48]; + + NymPacket::outfox_build(payload, route, &destination, Some(size.plaintext_size())).unwrap() + } + + fn make_valid_sphinx_packet(size: PacketSize) -> NymPacket { let (_, node1_pk) = crypto::keygen(); let node1 = Node::new( NodeAddressBytes::from_bytes([5u8; NODE_ADDRESS_LENGTH]), @@ -161,9 +195,7 @@ mod packet_encoding { SphinxDelay::new_from_nanos(42), SphinxDelay::new_from_nanos(42), ]; - SphinxPacketBuilder::new() - .with_payload_size(size.payload_size()) - .build_packet(b"foomp", &route, &destination, &delays) + NymPacket::sphinx_build(size.payload_size(), b"foomp", &route, &destination, &delays) .unwrap() } @@ -171,32 +203,50 @@ mod packet_encoding { fn whole_packet_can_be_decoded_from_a_valid_encoded_instance() { let header = Default::default(); let sphinx_packet = make_valid_sphinx_packet(Default::default()); - let sphinx_bytes = sphinx_packet.to_bytes(); + let sphinx_bytes = sphinx_packet.to_bytes().unwrap(); - let packet = FramedSphinxPacket { + let packet = FramedNymPacket { header, packet: sphinx_packet, }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(packet, &mut bytes).unwrap(); - let decoded = SphinxCodec.decode(&mut bytes).unwrap().unwrap(); + NymCodec.encode(packet, &mut bytes).unwrap(); + let decoded = NymCodec.decode(&mut bytes).unwrap().unwrap(); assert_eq!(decoded.header, header); - assert_eq!(decoded.packet.to_bytes(), sphinx_bytes) + assert_eq!(decoded.packet.to_bytes().unwrap(), sphinx_bytes) + } + + #[test] + fn whole_outfox_can_be_decoded_from_a_valid_encoded_instance() { + let header = Header::outfox(); + let packet = make_valid_outfox_packet(PacketSize::OutfoxRegularPacket); + let packet_bytes = packet.to_bytes().unwrap(); + + NymPacket::outfox_from_bytes(packet_bytes.as_slice()).unwrap(); + + let packet = FramedNymPacket { header, packet }; + + let mut bytes = BytesMut::new(); + NymCodec.encode(packet, &mut bytes).unwrap(); + let decoded = NymCodec.decode(&mut bytes).unwrap().unwrap(); + + assert_eq!(decoded.header, header); + assert_eq!(decoded.packet.to_bytes().unwrap(), packet_bytes) } #[cfg(test)] mod decode_will_allocate_enough_bytes_for_next_call { use super::*; use nym_sphinx_params::packet_version::PacketVersion; - use nym_sphinx_params::PacketMode; + use nym_sphinx_params::PacketType; #[test] fn for_empty_bytes() { // empty bytes should allocate for header + ack packet let mut empty_bytes = BytesMut::new(); - assert!(SphinxCodec.decode(&mut empty_bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut empty_bytes).unwrap().is_none()); assert_eq!( empty_bytes.capacity(), Header::LEGACY_SIZE + PacketSize::AckPacket.size() @@ -217,11 +267,11 @@ mod packet_encoding { let header = Header { packet_version: PacketVersion::Legacy, packet_size, - packet_mode: Default::default(), + ..Default::default() }; let mut bytes = BytesMut::new(); header.encode(&mut bytes); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_none()); assert_eq!(bytes.capacity(), Header::LEGACY_SIZE + packet_size.size()) } @@ -241,11 +291,11 @@ mod packet_encoding { let header = Header { packet_version: PacketVersion::Versioned(123), packet_size, - packet_mode: Default::default(), + ..Default::default() }; let mut bytes = BytesMut::new(); header.encode(&mut bytes); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_none()); assert_eq!( bytes.capacity(), @@ -257,18 +307,17 @@ mod packet_encoding { #[test] fn for_full_frame_with_legacy_header() { // if full frame is used exactly, there should be enough space for header + ack packet - let packet = FramedSphinxPacket { + let packet = FramedNymPacket { header: Header { packet_version: PacketVersion::Legacy, - packet_size: Default::default(), - packet_mode: Default::default(), + ..Default::default() }, packet: make_valid_sphinx_packet(Default::default()), }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(packet, &mut bytes).unwrap(); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); + NymCodec.encode(packet, &mut bytes).unwrap(); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); assert_eq!( bytes.capacity(), Header::LEGACY_SIZE + PacketSize::AckPacket.size() @@ -278,14 +327,14 @@ mod packet_encoding { #[test] fn for_full_frame_with_versioned_header() { // if full frame is used exactly, there should be enough space for header + ack packet - let packet = FramedSphinxPacket { + let packet = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(packet, &mut bytes).unwrap(); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); + NymCodec.encode(packet, &mut bytes).unwrap(); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); assert_eq!( bytes.capacity(), Header::VERSIONED_SIZE + PacketSize::AckPacket.size() @@ -304,20 +353,19 @@ mod packet_encoding { ]; for packet_size in packet_sizes { - let first_packet = FramedSphinxPacket { + let first_packet = FramedNymPacket { header: Header { packet_version: PacketVersion::Legacy, - packet_size: Default::default(), - packet_mode: Default::default(), + ..Default::default() }, packet: make_valid_sphinx_packet(Default::default()), }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(first_packet, &mut bytes).unwrap(); + NymCodec.encode(first_packet, &mut bytes).unwrap(); bytes.put_u8(packet_size as u8); - bytes.put_u8(PacketMode::default() as u8); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); + bytes.put_u8(PacketType::default() as u8); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); assert!(bytes.capacity() >= Header::LEGACY_SIZE + packet_size.size()) } @@ -335,53 +383,53 @@ mod packet_encoding { ]; for packet_size in packet_sizes { - let first_packet = FramedSphinxPacket { + let first_packet = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(first_packet, &mut bytes).unwrap(); + NymCodec.encode(first_packet, &mut bytes).unwrap(); bytes.put_u8(PacketVersion::new_versioned(123).as_u8().unwrap()); bytes.put_u8(packet_size as u8); - bytes.put_u8(PacketMode::default() as u8); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); + bytes.put_u8(PacketType::default() as u8); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); - assert!(bytes.capacity() >= Header::VERSIONED_SIZE + packet_size.size()) + // assert!(bytes.capacity() >= Header::VERSIONED_SIZE + packet_size.size()) } } } #[test] fn can_decode_two_packets_immediately() { - let packet1 = FramedSphinxPacket { + let packet1 = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; - let packet2 = FramedSphinxPacket { + let packet2 = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; let mut bytes = BytesMut::new(); - SphinxCodec.encode(packet1, &mut bytes).unwrap(); - SphinxCodec.encode(packet2, &mut bytes).unwrap(); + NymCodec.encode(packet1, &mut bytes).unwrap(); + NymCodec.encode(packet2, &mut bytes).unwrap(); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_none()); } #[test] fn can_decode_two_packets_in_separate_calls() { - let packet1 = FramedSphinxPacket { + let packet1 = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; - let packet2 = FramedSphinxPacket { + let packet2 = FramedNymPacket { header: Header::default(), packet: make_valid_sphinx_packet(Default::default()), }; @@ -389,18 +437,17 @@ mod packet_encoding { let mut bytes = BytesMut::new(); let mut bytes_tmp = BytesMut::new(); - SphinxCodec.encode(packet1, &mut bytes).unwrap(); - SphinxCodec.encode(packet2, &mut bytes_tmp).unwrap(); + NymCodec.encode(packet1, &mut bytes).unwrap(); + NymCodec.encode(packet2, &mut bytes_tmp).unwrap(); let tmp = bytes_tmp.split_off(100); bytes.put(bytes_tmp); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_none()); bytes.put(tmp); - - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_some()); - assert!(SphinxCodec.decode(&mut bytes).unwrap().is_none()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_some()); + assert!(NymCodec.decode(&mut bytes).unwrap().is_none()); } } diff --git a/common/nymsphinx/framing/src/packet.rs b/common/nymsphinx/framing/src/packet.rs index e001083d31..3f6953566b 100644 --- a/common/nymsphinx/framing/src/packet.rs +++ b/common/nymsphinx/framing/src/packet.rs @@ -1,47 +1,57 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::codec::SphinxCodecError; +use crate::codec::NymCodecError; use bytes::{BufMut, BytesMut}; use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::packet_version::PacketVersion; -use nym_sphinx_params::PacketMode; -use nym_sphinx_types::SphinxPacket; +use nym_sphinx_params::PacketType; +use nym_sphinx_types::NymPacket; use std::convert::TryFrom; -pub struct FramedSphinxPacket { +#[derive(Debug)] +pub struct FramedNymPacket { /// Contains any metadata helping receiver to handle the underlying packet. pub(crate) header: Header, /// The actual SphinxPacket being sent. - pub(crate) packet: SphinxPacket, + pub(crate) packet: NymPacket, } -impl FramedSphinxPacket { - pub fn new(packet: SphinxPacket, packet_mode: PacketMode, use_legacy_version: bool) -> Self { +impl FramedNymPacket { + pub fn new(packet: NymPacket, packet_type: PacketType, use_legacy_version: bool) -> Self { // If this fails somebody is using the library in a super incorrect way, because they // already managed to somehow create a sphinx packet let packet_size = PacketSize::get_type(packet.len()).unwrap(); - FramedSphinxPacket { - header: Header { - packet_version: PacketVersion::new(use_legacy_version), - packet_size, - packet_mode, - }, - packet, - } + let use_legacy = if packet_type == PacketType::Outfox { + false + } else { + use_legacy_version + }; + + let header = Header { + packet_version: PacketVersion::new(use_legacy), + packet_size, + packet_type, + }; + + FramedNymPacket { header, packet } + } + + pub fn header(&self) -> Header { + self.header } pub fn packet_size(&self) -> PacketSize { self.header.packet_size } - pub fn packet_mode(&self) -> PacketMode { - self.header.packet_mode + pub fn packet_type(&self) -> PacketType { + self.header.packet_type } - pub fn into_inner(self) -> SphinxPacket { + pub fn into_inner(self) -> NymPacket { self.packet } } @@ -64,15 +74,23 @@ pub struct Header { /// /// TODO: ask @AP whether this can be sent like this - could it introduce some anonymity issues? /// (note: this will be behind some encryption, either something implemented by us or some SSL action) - // Note: currently packet_mode is deprecated but is still left as a concept behind to not break + // Note: currently packet_type is deprecated but is still left as a concept behind to not break // compatibility with existing network - pub(crate) packet_mode: PacketMode, + pub(crate) packet_type: PacketType, } impl Header { pub(crate) const LEGACY_SIZE: usize = 2; pub(crate) const VERSIONED_SIZE: usize = 3; + pub fn outfox() -> Header { + Header { + packet_version: PacketVersion::default(), + packet_size: PacketSize::OutfoxRegularPacket, + packet_type: PacketType::Outfox, + } + } + pub(crate) fn size(&self) -> usize { if self.packet_version.is_legacy() { Self::LEGACY_SIZE @@ -90,12 +108,12 @@ impl Header { } dst.put_u8(self.packet_size as u8); - dst.put_u8(self.packet_mode as u8); + dst.put_u8(self.packet_type as u8); // reserve bytes for the actual packet dst.reserve(self.packet_size.size()); } - pub(crate) fn decode(src: &mut BytesMut) -> Result, SphinxCodecError> { + pub(crate) fn decode(src: &mut BytesMut) -> Result, NymCodecError> { if src.len() < Self::LEGACY_SIZE { // can't do anything if we don't have enough bytes - but reserve enough for the next call src.reserve(Self::LEGACY_SIZE); @@ -107,7 +125,7 @@ impl Header { Ok(Some(Header { packet_version, packet_size: PacketSize::try_from(src[0])?, - packet_mode: PacketMode::try_from(src[1])?, + packet_type: PacketType::try_from(src[1])?, })) } else if src.len() < Self::VERSIONED_SIZE { // we're missing that 1 byte to read the full header... @@ -117,7 +135,7 @@ impl Header { Ok(Some(Header { packet_version, packet_size: PacketSize::try_from(src[1])?, - packet_mode: PacketMode::try_from(src[2])?, + packet_type: PacketType::try_from(src[2])?, })) } } @@ -148,7 +166,7 @@ mod header_encoding { [ PacketVersion::new_versioned(123).as_u8().unwrap(), unknown_packet_size, - PacketMode::default() as u8, + PacketType::default() as u8, ] .as_ref(), ); @@ -156,12 +174,12 @@ mod header_encoding { } #[test] - fn decoding_will_fail_for_unknown_packet_mode() { - let unknown_packet_mode: u8 = 255; + fn decoding_will_fail_for_unknown_packet_type() { + let unknown_packet_type: u8 = 255; // make sure this is still 'unknown' for if we make changes in the future - assert!(PacketMode::try_from(unknown_packet_mode).is_err()); + assert!(PacketType::try_from(unknown_packet_type).is_err()); - let mut bytes = BytesMut::from([PacketSize::default() as u8, unknown_packet_mode].as_ref()); + let mut bytes = BytesMut::from([PacketSize::default() as u8, unknown_packet_type].as_ref()); assert!(Header::decode(&mut bytes).is_err()) } @@ -191,7 +209,7 @@ mod header_encoding { let header = Header { packet_version: PacketVersion::Legacy, packet_size, - packet_mode: Default::default(), + ..Default::default() }; let mut bytes = BytesMut::new(); header.encode(&mut bytes); @@ -212,7 +230,7 @@ mod header_encoding { let header = Header { packet_version: PacketVersion::Versioned(123), packet_size, - packet_mode: Default::default(), + ..Default::default() }; let mut bytes = BytesMut::new(); header.encode(&mut bytes); diff --git a/common/nymsphinx/params/src/lib.rs b/common/nymsphinx/params/src/lib.rs index 5df4db1a2a..7ad247dfa5 100644 --- a/common/nymsphinx/params/src/lib.rs +++ b/common/nymsphinx/params/src/lib.rs @@ -8,11 +8,11 @@ use nym_crypto::ctr; type Aes128Ctr = ctr::Ctr64BE; // Re-export for ease of use -pub use packet_modes::PacketMode; pub use packet_sizes::PacketSize; +pub use packet_types::PacketType; -pub mod packet_modes; pub mod packet_sizes; +pub mod packet_types; pub mod packet_version; // If somebody can provide an argument why it might be reasonable to have more than 255 mix hops, @@ -29,7 +29,7 @@ pub type SerializedFragmentIdentifier = [u8; FRAG_ID_LEN]; // when packet header gets serialized, the following bytes (in that order) are put onto the wire: // - packet_version (starting with v1.1.0) // - packet_size indicator -// - packet_mode +// - packet_type // it also just so happens that the only valid values for packet_size indicator include values 1-6 // therefore if we receive byte `7` (or larger than that) we'll know we received a versioned packet, // otherwise we should treat it as legacy diff --git a/common/nymsphinx/params/src/packet_modes.rs b/common/nymsphinx/params/src/packet_modes.rs deleted file mode 100644 index 87a0c80caf..0000000000 --- a/common/nymsphinx/params/src/packet_modes.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021-2022 - Nym Technologies SA -// SPDX-License-Identifier: Apache-2.0 - -use std::convert::TryFrom; -use thiserror::Error; - -#[derive(Error, Debug)] -#[error("{received} is not a valid packet mode tag")] -pub struct InvalidPacketMode { - received: u8, -} - -#[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] -pub enum PacketMode { - /// Represents 'normal' packet sent through the network that should be delayed by an appropriate - /// value at each hop. - #[default] - Mix = 0, - - /// Represents a VPN packet that should not be delayed and ideally cached pre-computed keys - /// should be used for unwrapping data. Note that it does not offer the same level of anonymity. - Vpn = 1, -} - -impl PacketMode { - pub fn is_mix(self) -> bool { - self == PacketMode::Mix - } - - pub fn is_old_vpn(self) -> bool { - self == PacketMode::Vpn - } -} - -impl TryFrom for PacketMode { - type Error = InvalidPacketMode; - - fn try_from(value: u8) -> Result { - match value { - _ if value == (PacketMode::Mix as u8) => Ok(Self::Mix), - _ if value == (PacketMode::Vpn as u8) => Ok(Self::Vpn), - v => Err(InvalidPacketMode { received: v }), - } - } -} diff --git a/common/nymsphinx/params/src/packet_sizes.rs b/common/nymsphinx/params/src/packet_sizes.rs index 0e636e54b3..874cbd9805 100644 --- a/common/nymsphinx/params/src/packet_sizes.rs +++ b/common/nymsphinx/params/src/packet_sizes.rs @@ -1,9 +1,11 @@ // Copyright 2021-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::FRAG_ID_LEN; +use crate::{PacketType, FRAG_ID_LEN}; use nym_sphinx_types::header::HEADER_SIZE; -use nym_sphinx_types::PAYLOAD_OVERHEAD_SIZE; +use nym_sphinx_types::{ + MIN_PACKET_SIZE, MIX_PARAMS_LEN, OUTFOX_PACKET_OVERHEAD, PAYLOAD_OVERHEAD_SIZE, +}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::convert::TryFrom; @@ -12,20 +14,24 @@ use std::str::FromStr; use thiserror::Error; // each sphinx packet contains mandatory header and payload padding + markers -const PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; +const SPHINX_PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; // it's up to the smart people to figure those values out : ) -const REGULAR_PACKET_SIZE: usize = 2 * 1024 + PACKET_OVERHEAD; + // TODO: even though we have 16B IV, is having just 5B (FRAG_ID_LEN) of the ID possibly insecure? // TODO: I'm not entirely sure if we can easily extract `::NonceSize` // into a const usize before relevant stuff is stabilised in rust... const ACK_IV_SIZE: usize = 16; -const ACK_PACKET_SIZE: usize = ACK_IV_SIZE + FRAG_ID_LEN + PACKET_OVERHEAD; -const EXTENDED_PACKET_SIZE_8: usize = 8 * 1024 + PACKET_OVERHEAD; -const EXTENDED_PACKET_SIZE_16: usize = 16 * 1024 + PACKET_OVERHEAD; -const EXTENDED_PACKET_SIZE_32: usize = 32 * 1024 + PACKET_OVERHEAD; +const ACK_PACKET_SIZE: usize = ACK_IV_SIZE + FRAG_ID_LEN + SPHINX_PACKET_OVERHEAD; +const REGULAR_PACKET_SIZE: usize = 2 * 1024 + SPHINX_PACKET_OVERHEAD; +const EXTENDED_PACKET_SIZE_8: usize = 8 * 1024 + SPHINX_PACKET_OVERHEAD; +const EXTENDED_PACKET_SIZE_16: usize = 16 * 1024 + SPHINX_PACKET_OVERHEAD; +const EXTENDED_PACKET_SIZE_32: usize = 32 * 1024 + SPHINX_PACKET_OVERHEAD; + +const OUTFOX_ACK_PACKET_SIZE: usize = MIN_PACKET_SIZE + OUTFOX_PACKET_OVERHEAD; +const OUTFOX_REGULAR_PACKET_SIZE: usize = 2 * 1024 + OUTFOX_PACKET_OVERHEAD; #[derive(Debug, Error)] pub enum InvalidPacketSize { @@ -62,6 +68,13 @@ pub enum PacketSize { // for example for streaming fast and furious in compressed XviD quality #[serde(rename = "extended16")] ExtendedPacket16 = 5, + + #[serde(rename = "outfox_regular")] + OutfoxRegularPacket = 6, + + // for sending SURB-ACKs + #[serde(rename = "outfox_ack")] + OutfoxAckPacket = 7, } impl PartialOrd for PacketSize { @@ -88,6 +101,8 @@ impl FromStr for PacketSize { "extended8" => Ok(Self::ExtendedPacket8), "extended16" => Ok(Self::ExtendedPacket16), "extended32" => Ok(Self::ExtendedPacket32), + "outfox_regular" => Ok(Self::OutfoxRegularPacket), + "outfox_ack" => Ok(Self::OutfoxAckPacket), s => Err(InvalidPacketSize::UnknownExtendedPacketVariant { received: s.to_string(), }), @@ -103,6 +118,8 @@ impl Display for PacketSize { PacketSize::ExtendedPacket32 => write!(f, "extended32"), PacketSize::ExtendedPacket8 => write!(f, "extended8"), PacketSize::ExtendedPacket16 => write!(f, "extended16"), + PacketSize::OutfoxRegularPacket => write!(f, "outfox_regular"), + PacketSize::OutfoxAckPacket => write!(f, "outfox_ack"), } } } @@ -127,6 +144,8 @@ impl TryFrom for PacketSize { _ if value == (PacketSize::ExtendedPacket8 as u8) => Ok(Self::ExtendedPacket8), _ if value == (PacketSize::ExtendedPacket16 as u8) => Ok(Self::ExtendedPacket16), _ if value == (PacketSize::ExtendedPacket32 as u8) => Ok(Self::ExtendedPacket32), + _ if value == (PacketSize::OutfoxRegularPacket as u8) => Ok(Self::OutfoxRegularPacket), + _ if value == (PacketSize::OutfoxAckPacket as u8) => Ok(Self::OutfoxAckPacket), v => Err(InvalidPacketSize::UnknownPacketTag { received: v }), } } @@ -140,15 +159,41 @@ impl PacketSize { PacketSize::ExtendedPacket8 => EXTENDED_PACKET_SIZE_8, PacketSize::ExtendedPacket16 => EXTENDED_PACKET_SIZE_16, PacketSize::ExtendedPacket32 => EXTENDED_PACKET_SIZE_32, + PacketSize::OutfoxRegularPacket => OUTFOX_REGULAR_PACKET_SIZE, + PacketSize::OutfoxAckPacket => OUTFOX_ACK_PACKET_SIZE, + } + } + + pub const fn header_size(&self) -> usize { + match self { + PacketSize::RegularPacket + | PacketSize::AckPacket + | PacketSize::ExtendedPacket8 + | PacketSize::ExtendedPacket16 + | PacketSize::ExtendedPacket32 => HEADER_SIZE, + PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => MIX_PARAMS_LEN, + } + } + + pub const fn payload_overhead(&self) -> usize { + match self { + PacketSize::RegularPacket + | PacketSize::AckPacket + | PacketSize::ExtendedPacket8 + | PacketSize::ExtendedPacket16 + | PacketSize::ExtendedPacket32 => PAYLOAD_OVERHEAD_SIZE, + PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => { + OUTFOX_PACKET_OVERHEAD - MIX_PARAMS_LEN // Mix params are calculated into the total overhead so we take them out here + } } } pub const fn plaintext_size(self) -> usize { - self.size() - HEADER_SIZE - PAYLOAD_OVERHEAD_SIZE + self.size() - self.header_size() - self.payload_overhead() } pub const fn payload_size(self) -> usize { - self.size() - HEADER_SIZE + self.size() - self.header_size() } pub fn get_type(size: usize) -> Result { @@ -162,6 +207,12 @@ impl PacketSize { Ok(PacketSize::ExtendedPacket16) } else if PacketSize::ExtendedPacket32.size() == size { Ok(PacketSize::ExtendedPacket32) + } else if PacketSize::OutfoxRegularPacket.size() == size + || PacketSize::OutfoxRegularPacket.size() == size + 6 + { + Ok(PacketSize::OutfoxRegularPacket) + } else if PacketSize::OutfoxAckPacket.size() == size { + Ok(PacketSize::OutfoxAckPacket) } else { Err(InvalidPacketSize::UnknownPacketSize { received: size }) } @@ -169,7 +220,10 @@ impl PacketSize { pub fn is_extended_size(&self) -> bool { match self { - PacketSize::RegularPacket | PacketSize::AckPacket => false, + PacketSize::RegularPacket + | PacketSize::AckPacket + | PacketSize::OutfoxAckPacket + | PacketSize::OutfoxRegularPacket => false, PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 | PacketSize::ExtendedPacket32 => true, @@ -184,8 +238,16 @@ impl PacketSize { } } - pub fn get_type_from_plaintext(plaintext_size: usize) -> Result { - let packet_size = plaintext_size + PACKET_OVERHEAD; + pub fn get_type_from_plaintext( + plaintext_size: usize, + packet_type: PacketType, + ) -> Result { + let overhead = match packet_type { + PacketType::Mix => SPHINX_PACKET_OVERHEAD, + PacketType::Vpn => SPHINX_PACKET_OVERHEAD, + PacketType::Outfox => OUTFOX_PACKET_OVERHEAD, + }; + let packet_size = plaintext_size + overhead; Self::get_type(packet_size) } } diff --git a/common/nymsphinx/params/src/packet_types.rs b/common/nymsphinx/params/src/packet_types.rs new file mode 100644 index 0000000000..39a5701367 --- /dev/null +++ b/common/nymsphinx/params/src/packet_types.rs @@ -0,0 +1,76 @@ +// Copyright 2021-2022 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use serde::{Deserialize, Serialize}; +use std::convert::TryFrom; +use std::fmt; +use thiserror::Error; + +use crate::PacketSize; + +#[derive(Error, Debug)] +#[error("{received} is not a valid packet mode tag")] +pub struct InvalidPacketType { + received: u8, +} + +#[repr(u8)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] +pub enum PacketType { + /// Represents 'normal' packet sent through the network that should be delayed by an appropriate + /// value at each hop. + #[default] + Mix = 0, + + /// Represents a packet that should be sent through the network as fast as possible. + Vpn = 1, + + /// Abusing this to add Outfox support + Outfox = 2, +} + +impl fmt::Display for PacketType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + PacketType::Mix => write!(f, "Mix"), + PacketType::Vpn => write!(f, "Vpn"), + PacketType::Outfox => write!(f, "Outfox"), + } + } +} + +impl PacketType { + pub fn is_mix(self) -> bool { + self == PacketType::Mix + } + + pub fn is_outfox(self) -> bool { + self == PacketType::Outfox + } +} + +impl TryFrom for PacketType { + type Error = InvalidPacketType; + + fn try_from(value: u8) -> Result { + match value { + _ if value == (PacketType::Mix as u8) => Ok(Self::Mix), + _ if value == (PacketType::Outfox as u8) => Ok(Self::Outfox), + v => Err(InvalidPacketType { received: v }), + } + } +} + +impl From for PacketType { + fn from(s: PacketSize) -> Self { + match s { + PacketSize::RegularPacket => PacketType::Mix, + PacketSize::AckPacket => PacketType::Mix, + PacketSize::ExtendedPacket32 => PacketType::Mix, + PacketSize::ExtendedPacket8 => PacketType::Mix, + PacketSize::ExtendedPacket16 => PacketType::Mix, + PacketSize::OutfoxRegularPacket => PacketType::Outfox, + PacketSize::OutfoxAckPacket => PacketType::Outfox, + } + } +} diff --git a/common/nymsphinx/params/src/packet_version.rs b/common/nymsphinx/params/src/packet_version.rs index 001f46c84d..c8c6ce3fc6 100644 --- a/common/nymsphinx/params/src/packet_version.rs +++ b/common/nymsphinx/params/src/packet_version.rs @@ -1,9 +1,11 @@ // Copyright 2022 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use serde::{Deserialize, Serialize}; + use crate::{PacketSize, CURRENT_PACKET_VERSION_NUMBER}; -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum PacketVersion { // this will allow updated mixnodes to still understand packets from before the update Legacy, diff --git a/common/nymsphinx/src/lib.rs b/common/nymsphinx/src/lib.rs index b3c6bac16a..c27867635b 100644 --- a/common/nymsphinx/src/lib.rs +++ b/common/nymsphinx/src/lib.rs @@ -21,4 +21,4 @@ pub use nym_sphinx_types::*; pub use nym_sphinx_framing as framing; // TEMP UNTIL FURTHER REFACTORING -pub use preparer::payload::NymsphinxPayloadBuilder; +pub use preparer::payload::NymPayloadBuilder; diff --git a/common/nymsphinx/src/message.rs b/common/nymsphinx/src/message.rs index 3e0e260c2d..7a8f3b6531 100644 --- a/common/nymsphinx/src/message.rs +++ b/common/nymsphinx/src/message.rs @@ -11,12 +11,14 @@ use nym_sphinx_anonymous_replies::requests::{ ReplyMessageContent, }; use nym_sphinx_chunking::fragment::Fragment; -use nym_sphinx_params::{PacketSize, ReplySurbKeyDigestAlgorithm}; +use nym_sphinx_params::{PacketSize, PacketType, ReplySurbKeyDigestAlgorithm}; use rand::Rng; use std::fmt::{Display, Formatter}; use thiserror::Error; pub(crate) const ACK_OVERHEAD: usize = MAX_NODE_ADDRESS_UNPADDED_LEN + PacketSize::AckPacket.size(); +pub(crate) const OUTFOX_ACK_OVERHEAD: usize = + MAX_NODE_ADDRESS_UNPADDED_LEN + PacketSize::OutfoxAckPacket.size(); #[derive(Debug, Error)] pub enum NymMessageError { @@ -187,8 +189,15 @@ impl NymMessage { NymMessage::Reply(_) => ReplySurbKeyDigestAlgorithm::output_size(), }; + let packet_type = PacketType::from(packet_size); + // each packet will contain an ack + variant specific data (as described above) - packet_size.plaintext_size() - ACK_OVERHEAD - variant_overhead + match packet_type { + PacketType::Outfox => { + packet_size.plaintext_size() - OUTFOX_ACK_OVERHEAD - variant_overhead + } + _ => packet_size.plaintext_size() - ACK_OVERHEAD - variant_overhead, + } } /// Length of the actual (from the **message** point of view) data that is available in each packet. diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index e06a9f44b9..2a9bca6159 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -1,8 +1,8 @@ // Copyright 2021-2022 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::message::{NymMessage, ACK_OVERHEAD}; -use crate::NymsphinxPayloadBuilder; +use crate::message::{NymMessage, ACK_OVERHEAD, OUTFOX_ACK_OVERHEAD}; +use crate::NymPayloadBuilder; use nym_crypto::asymmetric::encryption; use nym_crypto::Digest; use nym_sphinx_acknowledgements::surb_ack::SurbAck; @@ -13,9 +13,8 @@ use nym_sphinx_anonymous_replies::reply_surb::ReplySurb; use nym_sphinx_chunking::fragment::{Fragment, FragmentIdentifier}; use nym_sphinx_forwarding::packet::MixPacket; use nym_sphinx_params::packet_sizes::PacketSize; -use nym_sphinx_params::{ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; -use nym_sphinx_types::builder::SphinxPacketBuilder; -use nym_sphinx_types::{delays, Delay}; +use nym_sphinx_params::{PacketType, ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; +use nym_sphinx_types::{delays, Delay, NymPacket}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, Rng}; use std::convert::TryFrom; @@ -77,6 +76,7 @@ pub trait FragmentPreparer { fragment_id: FragmentIdentifier, topology: &NymTopology, ack_key: &AckKey, + packet_type: PacketType, ) -> Result { let ack_delay = self.average_ack_delay(); @@ -87,6 +87,7 @@ pub trait FragmentPreparer { fragment_id.to_bytes(), ack_delay, topology, + packet_type, ) } @@ -107,15 +108,20 @@ pub trait FragmentPreparer { ack_key: &AckKey, reply_surb: ReplySurb, packet_sender: &Recipient, + packet_type: PacketType, ) -> Result { // each reply attaches the digest of the encryption key so that the recipient could // lookup correct key for decryption, let reply_overhead = ReplySurbKeyDigestAlgorithm::output_size(); - let expected_plaintext = fragment.serialized_size() + ACK_OVERHEAD + reply_overhead; + let expected_plaintext = match packet_type { + PacketType::Outfox => fragment.serialized_size() + OUTFOX_ACK_OVERHEAD + reply_overhead, + _ => fragment.serialized_size() + ACK_OVERHEAD + reply_overhead, + }; // the reason we're unwrapping (or rather 'expecting') here rather than handling the error // more gracefully is that this error should never be reached as it implies incorrect chunking - let packet_size = PacketSize::get_type_from_plaintext(expected_plaintext) + // reply packets are always Sphinx + let packet_size = PacketSize::get_type_from_plaintext(expected_plaintext, PacketType::Mix) .expect("the message has been incorrectly fragmented"); // this is not going to be accurate by any means. but that's the best estimation we can do @@ -126,24 +132,34 @@ pub trait FragmentPreparer { let fragment_identifier = fragment.fragment_identifier(); // create an ack - let surb_ack = - self.generate_surb_ack(packet_sender, fragment_identifier, topology, ack_key)?; + let surb_ack = self.generate_surb_ack( + packet_sender, + fragment_identifier, + topology, + ack_key, + packet_type, + )?; let ack_delay = surb_ack.expected_total_delay(); - let packet_payload = NymsphinxPayloadBuilder::new(fragment, surb_ack) - .build_reply(reply_surb.encryption_key()); + let packet_payload = match NymPayloadBuilder::new(fragment, surb_ack) + .build_reply(reply_surb.encryption_key()) + { + Ok(payload) => payload, + Err(_e) => return Err(NymTopologyError::PayloadBuilder), + }; // the unwrap here is fine as the failures can only originate from attempting to use invalid payload lengths // and we just very carefully constructed a (presumably) valid one - let (sphinx_packet, first_hop_address) = - reply_surb.apply_surb(packet_payload, packet_size).unwrap(); + let (sphinx_packet, first_hop_address) = reply_surb + .apply_surb(packet_payload, packet_size, packet_type) + .unwrap(); Ok(PreparedFragment { // the round-trip delay is the sum of delays of all hops on the forward route as // well as the total delay of the ack packet. // we don't know the delays inside the reply surbs so we use best-effort estimation from our poisson distribution total_delay: expected_forward_delay + ack_delay, - mix_packet: MixPacket::new(first_hop_address, sphinx_packet, Default::default()), + mix_packet: MixPacket::new(first_hop_address, sphinx_packet, packet_type), fragment_identifier, }) } @@ -172,27 +188,42 @@ pub trait FragmentPreparer { ack_key: &AckKey, packet_sender: &Recipient, packet_recipient: &Recipient, + packet_type: PacketType, ) -> Result { // each plain or repliable packet (i.e. not a reply) attaches an ephemeral public key so that the recipient // could perform diffie-hellman with its own keys followed by a kdf to re-derive // the packet encryption key let non_reply_overhead = encryption::PUBLIC_KEY_SIZE; - let expected_plaintext = fragment.serialized_size() + ACK_OVERHEAD + non_reply_overhead; + let expected_plaintext = match packet_type { + PacketType::Outfox => { + fragment.serialized_size() + OUTFOX_ACK_OVERHEAD + non_reply_overhead + } + _ => fragment.serialized_size() + ACK_OVERHEAD + non_reply_overhead, + }; // the reason we're unwrapping (or rather 'expecting') here rather than handling the error // more gracefully is that this error should never be reached as it implies incorrect chunking - let packet_size = PacketSize::get_type_from_plaintext(expected_plaintext) + let packet_size = PacketSize::get_type_from_plaintext(expected_plaintext, packet_type) .expect("the message has been incorrectly fragmented"); let fragment_identifier = fragment.fragment_identifier(); // create an ack - let surb_ack = - self.generate_surb_ack(packet_sender, fragment_identifier, topology, ack_key)?; + let surb_ack = self.generate_surb_ack( + packet_sender, + fragment_identifier, + topology, + ack_key, + packet_type, + )?; let ack_delay = surb_ack.expected_total_delay(); - let packet_payload = NymsphinxPayloadBuilder::new(fragment, surb_ack) - .build_regular(self.rng(), packet_recipient.encryption_key()); + let packet_payload = match NymPayloadBuilder::new(fragment, surb_ack) + .build_regular(self.rng(), packet_recipient.encryption_key()) + { + Ok(payload) => payload, + Err(_e) => return Err(NymTopologyError::PayloadBuilder), + }; // generate pseudorandom route for the packet let hops = self.num_mix_hops(); @@ -206,10 +237,28 @@ pub trait FragmentPreparer { // create the actual sphinx packet here. With valid route and correct payload size, // there's absolutely no reason for this call to fail. - let sphinx_packet = SphinxPacketBuilder::new() - .with_payload_size(packet_size.payload_size()) - .build_packet(packet_payload, &route, &destination, &delays) - .unwrap(); + let packet = match packet_type { + PacketType::Outfox => NymPacket::outfox_build( + packet_payload, + route.as_slice(), + &destination, + Some(packet_size.plaintext_size()), + )?, + PacketType::Mix => NymPacket::sphinx_build( + packet_size.payload_size(), + packet_payload, + &route, + &destination, + &delays, + )?, + PacketType::Vpn => NymPacket::sphinx_build( + packet_size.payload_size(), + packet_payload, + &route, + &destination, + &delays, + )?, + }; // from the previously constructed route extract the first hop let first_hop_address = @@ -220,7 +269,7 @@ pub trait FragmentPreparer { // well as the total delay of the ack packet. // note that the last hop of the packet is a gateway that does not do any delays total_delay: delays.iter().take(delays.len() - 1).sum::() + ack_delay, - mix_packet: MixPacket::new(first_hop_address, sphinx_packet, Default::default()), + mix_packet: MixPacket::new(first_hop_address, packet, packet_type), fragment_identifier, }) } @@ -317,11 +366,18 @@ where topology: &NymTopology, ack_key: &AckKey, reply_surb: ReplySurb, + packet_type: PacketType, ) -> Result { let sender = self.sender_address; ::prepare_reply_chunk_for_sending( - self, fragment, topology, ack_key, reply_surb, &sender, + self, + fragment, + topology, + ack_key, + reply_surb, + &sender, + packet_type, ) } @@ -331,6 +387,7 @@ where topology: &NymTopology, ack_key: &AckKey, packet_recipient: &Recipient, + packet_type: PacketType, ) -> Result { let sender = self.sender_address; @@ -341,6 +398,7 @@ where ack_key, &sender, packet_recipient, + packet_type, ) } @@ -350,9 +408,17 @@ where fragment_id: FragmentIdentifier, topology: &NymTopology, ack_key: &AckKey, + packet_type: PacketType, ) -> Result { let sender = self.sender_address; - ::generate_surb_ack(self, &sender, fragment_id, topology, ack_key) + ::generate_surb_ack( + self, + &sender, + fragment_id, + topology, + ack_key, + packet_type, + ) } pub fn pad_and_split_message( diff --git a/common/nymsphinx/src/preparer/payload.rs b/common/nymsphinx/src/preparer/payload.rs index 60786d3f11..5999026252 100644 --- a/common/nymsphinx/src/preparer/payload.rs +++ b/common/nymsphinx/src/preparer/payload.rs @@ -6,7 +6,7 @@ use nym_crypto::asymmetric::encryption; use nym_crypto::shared_key::new_ephemeral_shared_key; use nym_crypto::symmetric::stream_cipher; use nym_crypto::symmetric::stream_cipher::CipherKey; -use nym_sphinx_acknowledgements::surb_ack::SurbAck; +use nym_sphinx_acknowledgements::surb_ack::{SurbAck, SurbAckRecoveryError}; use nym_sphinx_anonymous_replies::SurbEncryptionKey; use nym_sphinx_chunking::fragment::Fragment; use nym_sphinx_params::{ @@ -14,25 +14,25 @@ use nym_sphinx_params::{ }; use rand::{CryptoRng, RngCore}; -pub struct NymsphinxPayloadBuilder { +pub struct NymPayloadBuilder { fragment: Fragment, surb_ack: SurbAck, } -impl NymsphinxPayloadBuilder { +impl NymPayloadBuilder { pub fn new(fragment: Fragment, surb_ack: SurbAck) -> Self { - NymsphinxPayloadBuilder { fragment, surb_ack } + NymPayloadBuilder { fragment, surb_ack } } fn build( self, packet_encryption_key: &CipherKey, variant_data: impl IntoIterator, - ) -> NymsphinxPayload + ) -> Result where C: StreamCipher + KeyIvInit, { - let (_, surb_ack_bytes) = self.surb_ack.prepare_for_sending(); + let (_, surb_ack_bytes) = self.surb_ack.prepare_for_sending()?; let mut fragment_data = self.fragment.into_bytes(); stream_cipher::encrypt_in_place::( @@ -46,16 +46,20 @@ impl NymsphinxPayloadBuilder { // where variant-specific data is as follows: // for replies it would be the digest of the encryption key used // for 'regular' messages it would be the public component used in DH later used in the KDF - NymsphinxPayload( + + Ok(NymPayload( surb_ack_bytes .into_iter() .chain(variant_data.into_iter()) .chain(fragment_data.into_iter()) .collect(), - ) + )) } - pub fn build_reply(self, packet_encryption_key: &SurbEncryptionKey) -> NymsphinxPayload { + pub fn build_reply( + self, + packet_encryption_key: &SurbEncryptionKey, + ) -> Result { let key_digest = packet_encryption_key.compute_digest(); self.build::( packet_encryption_key.inner(), @@ -67,7 +71,7 @@ impl NymsphinxPayloadBuilder { self, rng: &mut R, recipient_encryption_key: &encryption::PublicKey, - ) -> NymsphinxPayload + ) -> Result where R: RngCore + CryptoRng, { @@ -88,9 +92,9 @@ impl NymsphinxPayloadBuilder { // the actual byte data that will be put into the sphinx packet paylaod. // no more transformations are going to happen to it // TODO: use that fact for some better compile time assertions -pub struct NymsphinxPayload(Vec); +pub struct NymPayload(Vec); -impl AsRef<[u8]> for NymsphinxPayload { +impl AsRef<[u8]> for NymPayload { fn as_ref(&self) -> &[u8] { &self.0 } diff --git a/common/nymsphinx/src/receiver.rs b/common/nymsphinx/src/receiver.rs index 49af877502..631ee5eef0 100644 --- a/common/nymsphinx/src/receiver.rs +++ b/common/nymsphinx/src/receiver.rs @@ -7,8 +7,6 @@ use nym_crypto::asymmetric::encryption; use nym_crypto::shared_key::recompute_shared_key; use nym_crypto::symmetric::stream_cipher; use nym_crypto::symmetric::stream_cipher::CipherKey; -use nym_outfox::error::OutfoxError; -use nym_outfox::lion::lion_transform_decrypt; use nym_sphinx_anonymous_replies::requests::AnonymousSenderTag; use nym_sphinx_anonymous_replies::SurbEncryptionKey; use nym_sphinx_chunking::fragment::Fragment; @@ -76,49 +74,6 @@ pub enum MessageRecoveryError { #[error("Failed to recover message fragment - {0}")] FragmentRecoveryError(#[from] ChunkingError), - - #[error("Outfox: {source}")] - OutfoxRecoveryError { - #[from] - source: OutfoxError, - }, -} - -#[derive(Default)] -pub struct OutfoxMessageReceiver { - reconstructor: MessageReconstructor, -} - -impl OutfoxMessageReceiver { - pub fn new() -> Self { - Default::default() - } -} - -impl MessageReceiver for OutfoxMessageReceiver { - fn new() -> Self { - Self::default() - } - - fn reconstructor(&mut self) -> &mut MessageReconstructor { - &mut self.reconstructor - } - - fn num_mix_hops(&self) -> u8 { - DEFAULT_NUM_MIX_HOPS - } - - fn decrypt_raw_message( - &self, - message: &mut [u8], - key: &CipherKey, - ) -> Result<(), MessageRecoveryError> - where - C: StreamCipher + KeyIvInit, - { - lion_transform_decrypt(message, key)?; - Ok(()) - } } pub trait MessageReceiver { diff --git a/common/nymsphinx/types/Cargo.toml b/common/nymsphinx/types/Cargo.toml index 6be749396a..2c52ef03d9 100644 --- a/common/nymsphinx/types/Cargo.toml +++ b/common/nymsphinx/types/Cargo.toml @@ -9,6 +9,5 @@ repository = { workspace = true } [dependencies] sphinx-packet = { version = "0.1.0" } - -#[patch.crates-io] -#sphinx-packet = { path = "../../../../sphinx" } +nym-outfox = { path = "../../../nym-outfox" } +thiserror = "1" diff --git a/common/nymsphinx/types/src/lib.rs b/common/nymsphinx/types/src/lib.rs index e80268ada0..bd3063f939 100644 --- a/common/nymsphinx/types/src/lib.rs +++ b/common/nymsphinx/types/src/lib.rs @@ -1,7 +1,12 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +pub use nym_outfox::{ + constants::MIN_PACKET_SIZE, constants::MIX_PARAMS_LEN, constants::OUTFOX_PACKET_OVERHEAD, + error::OutfoxError, +}; // re-exporting types and constants available in sphinx +use nym_outfox::packet::{OutfoxPacket, OutfoxProcessedPacket}; pub use sphinx_packet::{ constants::{ self, DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, MAX_PATH_LENGTH, NODE_ADDRESS_LENGTH, @@ -9,9 +14,123 @@ pub use sphinx_packet::{ }, crypto::{self, EphemeralSecret, PrivateKey, PublicKey, SharedSecret}, header::{self, delays, delays::Delay, ProcessedHeader, SphinxHeader, HEADER_SIZE}, - packet::builder::{self, DEFAULT_PAYLOAD_SIZE}, + packet::builder::DEFAULT_PAYLOAD_SIZE, payload::{Payload, PAYLOAD_OVERHEAD_SIZE}, route::{Destination, DestinationAddressBytes, Node, NodeAddressBytes, SURBIdentifier}, surb::{SURBMaterial, SURB}, - Error, ProcessedPacket, Result, SphinxPacket, + Error as SphinxError, ProcessedPacket, }; +use sphinx_packet::{SphinxPacket, SphinxPacketBuilder}; +use std::{array::TryFromSliceError, fmt}; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum NymPacketError { + #[error("Sphinx error: {0}")] + Sphinx(#[from] sphinx_packet::Error), + + #[error("Outfox error: {0}")] + Outfox(#[from] nym_outfox::error::OutfoxError), + + #[error("{0}")] + FromSlice(#[from] TryFromSliceError), +} + +#[allow(clippy::large_enum_variant)] +pub enum NymPacket { + Sphinx(SphinxPacket), + Outfox(OutfoxPacket), +} + +pub enum NymProcessedPacket { + Sphinx(ProcessedPacket), + Outfox(OutfoxProcessedPacket), +} + +impl fmt::Debug for NymPacket { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match &self { + NymPacket::Sphinx(packet) => f + .debug_struct("NymPacket::Sphinx") + .field("len", &packet.len()) + .finish(), + NymPacket::Outfox(packet) => f + .debug_struct("NymPacket::Outfox") + .field("len", &packet.len()) + .finish(), + } + } +} + +impl NymPacket { + pub fn sphinx_build>( + size: usize, + message: M, + route: &[Node], + destination: &Destination, + delays: &[Delay], + ) -> Result { + Ok(NymPacket::Sphinx( + SphinxPacketBuilder::new() + .with_payload_size(size) + .build_packet(message, route, destination, delays)?, + )) + } + pub fn sphinx_from_bytes(bytes: &[u8]) -> Result { + Ok(NymPacket::Sphinx(SphinxPacket::from_bytes(bytes)?)) + } + + pub fn outfox_build>( + payload: M, + route: &[Node], + destination: &Destination, + size: Option, + ) -> Result { + Ok(NymPacket::Outfox(OutfoxPacket::build( + payload, + route.try_into()?, + destination, + size, + )?)) + } + + pub fn outfox_from_bytes(bytes: &[u8]) -> Result { + Ok(NymPacket::Outfox(OutfoxPacket::try_from(bytes)?)) + } + + pub fn len(&self) -> usize { + match self { + NymPacket::Sphinx(packet) => packet.len(), + NymPacket::Outfox(packet) => packet.len(), + } + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + pub fn to_bytes(&self) -> Result, NymPacketError> { + match self { + NymPacket::Sphinx(packet) => Ok(packet.to_bytes()), + NymPacket::Outfox(packet) => Ok(packet.to_bytes()?), + } + } + + pub fn process( + self, + node_secret_key: &PrivateKey, + ) -> Result { + match self { + NymPacket::Sphinx(packet) => { + Ok(NymProcessedPacket::Sphinx(packet.process(node_secret_key)?)) + } + NymPacket::Outfox(mut packet) => { + let next_address = packet.decode_next_layer(node_secret_key)?; + Ok(NymProcessedPacket::Outfox(OutfoxProcessedPacket::new( + packet, + next_address, + ))) + } + } + } +} diff --git a/common/socks5-client-core/src/config/mod.rs b/common/socks5-client-core/src/config/mod.rs index fbe5f06c8d..33e6bd2774 100644 --- a/common/socks5-client-core/src/config/mod.rs +++ b/common/socks5-client-core/src/config/mod.rs @@ -12,7 +12,7 @@ use nym_socks5_requests::Socks5ProtocolVersion; use nym_sphinx::addressing::clients::Recipient; use serde::{Deserialize, Serialize}; use std::fmt::Debug; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::str::FromStr; pub mod old_config_v1_1_13; @@ -36,9 +36,9 @@ impl NymConfig for Config { } fn default_root_directory() -> PathBuf { - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value"); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios"))] let base_dir = PathBuf::from("/tmp"); base_dir.join(".nym").join("socks5-clients") @@ -77,6 +77,14 @@ impl Config { } } + #[must_use] + pub fn with_root_directory>(mut self, root_dir: P) -> Self { + self.base = self.base.reset_nym_root_directory(root_dir); + let data_dir = self.data_directory(); + self.base = self.base.reset_data_directory(data_dir); + self + } + pub fn validate(&self) -> bool { // no other sections have explicit requirements (yet) self.base.validate() @@ -224,6 +232,10 @@ impl Socks5 { self.send_anonymously = anonymous_replies; } + pub fn get_raw_provider_mix_address(&self) -> String { + self.provider_mix_address.clone() + } + pub fn get_provider_mix_address(&self) -> Recipient { Recipient::try_from_base58_string(&self.provider_mix_address) .expect("malformed provider address") diff --git a/common/socks5-client-core/src/config/old_config_v1_1_13.rs b/common/socks5-client-core/src/config/old_config_v1_1_13.rs index 241acf96a6..754b363d81 100644 --- a/common/socks5-client-core/src/config/old_config_v1_1_13.rs +++ b/common/socks5-client-core/src/config/old_config_v1_1_13.rs @@ -23,9 +23,9 @@ impl NymConfig for OldConfigV1_1_13 { } fn default_root_directory() -> PathBuf { - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value"); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios"))] let base_dir = PathBuf::from("/tmp"); base_dir.join(".nym").join("socks5-clients") diff --git a/common/socks5-client-core/src/lib.rs b/common/socks5-client-core/src/lib.rs index 1b9b504485..8564325f78 100644 --- a/common/socks5-client-core/src/lib.rs +++ b/common/socks5-client-core/src/lib.rs @@ -5,39 +5,24 @@ use crate::config::{Config, Socks5}; use crate::error::Socks5ClientCoreError; use crate::socks::{ authentication::{AuthenticationMethods, Authenticator, User}, - server::SphinxSocksServer, + server::NymSocksServer, }; use futures::channel::mpsc; use futures::StreamExt; use log::*; -use nym_bandwidth_controller::BandwidthController; +use nym_client_core::client::base_client::storage::MixnetClientStorage; use nym_client_core::client::base_client::{ - BaseClientBuilder, ClientInput, ClientOutput, ClientState, + non_wasm_helpers, BaseClientBuilder, ClientInput, ClientOutput, ClientState, }; -use nym_client_core::config::persistence::key_pathfinder::ClientKeyPathfinder; +use nym_client_core::client::key_manager::persistence::KeyStore; +use nym_client_core::client::replies::reply_storage::ReplyStorageBackend; use nym_client_core::config::DebugConfig; +use nym_credential_storage::storage::Storage as CredentialStorage; use nym_sphinx::addressing::clients::Recipient; +use nym_sphinx::params::PacketType; use nym_task::{TaskClient, TaskManager}; -use nym_validator_client::nyxd::QueryNyxdClient; -use nym_validator_client::Client; use std::error::Error; -#[cfg(target_os = "android")] -use nym_client_core::client::{ - base_client::helpers::setup_empty_reply_surb_backend, base_client::storage, - key_manager::persistence::InMemEphemeralKeys, replies::reply_storage, -}; -#[cfg(target_os = "android")] -use nym_credential_storage::ephemeral_storage::EphemeralStorage; - -#[cfg(not(target_os = "android"))] -use nym_client_core::client::{ - base_client::non_wasm_helpers, base_client::storage::OnDiskPersistent, - key_manager::persistence::OnDiskKeys, replies::reply_storage::fs_backend, -}; -#[cfg(not(target_os = "android"))] -use nym_credential_storage::persistent_storage::PersistentStorage; - pub mod config; pub mod error; pub mod socks; @@ -46,30 +31,41 @@ pub mod socks; pub type Socks5ControlMessageSender = mpsc::UnboundedSender; pub type Socks5ControlMessageReceiver = mpsc::UnboundedReceiver; -#[cfg(target_os = "android")] -type AndroidSocks5ClientBuilder<'a> = - BaseClientBuilder<'a, Client, storage::Ephemeral>; - -#[cfg(not(target_os = "android"))] -type Socks5ClientBuilder<'a> = BaseClientBuilder<'a, Client, OnDiskPersistent>; - #[derive(Debug)] pub enum Socks5ControlMessage { /// Tell the main task to stop Stop, } -pub struct NymClient { +pub struct StartedSocks5Client { + /// Handle for managing graceful shutdown of this client. If dropped, the client will be stopped. + pub shutdown_handle: TaskManager, + + /// Address of the started client + pub address: Recipient, +} + +pub struct NymClient { /// Client configuration options, including, among other things, packet sending rates, /// key filepaths, etc. config: Config, + + storage: S, } -impl NymClient { - pub fn new(config: Config) -> Self { - NymClient { config } +impl NymClient +where + S: MixnetClientStorage + 'static, + S::ReplyStore: Send + Sync, + ::StorageError: Sync + Send, + ::StorageError: Send + Sync, + ::StorageError: Send + Sync, +{ + pub fn new(config: Config, storage: S) -> Self { + NymClient { config, storage } } + #[allow(clippy::too_many_arguments)] pub fn start_socks5_listener( socks5_config: &Socks5, debug_config: DebugConfig, @@ -78,6 +74,7 @@ impl NymClient { client_status: ClientState, self_address: Recipient, shutdown: TaskClient, + packet_type: PacketType, ) { info!("Starting socks5 listener..."); let auth_methods = vec![AuthenticationMethods::NoAuth as u8]; @@ -103,7 +100,7 @@ impl NymClient { .unwrap_or(debug_config.traffic.primary_packet_size); let authenticator = Authenticator::new(auth_methods, allowed_users); - let mut sphinx_socks = SphinxSocksServer::new( + let mut sphinx_socks = NymSocksServer::new( socks5_config.get_listening_port(), authenticator, socks5_config.get_provider_mix_address(), @@ -118,6 +115,7 @@ impl NymClient { socks5_config.get_per_request_surbs(), ), shutdown.clone(), + packet_type, ); nym_task::spawn_with_report_error( async move { @@ -135,21 +133,22 @@ impl NymClient { /// blocking version of `start` method. Will run forever (or until SIGINT is sent) pub async fn run_forever(self) -> Result<(), Box> { - let shutdown = self.start().await?; + let started = self.start().await?; - let res = shutdown.catch_interrupt().await; + let res = started.shutdown_handle.catch_interrupt().await; log::info!("Stopping nym-socks5-client"); res } - // Variant of `run_forever` that listends for remote control messages + // Variant of `run_forever` that listens for remote control messages pub async fn run_and_listen( self, mut receiver: Socks5ControlMessageReceiver, sender: nym_task::StatusSender, ) -> Result<(), Box> { // Start the main task - let mut shutdown = self.start().await?; + let started = self.start().await?; + let mut shutdown = started.shutdown_handle; // Listen to status messages from task, that we forward back to the caller shutdown.start_status_listener(sender).await; @@ -188,19 +187,38 @@ impl NymClient { res } - pub async fn start(self) -> Result { - #[cfg(not(target_os = "android"))] - let base_builder = self.create_base_client_builder().await?; + pub async fn start(self) -> Result { + let (key_store, reply_storage_backend, credential_store) = self.storage.into_split(); - #[cfg(target_os = "android")] - let base_builder = self.create_base_client_builder().await; + // don't create bandwidth controller if credentials are disabled + let bandwidth_controller = if self.config.get_base().get_disabled_credentials_mode() { + None + } else { + Some(non_wasm_helpers::create_bandwidth_controller( + self.config.get_base(), + credential_store, + )) + }; - let mut started_client = base_builder.start_base().await?; + let base_builder = BaseClientBuilder::<_, S>::new_from_base_config( + self.config.get_base(), + key_store, + bandwidth_controller, + reply_storage_backend, + ); + + let packet_type = self.config.get_base().get_packet_type(); + let mut started_client = base_builder.start_base(packet_type).await?; let self_address = started_client.address; let client_input = started_client.client_input.register_producer(); let client_output = started_client.client_output.register_consumer(); let client_state = started_client.client_state; + info!( + "Running with {:?} packets", + self.config.get_base().get_packet_type() + ); + Self::start_socks5_listener( self.config.get_socks5(), *self.config.get_debug_settings(), @@ -209,100 +227,15 @@ impl NymClient { client_state, self_address, started_client.task_manager.subscribe(), + self.config.get_base().get_packet_type(), ); info!("Client startup finished!"); - info!("The address of this client is: {}", self_address); + info!("The address of this client is: {self_address}"); - Ok(started_client.task_manager) - } -} - -#[cfg(not(target_os = "android"))] -impl NymClient { - fn key_store(&self) -> OnDiskKeys { - let pathfinder = ClientKeyPathfinder::new_from_config(self.config.get_base()); - OnDiskKeys::new(pathfinder) - } - - async fn create_bandwidth_controller( - &self, - ) -> BandwidthController, PersistentStorage> { - let storage = nym_credential_storage::initialise_persistent_storage( - self.config.get_base().get_database_path(), - ) - .await; - - non_wasm_helpers::create_bandwidth_controller(self.config.get_base(), storage) - } - - async fn create_reply_storage_backend( - &self, - ) -> Result { - non_wasm_helpers::setup_fs_reply_surb_backend( - self.config.get_base().get_reply_surb_database_path(), - &self.config.get_debug_settings().reply_surbs, - ) - .await - .map_err(Into::into) - } - - async fn create_base_client_builder( - &self, - ) -> Result { - // don't create bandwidth controller if credentials are disabled - let bandwidth_controller = if self.config.get_base().get_disabled_credentials_mode() { - None - } else { - Some(self.create_bandwidth_controller().await) - }; - - let key_store = self.key_store(); - let reply_storage_backend = self.create_reply_storage_backend().await?; - - Ok(BaseClientBuilder::new_from_base_config( - self.config.get_base(), - key_store, - bandwidth_controller, - reply_storage_backend, - )) - } -} - -#[cfg(target_os = "android")] -impl NymClient { - fn key_store(&self) -> InMemEphemeralKeys { - InMemEphemeralKeys::new() - } - - fn create_bandwidth_controller( - config: &Config, - ) -> BandwidthController, EphemeralStorage> { - let storage = nym_credential_storage::initialise_ephemeral_storage(); - - create_bandwidth_controller(config.get_base(), storage) - } - - fn create_reply_storage_backend(&self) -> reply_storage::Empty { - setup_empty_reply_surb_backend(self.config.get_debug_settings()) - } - - #[cfg(target_os = "android")] - fn create_base_client_builder(&self) -> Socks5ClientBuilder { - let bandwidth_controller = if self.config.get_base().get_disabled_credentials_mode() { - None - } else { - Some(self.create_bandwidth_controller().await) - }; - - let key_store = self.key_store(); - let reply_storage_backend = self.create_reply_storage_backend(); - - BaseClientBuilder::new_from_base_config( - self.config.get_base(), - key_store, - bandwidth_controller, - reply_storage_backend, - ) + Ok(StartedSocks5Client { + shutdown_handle: started_client.task_manager, + address: self_address, + }) } } diff --git a/common/socks5-client-core/src/socks/client.rs b/common/socks5-client-core/src/socks/client.rs index d1d4b10697..ebd980a0e6 100644 --- a/common/socks5-client-core/src/socks/client.rs +++ b/common/socks5-client-core/src/socks/client.rs @@ -18,6 +18,7 @@ use nym_socks5_requests::{ }; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::params::PacketSize; +use nym_sphinx::params::PacketType; use nym_task::connections::{LaneQueueLengths, TransmissionLane}; use nym_task::TaskClient; use pin_project::pin_project; @@ -185,6 +186,7 @@ pub(crate) struct SocksClient { started_proxy: bool, lane_queue_lengths: LaneQueueLengths, shutdown_listener: TaskClient, + packet_type: Option, } impl Drop for SocksClient { @@ -213,6 +215,7 @@ impl SocksClient { self_address: &Recipient, lane_queue_lengths: LaneQueueLengths, mut shutdown_listener: TaskClient, + packet_type: Option, ) -> Self { // If this task fails and exits, we don't want to send shutdown signal shutdown_listener.mark_as_success(); @@ -233,6 +236,7 @@ impl SocksClient { started_proxy: false, lane_queue_lengths, shutdown_listener, + packet_type, } } @@ -349,6 +353,7 @@ impl SocksClient { msg.into_bytes(), self.config.connection_start_surbs, TransmissionLane::ConnectionId(self.connection_id), + self.packet_type, ); self.input_sender .send(input_message) @@ -371,6 +376,7 @@ impl SocksClient { self.service_provider, msg.into_bytes(), TransmissionLane::ConnectionId(self.connection_id), + self.packet_type, ); self.input_sender .send(input_message) @@ -408,6 +414,7 @@ impl SocksClient { let request_version = self.config.request_version(); let recipient = self.service_provider; + let packet_type = self.packet_type; let (stream, _) = ProxyRunner::new( stream, local_stream_remote, @@ -439,9 +446,15 @@ impl SocksClient { provider_message.into_bytes(), per_request_surbs, lane, + packet_type, ) } else { - InputMessage::new_regular(recipient, provider_message.into_bytes(), lane) + InputMessage::new_regular( + recipient, + provider_message.into_bytes(), + lane, + packet_type, + ) } }) .await diff --git a/common/socks5-client-core/src/socks/server.rs b/common/socks5-client-core/src/socks/server.rs index 179b78cca5..1fd5703113 100644 --- a/common/socks5-client-core/src/socks/server.rs +++ b/common/socks5-client-core/src/socks/server.rs @@ -10,6 +10,7 @@ use nym_client_core::client::{ }; use nym_socks5_proxy_helpers::connection_controller::Controller; use nym_sphinx::addressing::clients::Recipient; +use nym_sphinx::params::PacketType; use nym_task::connections::{ConnectionCommandSender, LaneQueueLengths}; use nym_task::TaskClient; use std::net::SocketAddr; @@ -17,7 +18,7 @@ use tap::TapFallible; use tokio::net::TcpListener; /// A Socks5 server that listens for connections. -pub struct SphinxSocksServer { +pub struct NymSocksServer { authenticator: Authenticator, listening_address: SocketAddr, service_provider: Recipient, @@ -25,10 +26,12 @@ pub struct SphinxSocksServer { client_config: client::Config, lane_queue_lengths: LaneQueueLengths, shutdown: TaskClient, + packet_type: PacketType, } -impl SphinxSocksServer { +impl NymSocksServer { /// Create a new SphinxSocks instance + #[allow(clippy::too_many_arguments)] pub(crate) fn new( port: u16, authenticator: Authenticator, @@ -37,12 +40,13 @@ impl SphinxSocksServer { lane_queue_lengths: LaneQueueLengths, client_config: client::Config, shutdown: TaskClient, + packet_type: PacketType, ) -> Self { // hardcode ip as we (presumably) ONLY want to listen locally. If we change it, we can // just modify the config let ip = "127.0.0.1"; info!("Listening on {}:{}", ip, port); - SphinxSocksServer { + NymSocksServer { authenticator, listening_address: format!("{ip}:{port}").parse().unwrap(), service_provider, @@ -50,6 +54,7 @@ impl SphinxSocksServer { client_config, lane_queue_lengths, shutdown, + packet_type, } } @@ -104,6 +109,7 @@ impl SphinxSocksServer { &self.self_address, self.lane_queue_lengths.clone(), self.shutdown.clone(), + Some(self.packet_type) ); tokio::spawn(async move { @@ -119,8 +125,8 @@ impl SphinxSocksServer { }); }, _ = self.shutdown.recv() => { - log::trace!("SphinxSocksServer: Received shutdown"); - log::debug!("SphinxSocksServer: Exiting"); + log::trace!("NymSocksServer: Received shutdown"); + log::debug!("NymSocksServer: Exiting"); return Ok(()); } } diff --git a/common/topology/src/error.rs b/common/topology/src/error.rs index 170bb1889c..bb36b42886 100644 --- a/common/topology/src/error.rs +++ b/common/topology/src/error.rs @@ -1,10 +1,13 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use std::array::TryFromSliceError; + use crate::MixLayer; +use nym_sphinx_types::NymPacketError; use thiserror::Error; -#[derive(Debug, Clone, Error)] +#[derive(Debug, Error)] pub enum NymTopologyError { #[error("The provided network topology is empty - there are no mixnodes and no gateways on it - the network request(s) probably failed")] EmptyNetworkTopology, @@ -33,4 +36,16 @@ pub enum NymTopologyError { total_nodes: usize, layer_distribution: Vec<(MixLayer, usize)>, }, + // We can't import SurbAckRecoveryError due to cyclic dependency, this is a bit dirty + #[error("Could not build payload")] + PayloadBuilder, + + #[error("Outfox: {0}")] + Outfox(#[from] nym_sphinx_types::OutfoxError), + + #[error("{0}")] + FromSlice(#[from] TryFromSliceError), + + #[error("{0}")] + PacketError(#[from] NymPacketError), } diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 7dfba979b3..b33e35b3f8 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array 0.14.6", +] + [[package]] name = "aes" version = "0.7.5" @@ -9,7 +19,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher", + "cipher 0.3.0", "cpufeatures", "ctr", "opaque-debug 0.3.0", @@ -38,6 +48,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + [[package]] name = "autocfg" version = "1.1.0" @@ -86,6 +102,20 @@ dependencies = [ "opaque-debug 0.2.3", ] +[[package]] +name = "blake3" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "digest 0.10.7", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -159,6 +189,30 @@ dependencies = [ "keystream", ] +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher 0.4.4", + "poly1305", + "zeroize", +] + [[package]] name = "cipher" version = "0.3.0" @@ -168,6 +222,17 @@ dependencies = [ "generic-array 0.14.6", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + [[package]] name = "coconut-test" version = "0.1.0" @@ -199,13 +264,19 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +[[package]] +name = "constant_time_eq" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + [[package]] name = "cosmwasm-crypto" version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75836a10cb9654c54e77ee56da94d592923092a10b369cdb0dbd56acefc16340" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -284,6 +355,49 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -309,6 +423,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.6", + "rand_core 0.6.4", "typenum", ] @@ -338,7 +453,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher", + "cipher 0.3.0", ] [[package]] @@ -620,9 +735,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", @@ -700,7 +815,7 @@ dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.6", + "digest 0.10.7", "ff", "generic-array 0.14.6", "group", @@ -926,8 +1041,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -975,6 +1092,15 @@ dependencies = [ "ahash", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.1" @@ -1013,7 +1139,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -1042,6 +1168,15 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.6", +] + [[package]] name = "instant" version = "0.1.12" @@ -1057,7 +1192,7 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.1", "libc", "windows-sys 0.48.0", ] @@ -1188,6 +1323,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "mixnet-vesting-integration-tests" version = "0.1.0" @@ -1214,6 +1358,16 @@ dependencies = [ "libm", ] +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + [[package]] name = "nym-coconut-bandwidth" version = "0.1.0" @@ -1358,7 +1512,6 @@ dependencies = [ "cw-storage-plus 1.0.1", "cw-utils 1.0.1", "cw3", - "cw3-fixed-multisig", "cw4", "schemars", "serde", @@ -1395,6 +1548,23 @@ dependencies = [ "serde", ] +[[package]] +name = "nym-outfox" +version = "0.1.0" +dependencies = [ + "blake3", + "chacha20", + "chacha20poly1305", + "curve25519-dalek", + "getrandom 0.2.8", + "log", + "rand 0.7.3", + "rayon", + "sphinx-packet", + "thiserror", + "zeroize", +] + [[package]] name = "nym-pemstore" version = "0.2.0" @@ -1434,7 +1604,9 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "nym-outfox", "sphinx-packet", + "thiserror", ] [[package]] @@ -1534,6 +1706,17 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1692,6 +1875,28 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -1824,6 +2029,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "sec1" version = "0.3.0" @@ -1936,7 +2147,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -1945,7 +2156,7 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] @@ -2155,6 +2366,16 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle 2.4.1", +] + [[package]] name = "url" version = "2.3.1" diff --git a/contracts/mixnet/Developing.md b/contracts/mixnet/Developing.md index 393df2ec17..c27fc09461 100644 --- a/contracts/mixnet/Developing.md +++ b/contracts/mixnet/Developing.md @@ -76,7 +76,7 @@ docker run --rm -v "$(pwd)":/code \ cosmwasm/rust-optimizer:0.10.7 ``` -We must mount the contract code to `/code`. You can use a absolute path instead +We must mount the contract code to `/code`. You can use an absolute path instead of `$(pwd)` if you don't want to `cd` to the directory first. The other two volumes are nice for speedup. Mounting `/code/target` in particular is useful to avoid docker overwriting your local dev files with root permissions. diff --git a/contracts/mixnet/Importing.md b/contracts/mixnet/Importing.md index e367b6582d..133a485cda 100644 --- a/contracts/mixnet/Importing.md +++ b/contracts/mixnet/Importing.md @@ -22,8 +22,8 @@ any uploaded contract. ## Reviewing -Once you have done the quick programatic checks, it is good to give at least a quick -look through the code. A glance at `examples/schema.rs` to make sure it is outputing +Once you have done the quick programmatic checks, it is good to give at least a quick +look through the code. A glance at `examples/schema.rs` to make sure it is outputting all relevant structs from `contract.rs`, and also ensure `src/lib.rs` is just the default wrapper (nothing funny going on there). After this point, we can dive into the contract code itself. Check the flows for the handle methods, any invariants and diff --git a/explorer/src/pages/ServiceProviders/index.tsx b/explorer/src/pages/ServiceProviders/index.tsx index 12df559e93..0c864d503f 100644 --- a/explorer/src/pages/ServiceProviders/index.tsx +++ b/explorer/src/pages/ServiceProviders/index.tsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; -import { Card, FormControl, Grid, MenuItem, Select, SelectChangeEvent, Typography } from '@mui/material'; +import React from 'react'; +import { Button, Card, FormControl, Grid, ListItem, Menu, SelectChangeEvent, Typography } from '@mui/material'; import { TableToolbar } from '../../components/TableToolbar'; import { Title } from '../../components/Title'; import { UniversalDataGrid } from '../../components/Universal-DataGrid'; @@ -15,17 +15,34 @@ const columns = [ ]; const SupportedApps = () => { - const [selected, setSelected] = useState(''); - const handleChange = (e: SelectChangeEvent) => setSelected(e.target.value); + const [anchorEl, setAnchorEl] = React.useState(null); + const open = Boolean(anchorEl); + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + const handleClose = () => { + setAnchorEl(null); + }; + const anchorRef = React.useRef(null); + return ( - + + + Keybase + Telegram + Electrum + Blockstream Green + ); }; diff --git a/gateway/gateway-requests/src/types.rs b/gateway/gateway-requests/src/types.rs index 0685c0d473..3683144980 100644 --- a/gateway/gateway-requests/src/types.rs +++ b/gateway/gateway-requests/src/types.rs @@ -5,6 +5,7 @@ use crate::authentication::encrypted_address::EncryptedAddressBytes; use crate::iv::IV; use crate::registration::handshake::SharedKeys; use crate::{GatewayMacSize, PROTOCOL_VERSION}; +use log::error; use nym_coconut_interface::Credential; use nym_crypto::generic_array::typenum::Unsigned; use nym_crypto::hmac::recompute_keyed_hmac_and_verify_tag; @@ -290,7 +291,13 @@ impl BinaryRequest { pub fn into_encrypted_tagged_bytes(self, shared_key: &SharedKeys) -> Vec { match self { BinaryRequest::ForwardSphinx(mix_packet) => { - let forwarding_data = mix_packet.into_bytes(); + let forwarding_data = match mix_packet.into_bytes() { + Ok(mix_packet) => mix_packet, + Err(e) => { + error!("Could not convert packet to bytes: {e}"); + return vec![]; + } + }; // TODO: it could be theoretically slightly more efficient if the data wasn't taken // by reference because then it makes a copy for encryption rather than do it in place diff --git a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs index dfc4ae377a..1a41937c4b 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs @@ -283,7 +283,7 @@ where &self, mix_packet: MixPacket, ) -> Result { - let consumed_bandwidth = mix_packet.sphinx_packet().len() as i64; + let consumed_bandwidth = mix_packet.packet().len() as i64; let available_bandwidth = self.get_available_bandwidth().await?; @@ -309,7 +309,10 @@ where async fn handle_binary(&self, bin_msg: Vec) -> Message { // this function decrypts the request and checks the MAC match BinaryRequest::try_from_encrypted_tagged_bytes(bin_msg, &self.client.shared_keys) { - Err(e) => RequestHandlingError::InvalidBinaryRequest(e).into_error_message(), + Err(e) => { + error!("{e}"); + RequestHandlingError::InvalidBinaryRequest(e).into_error_message() + } Ok(request) => match request { // currently only a single type exists BinaryRequest::ForwardSphinx(mix_packet) => self diff --git a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs index 148dbc2579..dd2bc5d402 100644 --- a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs +++ b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs @@ -11,8 +11,8 @@ use log::*; use nym_mixnet_client::forwarder::MixForwardingSender; use nym_mixnode_common::packet_processor::processor::ProcessedFinalHop; use nym_sphinx::forwarding::packet::MixPacket; -use nym_sphinx::framing::codec::SphinxCodec; -use nym_sphinx::framing::packet::FramedSphinxPacket; +use nym_sphinx::framing::codec::NymCodec; +use nym_sphinx::framing::packet::FramedNymPacket; use nym_sphinx::DestinationAddressBytes; use nym_task::TaskClient; use std::collections::HashMap; @@ -155,7 +155,7 @@ impl ConnectionHandler { self.forward_ack(forward_ack, client_address); } - async fn handle_received_packet(&mut self, framed_sphinx_packet: FramedSphinxPacket) { + async fn handle_received_packet(&mut self, framed_sphinx_packet: FramedNymPacket) { // // TODO: here be replay attack detection - it will require similar key cache to the one in // packet processor for vpn packets, @@ -182,7 +182,7 @@ impl ConnectionHandler { ) { debug!("Starting connection handler for {:?}", remote); shutdown.mark_as_success(); - let mut framed_conn = Framed::new(conn, SphinxCodec); + let mut framed_conn = Framed::new(conn, NymCodec); while !shutdown.is_shutdown() { tokio::select! { biased; diff --git a/gateway/src/node/mixnet_handling/receiver/packet_processing.rs b/gateway/src/node/mixnet_handling/receiver/packet_processing.rs index cf5e5e8e18..e7416c415c 100644 --- a/gateway/src/node/mixnet_handling/receiver/packet_processing.rs +++ b/gateway/src/node/mixnet_handling/receiver/packet_processing.rs @@ -5,7 +5,7 @@ use nym_crypto::asymmetric::encryption; use nym_mixnode_common::packet_processor::error::MixProcessingError; pub use nym_mixnode_common::packet_processor::processor::MixProcessingResult; use nym_mixnode_common::packet_processor::processor::{ProcessedFinalHop, SphinxPacketProcessor}; -use nym_sphinx::framing::packet::FramedSphinxPacket; +use nym_sphinx::framing::packet::FramedNymPacket; use thiserror::Error; #[derive(Error, Debug)] @@ -32,7 +32,7 @@ impl PacketProcessor { pub(crate) fn process_received( &self, - received: FramedSphinxPacket, + received: FramedNymPacket, ) -> Result { match self.inner_processor.process_received(received)? { MixProcessingResult::ForwardHop(..) => { diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 5f3da88b7f..ca509fdb42 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -51,6 +51,7 @@ nym-mixnet-client = { path = "../common/client-libs/mixnet-client" } nym-mixnode-common = { path = "../common/mixnode-common" } nym-nonexhaustive-delayqueue = { path = "../common/nonexhaustive-delayqueue" } nym-sphinx = { path = "../common/nymsphinx" } +nym-sphinx-params = { path = "../common/nymsphinx/params" } nym-pemstore = { path = "../common/pemstore", version = "0.2.0" } nym-task = { path = "../common/task" } nym-types = { path = "../common/types" } diff --git a/mixnode/src/main.rs b/mixnode/src/main.rs index 066d4a061e..b0cb340634 100644 --- a/mixnode/src/main.rs +++ b/mixnode/src/main.rs @@ -51,9 +51,14 @@ fn test_function() { async fn main() { cfg_if::cfg_if! { if #[cfg(feature = "cpucycles")] { - setup_tracing!("/tmp/tracing.log"); + let home_dir = dirs::home_dir().expect("Could not get $HOME"); + let logs_dir = home_dir.join(".nym").join("logs"); + let logs_dir_str = logs_dir.to_str().expect("Could not construct logs path"); + setup_tracing!(logs_dir_str); + info!("CPU cycles measurement is ON") } else { setup_logging(); + info!("CPU cycles measurement is OFF") } } diff --git a/mixnode/src/node/listener/connection_handler/mod.rs b/mixnode/src/node/listener/connection_handler/mod.rs index ed08d8c407..733d2660f8 100644 --- a/mixnode/src/node/listener/connection_handler/mod.rs +++ b/mixnode/src/node/listener/connection_handler/mod.rs @@ -9,8 +9,8 @@ use crate::node::TaskClient; use futures::StreamExt; use nym_mixnode_common::measure; use nym_sphinx::forwarding::packet::MixPacket; -use nym_sphinx::framing::codec::SphinxCodec; -use nym_sphinx::framing::packet::FramedSphinxPacket; +use nym_sphinx::framing::codec::NymCodec; +use nym_sphinx::framing::packet::FramedNymPacket; use nym_sphinx::Delay as SphinxDelay; use std::net::SocketAddr; use tokio::net::TcpStream; @@ -54,7 +54,7 @@ impl ConnectionHandler { feature = "cpucycles", instrument(skip(self, framed_sphinx_packet), fields(cpucycles)) )] - fn handle_received_packet(&self, framed_sphinx_packet: FramedSphinxPacket) { + fn handle_received_packet(&self, framed_sphinx_packet: FramedNymPacket) { // // TODO: here be replay attack detection - it will require similar key cache to the one in // packet processor for vpn packets, @@ -86,7 +86,7 @@ impl ConnectionHandler { ) { debug!("Starting connection handler for {:?}", remote); shutdown.mark_as_success(); - let mut framed_conn = Framed::new(conn, SphinxCodec); + let mut framed_conn = Framed::new(conn, NymCodec); while !shutdown.is_shutdown() { tokio::select! { biased; @@ -108,7 +108,7 @@ impl ConnectionHandler { } Some(Err(err)) => { error!( - "The socket connection got corrupted with error: {err}. Closing the socket", + "{remote:?} - The socket connection got corrupted with error: {err}. Closing the socket", ); return; } diff --git a/mixnode/src/node/listener/connection_handler/packet_processing.rs b/mixnode/src/node/listener/connection_handler/packet_processing.rs index 9ecf8ad435..1d52602b1d 100644 --- a/mixnode/src/node/listener/connection_handler/packet_processing.rs +++ b/mixnode/src/node/listener/connection_handler/packet_processing.rs @@ -6,7 +6,7 @@ use nym_crypto::asymmetric::encryption; use nym_mixnode_common::packet_processor::error::MixProcessingError; pub use nym_mixnode_common::packet_processor::processor::MixProcessingResult; use nym_mixnode_common::packet_processor::processor::SphinxPacketProcessor; -use nym_sphinx::framing::packet::FramedSphinxPacket; +use nym_sphinx::framing::packet::FramedNymPacket; // PacketProcessor contains all data required to correctly unwrap and forward sphinx packets #[derive(Clone)] @@ -31,7 +31,7 @@ impl PacketProcessor { pub(crate) fn process_received( &self, - received: FramedSphinxPacket, + received: FramedNymPacket, ) -> Result { self.node_stats_update_sender.report_received(); self.inner_processor.process_received(received) diff --git a/mixnode/src/node/packet_delayforwarder.rs b/mixnode/src/node/packet_delayforwarder.rs index 41a3e7e0fa..0e7abfa793 100644 --- a/mixnode/src/node/packet_delayforwarder.rs +++ b/mixnode/src/node/packet_delayforwarder.rs @@ -58,12 +58,12 @@ where fn forward_packet(&mut self, packet: MixPacket) { let next_hop = packet.next_hop(); - let packet_mode = packet.packet_mode(); - let sphinx_packet = packet.into_sphinx_packet(); + let packet_type = packet.packet_type(); + let packet = packet.into_packet(); - if let Err(err) = - self.mixnet_client - .send_without_response(next_hop, sphinx_packet, packet_mode) + if let Err(err) = self + .mixnet_client + .send_without_response(next_hop, packet, packet_type) { if err.kind() == io::ErrorKind::WouldBlock { // we only know for sure if we dropped a packet if our sending queue was full @@ -134,38 +134,38 @@ mod tests { use std::sync::{Arc, Mutex}; use std::time::Duration; + use nym_sphinx::NymPacket; use nym_task::TaskManager; use nym_sphinx::addressing::nodes::NymNodeRoutingAddress; use nym_sphinx_params::packet_sizes::PacketSize; - use nym_sphinx_params::PacketMode; - use nym_sphinx_types::builder::SphinxPacketBuilder; + use nym_sphinx_params::PacketType; use nym_sphinx_types::{ crypto, Delay as SphinxDelay, Destination, DestinationAddressBytes, Node, NodeAddressBytes, - SphinxPacket, DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, NODE_ADDRESS_LENGTH, + DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, NODE_ADDRESS_LENGTH, }; #[derive(Default)] struct TestClient { - pub packets_sent: Arc>>, + pub packets_sent: Arc>>, } impl nym_mixnet_client::SendWithoutResponse for TestClient { fn send_without_response( &mut self, address: NymNodeRoutingAddress, - packet: SphinxPacket, - packet_mode: PacketMode, + packet: NymPacket, + packet_type: PacketType, ) -> io::Result<()> { self.packets_sent .lock() .unwrap() - .push((address, packet, packet_mode)); + .push((address, packet, packet_type)); Ok(()) } } - fn make_valid_sphinx_packet(size: PacketSize) -> SphinxPacket { + fn make_valid_sphinx_packet(size: PacketSize) -> NymPacket { let (_, node1_pk) = crypto::keygen(); let node1 = Node::new( NodeAddressBytes::from_bytes([5u8; NODE_ADDRESS_LENGTH]), @@ -192,12 +192,45 @@ mod tests { SphinxDelay::new_from_nanos(42), SphinxDelay::new_from_nanos(42), ]; - SphinxPacketBuilder::new() - .with_payload_size(size.payload_size()) - .build_packet(b"foomp", &route, &destination, &delays) + NymPacket::sphinx_build(size.payload_size(), b"foomp", &route, &destination, &delays) .unwrap() } + fn make_valid_outfox_packet(size: PacketSize) -> NymPacket { + let (_, node1_pk) = crypto::keygen(); + let node1 = Node::new( + NodeAddressBytes::from_bytes([5u8; NODE_ADDRESS_LENGTH]), + node1_pk, + ); + let (_, node2_pk) = crypto::keygen(); + let node2 = Node::new( + NodeAddressBytes::from_bytes([4u8; NODE_ADDRESS_LENGTH]), + node2_pk, + ); + let (_, node3_pk) = crypto::keygen(); + let node3 = Node::new( + NodeAddressBytes::from_bytes([2u8; NODE_ADDRESS_LENGTH]), + node3_pk, + ); + + let (_, node4_pk) = crypto::keygen(); + let node4 = Node::new( + NodeAddressBytes::from_bytes([2u8; NODE_ADDRESS_LENGTH]), + node4_pk, + ); + + let destination = Destination::new( + DestinationAddressBytes::from_bytes([3u8; DESTINATION_ADDRESS_LENGTH]), + [4u8; IDENTIFIER_LENGTH], + ); + + let route = &[node1, node2, node3, node4]; + + let payload = vec![1; 48]; + + NymPacket::outfox_build(payload, route, &destination, Some(size.plaintext_size())).unwrap() + } + #[tokio::test] async fn packets_received_are_forwarded() { // Wire up the DelayForwarder @@ -219,7 +252,50 @@ mod tests { let mix_packet = MixPacket::new( next_hop, make_valid_sphinx_packet(PacketSize::default()), - PacketMode::default(), + PacketType::default(), + ); + let forward_instant = None; + packet_sender + .unbounded_send((mix_packet, forward_instant)) + .unwrap(); + + // Give the the worker a chance to act + tokio::time::sleep(Duration::from_millis(10)).await; + + // The client should have forwarded the packet straight away + assert_eq!( + client_packets_sent + .lock() + .unwrap() + .iter() + .map(|(a, _, _)| *a) + .collect::>(), + vec![next_hop] + ); + } + + #[tokio::test] + async fn outfox_packets_received_are_forwarded() { + // Wire up the DelayForwarder + let (stats_sender, _stats_receiver) = mpsc::unbounded(); + let node_stats_update_sender = UpdateSender::new(stats_sender); + let client = TestClient::default(); + let client_packets_sent = client.packets_sent.clone(); + let shutdown = TaskManager::default(); + let mut delay_forwarder = + DelayForwarder::new(client, node_stats_update_sender, shutdown.subscribe()); + let packet_sender = delay_forwarder.sender(); + + // Spawn the worker, listening on packet_sender channel + tokio::spawn(async move { delay_forwarder.run().await }); + + // Send a `MixPacket` down the channel without any delay attached. + let next_hop = + NymNodeRoutingAddress::from(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)), 42)); + let mix_packet = MixPacket::new( + next_hop, + make_valid_outfox_packet(PacketSize::default()), + PacketType::default(), ); let forward_instant = None; packet_sender diff --git a/nym-api/src/network_monitor/chunker.rs b/nym-api/src/network_monitor/chunker.rs new file mode 100644 index 0000000000..1e1f4d0d4d --- /dev/null +++ b/nym-api/src/network_monitor/chunker.rs @@ -0,0 +1,86 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use nym_sphinx::forwarding::packet::MixPacket; +use nym_sphinx::message::NymMessage; +use nym_sphinx::params::{PacketSize, PacketType}; +use nym_sphinx::{ + acknowledgements::AckKey, addressing::clients::Recipient, preparer::MessagePreparer, +}; +use nym_topology::NymTopology; +use rand_07::rngs::OsRng; +use std::time::Duration; + +const DEFAULT_AVERAGE_PACKET_DELAY: Duration = Duration::from_millis(200); +const DEFAULT_AVERAGE_ACK_DELAY: Duration = Duration::from_millis(200); + +#[derive(Clone)] +pub(crate) struct Chunker { + rng: OsRng, + packet_size: PacketSize, + message_preparer: MessagePreparer, +} + +impl Chunker { + pub(crate) fn new(tested_mix_me: Recipient) -> Self { + Chunker { + rng: OsRng, + // no point in using anything else for monitoring + // unless we should make it variable so mixnodes wouldn't know if + // non-default packet is for measurement or not + packet_size: PacketSize::RegularPacket, + message_preparer: MessagePreparer::new( + OsRng, + tested_mix_me, + DEFAULT_AVERAGE_PACKET_DELAY, + DEFAULT_AVERAGE_ACK_DELAY, + ), + } + } + + pub(crate) fn prepare_packets_from( + &mut self, + message: Vec, + topology: &NymTopology, + packet_sender: Recipient, + packet_type: PacketType, + ) -> Vec { + // I really dislike how we have to overwrite the parameter of the `MessagePreparer` on each run + // but without some significant API changes in the `MessagePreparer` this was the easiest + // way to being able to have variable sender address. + self.message_preparer.set_sender_address(packet_sender); + self.prepare_packets(message, topology, packet_sender, packet_type) + } + + fn prepare_packets( + &mut self, + message: Vec, + topology: &NymTopology, + packet_sender: Recipient, + packet_type: PacketType, + ) -> Vec { + let ack_key: AckKey = AckKey::new(&mut self.rng); + + let split_message = self + .message_preparer + .pad_and_split_message(NymMessage::new_plain(message), self.packet_size); + + let mut mix_packets = Vec::with_capacity(split_message.len()); + for message_chunk in split_message { + // don't bother with acks etc. for time being + let prepared_fragment = self + .message_preparer + .prepare_chunk_for_sending( + message_chunk, + topology, + &ack_key, + &packet_sender, + packet_type, + ) + .unwrap(); + + mix_packets.push(prepared_fragment.mix_packet); + } + mix_packets + } +} diff --git a/nym-api/src/network_monitor/mod.rs b/nym-api/src/network_monitor/mod.rs index 03e4ea65e8..a42fd3b49b 100644 --- a/nym-api/src/network_monitor/mod.rs +++ b/nym-api/src/network_monitor/mod.rs @@ -21,6 +21,7 @@ use nym_bandwidth_controller::BandwidthController; use nym_credential_storage::persistent_storage::PersistentStorage; use nym_crypto::asymmetric::{encryption, identity}; use nym_sphinx::acknowledgements::AckKey; +use nym_sphinx::params::PacketType; use nym_sphinx::receiver::MessageReceiver; use nym_task::TaskManager; use std::sync::Arc; @@ -129,6 +130,7 @@ impl<'a> NetworkMonitorBuilder<'a> { received_processor, summary_producer, self.node_status_storage, + PacketType::Mix, ); NetworkMonitorRunnables { diff --git a/nym-api/src/network_monitor/monitor/mod.rs b/nym-api/src/network_monitor/monitor/mod.rs index e3a774b166..77e48634d5 100644 --- a/nym-api/src/network_monitor/monitor/mod.rs +++ b/nym-api/src/network_monitor/monitor/mod.rs @@ -10,6 +10,7 @@ use crate::network_monitor::test_route::TestRoute; use crate::storage::NymApiStorage; use crate::support::config::Config; use log::{debug, error, info}; +use nym_sphinx::params::PacketType; use nym_sphinx::receiver::MessageReceiver; use nym_task::TaskClient; use std::collections::{HashMap, HashSet}; @@ -44,6 +45,8 @@ pub(super) struct Monitor { /// The minimum number of test routes that need to be constructed (and working) in order for /// a monitor test run to be valid. minimum_test_routes: usize, + + packet_type: PacketType, } impl Monitor { @@ -54,6 +57,7 @@ impl Monitor { received_processor: ReceivedProcessor, summary_producer: SummaryProducer, node_status_storage: NymApiStorage, + packet_type: PacketType, ) -> Self { Monitor { test_nonce: 1, @@ -68,6 +72,7 @@ impl Monitor { route_test_packets: config.get_route_test_packets(), test_routes: config.get_test_routes(), minimum_test_routes: config.get_minimum_test_routes(), + packet_type, } } @@ -125,8 +130,11 @@ impl Monitor { for route in routes { let mut packet_preparer = self.packet_preparer.clone(); let route = route.clone(); - let gateway_packets = packet_preparer - .prepare_test_route_viability_packets(&route, self.route_test_packets); + let gateway_packets = packet_preparer.prepare_test_route_viability_packets( + &route, + self.route_test_packets, + self.packet_type, + ); packets.push(gateway_packets); } @@ -233,7 +241,7 @@ impl Monitor { info!("Generating test mix packets for all the network nodes..."); let prepared_packets = self .packet_preparer - .prepare_test_packets(self.test_nonce, routes) + .prepare_test_packets(self.test_nonce, routes, self.packet_type) .await; let total_sent = prepared_packets diff --git a/nym-api/src/network_monitor/monitor/preparer.rs b/nym-api/src/network_monitor/monitor/preparer.rs index 7343a06a6e..b873669f99 100644 --- a/nym-api/src/network_monitor/monitor/preparer.rs +++ b/nym-api/src/network_monitor/monitor/preparer.rs @@ -12,7 +12,7 @@ use nym_node_tester_utils::NodeTester; use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::forwarding::packet::MixPacket; -use nym_sphinx::params::PacketSize; +use nym_sphinx::params::{PacketSize, PacketType}; use nym_topology::{gateway, mix}; use rand_07::{rngs::ThreadRng, seq::SliceRandom, thread_rng, Rng}; use std::collections::{HashMap, HashSet}; @@ -290,6 +290,8 @@ impl PacketPreparer { &mut self, route: &TestRoute, num: usize, + // TODO: Maybe do this + _packet_type: PacketType, ) -> GatewayPackets { let mut tester = self.ephemeral_mix_tester(route); let topology = route.topology(); @@ -359,6 +361,8 @@ impl PacketPreparer { &mut self, test_nonce: u64, test_routes: &[TestRoute], + // TODO: Maybe do this + _packet_type: PacketType, ) -> PreparedPackets { // only test mixnodes that are rewarded, i.e. that will be rewarded in this interval. // (remember that "idle" nodes are still part of that set) diff --git a/nym-api/src/nym_contract_cache/cache/data.rs b/nym-api/src/nym_contract_cache/cache/data.rs index 98c0046620..adde788bab 100644 --- a/nym-api/src/nym_contract_cache/cache/data.rs +++ b/nym-api/src/nym_contract_cache/cache/data.rs @@ -26,7 +26,7 @@ pub(crate) struct ValidatorCacheData { pub(crate) mix_to_family: Cache>, pub(crate) service_providers: Cache>, - pub(crate) names: Cache>, + pub(crate) registered_names: Cache>, } impl ValidatorCacheData { @@ -42,7 +42,7 @@ impl ValidatorCacheData { current_reward_params: Cache::default(), mix_to_family: Cache::default(), service_providers: Cache::default(), - names: Cache::default(), + registered_names: Cache::default(), } } } diff --git a/nym-api/src/nym_contract_cache/cache/mod.rs b/nym-api/src/nym_contract_cache/cache/mod.rs index 76d033da40..73b9699c6a 100644 --- a/nym-api/src/nym_contract_cache/cache/mod.rs +++ b/nym-api/src/nym_contract_cache/cache/mod.rs @@ -66,7 +66,7 @@ impl NymContractCache { cache.mix_to_family.update(mix_to_family); // Just return empty lists when these are not available cache.service_providers.update(services.unwrap_or_default()); - cache.names.update(names.unwrap_or_default()); + cache.registered_names.update(names.unwrap_or_default()); } Err(err) => { error!("{err}"); @@ -305,7 +305,7 @@ impl NymContractCache { pub(crate) async fn names(&self) -> Cache> { match time::timeout(Duration::from_millis(100), self.inner.read()).await { - Ok(cache) => cache.names.clone(), + Ok(cache) => cache.registered_names.clone(), Err(err) => { error!("{err}"); Cache::new(Vec::new()) diff --git a/nym-api/src/nym_contract_cache/mod.rs b/nym-api/src/nym_contract_cache/mod.rs index bdc1fe6882..2926a3304f 100644 --- a/nym-api/src/nym_contract_cache/mod.rs +++ b/nym-api/src/nym_contract_cache/mod.rs @@ -29,7 +29,7 @@ pub(crate) fn nym_contract_cache_routes(settings: &OpenApiSettings) -> (Vec) -> Json) -> Json { +pub async fn get_registered_names(cache: &State) -> Json { let names = cache.names().await.value; Json(names.as_slice().into()) } diff --git a/nym-api/tests/package-lock.json b/nym-api/tests/package-lock.json index 7e89111737..020a0426be 100644 --- a/nym-api/tests/package-lock.json +++ b/nym-api/tests/package-lock.json @@ -15,7 +15,7 @@ "json-stringify-safe": "5.0.1", "tslog": "3.3.3", "uuid": "8.3.2", - "yaml": "^2.1.1" + "yaml": "^2.2.2" }, "devDependencies": { "@types/jest": "28.1.6", @@ -27,7 +27,7 @@ "eslint-plugin-prettier": "^4.0.0", "jest": "^28.1.3", "jest-junit": "^14.0.0", - "prettier": "2.7.1", + "prettier": "^2.8.7", "process": "0.11.10", "ts-jest": "28.0.7", "typescript": "^4.7.4", @@ -4038,9 +4038,9 @@ } }, "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -4822,9 +4822,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", - "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", "engines": { "node": ">= 14" } @@ -7840,9 +7840,9 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" }, "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true }, "prettier-linter-helpers": { @@ -8367,9 +8367,9 @@ "dev": true }, "yaml": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", - "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==" }, "yargs": { "version": "17.5.1", diff --git a/nym-api/tests/package.json b/nym-api/tests/package.json index c3aa4a12ea..e93160b7b6 100644 --- a/nym-api/tests/package.json +++ b/nym-api/tests/package.json @@ -30,7 +30,7 @@ "json-stringify-safe": "5.0.1", "tslog": "3.3.3", "uuid": "8.3.2", - "yaml": "^2.1.1" + "yaml": "^2.2.2" }, "devDependencies": { "@types/jest": "28.1.6", diff --git a/nym-api/tests/yarn.lock b/nym-api/tests/yarn.lock index 3a14e33db6..9e5476cf80 100644 --- a/nym-api/tests/yarn.lock +++ b/nym-api/tests/yarn.lock @@ -2907,10 +2907,10 @@ yallist@^4.0.0: resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz" - integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw== +yaml@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.2.tgz#ec551ef37326e6d42872dad1970300f8eb83a073" + integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA== yargs-parser@^21.0.0, yargs-parser@^21.0.1: version "21.1.1" diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index e5c40df6cb..ef860d020f 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -219,18 +219,18 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bip32" -version = "0.4.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30ed1d6f8437a487a266c8293aeb95b61a23261273e3e02912cdb8b68bf798b" +checksum = "873faa4363bfc54c36a48321da034c92a0645a363eed34d948683ffc1706e37f" dependencies = [ "bs58", - "hmac 0.12.1", + "hmac 0.11.0", "k256", "once_cell", "pbkdf2", "rand_core 0.6.4", - "ripemd", - "sha2 0.10.6", + "ripemd160", + "sha2 0.9.9", "subtle 2.4.1", "zeroize", ] @@ -317,6 +317,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ + "block-padding", "generic-array 0.14.7", ] @@ -329,6 +330,12 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "bls12_381" version = "0.5.0" @@ -691,9 +698,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "constant_time_eq" @@ -750,9 +757,8 @@ dependencies = [ [[package]] name = "cosmos-sdk-proto" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb61f3d2224c90ea78e1fa7444787761a549170c46b6b0ed09b93f9b7e4076a" +version = "0.12.3" +source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d" dependencies = [ "prost", "prost-types", @@ -761,9 +767,8 @@ dependencies = [ [[package]] name = "cosmrs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20d5890dac07a62337e5841adb8f2074a66a962a098a48df9460f64d483beaf4" +version = "0.7.1" +source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d" dependencies = [ "bip32", "cosmos-sdk-proto", @@ -784,11 +789,11 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75836a10cb9654c54e77ee56da94d592923092a10b369cdb0dbd56acefc16340" +checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" dependencies = [ - "digest 0.10.6", + "digest 0.9.0", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -797,53 +802,26 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9f7f0e51bfc7295f7b2664fe8513c966428642aa765dad8a74acdab5e0c773" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cosmwasm-schema" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f00b363610218eea83f24bbab09e1a7c3920b79f068334fdfcc62f6129ef9fc" -dependencies = [ - "cosmwasm-schema-derive", - "schemars", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cosmwasm-schema-derive" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae38f909b2822d32b275c9e2db9728497aa33ffe67dd463bc67c6a3b7092785c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49b85345e811c8e80ec55d0d091e4fcb4f00f97ab058f9be5f614c444a730cb" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" dependencies = [ "base64 0.13.1", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", "forward_ref", - "hex", "schemars", "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "serde-json-wasm", "thiserror", "uint", ] @@ -957,9 +935,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", @@ -1075,26 +1053,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "cw-controllers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91440ce8ec4f0642798bc8c8cb6b9b53c1926c6dadaf0eed267a5145cd529071" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw-storage-plus" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a5083c258acd68386734f428a5a171b29f7d733151ae83090c6fcc9417ffa" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" dependencies = [ "cosmwasm-std", "schemars", @@ -1103,84 +1066,46 @@ dependencies = [ [[package]] name = "cw-utils" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" +checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", - "cw2", "schemars", - "semver 1.0.17", "serde", "thiserror", ] [[package]] name = "cw2" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb70cee2cf0b4a8ff7253e6bc6647107905e8eb37208f87d54f67810faa62f8" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "schemars", "serde", ] -[[package]] -name = "cw20" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91666da6c7b40c8dd5ff94df655a28114efc10c79b70b4d06f13c31e37d60609" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils", - "schemars", - "serde", -] - [[package]] name = "cw3" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe0b587008aa221cd2a2579a21990a28c4347dc53ad43167c68ad765f5b6efa" +checksum = "fe19462a7f644ba60c19d3443cb90d00c50d9b6b3b0a3a7fca93df8261af979b" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-utils", - "cw20", "schemars", "serde", - "thiserror", -] - -[[package]] -name = "cw3-fixed-multisig" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e2415adb201e5e89dab34edf59d7dc166bc558526de009a49ae66276c9119a" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw3", - "schemars", - "serde", - "thiserror", ] [[package]] name = "cw4" -version = "1.0.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c236e0bae02ce97e89235a681dd0e07d099524b369f1ef908d704db3e6b049b" +checksum = "0acc3549d5ce11c6901b3a676f2e2628684722197054d97cd0101ea174ed5cbd" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "schemars", @@ -1248,23 +1173,11 @@ dependencies = [ [[package]] name = "der" -version = "0.6.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ "const-oid", - "zeroize", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", ] [[package]] @@ -1397,9 +1310,9 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" dependencies = [ "der", "elliptic-curve", @@ -1453,18 +1366,16 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.6", - "ff 0.12.1", + "ff 0.11.1", "generic-array 0.14.7", - "group 0.12.1", - "pkcs8", + "group 0.11.0", "rand_core 0.6.4", "sec1", "subtle 2.4.1", @@ -1595,16 +1506,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle 2.4.1", -] - [[package]] name = "field-offset" version = "0.3.5" @@ -2126,17 +2027,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle 2.4.1", -] - [[package]] name = "gtk" version = "0.15.5" @@ -2768,22 +2658,23 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sec1", + "sha2 0.9.9", "sha3", ] [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" dependencies = [ "cpufeatures", ] @@ -3586,8 +3477,6 @@ dependencies = [ name = "nym-group-contract-common" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cw-controllers", "cw4", "schemars", "serde", @@ -3604,7 +3493,7 @@ dependencies = [ "nym-contracts-common", "schemars", "serde", - "serde-json-wasm 0.4.1", + "serde-json-wasm", "serde_repr", "thiserror", "time", @@ -3614,12 +3503,9 @@ dependencies = [ name = "nym-multisig-contract-common" version = "0.1.0" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", "cw-utils", "cw3", - "cw3-fixed-multisig", "cw4", "schemars", "serde", @@ -3677,8 +3563,10 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek", "getrandom 0.2.8", + "log", + "rand 0.7.3", "rayon", - "sphinx-packet 0.1.0 (git+https://github.com/nymtech/sphinx.git)", + "sphinx-packet", "thiserror", "zeroize", ] @@ -3769,7 +3657,6 @@ version = "0.1.0" dependencies = [ "log", "nym-crypto", - "nym-outfox", "nym-sphinx-acknowledgements", "nym-sphinx-addressing", "nym-sphinx-anonymous-replies", @@ -3864,6 +3751,7 @@ dependencies = [ "nym-sphinx-addressing", "nym-sphinx-params", "nym-sphinx-types", + "thiserror", ] [[package]] @@ -3900,7 +3788,9 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "sphinx-packet 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nym-outfox", + "sphinx-packet", + "thiserror", ] [[package]] @@ -4232,11 +4122,11 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pbkdf2" -version = "0.11.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" dependencies = [ - "digest 0.10.6", + "crypto-mac 0.11.1", ] [[package]] @@ -4459,12 +4349,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", + "zeroize", ] [[package]] @@ -4864,12 +4755,12 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" dependencies = [ "crypto-bigint", - "hmac 0.12.1", + "hmac 0.11.0", "zeroize", ] @@ -4912,15 +4803,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.6", -] - [[package]] name = "ripemd160" version = "0.9.1" @@ -5131,11 +5013,10 @@ dependencies = [ [[package]] name = "sec1" -version = "0.3.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" dependencies = [ - "base16ct", "der", "generic-array 0.14.7", "pkcs8", @@ -5231,15 +5112,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde-json-wasm" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" -dependencies = [ - "serde", -] - [[package]] name = "serde_bytes" version = "0.11.9" @@ -5409,12 +5281,14 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.8" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" dependencies = [ - "digest 0.10.6", + "block-buffer 0.9.0", + "digest 0.9.0", "keccak", + "opaque-debug 0.3.0", ] [[package]] @@ -5437,11 +5311,11 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" dependencies = [ - "digest 0.10.6", + "digest 0.9.0", "rand_core 0.6.4", ] @@ -5528,29 +5402,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "sphinx-packet" -version = "0.1.0" -source = "git+https://github.com/nymtech/sphinx.git#ca107d94360cdf8bbfbdb12fe5320ed74f80e40c" -dependencies = [ - "aes 0.7.5", - "arrayref", - "blake2", - "bs58", - "byteorder", - "chacha", - "curve25519-dalek", - "digest 0.9.0", - "hkdf 0.11.0", - "hmac 0.11.0", - "lioness", - "log", - "rand 0.7.3", - "rand_distr", - "sha2 0.9.9", - "subtle 2.4.1", -] - [[package]] name = "spin" version = "0.5.2" @@ -5568,9 +5419,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.6.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", "der", @@ -6212,9 +6063,9 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a199518e0366ba0aeb0d0e0a59dbd99ea0bdc14280f414ecc758c9228a454ad8" +checksum = "3ca881fa4dedd2b46334f13be7fbc8cc1549ba4be5a833fe4e73d1a1baaf7949" dependencies = [ "async-trait", "bytes", @@ -6243,9 +6094,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d8f6a64ae3b59ea3c73efad727271ee085b544b817d7f46901817ca6bb1773" +checksum = "f6c56ee93f4e9b7e7daba86d171f44572e91b741084384d0ae00df7991873dfd" dependencies = [ "flex-error", "serde", @@ -6257,9 +6108,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b303d6387aaea38cea7ef924476d1f798573044e7b4f6ddd1166ac5184b2281" +checksum = "b71f925d74903f4abbdc4af0110635a307b3cb05b175fdff4a7247c14a4d0874" dependencies = [ "bytes", "flex-error", @@ -6275,9 +6126,9 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.23.8" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3036f0b65baa11e767dabd22a0663e842b595b0a1903f149b7b8b1e09b2b443d" +checksum = "a13e63f57ee05a1e927887191c76d1b139de9fa40c180b9f8727ee44377242a6" dependencies = [ "async-trait", "bytes", diff --git a/nym-connect/desktop/src-tauri/src/tasks.rs b/nym-connect/desktop/src-tauri/src/tasks.rs index 8dfa446556..c65289dde8 100644 --- a/nym-connect/desktop/src-tauri/src/tasks.rs +++ b/nym-connect/desktop/src-tauri/src/tasks.rs @@ -1,4 +1,5 @@ use futures::{channel::mpsc, StreamExt}; +use nym_client_core::client::base_client::storage::OnDiskPersistent; use nym_client_core::{ config::{ClientCoreConfigTrait, GatewayEndpointConfig}, error::ClientCoreStatusMessage, @@ -45,7 +46,6 @@ pub fn start_nym_socks5_client( .tap_err(|_| log::warn!("Failed to load configuration file"))?; let used_gateway = config.get_base().get_gateway_endpoint().clone(); - let socks5_client = Socks5NymClient::new(config); log::info!("Starting socks5 client"); // Channel to send control messages to the socks5 client @@ -65,6 +65,9 @@ pub fn start_nym_socks5_client( let result = tokio::runtime::Runtime::new() .expect("Failed to create runtime for SOCKS5 client") .block_on(async move { + let storage = OnDiskPersistent::from_config(config.get_base()).await?; + let socks5_client = Socks5NymClient::new(config, storage); + socks5_client .run_and_listen(socks5_ctrl_rx, socks5_status_tx) .await diff --git a/nym-connect/native/android/.gitignore b/nym-connect/native/android/.gitignore new file mode 100644 index 0000000000..aa724b7707 --- /dev/null +++ b/nym-connect/native/android/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/nym-connect/native/android/README.md b/nym-connect/native/android/README.md new file mode 100644 index 0000000000..a192ed73b4 --- /dev/null +++ b/nym-connect/native/android/README.md @@ -0,0 +1,32 @@ +## Nym Connect for Android + +### Prerequisites + +_TODO_ + +### Getting started + +Install Android Studio and open the project. + +### Lib Nym socks5 + +This Application needs the native [nym-socks5-listener](https://github.com/nymtech/nym/blob/develop/sdk/lib/socks5-listener/Cargo.toml) +library in order to work. + +To build it, from the root of the repo run + +```shell +cd sdk/lib/socks5-listener/ +./build-android.sh +``` + +To build in release mode + +```shell +RELEASE=true ./build-android.sh +``` + +The shared library for each ABIs will be automatically moved into +`app/src/main/jniLibs/*` directories. + +### Run _TODO_ \ No newline at end of file diff --git a/nym-connect/native/android/app/.gitignore b/nym-connect/native/android/app/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/nym-connect/native/android/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/nym-connect/native/android/app/build.gradle b/nym-connect/native/android/app/build.gradle new file mode 100644 index 0000000000..3b4fff82e9 --- /dev/null +++ b/nym-connect/native/android/app/build.gradle @@ -0,0 +1,84 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.21' +} + +android { + namespace 'net.nymtech.nyms5' + compileSdk 33 + + defaultConfig { + applicationId "net.nymtech.nyms5" + minSdk 24 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary true + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + splits { + abi { + enable true + reset() + include "x86_64", "arm64-v8a" + universalApk false + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion '1.4.6' + } + packagingOptions { + resources { + excludes += '/META-INF/{AL2.0,LGPL2.1}' + } + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.activity:activity-compose:1.5.1' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' + implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0' + implementation platform('androidx.compose:compose-bom:2022.10.00') + implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1' + implementation 'androidx.compose.runtime:runtime-livedata' + implementation 'androidx.compose.ui:ui' + implementation 'androidx.compose.ui:ui-graphics' + implementation 'androidx.compose.ui:ui-tooling-preview' + implementation 'androidx.compose.material3:material3' + implementation 'androidx.work:work-runtime-ktx:2.8.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00') + androidTestImplementation 'androidx.compose.ui:ui-test-junit4' + debugImplementation 'androidx.compose.ui:ui-tooling' + debugImplementation 'androidx.compose.ui:ui-test-manifest' + implementation 'com.github.kittinunf.fuel:fuel:3.0.0-alpha1' +} \ No newline at end of file diff --git a/nym-connect/native/android/app/proguard-rules.pro b/nym-connect/native/android/app/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/nym-connect/native/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/nym-connect/native/android/app/src/androidTest/java/net/nymtech/nyms5/ExampleInstrumentedTest.kt b/nym-connect/native/android/app/src/androidTest/java/net/nymtech/nyms5/ExampleInstrumentedTest.kt new file mode 100644 index 0000000000..03593bfec4 --- /dev/null +++ b/nym-connect/native/android/app/src/androidTest/java/net/nymtech/nyms5/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package net.nymtech.nyms5 + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("net.nymtech.nyms5", appContext.packageName) + } +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/AndroidManifest.xml b/nym-connect/native/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..311aa8bd42 --- /dev/null +++ b/nym-connect/native/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/App.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/App.kt new file mode 100644 index 0000000000..08c075a460 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/App.kt @@ -0,0 +1,24 @@ +package net.nymtech.nyms5 + +import android.app.Application +import android.util.Log +import androidx.work.Configuration +import androidx.work.DelegatingWorkerFactory + +class App : Application(), Configuration.Provider { + companion object { + // NymProxy singleton (unique instance) + val nymProxy = NymProxy() + } + + private val tag = "App" + + override fun getWorkManagerConfiguration(): Configuration { + val workerFactory = DelegatingWorkerFactory() + // pass in the NymProxy class instance + workerFactory.addFactory(CustomWorkerFactory(nymProxy)) + + Log.d(tag, "using a custom configuration for WorkManager") + return Configuration.Builder().setWorkerFactory(workerFactory).build() + } +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/CustomWorkerFactory.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/CustomWorkerFactory.kt new file mode 100644 index 0000000000..61d0683457 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/CustomWorkerFactory.kt @@ -0,0 +1,26 @@ +package net.nymtech.nyms5 + +import android.content.Context +import androidx.work.ListenableWorker +import androidx.work.WorkerFactory +import androidx.work.WorkerParameters + +class CustomWorkerFactory(private val nymProxy: NymProxy) : WorkerFactory() { + + override fun createWorker( + appContext: Context, + workerClassName: String, + workerParameters: WorkerParameters + ): ListenableWorker? { + + return when (workerClassName) { + ProxyWorker::class.java.name -> + ProxyWorker(appContext, workerParameters, nymProxy) + + else -> + // Return null, so that the base class can delegate to the default WorkerFactory. + null + } + + } +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainActivity.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainActivity.kt new file mode 100644 index 0000000000..eddcb9e027 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainActivity.kt @@ -0,0 +1,188 @@ +package net.nymtech.nyms5 + +import android.os.Bundle +import android.util.Log +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.viewModels +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Switch +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import kotlinx.coroutines.launch +import net.nymtech.nyms5.ui.theme.NymTheme +import androidx.compose.runtime.getValue +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Alignment +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.font.FontStyle +import androidx.work.WorkInfo +import androidx.work.WorkManager + +class MainActivity : ComponentActivity() { + private val tag = "MainActivity" + + private val viewModel: MainViewModel by viewModels { + MainViewModelFactory( + workManager = WorkManager.getInstance(applicationContext), + nymProxy = App.nymProxy + ) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + Log.d(tag, "____onCreate") + + // observe proxy work progress + WorkManager.getInstance(applicationContext) + .getWorkInfoByIdLiveData(ProxyWorker.workId) + // this observer is tied to the activity lifecycle + .observe(this) { workInfo -> + if (workInfo != null && workInfo.state == WorkInfo.State.RUNNING) { + val progress = + workInfo.progress.getString(ProxyWorker.State) + when (progress) { + ProxyWorker.Work.Status.CONNECTED.name -> { + Log.i(tag, "Nym proxy $progress") + viewModel.setConnected() + } + + else -> Log.i(tag, "Nym proxy $progress") + } + } + } + + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + Log.d(tag, "____uiState collect") + viewModel.uiState.collect { + setContent { + NymTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + val loading = it.loading + + S5ClientSwitch(it.connected, loading, { + if (!loading) { + when { + it -> { + Log.d(tag, "switch ON") + viewModel.startProxyWork() + } + + else -> { + Log.d(tag, "switch OFF") + viewModel.cancelProxyWork() + } + } + } + }) + } + } + } + } + } + } + } +} + +@Composable +fun S5ClientSwitch( + connected: Boolean, + loading: Boolean, + onSwitch: (value: Boolean) -> Unit, + modifier: Modifier = Modifier +) { + val clipboardManager = LocalClipboardManager.current + val proxyHost = stringResource(R.string.proxy_host) + if (loading) { + Row { + LinearProgressIndicator( + modifier = modifier.fillMaxWidth(), + color = MaterialTheme.colorScheme.secondary + ) + } + } else { + Spacer(modifier = modifier.height(2.dp)) + } + Column(modifier = modifier.padding(16.dp)) { + Row( + modifier = modifier.padding(16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Text("Nym proxy") + Spacer(modifier = modifier.width(14.dp)) + Switch(checked = connected, enabled = !loading, onCheckedChange = { + onSwitch(!connected) + }) + } + if (connected && !loading) { + Column(modifier = modifier.padding(16.dp)) { + Text( + color = Color.Green, + fontStyle = FontStyle.Italic, + text = stringResource(R.string.connected_text) + ) + Row( + verticalAlignment = Alignment.CenterVertically + ) { + Text(proxyHost) + Spacer(modifier = modifier.width(14.dp)) + TextButton(onClick = { + clipboardManager.setText(AnnotatedString(proxyHost)) + }) { + Text("Copy") + } + } + } + } + } +} + +@Preview +@Composable +fun PreviewSocks5Client() { + val tag = "UI" + var connected by rememberSaveable { mutableStateOf(false) } + var loading by rememberSaveable { mutableStateOf(false) } + NymTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + S5ClientSwitch(connected, loading, { + when { + it -> Log.d(tag, "switch ON") + else -> Log.d(tag, "switch OFF") + } + connected = it + loading = !loading + }) + } + } +} diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainViewModel.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainViewModel.kt new file mode 100644 index 0000000000..36f4858dc7 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/MainViewModel.kt @@ -0,0 +1,136 @@ +package net.nymtech.nyms5 + +import android.util.Log +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.viewModelScope +import androidx.work.Constraints +import androidx.work.ExistingWorkPolicy +import androidx.work.NetworkType +import androidx.work.OneTimeWorkRequest +import androidx.work.OneTimeWorkRequestBuilder +import androidx.work.OutOfQuotaPolicy +import androidx.work.WorkInfo +import androidx.work.WorkManager +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch + +class MainViewModel( + private val workManager: WorkManager, + private val nymProxy: NymProxy +) : ViewModel() { + private val tag = "viewModel" + + private val workRequest: OneTimeWorkRequest = + OneTimeWorkRequestBuilder() + .setConstraints( + Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED).build() + ) + .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST) + .addTag(ProxyWorker.workTag) + .setId(ProxyWorker.workId) + .build() + + init { + Log.d(tag, "____init") + + // TODO ⚠ In some circumstances this `init` block can be run multiple + // time which means the below observer will be registered more than once + // This can leads to multiple sequential calls to `stopClient` + // → nym_socks5_listener panics when this happens, crashing the + // entire App + + // When the work is cancelled "externally" ie. when the user tap the + // "Stop" action on the notification, or when the app is intentionally + // killed the underlying proxy client keeps running in background + // We have to manually call `stopClient` to stop it + workManager.getWorkInfoByIdLiveData(ProxyWorker.workId) + // watch "forever", ie. even when the main activity has been stopped + .observeForever { workInfo -> + if (workInfo?.state == WorkInfo.State.CANCELLED || workInfo?.state == WorkInfo.State.FAILED) { + cancelProxyWork() + Log.d(tag, "proxy work cancelled") + } + } + } + + private val callback = object { + fun onStop() { + Log.d(tag, "⚡ ON STOP callback") + _uiState.update { currentState -> + currentState.copy( + connected = false, + loading = false, + ) + } + Log.i(tag, "Nym proxy disconnected") + } + } + + data class ProxyState( + val connected: Boolean = false, + val loading: Boolean = false + ) + + // Expose screen UI state + private val _uiState = MutableStateFlow(ProxyState()) + val uiState: StateFlow = _uiState.asStateFlow() + + fun setConnected() { + _uiState.update { currentState -> + currentState.copy( + connected = true, + loading = false, + ) + } + } + + fun startProxyWork() { + // start loading state + _uiState.update { currentState -> + currentState.copy( + connected = true, + loading = true, + ) + } + + // start long-running proxy service + workManager.enqueueUniqueWork( + ProxyWorker.name, + ExistingWorkPolicy.REPLACE, + workRequest + ) + } + + fun cancelProxyWork() { + // update state + _uiState.update { currentState -> + currentState.copy( + connected = false, + loading = true, + ) + } + viewModelScope.launch(Dispatchers.IO) { + nymProxy.stop(callback) + } + } +} + +class MainViewModelFactory( + private val workManager: WorkManager, + private val nymProxy: NymProxy +) : + ViewModelProvider.Factory { + override fun create(modelClass: Class): T { + return if (modelClass.isAssignableFrom(MainViewModel::class.java)) { + MainViewModel(workManager, nymProxy) as T + } else { + throw IllegalArgumentException("Unknown ViewModel class") + } + } +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/NymProxy.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/NymProxy.kt new file mode 100644 index 0000000000..4c5f7a2eb2 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/NymProxy.kt @@ -0,0 +1,42 @@ +package net.nymtech.nyms5 + +import android.util.Log + +const val nymNativeLib = "nym_socks5_listener" + +class NymProxy { + private val tag = "NymProxy" + + // Load the native library "libnym_socks5_listener.so" + init { + System.loadLibrary(nymNativeLib) + Log.i(tag, "loaded native library $nymNativeLib") + } + + fun start(serviceProvider: String, callback: Any) { + Log.d(tag, "calling $nymNativeLib:run") + try { + run(serviceProvider, callback) + } catch (e: Throwable) { + Log.e(tag, "$nymNativeLib:run internal error: $e") + } + } + + /* fun start() { + Log.d(tag, "calling $nymNativeLib:startClient") + return startClient() + } */ + + fun stop(callback: Any) { + Log.d(tag, "calling $nymNativeLib:stopClient") + try { + stopClient(callback) + } catch (e: Throwable) { + Log.e(tag, "$nymNativeLib:stopClient internal error: $e") + } + } + + private external fun run(spAddress: String, callback: Any) + private external fun stopClient(callbacks: Any) + // private external fun startClient() +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ProxyWorker.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ProxyWorker.kt new file mode 100644 index 0000000000..923aa0fdb2 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ProxyWorker.kt @@ -0,0 +1,196 @@ +package net.nymtech.nyms5 + +import android.app.Notification +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.content.Context +import android.content.Intent +import android.os.Build +import android.util.Log +import androidx.annotation.RequiresApi +import androidx.core.app.NotificationCompat +import androidx.work.CoroutineWorker +import androidx.work.ForegroundInfo +import androidx.work.WorkManager +import androidx.work.WorkerParameters +import androidx.work.workDataOf +import fuel.Fuel +import fuel.get +import kotlinx.serialization.Serializable +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json +import java.util.UUID +import kotlin.random.Random + +class ProxyWorker( + context: Context, + parameters: WorkerParameters, + private val nymProxy: NymProxy +) : + CoroutineWorker(context, parameters) { + companion object Work { + const val name = "nymS5ProxyWorker" + const val workTag = "nymProxy" + val workId: UUID = UUID.randomUUID() + + const val State = "State" + + enum class Status { + DISCONNECTED, + STARTING, + CONNECTED + } + } + + private val tag = "proxyWorker" + + private val spUrl = context.getString(R.string.sp_url) + + private val defaultSp = context.getString(R.string.default_sp) + + private val channelId = + applicationContext.getString(R.string.notification_channel_id) + + private val notificationId = 2001 + + private val notificationManager = + context.getSystemService(Context.NOTIFICATION_SERVICE) as + NotificationManager + + @Serializable + data class SPData( + val service_provider_client_id: String, + val gateway_identity_key: String, + val routing_score: Float, + val ip_address: String + ) + + @Serializable + data class SPListData(val items: List) + + private val json = Json { ignoreUnknownKeys = true } + + private val callback = object { + fun onStart() { + Log.d(tag, "⚡ ON START callback") + setProgressAsync(workDataOf(State to Status.CONNECTED.name)) + } + } + + @RequiresApi(Build.VERSION_CODES.O) + override suspend fun doWork(): Result { + setProgress(workDataOf(State to Status.STARTING.name)) + + // `setForeground` can fail + // see https://developer.android.com/guide/background/persistent/getting-started/define-work#coroutineworker + try { + setForeground(createForegroundInfo()) + } catch (e: Throwable) { + Log.w( + tag, + "failed to make the work run in the context of a foreground service" + ) + } + + return try { + Log.d(tag, "starting work") + + var serviceProvider: String? = null + // fetch the SP list and select a random one + try { + val res = Fuel.get(spUrl) + if (res.statusCode == 200) { + val spJson = json.decodeFromString(res.body) + serviceProvider = + Random.nextInt(until = spJson.items.size) + .let { spJson.items[it].service_provider_client_id } + Log.d(tag, "selected service provider: $serviceProvider") + } else { + Log.w( + tag, + "failed to fetch the service providers list: $res.statusCode" + ) + Log.w(tag, "using a default service provider $defaultSp") + } + } catch (e: Throwable) { + Log.e( + tag, + "an error occurred while fetching the service providers list: $e" + ) + Log.w(tag, "using a default service provider $defaultSp") + } + + nymProxy.start(serviceProvider ?: defaultSp, callback) + + setProgress(workDataOf(State to Status.DISCONNECTED.name)) + Log.d(tag, "work finished") + Result.success() + } catch (e: Throwable) { + Log.e(tag, "error: ${e.message}") + Result.failure() + } + } + + private fun createNotification(): Notification { + val title = applicationContext.getString(R.string.notification_title) + val cancel = applicationContext.getString(R.string.stop_proxy) + // this pending intent is used to cancel the worker + val stopPendingIntent = WorkManager.getInstance(applicationContext) + .createCancelPendingIntent(id) + + // this intent is used for the notification's tap action + // on tap → show to the main activity + val tapIntent = + Intent(applicationContext, MainActivity::class.java).apply { + flags = + Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + } + val tapPendingIntent: PendingIntent = PendingIntent.getActivity( + applicationContext, + 0, + tapIntent, + PendingIntent.FLAG_IMMUTABLE + ) + + return NotificationCompat.Builder(applicationContext, channelId) + .setContentTitle(title) + .setTicker(title) + .setContentText("Nym socks5 proxy running") + .setSmallIcon(R.drawable.shield_24) + .setOngoing(true) + .setContentIntent(tapPendingIntent) + .addAction(android.R.drawable.ic_delete, cancel, stopPendingIntent) + .build() + } + + // Creates an instance of ForegroundInfo which can be used to update the + // ongoing notification. + @RequiresApi(Build.VERSION_CODES.O) + private fun createForegroundInfo(): ForegroundInfo { + // Create a Notification channel if necessary + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + createChannel() + } + + return ForegroundInfo(notificationId, createNotification()) + } + + @RequiresApi(Build.VERSION_CODES.O) + private fun createChannel() { + notificationManager.createNotificationChannel( + NotificationChannel( + channelId, + applicationContext.getString(R.string.notification_channel_name), + NotificationManager.IMPORTANCE_DEFAULT + ) + ) + } + + // TODO without this override, under Android 11 the app crashes + // see https://developer.android.com/guide/background/persistent/getting-started/define-work#coroutineworker + // override doesn't seem to be a problem for newer versions + override suspend fun getForegroundInfo(): ForegroundInfo { + return ForegroundInfo(notificationId, createNotification()) + } +} diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Color.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Color.kt new file mode 100644 index 0000000000..1667a76208 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package net.nymtech.nyms5.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Theme.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Theme.kt new file mode 100644 index 0000000000..1792f65f66 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Theme.kt @@ -0,0 +1,70 @@ +package net.nymtech.nyms5.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun NymTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Type.kt b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Type.kt new file mode 100644 index 0000000000..e8f9620039 --- /dev/null +++ b/nym-connect/native/android/app/src/main/java/net/nymtech/nyms5/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package net.nymtech.nyms5.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/jniLibs/arm64-v8a/.gitkeep b/nym-connect/native/android/app/src/main/jniLibs/arm64-v8a/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/nym-connect/native/android/app/src/main/jniLibs/x86_64/.gitkeep b/nym-connect/native/android/app/src/main/jniLibs/x86_64/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/nym-connect/native/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/nym-connect/native/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000000..2b068d1146 --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/drawable/ic_launcher_background.xml b/nym-connect/native/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000..07d5da9cbf --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nym-connect/native/android/app/src/main/res/drawable/shield_24.xml b/nym-connect/native/android/app/src/main/res/drawable/shield_24.xml new file mode 100644 index 0000000000..e49a1f265d --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/drawable/shield_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..036d09bc5f --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..036d09bc5f --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..4974445c9a Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..483ace7edf Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..59b2f1db44 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..307fb6aab9 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..e634763b42 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..37a8d502c8 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..5b412e78a0 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..580c767c54 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..51a588fdee Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..65cefcb196 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..312d818bbe Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..5070e583a0 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..18252905f8 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..514ec36652 Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..83e115a87d Binary files /dev/null and b/nym-connect/native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/nym-connect/native/android/app/src/main/res/values/colors.xml b/nym-connect/native/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000..f8c6127d32 --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/values/ic_launcher_background.xml b/nym-connect/native/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000000..a3b9258141 --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #1D2125 + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/values/strings.xml b/nym-connect/native/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000..bb0c7d4c0e --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + Nyms5 + Nym socks5 process + Nym proxy + 21 + Nym proxy + Stop + http://localhost:1080 + https://harbourmaster.nymtech.net/v1/services?size=100 + DpB3cHAchJiNBQi5FrZx2csXb1mrHkpYh9Wzf8Rjsuko.ANNWrvHqMYuertHGHUrZdBntQhpzfbWekB39qez9U2Vx@2BuMSfMW3zpeAjKXyKLhmY4QW1DXurrtSPEJ6CjX3SEh + Connected to the mixnet + \ No newline at end of file diff --git a/nym-connect/native/android/app/src/main/res/values/themes.xml b/nym-connect/native/android/app/src/main/res/values/themes.xml new file mode 100644 index 0000000000..be09533927 --- /dev/null +++ b/nym-connect/native/android/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +