unified sending interface + example of split sending
This commit is contained in:
Generated
+1
@@ -4438,6 +4438,7 @@ dependencies = [
|
||||
name = "nym-sdk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bip39",
|
||||
"dotenvy",
|
||||
"futures",
|
||||
|
||||
Generated
-6
@@ -290,12 +290,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-bigint"
|
||||
version = "0.4.9"
|
||||
|
||||
@@ -54,7 +54,7 @@ If you're integrating mixnet functionality into an existing app and want to inte
|
||||
```
|
||||
|
||||
### Anonymous replies with SURBs
|
||||
Both functions used to send messages through the mixnet (`send_str` and `send_bytes`) send a pre-determined number of SURBs along with their messages by default.
|
||||
Both functions used to send messages through the mixnet (`send_message` and `send_plain_message`) send a pre-determined number of SURBs along with their messages by default.
|
||||
|
||||
The number of SURBs is set [here](https://github.com/nymtech/nym/blob/release/{{platform_release_version}}/sdk/rust/nym-sdk/src/mixnet/client.rs#L34):
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -3656,7 +3656,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-connect"
|
||||
version = "1.1.15"
|
||||
version = "1.1.16"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bip39",
|
||||
|
||||
Generated
+226
-48
@@ -21,7 +21,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher 0.3.0",
|
||||
"cpufeatures",
|
||||
"ctr 0.8.0",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -31,7 +44,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher",
|
||||
"cipher 0.4.4",
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
@@ -42,11 +55,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"aes",
|
||||
"cipher",
|
||||
"ctr",
|
||||
"aes 0.8.2",
|
||||
"cipher 0.4.4",
|
||||
"ctr 0.9.2",
|
||||
"ghash",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -97,7 +110,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95c2fcf79ad1932ac6269a738109997a83c227c09b75842ae564dc8ede6a861c"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"blake2",
|
||||
"blake2 0.10.6",
|
||||
"password-hash",
|
||||
]
|
||||
|
||||
@@ -212,14 +225,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e141fb0f8be1c7b45887af94c88b182472b57c96b56773250ae00cd6a14a164"
|
||||
dependencies = [
|
||||
"bs58 0.5.0",
|
||||
"hmac",
|
||||
"hmac 0.12.1",
|
||||
"k256 0.13.1",
|
||||
"once_cell",
|
||||
"pbkdf2",
|
||||
"rand_core 0.6.4",
|
||||
"ripemd",
|
||||
"sha2 0.10.6",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -261,6 +274,18 @@ dependencies = [
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
"crypto-mac 0.7.0",
|
||||
"digest 0.8.1",
|
||||
"opaque-debug 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.10.6"
|
||||
@@ -282,7 +307,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -291,7 +316,7 @@ version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -304,7 +329,7 @@ dependencies = [
|
||||
"group 0.11.0",
|
||||
"pairing",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -366,6 +391,12 @@ version = "3.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.13.0"
|
||||
@@ -480,6 +511,15 @@ dependencies = [
|
||||
"keystream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
@@ -809,9 +849,9 @@ version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -821,9 +861,9 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -833,11 +873,31 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"rand_core 0.6.4",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
"subtle 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cssparser"
|
||||
version = "0.27.2"
|
||||
@@ -884,13 +944,22 @@ dependencies = [
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctr"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
|
||||
dependencies = [
|
||||
"cipher 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctr"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
"cipher 0.4.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -908,7 +977,7 @@ dependencies = [
|
||||
"byteorder",
|
||||
"digest 0.9.0",
|
||||
"rand_core 0.5.1",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -1100,13 +1169,22 @@ dependencies = [
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1118,7 +1196,7 @@ dependencies = [
|
||||
"block-buffer 0.10.3",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1326,12 +1404,12 @@ dependencies = [
|
||||
"der 0.6.1",
|
||||
"digest 0.10.7",
|
||||
"ff 0.12.1",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"group 0.12.1",
|
||||
"pkcs8 0.9.0",
|
||||
"rand_core 0.6.4",
|
||||
"sec1 0.3.0",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -1345,12 +1423,12 @@ dependencies = [
|
||||
"crypto-bigint 0.5.2",
|
||||
"digest 0.10.7",
|
||||
"ff 0.13.0",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"group 0.13.0",
|
||||
"pkcs8 0.10.2",
|
||||
"rand_core 0.6.4",
|
||||
"sec1 0.7.3",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -1459,7 +1537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924"
|
||||
dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1469,7 +1547,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160"
|
||||
dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1479,7 +1557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
|
||||
dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1759,6 +1837,15 @@ dependencies = [
|
||||
"windows 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
@@ -1814,7 +1901,7 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40"
|
||||
dependencies = [
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
"polyval",
|
||||
]
|
||||
|
||||
@@ -1945,7 +2032,7 @@ dependencies = [
|
||||
"byteorder",
|
||||
"ff 0.11.1",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1956,7 +2043,7 @@ checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7"
|
||||
dependencies = [
|
||||
"ff 0.12.1",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1967,7 +2054,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
||||
dependencies = [
|
||||
"ff 0.13.0",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2143,6 +2230,26 @@ version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
|
||||
|
||||
[[package]]
|
||||
name = "hkdf"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b"
|
||||
dependencies = [
|
||||
"digest 0.9.0",
|
||||
"hmac 0.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
|
||||
dependencies = [
|
||||
"crypto-mac 0.11.1",
|
||||
"digest 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
@@ -2394,7 +2501,7 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2553,6 +2660,12 @@ dependencies = [
|
||||
"signature 2.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keystream"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28"
|
||||
|
||||
[[package]]
|
||||
name = "kuchiki"
|
||||
version = "0.8.1"
|
||||
@@ -2589,6 +2702,12 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.8"
|
||||
@@ -2616,6 +2735,18 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "lioness"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"blake2 0.8.1",
|
||||
"chacha",
|
||||
"keystream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.9"
|
||||
@@ -2859,6 +2990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3146,7 +3278,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"argon2",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"getrandom 0.2.10",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
@@ -3364,6 +3496,12 @@ version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
@@ -3518,7 +3656,7 @@ checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3540,7 +3678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
||||
dependencies = [
|
||||
"digest 0.10.7",
|
||||
"hmac",
|
||||
"hmac 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3821,7 +3959,7 @@ checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
@@ -4027,6 +4165,16 @@ dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_distr"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"rand 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
@@ -4153,7 +4301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb"
|
||||
dependencies = [
|
||||
"crypto-bigint 0.4.9",
|
||||
"hmac",
|
||||
"hmac 0.12.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -4163,8 +4311,8 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"subtle",
|
||||
"hmac 0.12.1",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4363,9 +4511,9 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928"
|
||||
dependencies = [
|
||||
"base16ct 0.1.1",
|
||||
"der 0.6.1",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"pkcs8 0.9.0",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -4377,9 +4525,9 @@ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
||||
dependencies = [
|
||||
"base16ct 0.2.0",
|
||||
"der 0.7.7",
|
||||
"generic-array",
|
||||
"generic-array 0.14.7",
|
||||
"pkcs8 0.10.2",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -4620,7 +4768,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4731,6 +4879,30 @@ dependencies = [
|
||||
"system-deps 5.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sphinx-packet"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc43eda802856ee82a7555c7b75ceb9e07451741c7a2f5f23d036020e01189d4"
|
||||
dependencies = [
|
||||
"aes 0.7.5",
|
||||
"arrayref",
|
||||
"blake2 0.8.1",
|
||||
"bs58 0.4.0",
|
||||
"byteorder",
|
||||
"chacha",
|
||||
"curve25519-dalek",
|
||||
"digest 0.9.0",
|
||||
"hkdf",
|
||||
"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"
|
||||
@@ -4826,6 +4998,12 @@ dependencies = [
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.4.1"
|
||||
@@ -5185,7 +5363,7 @@ dependencies = [
|
||||
"serde_repr",
|
||||
"sha2 0.10.6",
|
||||
"signature 2.1.0",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"subtle-encoding",
|
||||
"tendermint-proto",
|
||||
"time",
|
||||
@@ -5245,7 +5423,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
"subtle-encoding",
|
||||
"tendermint",
|
||||
"tendermint-config",
|
||||
@@ -5643,7 +5821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -6,6 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
bip39 = { workspace = true }
|
||||
nym-client-core = { path = "../../../common/client-core", features = ["fs-surb-storage"]}
|
||||
nym-crypto = { path = "../../../common/crypto" }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -29,7 +30,10 @@ async fn main() {
|
||||
let our_address = client.nym_address();
|
||||
|
||||
// Send a message throughout the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message");
|
||||
if let Some(received) = client.wait_for_messages().await {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -19,7 +20,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send a message through the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message");
|
||||
if let Some(received) = client.wait_for_messages().await {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[tokio::main]
|
||||
@@ -26,7 +27,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send a message throught the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message");
|
||||
if let Some(received) = client.wait_for_messages().await {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
use nym_topology::provider_trait::{async_trait, TopologyProvider};
|
||||
use nym_topology::{nym_topology_from_detailed, NymTopology};
|
||||
use url::Url;
|
||||
@@ -69,7 +70,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send a message through the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message (ctrl-c to exit)");
|
||||
client
|
||||
|
||||
@@ -3,6 +3,7 @@ use nym_client_core::client::base_client::storage::gateway_details::{
|
||||
};
|
||||
use nym_sdk::mixnet::{
|
||||
self, EmptyReplyStorage, EphemeralCredentialStorage, KeyManager, KeyStore, MixnetClientStorage,
|
||||
MixnetMessageSender,
|
||||
};
|
||||
use nym_topology::provider_trait::async_trait;
|
||||
|
||||
@@ -26,7 +27,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send important info up the pipe to a buddy
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message");
|
||||
if let Some(received) = client.wait_for_messages().await {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
use nym_topology::mix::Layer;
|
||||
use nym_topology::{mix, NymTopology};
|
||||
use std::collections::BTreeMap;
|
||||
@@ -81,7 +82,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send a message through the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message (ctrl-c to exit)");
|
||||
client
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use futures::StreamExt;
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Notify;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
nym_bin_common::logging::setup_logging();
|
||||
|
||||
// Passing no config makes the client fire up an ephemeral session and figure stuff out on its own
|
||||
let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
|
||||
// Be able to get our client address
|
||||
let our_address = *client.nym_address();
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
let receive_notify = Arc::new(Notify::new());
|
||||
let receive_notify2 = receive_notify.clone();
|
||||
let send_notify = Arc::new(Notify::new());
|
||||
let send_notify2 = send_notify.clone();
|
||||
|
||||
let sender = client.split_sender();
|
||||
|
||||
// receiving task
|
||||
tokio::spawn(async move {
|
||||
if let Some(received) = client.next().await {
|
||||
for r in received {
|
||||
println!("Received: {}", String::from_utf8_lossy(&r.message));
|
||||
}
|
||||
}
|
||||
|
||||
client.disconnect().await;
|
||||
// notify that we're done and leave the task!
|
||||
receive_notify.notify_waiters();
|
||||
});
|
||||
|
||||
// sending task
|
||||
tokio::spawn(async move {
|
||||
sender
|
||||
.send_plain_message(our_address, "hello from a different task!")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
send_notify.notify_waiters();
|
||||
});
|
||||
|
||||
// wait for both tasks to be done
|
||||
println!("waiting for shutdown");
|
||||
send_notify2.notified().await;
|
||||
receive_notify2.notified().await;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
use nym_sdk::mixnet;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -12,7 +13,10 @@ async fn main() {
|
||||
println!("Our client nym address is: {our_address}");
|
||||
|
||||
// Send a message throught the mixnet to ourselves
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message (ctrl-c to exit)");
|
||||
client
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use nym_sdk::mixnet::{
|
||||
AnonymousSenderTag, MixnetClientBuilder, ReconstructedMessage, StoragePaths,
|
||||
AnonymousSenderTag, MixnetClientBuilder, MixnetMessageSender, ReconstructedMessage,
|
||||
StoragePaths,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -28,7 +29,10 @@ async fn main() {
|
||||
println!("\nOur client nym address is: {our_address}");
|
||||
|
||||
// Send a message through the mixnet to ourselves using our nym address
|
||||
client.send_str(*our_address, "hello there").await;
|
||||
client
|
||||
.send_plain_message(*our_address, "hello there")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// we're going to parse the sender_tag (AnonymousSenderTag) from the incoming message and use it to 'reply' to ourselves instead of our Nym address.
|
||||
// we know there will be a sender_tag since the sdk sends SURBs along with messages by default.
|
||||
@@ -57,7 +61,10 @@ async fn main() {
|
||||
|
||||
// reply to self with it: note we use `send_str_reply` instead of `send_str`
|
||||
println!("Replying with using SURBs");
|
||||
client.send_str_reply(return_recipient, "hi an0n!").await;
|
||||
client
|
||||
.send_reply(return_recipient, "hi an0n!")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Waiting for message (once you see it, ctrl-c to exit)\n");
|
||||
client
|
||||
|
||||
@@ -89,6 +89,9 @@ pub enum Error {
|
||||
|
||||
#[error("loaded shared gateway key without providing information about what gateway it corresponds to")]
|
||||
GatewayWithUnknownEndpoint,
|
||||
|
||||
#[error("failed to send the provided message")]
|
||||
MessageSendingFailure,
|
||||
}
|
||||
|
||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
@@ -36,6 +36,7 @@ mod connection_state;
|
||||
mod native_client;
|
||||
mod paths;
|
||||
mod socks5_client;
|
||||
mod traits;
|
||||
|
||||
pub use client::{DisconnectedMixnetClient, IncludedSurbs, MixnetClientBuilder};
|
||||
pub use config::{Config, KeyMode};
|
||||
@@ -73,3 +74,4 @@ pub use nym_sphinx::{
|
||||
pub use nym_topology::{provider_trait::TopologyProvider, NymTopology};
|
||||
pub use paths::StoragePaths;
|
||||
pub use socks5_client::Socks5MixnetClient;
|
||||
pub use traits::MixnetMessageSender;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use crate::mixnet::client::{IncludedSurbs, MixnetClientBuilder};
|
||||
use crate::Result;
|
||||
use crate::mixnet::client::MixnetClientBuilder;
|
||||
use crate::mixnet::traits::MixnetMessageSender;
|
||||
use crate::{Error, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::{Stream, StreamExt};
|
||||
use nym_client_core::client::{
|
||||
base_client::{ClientInput, ClientOutput, ClientState},
|
||||
@@ -7,10 +9,9 @@ use nym_client_core::client::{
|
||||
received_buffer::ReconstructedMessagesReceiver,
|
||||
};
|
||||
use nym_sphinx::addressing::clients::Recipient;
|
||||
use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag;
|
||||
use nym_sphinx::{params::PacketType, receiver::ReconstructedMessage};
|
||||
use nym_task::{
|
||||
connections::{ConnectionCommandSender, LaneQueueLengths, TransmissionLane},
|
||||
connections::{ConnectionCommandSender, LaneQueueLengths},
|
||||
TaskManager,
|
||||
};
|
||||
use nym_topology::NymTopology;
|
||||
@@ -74,9 +75,10 @@ impl MixnetClient {
|
||||
|
||||
/// Get a shallow clone of [`MixnetClientSender`]. Useful if you want split the send and
|
||||
/// receive logic in different locations.
|
||||
pub fn sender(&self) -> MixnetClientSender {
|
||||
pub fn split_sender(&self) -> MixnetClientSender {
|
||||
MixnetClientSender {
|
||||
client_input: self.client_input.clone(),
|
||||
packet_type: self.packet_type,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,132 +114,6 @@ impl MixnetClient {
|
||||
self.client_state.topology_accessor.release_manual_control()
|
||||
}
|
||||
|
||||
/// Sends stringy data to the supplied Nym address
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let address = "foobar";
|
||||
/// let recipient = mixnet::Recipient::try_from_base58_string(address).unwrap();
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// client.send_str(recipient, "hi").await;
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn send_str(&self, address: Recipient, message: &str) {
|
||||
self.send_bytes(address, message, IncludedSurbs::default())
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Sends bytes to the supplied Nym address. There is the option to specify the number of
|
||||
/// reply-SURBs to include.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let address = "foobar";
|
||||
/// let recipient = mixnet::Recipient::try_from_base58_string(address).unwrap();
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// let surbs = mixnet::IncludedSurbs::default();
|
||||
/// client.send_bytes(recipient, "hi".to_owned().into_bytes(), surbs).await;
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn send_bytes<M: AsRef<[u8]>>(
|
||||
&self,
|
||||
address: Recipient,
|
||||
message: M,
|
||||
surbs: IncludedSurbs,
|
||||
) {
|
||||
let lane = TransmissionLane::General;
|
||||
let input_msg = match surbs {
|
||||
IncludedSurbs::Amount(surbs) => InputMessage::new_anonymous(
|
||||
address,
|
||||
message.as_ref().to_vec(),
|
||||
surbs,
|
||||
lane,
|
||||
self.packet_type,
|
||||
),
|
||||
IncludedSurbs::ExposeSelfAddress => InputMessage::new_regular(
|
||||
address,
|
||||
message.as_ref().to_vec(),
|
||||
lane,
|
||||
self.packet_type,
|
||||
),
|
||||
};
|
||||
self.send(input_msg).await
|
||||
}
|
||||
|
||||
/// Sends stringy reply data to the supplied anonymous recipient.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// // note: the tag is something you would have received from a remote client sending you surbs!
|
||||
/// let tag = mixnet::AnonymousSenderTag::try_from_base58_string("foobar").unwrap();
|
||||
/// client.send_str_reply(tag, "hi").await;
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn send_str_reply(&self, recipient_tag: AnonymousSenderTag, message: &str) {
|
||||
self.send_reply(recipient_tag, message).await;
|
||||
}
|
||||
|
||||
/// Sends binary reply data to the supplied anonymous recipient.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// // note: the tag is something you would have received from a remote client sending you surbs!
|
||||
/// let tag = mixnet::AnonymousSenderTag::try_from_base58_string("foobar").unwrap();
|
||||
/// client.send_reply(tag, b"hi").await;
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn send_reply<M: AsRef<[u8]>>(&self, recipient_tag: AnonymousSenderTag, message: M) {
|
||||
let lane = TransmissionLane::General;
|
||||
let input_msg = InputMessage::new_reply(
|
||||
recipient_tag,
|
||||
message.as_ref().to_vec(),
|
||||
lane,
|
||||
self.packet_type,
|
||||
);
|
||||
self.send(input_msg).await
|
||||
}
|
||||
|
||||
/// Sends a [`InputMessage`] to the mixnet. This is the most low-level sending function, for
|
||||
/// full customization.
|
||||
async fn send(&self, message: InputMessage) {
|
||||
if self.client_input.send(message).await.is_err() {
|
||||
log::error!("Failed to send message");
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends a [`InputMessage`] to the mixnet. This is the most low-level sending function, for
|
||||
/// full customization.
|
||||
///
|
||||
/// Waits until the message is actually sent, or close to being sent, until returning.
|
||||
///
|
||||
/// NOTE: this not yet implemented.
|
||||
#[allow(unused)]
|
||||
async fn send_wait(&self, _message: InputMessage) {
|
||||
todo!();
|
||||
}
|
||||
|
||||
/// Wait for messages from the mixnet
|
||||
pub async fn wait_for_messages(&mut self) -> Option<Vec<ReconstructedMessage>> {
|
||||
self.reconstructed_receiver.next().await
|
||||
@@ -265,14 +141,7 @@ impl MixnetClient {
|
||||
|
||||
pub struct MixnetClientSender {
|
||||
client_input: ClientInput,
|
||||
}
|
||||
|
||||
impl MixnetClientSender {
|
||||
pub async fn send_input_message(&mut self, message: InputMessage) {
|
||||
if self.client_input.send(message).await.is_err() {
|
||||
log::error!("Failed to send message");
|
||||
}
|
||||
}
|
||||
packet_type: Option<PacketType>,
|
||||
}
|
||||
|
||||
impl Stream for MixnetClient {
|
||||
@@ -282,3 +151,31 @@ impl Stream for MixnetClient {
|
||||
Pin::new(&mut self.reconstructed_receiver).poll_next(cx)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MixnetMessageSender for MixnetClient {
|
||||
fn packet_type(&self) -> Option<PacketType> {
|
||||
self.packet_type
|
||||
}
|
||||
|
||||
async fn send(&self, message: InputMessage) -> Result<()> {
|
||||
self.client_input
|
||||
.send(message)
|
||||
.await
|
||||
.map_err(|_| Error::MessageSendingFailure)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MixnetMessageSender for MixnetClientSender {
|
||||
fn packet_type(&self) -> Option<PacketType> {
|
||||
self.packet_type
|
||||
}
|
||||
|
||||
async fn send(&self, message: InputMessage) -> Result<()> {
|
||||
self.client_input
|
||||
.send(message)
|
||||
.await
|
||||
.map_err(|_| Error::MessageSendingFailure)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::mixnet::{AnonymousSenderTag, IncludedSurbs, Recipient};
|
||||
use crate::Result;
|
||||
use async_trait::async_trait;
|
||||
use nym_client_core::client::inbound_messages::InputMessage;
|
||||
use nym_sphinx::params::PacketType;
|
||||
use nym_task::connections::TransmissionLane;
|
||||
|
||||
// defined to guarantee common interface regardless of whether you're using the full client
|
||||
// or just the sending handler
|
||||
#[async_trait]
|
||||
pub trait MixnetMessageSender {
|
||||
fn packet_type(&self) -> Option<PacketType> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Sends a [`InputMessage`] to the mixnet. This is the most low-level sending function, for
|
||||
/// full customization.
|
||||
async fn send(&self, message: InputMessage) -> Result<()>;
|
||||
|
||||
/// Sends data to the supplied Nym address with the default surb behaviour.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet::{self, MixnetMessageSender};
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let address = "foobar";
|
||||
/// let recipient = mixnet::Recipient::try_from_base58_string(address).unwrap();
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// client.send_plain_message(recipient, "hi").await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
async fn send_plain_message<M>(&self, address: Recipient, message: M) -> Result<()>
|
||||
where
|
||||
M: AsRef<[u8]> + Send,
|
||||
{
|
||||
self.send_message(address, message, IncludedSurbs::default())
|
||||
.await
|
||||
}
|
||||
|
||||
/// Sends bytes to the supplied Nym address. There is the option to specify the number of
|
||||
/// reply-SURBs to include.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet::{self, MixnetMessageSender};
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let address = "foobar";
|
||||
/// let recipient = mixnet::Recipient::try_from_base58_string(address).unwrap();
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// let surbs = mixnet::IncludedSurbs::default();
|
||||
/// client.send_message(recipient, "hi".to_owned().into_bytes(), surbs).await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
async fn send_message<M>(
|
||||
&self,
|
||||
address: Recipient,
|
||||
message: M,
|
||||
surbs: IncludedSurbs,
|
||||
) -> Result<()>
|
||||
where
|
||||
M: AsRef<[u8]> + Send,
|
||||
{
|
||||
let lane = TransmissionLane::General;
|
||||
let input_msg = match surbs {
|
||||
IncludedSurbs::Amount(surbs) => InputMessage::new_anonymous(
|
||||
address,
|
||||
message.as_ref().to_vec(),
|
||||
surbs,
|
||||
lane,
|
||||
self.packet_type(),
|
||||
),
|
||||
IncludedSurbs::ExposeSelfAddress => InputMessage::new_regular(
|
||||
address,
|
||||
message.as_ref().to_vec(),
|
||||
lane,
|
||||
self.packet_type(),
|
||||
),
|
||||
};
|
||||
self.send(input_msg).await
|
||||
}
|
||||
|
||||
/// Sends reply data to the supplied anonymous recipient.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use nym_sdk::mixnet::{self, MixnetMessageSender};
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// let mut client = mixnet::MixnetClient::connect_new().await.unwrap();
|
||||
/// // note: the tag is something you would have received from a remote client sending you surbs!
|
||||
/// let tag = mixnet::AnonymousSenderTag::try_from_base58_string("foobar").unwrap();
|
||||
/// client.send_reply(tag, b"hi").await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
async fn send_reply<M>(&self, recipient_tag: AnonymousSenderTag, message: M) -> Result<()>
|
||||
where
|
||||
M: AsRef<[u8]> + Send,
|
||||
{
|
||||
let lane = TransmissionLane::General;
|
||||
let input_msg = InputMessage::new_reply(
|
||||
recipient_tag,
|
||||
message.as_ref().to_vec(),
|
||||
lane,
|
||||
self.packet_type(),
|
||||
);
|
||||
self.send(input_msg).await
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
// use nym_client::client::config::{BaseClientConfig, Config, GatewayEndpointConfig};
|
||||
// use nym_client::client::{DirectClient, KeyManager, Recipient, ReconstructedMessage, SocketClient};
|
||||
use nym_sdk::mixnet::{IncludedSurbs, MixnetClient, Recipient, ReconstructedMessage};
|
||||
use nym_sdk::mixnet::{
|
||||
IncludedSurbs, MixnetClient, MixnetMessageSender, Recipient, ReconstructedMessage,
|
||||
};
|
||||
use nym_service_providers_common::interface::{
|
||||
ControlRequest, ControlResponse, ProviderInterfaceVersion, Request, Response, ResponseContent,
|
||||
};
|
||||
@@ -51,34 +53,34 @@ async fn main() -> anyhow::Result<()> {
|
||||
// TODO: currently we HAVE TO use surbs unfortunately
|
||||
println!("Sending 'Health' request...");
|
||||
client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
provider,
|
||||
full_request_health.into_bytes(),
|
||||
IncludedSurbs::new(10),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
let response = wait_for_control_response(&mut client).await;
|
||||
println!("response to 'Health' request: {response:#?}");
|
||||
|
||||
println!("Sending 'BinaryInfo' request...");
|
||||
client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
provider,
|
||||
full_request_binary_info.into_bytes(),
|
||||
IncludedSurbs::none(),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
let response = wait_for_control_response(&mut client).await;
|
||||
println!("response to 'BinaryInfo' request: {response:#?}");
|
||||
|
||||
println!("Sending 'SupportedRequestVersions' request...");
|
||||
client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
provider,
|
||||
full_request_versions.into_bytes(),
|
||||
IncludedSurbs::none(),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
let response = wait_for_control_response(&mut client).await;
|
||||
println!("response to 'SupportedRequestVersions' request: {response:#?}");
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use nym_sdk::mixnet::{IncludedSurbs, MixnetClient, Recipient, ReconstructedMessage};
|
||||
use nym_sdk::mixnet::{
|
||||
IncludedSurbs, MixnetClient, MixnetMessageSender, Recipient, ReconstructedMessage,
|
||||
};
|
||||
use nym_service_providers_common::interface::{
|
||||
ProviderInterfaceVersion, Request, Response, ResponseContent,
|
||||
};
|
||||
@@ -47,23 +49,23 @@ async fn main() -> anyhow::Result<()> {
|
||||
);
|
||||
println!("Sending 'OpenProxy' query...");
|
||||
client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
provider,
|
||||
open_proxy_request.into_bytes(),
|
||||
IncludedSurbs::new(10),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
let response = wait_for_response(&mut client).await;
|
||||
println!("response to 'OpenProxy' query: {response:#?}");
|
||||
|
||||
println!("Sending 'Description' query...");
|
||||
client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
provider,
|
||||
description_request.into_bytes(),
|
||||
IncludedSurbs::none(),
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
let response = wait_for_response(&mut client).await;
|
||||
println!("response to 'Description' query: {response:#?}");
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ use log::warn;
|
||||
use nym_bin_common::bin_info_owned;
|
||||
use nym_client_core::config::disk_persistence::CommonClientPaths;
|
||||
use nym_network_defaults::NymNetworkDetails;
|
||||
use nym_sdk::mixnet::MixnetMessageSender;
|
||||
use nym_service_providers_common::interface::{
|
||||
BinaryInformation, ProviderInterfaceVersion, Request, RequestVersion,
|
||||
};
|
||||
@@ -223,7 +224,7 @@ impl NRServiceProviderBuilder {
|
||||
};
|
||||
|
||||
let stats_collector_clone = stats_collector.clone();
|
||||
let mixnet_client_sender = mixnet_client.sender();
|
||||
let mixnet_client_sender = mixnet_client.split_sender();
|
||||
let self_address = *mixnet_client.nym_address();
|
||||
|
||||
// start the listener for mix messages
|
||||
@@ -297,7 +298,7 @@ impl NRServiceProvider {
|
||||
/// Listens for any messages from `mix_reader` that should be written back to the mix network
|
||||
/// via the `websocket_writer`.
|
||||
async fn mixnet_response_listener(
|
||||
mut mixnet_client_sender: nym_sdk::mixnet::MixnetClientSender,
|
||||
mixnet_client_sender: nym_sdk::mixnet::MixnetClientSender,
|
||||
mut mix_input_reader: MixProxyReader<MixnetMessage>,
|
||||
stats_collector: Option<ServiceStatisticsCollector>,
|
||||
) {
|
||||
@@ -321,7 +322,7 @@ impl NRServiceProvider {
|
||||
}
|
||||
|
||||
let response_message = msg.into_input_message();
|
||||
mixnet_client_sender.send_input_message(response_message).await;
|
||||
mixnet_client_sender.send(response_message).await.unwrap();
|
||||
} else {
|
||||
log::error!("Exiting: channel closed!");
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::fmt;
|
||||
|
||||
use clap::{Parser, ValueEnum};
|
||||
use nym_bin_common::output_format::OutputFormat;
|
||||
use nym_sdk::mixnet::{self, IncludedSurbs};
|
||||
use nym_sdk::mixnet::{self, IncludedSurbs, MixnetMessageSender};
|
||||
use nym_service_providers_common::interface::{
|
||||
ControlRequest, ControlResponse, ProviderInterfaceVersion, Request, Response, ResponseContent,
|
||||
};
|
||||
@@ -154,34 +154,37 @@ impl QueryClient {
|
||||
|
||||
async fn query_bin_info(&mut self) -> ControlResponse {
|
||||
self.client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
self.provider,
|
||||
new_bin_info_request().into_bytes(),
|
||||
IncludedSurbs::new(10),
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for_control_response(&mut self.client).await
|
||||
}
|
||||
|
||||
async fn query_supported_versions(&mut self) -> ControlResponse {
|
||||
self.client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
self.provider,
|
||||
new_supported_request_versions_request().into_bytes(),
|
||||
IncludedSurbs::new(10),
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for_control_response(&mut self.client).await
|
||||
}
|
||||
|
||||
async fn query_open_proxy(&mut self) -> QueryResponse {
|
||||
self.client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
self.provider,
|
||||
new_open_proxy_request().into_bytes(),
|
||||
IncludedSurbs::new(10),
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
let response = wait_for_socks5_response(&mut self.client).await;
|
||||
response
|
||||
.content
|
||||
@@ -193,12 +196,13 @@ impl QueryClient {
|
||||
async fn ping(&mut self) -> PingResponse {
|
||||
let now = std::time::Instant::now();
|
||||
self.client
|
||||
.send_bytes(
|
||||
.send_message(
|
||||
self.provider,
|
||||
new_ping_request().into_bytes(),
|
||||
IncludedSurbs::new(5),
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
let response = wait_for_control_response(&mut self.client).await;
|
||||
assert!(matches!(response, ControlResponse::Health));
|
||||
let elapsed = now.elapsed();
|
||||
|
||||
Reference in New Issue
Block a user