upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-04-18 07:39:27 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-06-11 12:33:09 +0100
commit7c6a5ab4c5e7a81c7442061029b9230748a6639d (patch)
treeaea6567080857b629c826c7921314a6ce323a6db
parent3b4f0b0eee124133b641d6770704c368712f3dff (diff)
refactor: bump rust-nostr to v0.30 use ncryptsec
bump nostr and nostr-sdk packages and also in test_utils remove custom ncryptsec implementation and use the newly added implementation nip49 version in rust-nostr note a patched v0.30 is used so that log_n is exposed so that user can be warned it might take a few seconds to decrypt. this has now been merged into the library. note that this will no longer decrypt existing ncryptsec values as it is uses a longer string. this should therefore be bundled with the upcoming change to storing nsec and ncryptsec in git config.
-rw-r--r--Cargo.lock348
-rw-r--r--Cargo.toml4
-rw-r--r--src/key_handling/encryption.rs155
-rw-r--r--test_utils/Cargo.toml4
-rw-r--r--test_utils/src/lib.rs10
-rw-r--r--tests/login.rs2
6 files changed, 172 insertions, 351 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6b09b9e..51ef7a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -330,20 +330,20 @@ dependencies = [
330 330
331[[package]] 331[[package]]
332name = "async-wsocket" 332name = "async-wsocket"
333version = "0.3.0" 333version = "0.4.0"
334source = "registry+https://github.com/rust-lang/crates.io-index" 334source = "registry+https://github.com/rust-lang/crates.io-index"
335checksum = "d253e375ea899cb131b92a474587e217634e7ea927c24d8098eecbcad0c5c97a" 335checksum = "5c38341e6ee670913fb9dc3aba40c22d616261da4dc0928326d3168ebf576fb0"
336dependencies = [ 336dependencies = [
337 "async-utility", 337 "async-utility",
338 "futures-util", 338 "futures-util",
339 "thiserror", 339 "thiserror",
340 "tokio", 340 "tokio",
341 "tokio-rustls 0.25.0", 341 "tokio-rustls",
342 "tokio-socks", 342 "tokio-socks",
343 "tokio-tungstenite 0.21.0", 343 "tokio-tungstenite 0.21.0",
344 "url", 344 "url",
345 "wasm-ws", 345 "wasm-ws",
346 "webpki-roots 0.26.1", 346 "webpki-roots",
347] 347]
348 348
349[[package]] 349[[package]]
@@ -400,6 +400,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
400checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" 400checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
401 401
402[[package]] 402[[package]]
403name = "base64"
404version = "0.22.0"
405source = "registry+https://github.com/rust-lang/crates.io-index"
406checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
407
408[[package]]
403name = "base64ct" 409name = "base64ct"
404version = "1.6.0" 410version = "1.6.0"
405source = "registry+https://github.com/rust-lang/crates.io-index" 411source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -407,9 +413,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
407 413
408[[package]] 414[[package]]
409name = "bech32" 415name = "bech32"
410version = "0.9.1" 416version = "0.10.0-beta"
411source = "registry+https://github.com/rust-lang/crates.io-index" 417source = "registry+https://github.com/rust-lang/crates.io-index"
412checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" 418checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea"
413 419
414[[package]] 420[[package]]
415name = "bip39" 421name = "bip39"
@@ -424,23 +430,27 @@ dependencies = [
424 430
425[[package]] 431[[package]]
426name = "bitcoin" 432name = "bitcoin"
427version = "0.30.2" 433version = "0.31.2"
428source = "registry+https://github.com/rust-lang/crates.io-index" 434source = "registry+https://github.com/rust-lang/crates.io-index"
429checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" 435checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae"
430dependencies = [ 436dependencies = [
431 "bech32", 437 "bech32",
432 "bitcoin-private", 438 "bitcoin-internals",
433 "bitcoin_hashes 0.12.0", 439 "bitcoin_hashes 0.13.0",
440 "hex-conservative",
434 "hex_lit", 441 "hex_lit",
435 "secp256k1", 442 "secp256k1",
436 "serde", 443 "serde",
437] 444]
438 445
439[[package]] 446[[package]]
440name = "bitcoin-private" 447name = "bitcoin-internals"
441version = "0.1.0" 448version = "0.2.0"
442source = "registry+https://github.com/rust-lang/crates.io-index" 449source = "registry+https://github.com/rust-lang/crates.io-index"
443checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" 450checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb"
451dependencies = [
452 "serde",
453]
444 454
445[[package]] 455[[package]]
446name = "bitcoin_hashes" 456name = "bitcoin_hashes"
@@ -450,11 +460,12 @@ checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4"
450 460
451[[package]] 461[[package]]
452name = "bitcoin_hashes" 462name = "bitcoin_hashes"
453version = "0.12.0" 463version = "0.13.0"
454source = "registry+https://github.com/rust-lang/crates.io-index" 464source = "registry+https://github.com/rust-lang/crates.io-index"
455checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" 465checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
456dependencies = [ 466dependencies = [
457 "bitcoin-private", 467 "bitcoin-internals",
468 "hex-conservative",
458 "serde", 469 "serde",
459] 470]
460 471
@@ -849,15 +860,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
849checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 860checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
850 861
851[[package]] 862[[package]]
852name = "encoding_rs"
853version = "0.8.34"
854source = "registry+https://github.com/rust-lang/crates.io-index"
855checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
856dependencies = [
857 "cfg-if",
858]
859
860[[package]]
861name = "enumflags2" 863name = "enumflags2"
862version = "0.7.9" 864version = "0.7.9"
863source = "registry+https://github.com/rust-lang/crates.io-index" 865source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1185,25 +1187,6 @@ dependencies = [
1185] 1187]
1186 1188
1187[[package]] 1189[[package]]
1188name = "h2"
1189version = "0.3.26"
1190source = "registry+https://github.com/rust-lang/crates.io-index"
1191checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
1192dependencies = [
1193 "bytes",
1194 "fnv",
1195 "futures-core",
1196 "futures-sink",
1197 "futures-util",
1198 "http 0.2.12",
1199 "indexmap",
1200 "slab",
1201 "tokio",
1202 "tokio-util",
1203 "tracing",
1204]
1205
1206[[package]]
1207name = "hashbrown" 1190name = "hashbrown"
1208version = "0.14.3" 1191version = "0.14.3"
1209source = "registry+https://github.com/rust-lang/crates.io-index" 1192source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1238,6 +1221,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1238checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 1221checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
1239 1222
1240[[package]] 1223[[package]]
1224name = "hex-conservative"
1225version = "0.1.1"
1226source = "registry+https://github.com/rust-lang/crates.io-index"
1227checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2"
1228
1229[[package]]
1241name = "hex_lit" 1230name = "hex_lit"
1242version = "0.1.1" 1231version = "0.1.1"
1243source = "registry+https://github.com/rust-lang/crates.io-index" 1232source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1285,12 +1274,24 @@ dependencies = [
1285 1274
1286[[package]] 1275[[package]]
1287name = "http-body" 1276name = "http-body"
1288version = "0.4.6" 1277version = "1.0.0"
1289source = "registry+https://github.com/rust-lang/crates.io-index" 1278source = "registry+https://github.com/rust-lang/crates.io-index"
1290checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" 1279checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
1291dependencies = [ 1280dependencies = [
1292 "bytes", 1281 "bytes",
1293 "http 0.2.12", 1282 "http 1.1.0",
1283]
1284
1285[[package]]
1286name = "http-body-util"
1287version = "0.1.1"
1288source = "registry+https://github.com/rust-lang/crates.io-index"
1289checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
1290dependencies = [
1291 "bytes",
1292 "futures-core",
1293 "http 1.1.0",
1294 "http-body",
1294 "pin-project-lite", 1295 "pin-project-lite",
1295] 1296]
1296 1297
@@ -1301,47 +1302,59 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1301checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 1302checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
1302 1303
1303[[package]] 1304[[package]]
1304name = "httpdate"
1305version = "1.0.3"
1306source = "registry+https://github.com/rust-lang/crates.io-index"
1307checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
1308
1309[[package]]
1310name = "hyper" 1305name = "hyper"
1311version = "0.14.28" 1306version = "1.3.0"
1312source = "registry+https://github.com/rust-lang/crates.io-index" 1307source = "registry+https://github.com/rust-lang/crates.io-index"
1313checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" 1308checksum = "9f24ce812868d86d19daa79bf3bf9175bc44ea323391147a5e3abde2a283871b"
1314dependencies = [ 1309dependencies = [
1315 "bytes", 1310 "bytes",
1316 "futures-channel", 1311 "futures-channel",
1317 "futures-core",
1318 "futures-util", 1312 "futures-util",
1319 "h2", 1313 "http 1.1.0",
1320 "http 0.2.12",
1321 "http-body", 1314 "http-body",
1322 "httparse", 1315 "httparse",
1323 "httpdate",
1324 "itoa", 1316 "itoa",
1325 "pin-project-lite", 1317 "pin-project-lite",
1326 "socket2 0.5.6", 1318 "smallvec",
1327 "tokio", 1319 "tokio",
1328 "tower-service",
1329 "tracing",
1330 "want", 1320 "want",
1331] 1321]
1332 1322
1333[[package]] 1323[[package]]
1334name = "hyper-rustls" 1324name = "hyper-rustls"
1335version = "0.24.2" 1325version = "0.26.0"
1336source = "registry+https://github.com/rust-lang/crates.io-index" 1326source = "registry+https://github.com/rust-lang/crates.io-index"
1337checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" 1327checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c"
1338dependencies = [ 1328dependencies = [
1339 "futures-util", 1329 "futures-util",
1340 "http 0.2.12", 1330 "http 1.1.0",
1341 "hyper", 1331 "hyper",
1342 "rustls 0.21.10", 1332 "hyper-util",
1333 "rustls",
1334 "rustls-pki-types",
1343 "tokio", 1335 "tokio",
1344 "tokio-rustls 0.24.1", 1336 "tokio-rustls",
1337 "tower-service",
1338]
1339
1340[[package]]
1341name = "hyper-util"
1342version = "0.1.3"
1343source = "registry+https://github.com/rust-lang/crates.io-index"
1344checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
1345dependencies = [
1346 "bytes",
1347 "futures-channel",
1348 "futures-util",
1349 "http 1.1.0",
1350 "http-body",
1351 "hyper",
1352 "pin-project-lite",
1353 "socket2 0.5.6",
1354 "tokio",
1355 "tower",
1356 "tower-service",
1357 "tracing",
1345] 1358]
1346 1359
1347[[package]] 1360[[package]]
@@ -1549,9 +1562,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
1549 1562
1550[[package]] 1563[[package]]
1551name = "lnurl-pay" 1564name = "lnurl-pay"
1552version = "0.3.0" 1565version = "0.5.0"
1553source = "registry+https://github.com/rust-lang/crates.io-index" 1566source = "registry+https://github.com/rust-lang/crates.io-index"
1554checksum = "b628658116d331c9567f6cb22415d726125ff6e328d1fb1b422b1b58afeaec21" 1567checksum = "02c042191c2e3f27147decfad8182eea2c7dd1c6c1733562e25d3d401369669d"
1555dependencies = [ 1568dependencies = [
1556 "bech32", 1569 "bech32",
1557 "reqwest", 1570 "reqwest",
@@ -1763,12 +1776,11 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
1763 1776
1764[[package]] 1777[[package]]
1765name = "nostr" 1778name = "nostr"
1766version = "0.29.1" 1779version = "0.30.0"
1767source = "registry+https://github.com/rust-lang/crates.io-index" 1780source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1768checksum = "25e4e34578e8cc2b4050c6224a0c422b23ba1e61f2602b4e320c221ac3cbbc2e"
1769dependencies = [ 1781dependencies = [
1770 "aes 0.8.4", 1782 "aes 0.8.4",
1771 "base64", 1783 "base64 0.21.7",
1772 "bip39", 1784 "bip39",
1773 "bitcoin", 1785 "bitcoin",
1774 "cbc", 1786 "cbc",
@@ -1793,9 +1805,8 @@ dependencies = [
1793 1805
1794[[package]] 1806[[package]]
1795name = "nostr-database" 1807name = "nostr-database"
1796version = "0.29.0" 1808version = "0.30.0"
1797source = "registry+https://github.com/rust-lang/crates.io-index" 1809source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1798checksum = "8e15ab55f96ea5e560af0c75f1d942b1064266d443d11b2afbe51ca9ad78a018"
1799dependencies = [ 1810dependencies = [
1800 "async-trait", 1811 "async-trait",
1801 "lru", 1812 "lru",
@@ -1807,9 +1818,8 @@ dependencies = [
1807 1818
1808[[package]] 1819[[package]]
1809name = "nostr-relay-pool" 1820name = "nostr-relay-pool"
1810version = "0.29.4" 1821version = "0.30.0"
1811source = "registry+https://github.com/rust-lang/crates.io-index" 1822source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1812checksum = "e8efc437bcf8c433887a9897dfb6f99914170f656a2a66398e737b3050c2aa34"
1813dependencies = [ 1823dependencies = [
1814 "async-utility", 1824 "async-utility",
1815 "async-wsocket", 1825 "async-wsocket",
@@ -1823,9 +1833,8 @@ dependencies = [
1823 1833
1824[[package]] 1834[[package]]
1825name = "nostr-sdk" 1835name = "nostr-sdk"
1826version = "0.29.0" 1836version = "0.30.0"
1827source = "registry+https://github.com/rust-lang/crates.io-index" 1837source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1828checksum = "81ed0ab9cbc3b20d3dba99337f2e0739f052ebe32133d690e212022a06a22044"
1829dependencies = [ 1838dependencies = [
1830 "async-utility", 1839 "async-utility",
1831 "lnurl-pay", 1840 "lnurl-pay",
@@ -1842,22 +1851,21 @@ dependencies = [
1842 1851
1843[[package]] 1852[[package]]
1844name = "nostr-signer" 1853name = "nostr-signer"
1845version = "0.29.0" 1854version = "0.30.0"
1846source = "registry+https://github.com/rust-lang/crates.io-index" 1855source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1847checksum = "307bdc7c26887d7e65632e66872989a19892dfe9f2c6dbd9a1d3f959c5c524d5"
1848dependencies = [ 1856dependencies = [
1849 "async-utility", 1857 "async-utility",
1850 "nostr", 1858 "nostr",
1851 "nostr-relay-pool", 1859 "nostr-relay-pool",
1852 "thiserror", 1860 "thiserror",
1853 "tokio", 1861 "tokio",
1862 "tracing",
1854] 1863]
1855 1864
1856[[package]] 1865[[package]]
1857name = "nostr-zapper" 1866name = "nostr-zapper"
1858version = "0.29.0" 1867version = "0.30.0"
1859source = "registry+https://github.com/rust-lang/crates.io-index" 1868source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1860checksum = "061d5eb00b430747a984ea9e41cd82c849832151b4263d8230c9c220dc2c62f8"
1861dependencies = [ 1869dependencies = [
1862 "async-trait", 1870 "async-trait",
1863 "nostr", 1871 "nostr",
@@ -1957,9 +1965,8 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
1957 1965
1958[[package]] 1966[[package]]
1959name = "nwc" 1967name = "nwc"
1960version = "0.29.0" 1968version = "0.30.0"
1961source = "registry+https://github.com/rust-lang/crates.io-index" 1969source = "git+https://github.com/DanConwayDev/nostr?branch=expose-nip49-log-n#6ef397b6c4cd5edd6e6c31ff33d8a978b5b04f8c"
1962checksum = "d1894ffe54a1e5adf8dbb22b5a290c0748ec4a88aa07fa69c4359010edea49ed"
1963dependencies = [ 1970dependencies = [
1964 "async-utility", 1971 "async-utility",
1965 "nostr", 1972 "nostr",
@@ -2413,20 +2420,20 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
2413 2420
2414[[package]] 2421[[package]]
2415name = "reqwest" 2422name = "reqwest"
2416version = "0.11.27" 2423version = "0.12.3"
2417source = "registry+https://github.com/rust-lang/crates.io-index" 2424source = "registry+https://github.com/rust-lang/crates.io-index"
2418checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" 2425checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19"
2419dependencies = [ 2426dependencies = [
2420 "base64", 2427 "base64 0.22.0",
2421 "bytes", 2428 "bytes",
2422 "encoding_rs",
2423 "futures-core", 2429 "futures-core",
2424 "futures-util", 2430 "futures-util",
2425 "h2", 2431 "http 1.1.0",
2426 "http 0.2.12",
2427 "http-body", 2432 "http-body",
2433 "http-body-util",
2428 "hyper", 2434 "hyper",
2429 "hyper-rustls", 2435 "hyper-rustls",
2436 "hyper-util",
2430 "ipnet", 2437 "ipnet",
2431 "js-sys", 2438 "js-sys",
2432 "log", 2439 "log",
@@ -2434,22 +2441,22 @@ dependencies = [
2434 "once_cell", 2441 "once_cell",
2435 "percent-encoding", 2442 "percent-encoding",
2436 "pin-project-lite", 2443 "pin-project-lite",
2437 "rustls 0.21.10", 2444 "rustls",
2438 "rustls-pemfile", 2445 "rustls-pemfile",
2446 "rustls-pki-types",
2439 "serde", 2447 "serde",
2440 "serde_json", 2448 "serde_json",
2441 "serde_urlencoded", 2449 "serde_urlencoded",
2442 "sync_wrapper", 2450 "sync_wrapper",
2443 "system-configuration",
2444 "tokio", 2451 "tokio",
2445 "tokio-rustls 0.24.1", 2452 "tokio-rustls",
2446 "tokio-socks", 2453 "tokio-socks",
2447 "tower-service", 2454 "tower-service",
2448 "url", 2455 "url",
2449 "wasm-bindgen", 2456 "wasm-bindgen",
2450 "wasm-bindgen-futures", 2457 "wasm-bindgen-futures",
2451 "web-sys", 2458 "web-sys",
2452 "webpki-roots 0.25.4", 2459 "webpki-roots",
2453 "winreg", 2460 "winreg",
2454] 2461]
2455 2462
@@ -2537,18 +2544,6 @@ dependencies = [
2537 2544
2538[[package]] 2545[[package]]
2539name = "rustls" 2546name = "rustls"
2540version = "0.21.10"
2541source = "registry+https://github.com/rust-lang/crates.io-index"
2542checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
2543dependencies = [
2544 "log",
2545 "ring",
2546 "rustls-webpki 0.101.7",
2547 "sct",
2548]
2549
2550[[package]]
2551name = "rustls"
2552version = "0.22.3" 2547version = "0.22.3"
2553source = "registry+https://github.com/rust-lang/crates.io-index" 2548source = "registry+https://github.com/rust-lang/crates.io-index"
2554checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" 2549checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c"
@@ -2556,18 +2551,19 @@ dependencies = [
2556 "log", 2551 "log",
2557 "ring", 2552 "ring",
2558 "rustls-pki-types", 2553 "rustls-pki-types",
2559 "rustls-webpki 0.102.2", 2554 "rustls-webpki",
2560 "subtle", 2555 "subtle",
2561 "zeroize", 2556 "zeroize",
2562] 2557]
2563 2558
2564[[package]] 2559[[package]]
2565name = "rustls-pemfile" 2560name = "rustls-pemfile"
2566version = "1.0.4" 2561version = "2.1.2"
2567source = "registry+https://github.com/rust-lang/crates.io-index" 2562source = "registry+https://github.com/rust-lang/crates.io-index"
2568checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" 2563checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
2569dependencies = [ 2564dependencies = [
2570 "base64", 2565 "base64 0.22.0",
2566 "rustls-pki-types",
2571] 2567]
2572 2568
2573[[package]] 2569[[package]]
@@ -2578,16 +2574,6 @@ checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247"
2578 2574
2579[[package]] 2575[[package]]
2580name = "rustls-webpki" 2576name = "rustls-webpki"
2581version = "0.101.7"
2582source = "registry+https://github.com/rust-lang/crates.io-index"
2583checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
2584dependencies = [
2585 "ring",
2586 "untrusted",
2587]
2588
2589[[package]]
2590name = "rustls-webpki"
2591version = "0.102.2" 2577version = "0.102.2"
2592source = "registry+https://github.com/rust-lang/crates.io-index" 2578source = "registry+https://github.com/rust-lang/crates.io-index"
2593checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" 2579checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610"
@@ -2631,22 +2617,12 @@ dependencies = [
2631] 2617]
2632 2618
2633[[package]] 2619[[package]]
2634name = "sct"
2635version = "0.7.1"
2636source = "registry+https://github.com/rust-lang/crates.io-index"
2637checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
2638dependencies = [
2639 "ring",
2640 "untrusted",
2641]
2642
2643[[package]]
2644name = "secp256k1" 2620name = "secp256k1"
2645version = "0.27.0" 2621version = "0.28.2"
2646source = "registry+https://github.com/rust-lang/crates.io-index" 2622source = "registry+https://github.com/rust-lang/crates.io-index"
2647checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" 2623checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10"
2648dependencies = [ 2624dependencies = [
2649 "bitcoin_hashes 0.12.0", 2625 "bitcoin_hashes 0.13.0",
2650 "rand", 2626 "rand",
2651 "secp256k1-sys", 2627 "secp256k1-sys",
2652 "serde", 2628 "serde",
@@ -2654,9 +2630,9 @@ dependencies = [
2654 2630
2655[[package]] 2631[[package]]
2656name = "secp256k1-sys" 2632name = "secp256k1-sys"
2657version = "0.8.1" 2633version = "0.9.2"
2658source = "registry+https://github.com/rust-lang/crates.io-index" 2634source = "registry+https://github.com/rust-lang/crates.io-index"
2659checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" 2635checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb"
2660dependencies = [ 2636dependencies = [
2661 "cc", 2637 "cc",
2662] 2638]
@@ -2956,27 +2932,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2956checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" 2932checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
2957 2933
2958[[package]] 2934[[package]]
2959name = "system-configuration"
2960version = "0.5.1"
2961source = "registry+https://github.com/rust-lang/crates.io-index"
2962checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
2963dependencies = [
2964 "bitflags 1.3.2",
2965 "core-foundation",
2966 "system-configuration-sys",
2967]
2968
2969[[package]]
2970name = "system-configuration-sys"
2971version = "0.5.0"
2972source = "registry+https://github.com/rust-lang/crates.io-index"
2973checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
2974dependencies = [
2975 "core-foundation-sys",
2976 "libc",
2977]
2978
2979[[package]]
2980name = "tempfile" 2935name = "tempfile"
2981version = "3.10.1" 2936version = "3.10.1"
2982source = "registry+https://github.com/rust-lang/crates.io-index" 2937source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3080,21 +3035,11 @@ dependencies = [
3080 3035
3081[[package]] 3036[[package]]
3082name = "tokio-rustls" 3037name = "tokio-rustls"
3083version = "0.24.1"
3084source = "registry+https://github.com/rust-lang/crates.io-index"
3085checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
3086dependencies = [
3087 "rustls 0.21.10",
3088 "tokio",
3089]
3090
3091[[package]]
3092name = "tokio-rustls"
3093version = "0.25.0" 3038version = "0.25.0"
3094source = "registry+https://github.com/rust-lang/crates.io-index" 3039source = "registry+https://github.com/rust-lang/crates.io-index"
3095checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" 3040checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
3096dependencies = [ 3041dependencies = [
3097 "rustls 0.22.3", 3042 "rustls",
3098 "rustls-pki-types", 3043 "rustls-pki-types",
3099 "tokio", 3044 "tokio",
3100] 3045]
@@ -3131,26 +3076,12 @@ checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
3131dependencies = [ 3076dependencies = [
3132 "futures-util", 3077 "futures-util",
3133 "log", 3078 "log",
3134 "rustls 0.22.3", 3079 "rustls",
3135 "rustls-pki-types", 3080 "rustls-pki-types",
3136 "tokio", 3081 "tokio",
3137 "tokio-rustls 0.25.0", 3082 "tokio-rustls",
3138 "tungstenite 0.21.0", 3083 "tungstenite 0.21.0",
3139 "webpki-roots 0.26.1", 3084 "webpki-roots",
3140]
3141
3142[[package]]
3143name = "tokio-util"
3144version = "0.7.10"
3145source = "registry+https://github.com/rust-lang/crates.io-index"
3146checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
3147dependencies = [
3148 "bytes",
3149 "futures-core",
3150 "futures-sink",
3151 "pin-project-lite",
3152 "tokio",
3153 "tracing",
3154] 3085]
3155 3086
3156[[package]] 3087[[package]]
@@ -3171,6 +3102,28 @@ dependencies = [
3171] 3102]
3172 3103
3173[[package]] 3104[[package]]
3105name = "tower"
3106version = "0.4.13"
3107source = "registry+https://github.com/rust-lang/crates.io-index"
3108checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
3109dependencies = [
3110 "futures-core",
3111 "futures-util",
3112 "pin-project",
3113 "pin-project-lite",
3114 "tokio",
3115 "tower-layer",
3116 "tower-service",
3117 "tracing",
3118]
3119
3120[[package]]
3121name = "tower-layer"
3122version = "0.3.2"
3123source = "registry+https://github.com/rust-lang/crates.io-index"
3124checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
3125
3126[[package]]
3174name = "tower-service" 3127name = "tower-service"
3175version = "0.3.2" 3128version = "0.3.2"
3176source = "registry+https://github.com/rust-lang/crates.io-index" 3129source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3182,6 +3135,7 @@ version = "0.1.40"
3182source = "registry+https://github.com/rust-lang/crates.io-index" 3135source = "registry+https://github.com/rust-lang/crates.io-index"
3183checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" 3136checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
3184dependencies = [ 3137dependencies = [
3138 "log",
3185 "pin-project-lite", 3139 "pin-project-lite",
3186 "tracing-attributes", 3140 "tracing-attributes",
3187 "tracing-core", 3141 "tracing-core",
@@ -3245,7 +3199,7 @@ dependencies = [
3245 "httparse", 3199 "httparse",
3246 "log", 3200 "log",
3247 "rand", 3201 "rand",
3248 "rustls 0.22.3", 3202 "rustls",
3249 "rustls-pki-types", 3203 "rustls-pki-types",
3250 "sha1", 3204 "sha1",
3251 "thiserror", 3205 "thiserror",
@@ -3500,12 +3454,6 @@ dependencies = [
3500 3454
3501[[package]] 3455[[package]]
3502name = "webpki-roots" 3456name = "webpki-roots"
3503version = "0.25.4"
3504source = "registry+https://github.com/rust-lang/crates.io-index"
3505checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
3506
3507[[package]]
3508name = "webpki-roots"
3509version = "0.26.1" 3457version = "0.26.1"
3510source = "registry+https://github.com/rust-lang/crates.io-index" 3458source = "registry+https://github.com/rust-lang/crates.io-index"
3511checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" 3459checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009"
@@ -3685,9 +3633,9 @@ dependencies = [
3685 3633
3686[[package]] 3634[[package]]
3687name = "winreg" 3635name = "winreg"
3688version = "0.50.0" 3636version = "0.52.0"
3689source = "registry+https://github.com/rust-lang/crates.io-index" 3637source = "registry+https://github.com/rust-lang/crates.io-index"
3690checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" 3638checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
3691dependencies = [ 3639dependencies = [
3692 "cfg-if", 3640 "cfg-if",
3693 "windows-sys 0.48.0", 3641 "windows-sys 0.48.0",
diff --git a/Cargo.toml b/Cargo.toml
index ae3b657..1316357 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,8 +23,8 @@ futures = "0.3.28"
23git2 = "0.18.1" 23git2 = "0.18.1"
24indicatif = "0.17.7" 24indicatif = "0.17.7"
25keyring = "2.0.5" 25keyring = "2.0.5"
26nostr = "0.29" 26nostr = { git = "https://github.com/DanConwayDev/nostr", branch="expose-nip49-log-n" }
27nostr-sdk = "0.29" 27nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="expose-nip49-log-n" }
28passwords = "3.1.13" 28passwords = "3.1.13"
29scrypt = "0.11.0" 29scrypt = "0.11.0"
30serde = { version = "1.0.181", features = ["derive"] } 30serde = { version = "1.0.181", features = ["derive"] }
diff --git a/src/key_handling/encryption.rs b/src/key_handling/encryption.rs
index 54002fa..3f4ee41 100644
--- a/src/key_handling/encryption.rs
+++ b/src/key_handling/encryption.rs
@@ -1,16 +1,7 @@
1use std::str::FromStr; 1use anyhow::Result;
2
3use anyhow::{anyhow, bail, ensure, Context, Result};
4use chacha20poly1305::{
5 aead::{rand_core::RngCore, Aead, AeadCore, KeyInit, OsRng, Payload},
6 XChaCha20Poly1305,
7};
8#[cfg(test)] 2#[cfg(test)]
9use mockall::*; 3use mockall::*;
10use nostr::{prelude::*, Keys}; 4use nostr::{prelude::*, Keys};
11use nostr_sdk::bech32::{self, FromBase32, ToBase32};
12use rand::{distributions::Alphanumeric, thread_rng, Rng};
13use zeroize::Zeroize;
14 5
15#[derive(Default)] 6#[derive(Default)]
16pub struct Encryptor; 7pub struct Encryptor;
@@ -20,143 +11,38 @@ pub trait EncryptDecrypt {
20 /// requires less CPU time if the password is long 11 /// requires less CPU time if the password is long
21 fn encrypt_key(&self, keys: &Keys, password: &str) -> Result<String>; 12 fn encrypt_key(&self, keys: &Keys, password: &str) -> Result<String>;
22 fn decrypt_key(&self, encrypted_key: &str, password: &str) -> Result<Keys>; 13 fn decrypt_key(&self, encrypted_key: &str, password: &str) -> Result<Keys>;
23 /// generates a long random string
24 fn random_token(&self) -> String;
25} 14}
26 15
27/// approach and code adapted from nostr gossip client 16/// approach and code adapted from nostr gossip client
28impl EncryptDecrypt for Encryptor { 17impl EncryptDecrypt for Encryptor {
29 fn encrypt_key(&self, keys: &Keys, password: &str) -> Result<String> { 18 fn encrypt_key(&self, keys: &Keys, password: &str) -> Result<String> {
30 // Generate a random 16-byte salt
31 let salt = {
32 let mut salt: [u8; 16] = [0; 16];
33 OsRng.fill_bytes(&mut salt);
34 salt
35 };
36
37 let nonce = XChaCha20Poly1305::generate_nonce(&mut OsRng);
38
39 let log2_rounds: u8 = if password.len() > 20 { 19 let log2_rounds: u8 = if password.len() > 20 {
40 // we have enough of entropy - no need to spend CPU time adding much more 20 // we have enough of entropy - no need to spend CPU time adding much more
41 1 21 1
42 } else { 22 } else {
23 println!("this may take a few seconds...");
43 // default (scrypt::Params::RECOMMENDED_LOG_N) is 17 but 30s is too long to wait 24 // default (scrypt::Params::RECOMMENDED_LOG_N) is 17 but 30s is too long to wait
44 15 25 15
45 }; 26 };
46 27 Ok(nostr::nips::nip49::EncryptedSecretKey::new(
47 let associated_data: Vec<u8> = vec![1]; 28 keys.secret_key()?,
48 29 password,
49 let ciphertext = { 30 log2_rounds,
50 let cipher = { 31 KeySecurity::Medium,
51 let symmetric_key = password_to_key(password, &salt, log2_rounds) 32 )?
52 .context("failed create encryption key from password")?; 33 .to_bech32()?)
53 XChaCha20Poly1305::new((&symmetric_key).into())
54 };
55 cipher
56 .encrypt(
57 &nonce,
58 Payload {
59 msg: keys
60 .secret_key()
61 .context(
62 "supplied key should reveal secret key. Is this a public key only?",
63 )?
64 .display_secret()
65 .to_string()
66 .as_bytes(),
67 aad: &associated_data,
68 },
69 )
70 .map_err(|_| anyhow!("ChaChaPoly1305 failed to encrypt nsec with password"))?
71 };
72 // Combine salt, IV and ciphertext
73 let mut concatenation: Vec<u8> = Vec::new();
74 concatenation.push(0x1); // 1 byte version number
75 concatenation.push(log2_rounds); // 1 byte for scrypt N (rounds)
76 concatenation.extend(salt); // 16 bytes of salt
77 concatenation.extend(nonce); // 24 bytes of nonce
78 concatenation.extend(associated_data); // 1 byte of key security
79 concatenation.extend(ciphertext); // 48 bytes of ciphertext expected
80 // Total length is 91 = 1 + 1 + 16 + 24 + 1 + 48
81
82 bech32::encode(
83 "ncryptsec",
84 concatenation.to_base32(),
85 bech32::Variant::Bech32,
86 )
87 .context("encrypted nsec failed to encode")
88 } 34 }
89 35
90 fn decrypt_key(&self, encrypted_key: &str, password: &str) -> Result<nostr::Keys> { 36 fn decrypt_key(&self, encrypted_key: &str, password: &str) -> Result<nostr::Keys> {
91 let data = 37 let encrypted_key = nostr::nips::nip49::EncryptedSecretKey::from_bech32(encrypted_key)?;
92 bech32::decode(encrypted_key).context("failed to decode encrypted key as bech32")?; 38 // to request that log_n gets exposed
93 if data.0 != "ncryptsec" { 39 if encrypted_key.log_n() > 14 {
94 bail!("encrypted key is in the wrong format - it doesnt start with ncryptsec"); 40 println!("this may take a few seconds...");
95 }
96 let concatenation = Vec::<u8>::from_base32(&data.1)
97 .context("failed to convert bech32::decode output to Vec<u8>")?;
98
99 // Break into parts
100 let version: u8 = concatenation[0];
101 ensure!(version == 0x1, "encryption version is incorrect");
102 let log2_rounds: u8 = concatenation[1];
103 let salt: [u8; 16] = concatenation[2..2 + 16].try_into()?;
104 let nonce = &concatenation[2 + 16..2 + 16 + 24];
105 let associated_data = &concatenation[(2 + 16 + 24)..=(2 + 16 + 24)];
106 let ciphertext = &concatenation[2 + 16 + 24 + 1..];
107
108 let cipher = {
109 let symmetric_key = password_to_key(password, &salt, log2_rounds)?;
110 XChaCha20Poly1305::new((&symmetric_key).into())
111 };
112
113 let payload = Payload {
114 msg: ciphertext,
115 aad: associated_data,
116 };
117
118 let mut inner_secret = cipher
119 .decrypt(nonce.into(), payload)
120 .map_err(|_| anyhow!("failed to decrypt"))?;
121
122 if associated_data.is_empty() {
123 bail!("invalid encrypted key");
124 } 41 }
125 42 Ok(nostr::Keys::new(encrypted_key.to_secret_key(password)?))
126 let key =
127 Keys::from_str(std::str::from_utf8(&inner_secret).context("inner secret is not [u8]")?)
128 .context(
129 "incorrect password. Key decrypted with password did not produce a valid nsec.",
130 )?;
131
132 inner_secret.zeroize();
133
134 Ok(key)
135 }
136
137 fn random_token(&self) -> String {
138 thread_rng()
139 .sample_iter(&Alphanumeric)
140 .take(32)
141 .map(char::from)
142 .collect()
143 } 43 }
144} 44}
145 45
146/// uses scrypt to stretch password into key
147fn password_to_key(password: &str, salt: &[u8; 16], log_n: u8) -> Result<[u8; 32]> {
148 let params = scrypt::Params::new(log_n, 8, 1, 32)
149 .context("scrypt failed to generate params to stretch password")?;
150 let mut key: [u8; 32] = [0; 32];
151 if log_n > 14 {
152 println!("this may take a few seconds...");
153 }
154
155 scrypt::scrypt(password.as_bytes(), salt, &params, &mut key)
156 .context("scrypt failed to stretch password")?;
157 Ok(key)
158}
159
160#[cfg(test)] 46#[cfg(test)]
161mod tests { 47mod tests {
162 use test_utils::*; 48 use test_utils::*;
@@ -235,17 +121,4 @@ mod tests {
235 ); 121 );
236 Ok(()) 122 Ok(())
237 } 123 }
238
239 #[test]
240 fn password_to_key_returns_ok_with_standard_password() {
241 let salt = {
242 let mut salt: [u8; 16] = [0; 16];
243 OsRng.fill_bytes(&mut salt);
244 salt
245 };
246
247 let log2_rounds: u8 = 1;
248
249 assert!(password_to_key(TEST_PASSWORD, &salt, log2_rounds).is_ok());
250 }
251} 124}
diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml
index c4e1b1a..0784b1a 100644
--- a/test_utils/Cargo.toml
+++ b/test_utils/Cargo.toml
@@ -9,8 +9,8 @@ assert_cmd = "2.0.12"
9dialoguer = "0.10.4" 9dialoguer = "0.10.4"
10directories = "5.0.1" 10directories = "5.0.1"
11git2 = "0.18.1" 11git2 = "0.18.1"
12nostr = "0.29" 12nostr = { git = "https://github.com/DanConwayDev/nostr", branch="expose-nip49-log-n" }
13nostr-sdk = "0.29" 13nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="expose-nip49-log-n" }
14once_cell = "1.18.0" 14once_cell = "1.18.0"
15rand = "0.8" 15rand = "0.8"
16rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } 16rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" }
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs
index a693607..daed8fa 100644
--- a/test_utils/src/lib.rs
+++ b/test_utils/src/lib.rs
@@ -24,8 +24,8 @@ pub static TEST_KEY_1_NPUB: &str =
24pub static TEST_KEY_1_PUBKEY_HEX: &str = 24pub static TEST_KEY_1_PUBKEY_HEX: &str =
25 "f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768"; 25 "f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768";
26pub static TEST_KEY_1_DISPLAY_NAME: &str = "bob"; 26pub static TEST_KEY_1_DISPLAY_NAME: &str = "bob";
27pub static TEST_KEY_1_ENCRYPTED: &str = "ncryptsec1qyq607h3cykxc3f2a44u89cdk336fptccn3fm5pf3nmf93d3c86qpunc7r6klwcn6lyszjy72wxwqq9aljg4pm6atvjrds9e248yhv76xfnt464265kgnjsvg8rlg06wg4sp9uljzfpu8zuaztcvfn2j8ggdrg8mldh850cy75efsyqqansert9wqmn4e6khpgvfz7h5le9"; 27pub static TEST_KEY_1_ENCRYPTED: &str = "ncryptsec1qgq77e3uftz8dh3jkjxwdms3v6gwqaqduxyzld82kskas8jcs5xup3sf2pc5tr0erqkqrtu0ptnjgjlgvx8lt7c0d7laryq2u7psfa6zm7mk7ln3ln58468shwatm7cx5wy5wvm7yk74ksrngygwxg74";
28pub static TEST_KEY_1_ENCRYPTED_WEAK: &str = "ncryptsec1qy8ke0tjqnn8wt3w6lnc86c27ry3qrptxctjfcgruryxy0at238kwyjwsswd7z88thysruzw3awlrsxjvw5uptcd7vt70ft9rtkx00m8cgy3khm4hxa5d2gfnc6athnfruy2eyl6pkas8k34jg85z7xjqqadzfzh9rp0fzxqtw0tvxksac3n8yc98uksvuf93e0lcvqy8j6"; 28pub static TEST_KEY_1_ENCRYPTED_WEAK: &str = "ncryptsec1qg835almhlrmyxqtqeva44d5ugm9wk2ccmwspxrqv4wjsdpdlud9es5hsrvs0pas7dvsretm0mc26qwfc7v8986mqngnjshcplnqzj62lxf44a0kkdv788f6dh20x2eum96l2j8v37s5grrheu2hgrkf";
29pub static TEST_KEY_1_KEYS: Lazy<nostr::Keys> = 29pub static TEST_KEY_1_KEYS: Lazy<nostr::Keys> =
30 Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()); 30 Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap());
31 31
@@ -121,13 +121,13 @@ pub fn make_event_old_or_change_user(
121 121
122 unsigned.created_at = 122 unsigned.created_at =
123 nostr::types::Timestamp::from(nostr::types::Timestamp::now().as_u64() - how_old_in_secs); 123 nostr::types::Timestamp::from(nostr::types::Timestamp::now().as_u64() - how_old_in_secs);
124 unsigned.id = nostr::EventId::new( 124 unsigned.id = Some(nostr::EventId::new(
125 &keys.public_key(), 125 &keys.public_key(),
126 unsigned.created_at, 126 &unsigned.created_at,
127 &unsigned.kind, 127 &unsigned.kind,
128 &unsigned.tags, 128 &unsigned.tags,
129 &unsigned.content, 129 &unsigned.content,
130 ); 130 ));
131 131
132 unsigned.sign(keys).unwrap() 132 unsigned.sign(keys).unwrap()
133} 133}
diff --git a/tests/login.rs b/tests/login.rs
index 351d099..371a7e7 100644
--- a/tests/login.rs
+++ b/tests/login.rs
@@ -956,7 +956,7 @@ mod with_offline_flag {
956 p.expect(format!("login as {}\r\n", TEST_KEY_1_NPUB).as_str())? 956 p.expect(format!("login as {}\r\n", TEST_KEY_1_NPUB).as_str())?
957 .expect_password(EXPECTED_PASSWORD_PROMPT)? 957 .expect_password(EXPECTED_PASSWORD_PROMPT)?
958 .succeeds_with(TEST_INVALID_PASSWORD)?; 958 .succeeds_with(TEST_INVALID_PASSWORD)?;
959 p.expect_end_with(format!("Error: failed to log in as {}\r\n\r\nCaused by:\r\n 0: failed to decrypt key with provided password\r\n 1: failed to decrypt\r\n", TEST_KEY_1_NPUB).as_str()) 959 p.expect_end_with(format!("Error: failed to log in as {}\r\n\r\nCaused by:\r\n 0: failed to decrypt key with provided password\r\n 1: ChaCha20Poly1305: aead::Error\r\n", TEST_KEY_1_NPUB).as_str())
960 }) 960 })
961 } 961 }
962 } 962 }