From 1ac2f3862e540fedb9b18d486a31dfcef356e078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 15 Apr 2025 15:34:18 +0200 Subject: [PATCH 01/26] Relock cargo dependencies --- Cargo.lock | 681 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 436 insertions(+), 245 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f34579..ab8210f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aead" @@ -14,13 +14,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy 0.7.35", ] [[package]] @@ -40,9 +41,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "ark-bls12-381" @@ -164,9 +165,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "base16ct" @@ -182,9 +183,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bincode" @@ -197,9 +198,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "block-buffer" @@ -212,21 +213,24 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.79" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -260,15 +264,15 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "winapi", + "windows-link", ] [[package]] @@ -294,30 +298,30 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -338,15 +342,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.3" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436ace70fc06e06f7f689d2624dc4e2f0ea666efb5aa704215f7249ae6e047a7" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "fiat-crypto", - "platforms", "rustc_version", "serde", "subtle", @@ -355,13 +358,13 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", ] [[package]] @@ -376,12 +379,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.1" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ - "darling_core 0.20.1", - "darling_macro 0.20.1", + "darling_core 0.20.11", + "darling_macro 0.20.11", ] [[package]] @@ -394,22 +397,22 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] [[package]] name = "darling_core" -version = "0.20.1" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim", - "syn 2.0.25", + "strsim 0.11.1", + "syn 2.0.100", ] [[package]] @@ -425,25 +428,35 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.1" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ - "darling_core 0.20.1", + "darling_core 0.20.11", "quote", - "syn 2.0.25", + "syn 2.0.100", ] [[package]] name = "der" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", ] +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "derivative" version = "2.2.0" @@ -457,13 +470,13 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] @@ -480,9 +493,9 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest", @@ -493,15 +506,15 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -548,7 +561,7 @@ dependencies = [ "derive_more", "ferveo-common-pre-release", "generic-array", - "getrandom 0.2.10", + "getrandom 0.2.15", "group-threshold-cryptography-pre-release", "hex", "itertools", @@ -569,9 +582,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ "rand_core 0.6.4", "subtle", @@ -579,9 +592,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "fnv" @@ -613,9 +626,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -686,9 +699,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac", ] @@ -704,16 +717,17 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -750,18 +764,18 @@ checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", "js-sys", @@ -771,9 +785,12 @@ dependencies = [ [[package]] name = "inventory" -version = "0.3.8" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c38a87a1e0e2752433cd4b26019a469112a25fb43b30f5ee9b3b898925c5a0f9" +checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83" +dependencies = [ + "rustversion", +] [[package]] name = "itertools" @@ -786,24 +803,25 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -813,24 +831,24 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] [[package]] name = "libc" -version = "0.2.147" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -838,20 +856,26 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "measure_time" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56220900f1a0923789ecd6bf25fbae8af3b2f1ff3e9e297fc9b6b8674dd4d852" +checksum = "dbefd235b0aadd181626f281e1d684e116972988c14c264e42069d5e8a5775cc" dependencies = [ "instant", "log", ] +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "memoffset" version = "0.8.0" @@ -861,6 +885,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "miracl_core" version = "2.3.0" @@ -897,7 +931,7 @@ dependencies = [ "ferveo-pre-release", "nucypher-core", "pyo3", - "pyo3-build-config", + "pyo3-build-config 0.24.1", "umbral-pre", ] @@ -920,51 +954,55 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -972,9 +1010,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", @@ -985,15 +1023,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" - -[[package]] -name = "platforms" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "poly1305" @@ -1006,17 +1038,26 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy 0.8.24", +] [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -1033,7 +1074,7 @@ dependencies = [ "libc", "memoffset", "parking_lot", - "pyo3-build-config", + "pyo3-build-config 0.18.3", "pyo3-ffi", "pyo3-macros", "unindent", @@ -1046,7 +1087,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" dependencies = [ "once_cell", - "target-lexicon", + "target-lexicon 0.12.16", +] + +[[package]] +name = "pyo3-build-config" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27165889bd793000a098bb966adc4300c312497ea25cf7a690a9f0ac5aa5fc1" +dependencies = [ + "once_cell", + "target-lexicon 0.13.2", ] [[package]] @@ -1056,7 +1107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" dependencies = [ "libc", - "pyo3-build-config", + "pyo3-build-config 0.18.3", ] [[package]] @@ -1084,9 +1135,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -1150,7 +1201,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", ] [[package]] @@ -1164,9 +1215,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags", ] @@ -1183,9 +1234,9 @@ dependencies = [ [[package]] name = "rmp" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" dependencies = [ "byteorder", "num-traits", @@ -1194,9 +1245,9 @@ dependencies = [ [[package]] name = "rmp-serde" -version = "1.1.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b13be192e0220b8afb7222aa5813cb62cc269ebb5cac346ca6487681d2913e" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" dependencies = [ "byteorder", "rmp", @@ -1205,36 +1256,45 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] -name = "scoped-tls" -version = "1.0.1" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sec1" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", @@ -1245,46 +1305,47 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.11" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a16be4fe5320ade08736447e3198294a5ea9a6d44dde6f35f0a5e06859c427a" +checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1333,17 +1394,17 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.1", + "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", ] [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -1360,11 +1421,17 @@ dependencies = [ "keccak", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", "rand_core 0.6.4", @@ -1372,9 +1439,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "strsim" @@ -1382,6 +1449,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subproductdomain-pre-release" version = "0.1.0" @@ -1397,9 +1470,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -1414,9 +1487,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -1425,37 +1498,46 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.8" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "target-lexicon" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", ] [[package]] name = "time" -version = "0.3.23" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -1463,24 +1545,25 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ + "num-conv", "time-core", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "umbral-pre" @@ -1488,11 +1571,11 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7aa08487feab265cc169ef77650f3527664f6b945a06fbb233ef9a44d56ee11" dependencies = [ - "base64 0.21.2", + "base64 0.21.7", "chacha20poly1305", "derive_more", "generic-array", - "getrandom 0.2.10", + "getrandom 0.2.15", "hex", "hkdf", "js-sys", @@ -1510,9 +1593,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unindent" @@ -1532,9 +1615,19 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] [[package]] name = "wasi" @@ -1550,26 +1643,27 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", "wasm-bindgen-shared", ] @@ -1597,21 +1691,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1619,32 +1714,34 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.37" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e6e302a7ea94f83a6d09e78e7dc7d9ca7b186bc2829c24a22d0753efd680671" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ - "console_error_panic_hook", "js-sys", - "scoped-tls", + "minicov", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -1652,64 +1749,112 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.37" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb993dd8c836930ed130e020e77d9b2e65dd0fbab1b67c790b0f5d80b11a575" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", + "syn 2.0.100", ] [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "winapi-util" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-sys", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-core" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "windows-link" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] -name = "winapi-x86_64-pc-windows-gnu" +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] [[package]] -name = "windows" -version = "0.48.0" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1718,51 +1863,57 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "x25519-dalek" -version = "2.0.0-rc.3" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7fae07da688e17059d5886712c933bb0520f15eff2e09cfa18e30968f4e63a" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek", "rand_core 0.6.4", @@ -1770,11 +1921,51 @@ dependencies = [ "zeroize", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -1787,5 +1978,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.100", ] From 5eaf5636c8fcfd184782de2675d56edd1398cdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 15 Apr 2025 16:26:15 +0200 Subject: [PATCH 02/26] Modify encrypt/decrypt_with_shared_secret to allow to test it determiniscally --- nucypher-core/src/dkg.rs | 50 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 43fd127..cba8975 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -6,6 +6,7 @@ use chacha20poly1305::aead::{Aead, AeadCore, KeyInit, OsRng}; use chacha20poly1305::{ChaCha20Poly1305, Key, Nonce}; use ferveo::api::{CiphertextHeader, FerveoVariant}; use generic_array::typenum::Unsigned; +use rand_core::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use umbral_pre::serde_bytes; // TODO should this be in umbral? @@ -64,13 +65,23 @@ impl fmt::Display for DecryptionError { type NonceSize = ::NonceSize; +/// Encrypts data using a shared secret with the default OS RNG. fn encrypt_with_shared_secret( shared_secret: &SessionSharedSecret, plaintext: &[u8], +) -> Result, EncryptionError> { + encrypt_with_shared_secret_with_rng(shared_secret, plaintext, &mut OsRng) +} + +/// Encrypts data using a shared secret with a custom RNG. +fn encrypt_with_shared_secret_with_rng( + shared_secret: &SessionSharedSecret, + plaintext: &[u8], + rng: &mut R, ) -> Result, EncryptionError> { let key = Key::from_slice(shared_secret.as_ref()); let cipher = ChaCha20Poly1305::new(key); - let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); + let nonce = ChaCha20Poly1305::generate_nonce(rng); let mut result = nonce.to_vec(); let ciphertext = cipher .encrypt(&nonce, plaintext.as_ref()) @@ -595,13 +606,16 @@ impl<'a> ProtocolObject<'a> for EncryptedThresholdDecryptionResponse {} mod tests { use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; use generic_array::typenum::Unsigned; - use rand_core::RngCore; + use rand::rngs::StdRng; + use rand_core::{RngCore, SeedableRng}; + use x25519_dalek::{PublicKey, StaticSecret}; use crate::access_control::AccessControlPolicy; use crate::conditions::{Conditions, Context}; - use crate::dkg::session::SessionStaticSecret; + use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret}; use crate::dkg::{ - decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, + decrypt_with_shared_secret, encrypt_with_shared_secret, + encrypt_with_shared_secret_with_rng, DecryptionError, NonceSize, }; use crate::versioning::{ProtocolObject, ProtocolObjectInner}; use crate::{ @@ -832,4 +846,32 @@ mod tests { .decrypt(&random_shared_secret) .is_err()); } + + #[test] + fn test_encryption_deterministic() { + // Create a test session_shared_secret and test plaintext + let mut rng0 = ::from_seed([0u8; 32]); + let static_secret_a = StaticSecret::random_from_rng(&mut rng0); + let static_secret_b = StaticSecret::random_from_rng(&mut rng0); + let public_key_b = PublicKey::from(&static_secret_b); + let shared_secret = static_secret_a.diffie_hellman(&public_key_b); + let session_shared_secret = SessionSharedSecret::new(shared_secret); + + let plaintext = b"test data"; + + // Use a seeded RNG for deterministic testing on encryption + let mut rng1 = ::from_seed([0u8; 32]); + let ciphertext1 = + encrypt_with_shared_secret_with_rng(&session_shared_secret, plaintext, &mut rng1) + .unwrap(); + + // Reset the RNG with the same seed + let mut rng2 = ::from_seed([0u8; 32]); + let ciphertext2 = + encrypt_with_shared_secret_with_rng(&session_shared_secret, plaintext, &mut rng2) + .unwrap(); + + // The ciphertexts will be identical because we used the same seed + assert_eq!(ciphertext1, ciphertext2); + } } From 4033a3873a6f375678481fb72039885047ba228d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 15 Apr 2025 16:31:41 +0200 Subject: [PATCH 03/26] cargo-fixn' stuff --- nucypher-core-wasm/tests/wasm.rs | 2 +- nucypher-core/src/access_control.rs | 8 ++++---- nucypher-core/src/dkg.rs | 22 +++++++++++----------- nucypher-core/src/fleet_state.rs | 2 +- nucypher-core/src/key_frag.rs | 8 ++++---- nucypher-core/src/message_kit.rs | 4 ++-- nucypher-core/src/node_metadata.rs | 12 ++++++------ nucypher-core/src/reencryption.rs | 8 ++++---- nucypher-core/src/retrieval_kit.rs | 4 ++-- nucypher-core/src/revocation_order.rs | 4 ++-- nucypher-core/src/threshold_message_kit.rs | 4 ++-- nucypher-core/src/treasure_map.rs | 12 ++++++------ 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/nucypher-core-wasm/tests/wasm.rs b/nucypher-core-wasm/tests/wasm.rs index 3df9227..5c17461 100644 --- a/nucypher-core-wasm/tests/wasm.rs +++ b/nucypher-core-wasm/tests/wasm.rs @@ -612,7 +612,7 @@ fn fleet_state_checksum_to_bytes() { let fleet_state_checksum = make_fleet_state_checksum(); assert!( - fleet_state_checksum.to_bytes().len() > 0, + !fleet_state_checksum.to_bytes().is_empty(), "FleetStateChecksum does not serialize to bytes" ); } diff --git a/nucypher-core/src/access_control.rs b/nucypher-core/src/access_control.rs index 90d166d..0ac7731 100644 --- a/nucypher-core/src/access_control.rs +++ b/nucypher-core/src/access_control.rs @@ -43,7 +43,7 @@ impl AuthenticatedData { } } -impl<'a> ProtocolObjectInner<'a> for AuthenticatedData { +impl ProtocolObjectInner<'_> for AuthenticatedData { fn version() -> (u16, u16) { (1, 0) } @@ -65,7 +65,7 @@ impl<'a> ProtocolObjectInner<'a> for AuthenticatedData { } } -impl<'a> ProtocolObject<'a> for AuthenticatedData {} +impl ProtocolObject<'_> for AuthenticatedData {} /// Encrypt data based on conditions and dkg public key. pub fn encrypt_for_dkg( @@ -118,7 +118,7 @@ impl AccessControlPolicy { } } -impl<'a> ProtocolObjectInner<'a> for AccessControlPolicy { +impl ProtocolObjectInner<'_> for AccessControlPolicy { fn version() -> (u16, u16) { (1, 0) } @@ -140,7 +140,7 @@ impl<'a> ProtocolObjectInner<'a> for AccessControlPolicy { } } -impl<'a> ProtocolObject<'a> for AccessControlPolicy {} +impl ProtocolObject<'_> for AccessControlPolicy {} #[cfg(test)] mod tests { diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index cba8975..b853472 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -221,7 +221,7 @@ pub mod session { } } - impl<'a> ProtocolObjectInner<'a> for SessionStaticKey { + impl ProtocolObjectInner<'_> for SessionStaticKey { fn version() -> (u16, u16) { (2, 0) } @@ -246,7 +246,7 @@ pub mod session { } } - impl<'a> ProtocolObject<'a> for SessionStaticKey {} + impl ProtocolObject<'_> for SessionStaticKey {} /// A session secret key. #[derive(ZeroizeOnDrop)] @@ -402,7 +402,7 @@ impl ThresholdDecryptionRequest { } } -impl<'a> ProtocolObjectInner<'a> for ThresholdDecryptionRequest { +impl ProtocolObjectInner<'_> for ThresholdDecryptionRequest { fn version() -> (u16, u16) { (4, 0) } @@ -424,7 +424,7 @@ impl<'a> ProtocolObjectInner<'a> for ThresholdDecryptionRequest { } } -impl<'a> ProtocolObject<'a> for ThresholdDecryptionRequest {} +impl ProtocolObject<'_> for ThresholdDecryptionRequest {} /// An encrypted request for an Ursula to derive a decryption share. #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] @@ -467,7 +467,7 @@ impl EncryptedThresholdDecryptionRequest { } } -impl<'a> ProtocolObjectInner<'a> for EncryptedThresholdDecryptionRequest { +impl ProtocolObjectInner<'_> for EncryptedThresholdDecryptionRequest { fn version() -> (u16, u16) { (2, 0) } @@ -489,7 +489,7 @@ impl<'a> ProtocolObjectInner<'a> for EncryptedThresholdDecryptionRequest { } } -impl<'a> ProtocolObject<'a> for EncryptedThresholdDecryptionRequest {} +impl ProtocolObject<'_> for EncryptedThresholdDecryptionRequest {} /// A response from Ursula with a derived decryption share. #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] @@ -520,7 +520,7 @@ impl ThresholdDecryptionResponse { } } -impl<'a> ProtocolObjectInner<'a> for ThresholdDecryptionResponse { +impl ProtocolObjectInner<'_> for ThresholdDecryptionResponse { fn version() -> (u16, u16) { (2, 0) } @@ -542,7 +542,7 @@ impl<'a> ProtocolObjectInner<'a> for ThresholdDecryptionResponse { } } -impl<'a> ProtocolObject<'a> for ThresholdDecryptionResponse {} +impl ProtocolObject<'_> for ThresholdDecryptionResponse {} /// An encrypted response from Ursula with a derived decryption share. #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] @@ -578,7 +578,7 @@ impl EncryptedThresholdDecryptionResponse { } } -impl<'a> ProtocolObjectInner<'a> for EncryptedThresholdDecryptionResponse { +impl ProtocolObjectInner<'_> for EncryptedThresholdDecryptionResponse { fn version() -> (u16, u16) { (2, 0) } @@ -600,7 +600,7 @@ impl<'a> ProtocolObjectInner<'a> for EncryptedThresholdDecryptionResponse { } } -impl<'a> ProtocolObject<'a> for EncryptedThresholdDecryptionResponse {} +impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} #[cfg(test)] mod tests { @@ -856,7 +856,7 @@ mod tests { let public_key_b = PublicKey::from(&static_secret_b); let shared_secret = static_secret_a.diffie_hellman(&public_key_b); let session_shared_secret = SessionSharedSecret::new(shared_secret); - + let plaintext = b"test data"; // Use a seeded RNG for deterministic testing on encryption diff --git a/nucypher-core/src/fleet_state.rs b/nucypher-core/src/fleet_state.rs index 1ff1cdd..b0961fb 100644 --- a/nucypher-core/src/fleet_state.rs +++ b/nucypher-core/src/fleet_state.rs @@ -37,7 +37,7 @@ impl FleetStateChecksum { // so this may lead to unnecessary fleet state update. // But, unlike ProtocolObject::to_bytes(), payload serialization // is not standardized, so it is better not to rely on it. - digest.chain(&node.to_bytes()) + digest.chain(node.to_bytes()) }) .finalize(); diff --git a/nucypher-core/src/key_frag.rs b/nucypher-core/src/key_frag.rs index d64280e..7f0e7b8 100644 --- a/nucypher-core/src/key_frag.rs +++ b/nucypher-core/src/key_frag.rs @@ -52,7 +52,7 @@ impl AuthorizedKeyFrag { } } -impl<'a> ProtocolObjectInner<'a> for AuthorizedKeyFrag { +impl ProtocolObjectInner<'_> for AuthorizedKeyFrag { fn brand() -> [u8; 4] { *b"AKFr" } @@ -74,7 +74,7 @@ impl<'a> ProtocolObjectInner<'a> for AuthorizedKeyFrag { } } -impl<'a> ProtocolObject<'a> for AuthorizedKeyFrag {} +impl ProtocolObject<'_> for AuthorizedKeyFrag {} #[allow(clippy::enum_variant_names)] #[derive(Debug)] @@ -144,7 +144,7 @@ impl EncryptedKeyFrag { } } -impl<'a> ProtocolObjectInner<'a> for EncryptedKeyFrag { +impl ProtocolObjectInner<'_> for EncryptedKeyFrag { fn brand() -> [u8; 4] { *b"EKFr" } @@ -166,4 +166,4 @@ impl<'a> ProtocolObjectInner<'a> for EncryptedKeyFrag { } } -impl<'a> ProtocolObject<'a> for EncryptedKeyFrag {} +impl ProtocolObject<'_> for EncryptedKeyFrag {} diff --git a/nucypher-core/src/message_kit.rs b/nucypher-core/src/message_kit.rs index f6d5976..604c963 100644 --- a/nucypher-core/src/message_kit.rs +++ b/nucypher-core/src/message_kit.rs @@ -67,7 +67,7 @@ impl MessageKit { } } -impl<'a> ProtocolObjectInner<'a> for MessageKit { +impl ProtocolObjectInner<'_> for MessageKit { fn brand() -> [u8; 4] { *b"MKit" } @@ -89,4 +89,4 @@ impl<'a> ProtocolObjectInner<'a> for MessageKit { } } -impl<'a> ProtocolObject<'a> for MessageKit {} +impl ProtocolObject<'_> for MessageKit {} diff --git a/nucypher-core/src/node_metadata.rs b/nucypher-core/src/node_metadata.rs index 1afc7e2..e46d0a7 100644 --- a/nucypher-core/src/node_metadata.rs +++ b/nucypher-core/src/node_metadata.rs @@ -122,7 +122,7 @@ impl NodeMetadata { } } -impl<'a> ProtocolObjectInner<'a> for NodeMetadata { +impl ProtocolObjectInner<'_> for NodeMetadata { fn brand() -> [u8; 4] { *b"NdMd" } @@ -148,7 +148,7 @@ impl<'a> ProtocolObjectInner<'a> for NodeMetadata { } } -impl<'a> ProtocolObject<'a> for NodeMetadata {} +impl ProtocolObject<'_> for NodeMetadata {} /// A request for metadata exchange. #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] @@ -169,7 +169,7 @@ impl MetadataRequest { } } -impl<'a> ProtocolObjectInner<'a> for MetadataRequest { +impl ProtocolObjectInner<'_> for MetadataRequest { fn brand() -> [u8; 4] { *b"MdRq" } @@ -191,7 +191,7 @@ impl<'a> ProtocolObjectInner<'a> for MetadataRequest { } } -impl<'a> ProtocolObject<'a> for MetadataRequest {} +impl ProtocolObject<'_> for MetadataRequest {} /// Payload of the metadata response. #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] @@ -250,7 +250,7 @@ impl MetadataResponse { } } -impl<'a> ProtocolObjectInner<'a> for MetadataResponse { +impl ProtocolObjectInner<'_> for MetadataResponse { fn brand() -> [u8; 4] { *b"MdRs" } @@ -277,4 +277,4 @@ impl<'a> ProtocolObjectInner<'a> for MetadataResponse { } } -impl<'a> ProtocolObject<'a> for MetadataResponse {} +impl ProtocolObject<'_> for MetadataResponse {} diff --git a/nucypher-core/src/reencryption.rs b/nucypher-core/src/reencryption.rs index e728dff..1e56e9a 100644 --- a/nucypher-core/src/reencryption.rs +++ b/nucypher-core/src/reencryption.rs @@ -55,7 +55,7 @@ impl ReencryptionRequest { } } -impl<'a> ProtocolObjectInner<'a> for ReencryptionRequest { +impl ProtocolObjectInner<'_> for ReencryptionRequest { fn brand() -> [u8; 4] { *b"ReRq" } @@ -77,7 +77,7 @@ impl<'a> ProtocolObjectInner<'a> for ReencryptionRequest { } } -impl<'a> ProtocolObject<'a> for ReencryptionRequest {} +impl ProtocolObject<'_> for ReencryptionRequest {} /// A response from Ursula with reencrypted capsule frags. #[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] @@ -169,7 +169,7 @@ impl ReencryptionResponse { } } -impl<'a> ProtocolObjectInner<'a> for ReencryptionResponse { +impl ProtocolObjectInner<'_> for ReencryptionResponse { fn brand() -> [u8; 4] { *b"ReRs" } @@ -191,7 +191,7 @@ impl<'a> ProtocolObjectInner<'a> for ReencryptionResponse { } } -impl<'a> ProtocolObject<'a> for ReencryptionResponse {} +impl ProtocolObject<'_> for ReencryptionResponse {} #[cfg(test)] mod tests { diff --git a/nucypher-core/src/retrieval_kit.rs b/nucypher-core/src/retrieval_kit.rs index 9e74d68..8c1ef90 100644 --- a/nucypher-core/src/retrieval_kit.rs +++ b/nucypher-core/src/retrieval_kit.rs @@ -50,7 +50,7 @@ impl RetrievalKit { } } -impl<'a> ProtocolObjectInner<'a> for RetrievalKit { +impl ProtocolObjectInner<'_> for RetrievalKit { fn brand() -> [u8; 4] { *b"RKit" } @@ -72,4 +72,4 @@ impl<'a> ProtocolObjectInner<'a> for RetrievalKit { } } -impl<'a> ProtocolObject<'a> for RetrievalKit {} +impl ProtocolObject<'_> for RetrievalKit {} diff --git a/nucypher-core/src/revocation_order.rs b/nucypher-core/src/revocation_order.rs index e93a015..8c68d66 100644 --- a/nucypher-core/src/revocation_order.rs +++ b/nucypher-core/src/revocation_order.rs @@ -59,7 +59,7 @@ impl RevocationOrder { } } -impl<'a> ProtocolObjectInner<'a> for RevocationOrder { +impl ProtocolObjectInner<'_> for RevocationOrder { fn brand() -> [u8; 4] { *b"Revo" } @@ -81,4 +81,4 @@ impl<'a> ProtocolObjectInner<'a> for RevocationOrder { } } -impl<'a> ProtocolObject<'a> for RevocationOrder {} +impl ProtocolObject<'_> for RevocationOrder {} diff --git a/nucypher-core/src/threshold_message_kit.rs b/nucypher-core/src/threshold_message_kit.rs index 7856016..f645774 100644 --- a/nucypher-core/src/threshold_message_kit.rs +++ b/nucypher-core/src/threshold_message_kit.rs @@ -48,7 +48,7 @@ impl ThresholdMessageKit { } } -impl<'a> ProtocolObjectInner<'a> for ThresholdMessageKit { +impl ProtocolObjectInner<'_> for ThresholdMessageKit { fn version() -> (u16, u16) { (1, 0) } @@ -70,7 +70,7 @@ impl<'a> ProtocolObjectInner<'a> for ThresholdMessageKit { } } -impl<'a> ProtocolObject<'a> for ThresholdMessageKit {} +impl ProtocolObject<'_> for ThresholdMessageKit {} #[cfg(test)] mod tests { diff --git a/nucypher-core/src/treasure_map.rs b/nucypher-core/src/treasure_map.rs index f6b4f0a..744d6bc 100644 --- a/nucypher-core/src/treasure_map.rs +++ b/nucypher-core/src/treasure_map.rs @@ -97,7 +97,7 @@ impl TreasureMap { } } -impl<'a> ProtocolObjectInner<'a> for TreasureMap { +impl ProtocolObjectInner<'_> for TreasureMap { fn brand() -> [u8; 4] { *b"TMap" } @@ -119,7 +119,7 @@ impl<'a> ProtocolObjectInner<'a> for TreasureMap { } } -impl<'a> ProtocolObject<'a> for TreasureMap {} +impl ProtocolObject<'_> for TreasureMap {} #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] struct AuthorizedTreasureMap { @@ -157,7 +157,7 @@ impl AuthorizedTreasureMap { } } -impl<'a> ProtocolObjectInner<'a> for AuthorizedTreasureMap { +impl ProtocolObjectInner<'_> for AuthorizedTreasureMap { fn brand() -> [u8; 4] { *b"AMap" } @@ -179,7 +179,7 @@ impl<'a> ProtocolObjectInner<'a> for AuthorizedTreasureMap { } } -impl<'a> ProtocolObject<'a> for AuthorizedTreasureMap {} +impl ProtocolObject<'_> for AuthorizedTreasureMap {} /// A treasure map encrypted for Bob. #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] @@ -229,7 +229,7 @@ impl EncryptedTreasureMap { } } -impl<'a> ProtocolObjectInner<'a> for EncryptedTreasureMap { +impl ProtocolObjectInner<'_> for EncryptedTreasureMap { fn brand() -> [u8; 4] { *b"EMap" } @@ -251,4 +251,4 @@ impl<'a> ProtocolObjectInner<'a> for EncryptedTreasureMap { } } -impl<'a> ProtocolObject<'a> for EncryptedTreasureMap {} +impl ProtocolObject<'_> for EncryptedTreasureMap {} From f5749f43113acecf84591a5d98c6df7e114379ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 12:45:57 +0200 Subject: [PATCH 04/26] Use conditional compilation to set deterministic encryption for specific tests --- nucypher-core/Cargo.toml | 4 ++++ nucypher-core/src/dkg.rs | 40 +++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 2043430..04b07e9 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -26,3 +26,7 @@ zeroize = { version = "1.6.0", features = ["derive"] } rand_core = "0.6.4" rand_chacha = "0.3.1" rand = "0.8.5" + +[features] +default = ["deterministic_encryption"] +deterministic_encryption = [] \ No newline at end of file diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index b853472..6f57da8 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -2,7 +2,7 @@ use alloc::boxed::Box; use alloc::string::String; use core::fmt; -use chacha20poly1305::aead::{Aead, AeadCore, KeyInit, OsRng}; +use chacha20poly1305::aead::{Aead, AeadCore, KeyInit}; use chacha20poly1305::{ChaCha20Poly1305, Key, Nonce}; use ferveo::api::{CiphertextHeader, FerveoVariant}; use generic_array::typenum::Unsigned; @@ -66,13 +66,26 @@ impl fmt::Display for DecryptionError { type NonceSize = ::NonceSize; /// Encrypts data using a shared secret with the default OS RNG. +#[cfg(not(all(test, feature = "deterministic_encryption")))] fn encrypt_with_shared_secret( shared_secret: &SessionSharedSecret, plaintext: &[u8], ) -> Result, EncryptionError> { + use chacha20poly1305::aead::OsRng; encrypt_with_shared_secret_with_rng(shared_secret, plaintext, &mut OsRng) } +#[cfg(all(test, feature = "deterministic_encryption"))] +fn encrypt_with_shared_secret( + shared_secret: &SessionSharedSecret, + plaintext: &[u8], +) -> Result, EncryptionError> { + use rand::rngs::StdRng; + use rand::SeedableRng; + let mut rng = ::from_seed([0u8; 32]); + encrypt_with_shared_secret_with_rng(shared_secret, plaintext, &mut rng) +} + /// Encrypts data using a shared secret with a custom RNG. fn encrypt_with_shared_secret_with_rng( shared_secret: &SessionSharedSecret, @@ -606,16 +619,13 @@ impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} mod tests { use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; use generic_array::typenum::Unsigned; - use rand::rngs::StdRng; - use rand_core::{RngCore, SeedableRng}; - use x25519_dalek::{PublicKey, StaticSecret}; + use rand_core::RngCore; use crate::access_control::AccessControlPolicy; use crate::conditions::{Conditions, Context}; - use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret}; + use crate::dkg::session::SessionStaticSecret; use crate::dkg::{ - decrypt_with_shared_secret, encrypt_with_shared_secret, - encrypt_with_shared_secret_with_rng, DecryptionError, NonceSize, + decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, }; use crate::versioning::{ProtocolObject, ProtocolObjectInner}; use crate::{ @@ -848,7 +858,13 @@ mod tests { } #[test] + #[cfg(feature = "deterministic_encryption")] fn test_encryption_deterministic() { + use rand_core::SeedableRng; + use rand::rngs::StdRng; + use x25519_dalek::{PublicKey, StaticSecret}; + use crate::dkg::session::SessionSharedSecret; + // Create a test session_shared_secret and test plaintext let mut rng0 = ::from_seed([0u8; 32]); let static_secret_a = StaticSecret::random_from_rng(&mut rng0); @@ -860,16 +876,10 @@ mod tests { let plaintext = b"test data"; // Use a seeded RNG for deterministic testing on encryption - let mut rng1 = ::from_seed([0u8; 32]); - let ciphertext1 = - encrypt_with_shared_secret_with_rng(&session_shared_secret, plaintext, &mut rng1) - .unwrap(); + let ciphertext1 = encrypt_with_shared_secret(&session_shared_secret, plaintext).unwrap(); // Reset the RNG with the same seed - let mut rng2 = ::from_seed([0u8; 32]); - let ciphertext2 = - encrypt_with_shared_secret_with_rng(&session_shared_secret, plaintext, &mut rng2) - .unwrap(); + let ciphertext2 = encrypt_with_shared_secret(&session_shared_secret, plaintext).unwrap(); // The ciphertexts will be identical because we used the same seed assert_eq!(ciphertext1, ciphertext2); From 6c910983948f1b1de3354eb6c6c51abcd0b13a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 13:01:41 +0200 Subject: [PATCH 05/26] Tests and utils to generate test vectors for encrypt_with_shared_secret --- nucypher-core/src/dkg.rs | 64 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 6f57da8..e01574f 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -617,13 +617,16 @@ impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} #[cfg(test)] mod tests { + use alloc::vec; + use alloc::vec::Vec; + use alloc::boxed::Box; use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; use generic_array::typenum::Unsigned; use rand_core::RngCore; use crate::access_control::AccessControlPolicy; use crate::conditions::{Conditions, Context}; - use crate::dkg::session::SessionStaticSecret; + use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret}; use crate::dkg::{ decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, }; @@ -857,6 +860,46 @@ mod tests { .is_err()); } + #[cfg(feature = "deterministic_encryption")] + pub fn generate_test_vectors() -> Vec<(SessionSharedSecret, Vec, Box<[u8]>)> { + use rand_core::SeedableRng; + use rand::rngs::StdRng; + use x25519_dalek::{PublicKey, StaticSecret}; + use crate::dkg::session::SessionSharedSecret; + + let mut test_vectors = Vec::new(); + + // Generate test vectors with different seeds + for seed in 0..3 { + let mut rng = ::from_seed([seed as u8; 32]); + + // Generate test plaintexts + let plaintexts = vec![ + b"test data".to_vec(), + b"another test".to_vec(), + b"".to_vec(), // empty string test + ]; + + // Generate ciphertexts for each plaintext + for plaintext in plaintexts { + // Generate static secrets for each plaintext + let static_secret_a = StaticSecret::random_from_rng(&mut rng); + let static_secret_b = StaticSecret::random_from_rng(&mut rng); + let public_key_b = PublicKey::from(&static_secret_b); + + // Create shared secret + let shared_secret = static_secret_a.diffie_hellman(&public_key_b); + let session_shared_secret = SessionSharedSecret::new(shared_secret); + + let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) + .expect("Encryption failed"); + test_vectors.push((session_shared_secret, plaintext, ciphertext)); + } + } + + test_vectors + } + #[test] #[cfg(feature = "deterministic_encryption")] fn test_encryption_deterministic() { @@ -884,4 +927,23 @@ mod tests { // The ciphertexts will be identical because we used the same seed assert_eq!(ciphertext1, ciphertext2); } + + #[test] + #[cfg(feature = "deterministic_encryption")] + fn test_encryption_vectors() { + let test_vectors = generate_test_vectors(); + + // Verify each test vector + for (shared_secret, plaintext, ciphertext) in test_vectors { + // Verify decryption works + let decrypted = decrypt_with_shared_secret(&shared_secret, &ciphertext) + .expect("Decryption failed"); + assert_eq!(decrypted.as_ref(), plaintext.as_slice()); + + // Verify encryption is deterministic + let new_ciphertext = encrypt_with_shared_secret(&shared_secret, &plaintext) + .expect("Encryption failed"); + assert_eq!(new_ciphertext, ciphertext); + } + } } From 5126436b010774fac3e2bf6d7dc88ffd8cc6817e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 16:02:49 +0200 Subject: [PATCH 06/26] Utility function to produce test vectors as files --- nucypher-core/src/dkg.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index e01574f..5c06119 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -861,7 +861,15 @@ mod tests { } #[cfg(feature = "deterministic_encryption")] - pub fn generate_test_vectors() -> Vec<(SessionSharedSecret, Vec, Box<[u8]>)> { + pub struct TestVector { + pub seed: u8, + pub session_shared_secret: SessionSharedSecret, + pub plaintext: Vec, + pub ciphertext: Box<[u8]>, + } + + #[cfg(feature = "deterministic_encryption")] + pub fn generate_test_vectors() -> Vec { use rand_core::SeedableRng; use rand::rngs::StdRng; use x25519_dalek::{PublicKey, StaticSecret}; @@ -893,7 +901,13 @@ mod tests { let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) .expect("Encryption failed"); - test_vectors.push((session_shared_secret, plaintext, ciphertext)); + + test_vectors.push(TestVector { + seed, + session_shared_secret, + plaintext, + ciphertext, + }); } } @@ -934,16 +948,16 @@ mod tests { let test_vectors = generate_test_vectors(); // Verify each test vector - for (shared_secret, plaintext, ciphertext) in test_vectors { + for vector in test_vectors { // Verify decryption works - let decrypted = decrypt_with_shared_secret(&shared_secret, &ciphertext) + let decrypted = decrypt_with_shared_secret(&vector.session_shared_secret, &vector.ciphertext) .expect("Decryption failed"); - assert_eq!(decrypted.as_ref(), plaintext.as_slice()); + assert_eq!(decrypted.as_ref(), vector.plaintext.as_slice()); // Verify encryption is deterministic - let new_ciphertext = encrypt_with_shared_secret(&shared_secret, &plaintext) + let new_ciphertext = encrypt_with_shared_secret(&vector.session_shared_secret, &vector.plaintext) .expect("Encryption failed"); - assert_eq!(new_ciphertext, ciphertext); + assert_eq!(new_ciphertext, vector.ciphertext); } } } From 3be51bc0f6dcb283a7e5dcf75cdd17422765e200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 18:40:11 +0200 Subject: [PATCH 07/26] Don't store session shared secret as part of the test vector --- nucypher-core/src/dkg.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 5c06119..d19c3a1 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -863,7 +863,6 @@ mod tests { #[cfg(feature = "deterministic_encryption")] pub struct TestVector { pub seed: u8, - pub session_shared_secret: SessionSharedSecret, pub plaintext: Vec, pub ciphertext: Box<[u8]>, } @@ -904,7 +903,6 @@ mod tests { test_vectors.push(TestVector { seed, - session_shared_secret, plaintext, ciphertext, }); From 48fc6a4d4a7001042133565cc96a08f812c5edf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 18:47:42 +0200 Subject: [PATCH 08/26] New util function `create_session_shared_secret_from_seed` This will make test vector creation and consumption much easier --- nucypher-core/src/dkg.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index d19c3a1..7983352 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -869,17 +869,10 @@ mod tests { #[cfg(feature = "deterministic_encryption")] pub fn generate_test_vectors() -> Vec { - use rand_core::SeedableRng; - use rand::rngs::StdRng; - use x25519_dalek::{PublicKey, StaticSecret}; - use crate::dkg::session::SessionSharedSecret; - let mut test_vectors = Vec::new(); // Generate test vectors with different seeds for seed in 0..3 { - let mut rng = ::from_seed([seed as u8; 32]); - // Generate test plaintexts let plaintexts = vec![ b"test data".to_vec(), @@ -889,14 +882,7 @@ mod tests { // Generate ciphertexts for each plaintext for plaintext in plaintexts { - // Generate static secrets for each plaintext - let static_secret_a = StaticSecret::random_from_rng(&mut rng); - let static_secret_b = StaticSecret::random_from_rng(&mut rng); - let public_key_b = PublicKey::from(&static_secret_b); - - // Create shared secret - let shared_secret = static_secret_a.diffie_hellman(&public_key_b); - let session_shared_secret = SessionSharedSecret::new(shared_secret); + let session_shared_secret = create_session_shared_secret_from_seed(seed); let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) .expect("Encryption failed"); @@ -940,6 +926,20 @@ mod tests { assert_eq!(ciphertext1, ciphertext2); } + #[cfg(feature = "deterministic_encryption")] + fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { + use rand_core::SeedableRng; + use rand::rngs::StdRng; + use x25519_dalek::{PublicKey, StaticSecret}; + + let mut rng = ::from_seed([seed; 32]); + let static_secret_a = StaticSecret::random_from_rng(&mut rng); + let static_secret_b = StaticSecret::random_from_rng(&mut rng); + let public_key_b = PublicKey::from(&static_secret_b); + let shared_secret = static_secret_a.diffie_hellman(&public_key_b); + SessionSharedSecret::new(shared_secret) + } + #[test] #[cfg(feature = "deterministic_encryption")] fn test_encryption_vectors() { @@ -947,13 +947,15 @@ mod tests { // Verify each test vector for vector in test_vectors { + let session_shared_secret = create_session_shared_secret_from_seed(vector.seed); + // Verify decryption works - let decrypted = decrypt_with_shared_secret(&vector.session_shared_secret, &vector.ciphertext) + let decrypted = decrypt_with_shared_secret(&session_shared_secret, &vector.ciphertext) .expect("Decryption failed"); assert_eq!(decrypted.as_ref(), vector.plaintext.as_slice()); // Verify encryption is deterministic - let new_ciphertext = encrypt_with_shared_secret(&vector.session_shared_secret, &vector.plaintext) + let new_ciphertext = encrypt_with_shared_secret(&session_shared_secret, &vector.plaintext) .expect("Encryption failed"); assert_eq!(new_ciphertext, vector.ciphertext); } From 0195f2cb944d92dde3663bab0f40a669cc18ce4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 18:54:12 +0200 Subject: [PATCH 09/26] Add serde_json dependency --- Cargo.lock | 1 + nucypher-core/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ab8210f..1fa28c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,6 +915,7 @@ dependencies = [ "rand_core 0.6.4", "rmp-serde", "serde", + "serde_json", "serde_with 1.14.0", "sha2", "sha3", diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 04b07e9..77de678 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -13,6 +13,7 @@ categories = ["cryptography", "no-std"] umbral-pre = { version = "0.11.0", features = ["serde"] } ferveo = { package = "ferveo-pre-release", version = "0.3.0" } serde = { version = "1", default-features = false, features = ["derive"] } +serde_json = "1.0" generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" rmp-serde = "1" From e0365d6ee9fec35d07bf7dde621d870f05d50abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 18:58:09 +0200 Subject: [PATCH 10/26] Fix some imports --- nucypher-core/src/dkg.rs | 50 ++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 7983352..63b93ed 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -1,5 +1,6 @@ use alloc::boxed::Box; use alloc::string::String; +use alloc::vec::Vec; use core::fmt; use chacha20poly1305::aead::{Aead, AeadCore, KeyInit}; @@ -7,12 +8,13 @@ use chacha20poly1305::{ChaCha20Poly1305, Key, Nonce}; use ferveo::api::{CiphertextHeader, FerveoVariant}; use generic_array::typenum::Unsigned; use rand_core::{CryptoRng, RngCore}; -use serde::{Deserialize, Serialize}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde_json; use umbral_pre::serde_bytes; // TODO should this be in umbral? use crate::access_control::AccessControlPolicy; use crate::conditions::Context; -use crate::dkg::session::{SessionSharedSecret, SessionStaticKey}; +use crate::dkg::session::{SessionSharedSecret, SessionStaticKey, SessionSecretFactory}; use crate::versioning::{ messagepack_deserialize, messagepack_serialize, DeserializationError, ProtocolObject, ProtocolObjectInner, @@ -617,26 +619,41 @@ impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} #[cfg(test)] mod tests { + use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret, SessionSecretFactory, SessionStaticKey}; + use crate::dkg::{ + decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, + ThresholdDecryptionRequest, EncryptedThresholdDecryptionRequest, + ThresholdDecryptionResponse, EncryptedThresholdDecryptionResponse, + }; + use crate::{AuthenticatedData, Conditions}; use alloc::vec; use alloc::vec::Vec; use alloc::boxed::Box; - use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; + use core::clone::Clone; + use ferveo::api::{DkgPublicKey, FerveoVariant, SecretBox, encrypt as ferveo_encrypt}; use generic_array::typenum::Unsigned; + use rand::SeedableRng; + use rand::rngs::StdRng; use rand_core::RngCore; + use serde::{Deserialize, Serialize}; + use serde_json; + use x25519_dalek::{PublicKey, StaticSecret}; use crate::access_control::AccessControlPolicy; - use crate::conditions::{Conditions, Context}; - use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret}; - use crate::dkg::{ - decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, - }; - use crate::versioning::{ProtocolObject, ProtocolObjectInner}; - use crate::{ - AuthenticatedData, EncryptedThresholdDecryptionRequest, - EncryptedThresholdDecryptionResponse, SessionSecretFactory, SessionStaticKey, - ThresholdDecryptionRequest, ThresholdDecryptionResponse, + use crate::conditions::Context; + use crate::versioning::{ + messagepack_deserialize, messagepack_serialize, DeserializationError, ProtocolObject, + ProtocolObjectInner, }; + #[cfg(feature = "deterministic_encryption")] + #[derive(Serialize, Deserialize)] + pub struct TestVector { + pub seed: u8, + pub plaintext: Vec, + pub ciphertext: Box<[u8]>, + } + #[test] fn decryption_with_shared_secret() { let service_secret = SessionStaticSecret::random(); @@ -860,13 +877,6 @@ mod tests { .is_err()); } - #[cfg(feature = "deterministic_encryption")] - pub struct TestVector { - pub seed: u8, - pub plaintext: Vec, - pub ciphertext: Box<[u8]>, - } - #[cfg(feature = "deterministic_encryption")] pub fn generate_test_vectors() -> Vec { let mut test_vectors = Vec::new(); From cdaa05e51f9eb3de37631f971278d3319c6b6ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 16 Apr 2025 20:07:23 +0200 Subject: [PATCH 11/26] Serialize test vectors as JSON strings --- nucypher-core/src/dkg.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 63b93ed..a3e7855 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -638,6 +638,10 @@ mod tests { use serde::{Deserialize, Serialize}; use serde_json; use x25519_dalek::{PublicKey, StaticSecret}; + #[cfg(feature = "deterministic_encryption")] + use alloc::string::String; + #[cfg(feature = "deterministic_encryption")] + use alloc::format; use crate::access_control::AccessControlPolicy; use crate::conditions::Context; @@ -908,6 +912,16 @@ mod tests { test_vectors } + #[cfg(feature = "deterministic_encryption")] + pub fn serialize_test_vector_to_json(vector: &TestVector) -> String { + serde_json::to_string(vector).expect("Failed to serialize test vector to JSON") + } + + #[cfg(feature = "deterministic_encryption")] + pub fn deserialize_test_vector_from_json(json: &str) -> TestVector { + serde_json::from_str(json).expect("Failed to deserialize test vector from JSON") + } + #[test] #[cfg(feature = "deterministic_encryption")] fn test_encryption_deterministic() { From 7b44d2a0e5041feefa22ce0f14d8e5d562fbdfb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Mon, 21 Apr 2025 19:18:47 +0200 Subject: [PATCH 12/26] Implement deterministic encryption via supplied nonces --- nucypher-core/src/dkg.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index a3e7855..fa41f23 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -74,7 +74,8 @@ fn encrypt_with_shared_secret( plaintext: &[u8], ) -> Result, EncryptionError> { use chacha20poly1305::aead::OsRng; - encrypt_with_shared_secret_with_rng(shared_secret, plaintext, &mut OsRng) + let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); + encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) } #[cfg(all(test, feature = "deterministic_encryption"))] @@ -84,19 +85,19 @@ fn encrypt_with_shared_secret( ) -> Result, EncryptionError> { use rand::rngs::StdRng; use rand::SeedableRng; - let mut rng = ::from_seed([0u8; 32]); - encrypt_with_shared_secret_with_rng(shared_secret, plaintext, &mut rng) + let rng = ::from_seed([0u8; 32]); // TODO: Note that this seed is currently fixed for all tests + let nonce = ChaCha20Poly1305::generate_nonce(rng); + encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) } -/// Encrypts data using a shared secret with a custom RNG. -fn encrypt_with_shared_secret_with_rng( +/// Encrypts data using a shared secret with a custom nonce. +fn encrypt_with_shared_secret_and_nonce( shared_secret: &SessionSharedSecret, + nonce: &Nonce, plaintext: &[u8], - rng: &mut R, ) -> Result, EncryptionError> { let key = Key::from_slice(shared_secret.as_ref()); let cipher = ChaCha20Poly1305::new(key); - let nonce = ChaCha20Poly1305::generate_nonce(rng); let mut result = nonce.to_vec(); let ciphertext = cipher .encrypt(&nonce, plaintext.as_ref()) @@ -655,6 +656,7 @@ mod tests { pub struct TestVector { pub seed: u8, pub plaintext: Vec, + pub nonce: [u8; 12], pub ciphertext: Box<[u8]>, } @@ -883,6 +885,8 @@ mod tests { #[cfg(feature = "deterministic_encryption")] pub fn generate_test_vectors() -> Vec { + use chacha20poly1305::{AeadCore, ChaCha20Poly1305}; + let mut test_vectors = Vec::new(); // Generate test vectors with different seeds @@ -901,9 +905,14 @@ mod tests { let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) .expect("Encryption failed"); + // TODO: Note that this seed is currently fixed for all tests, and hence the nonce is also fixed + let rng = ::from_seed([0u8; 32]); + let nonce = ChaCha20Poly1305::generate_nonce(rng); + test_vectors.push(TestVector { seed, plaintext, + nonce: nonce.as_slice().try_into().unwrap(), ciphertext, }); } From 43c7f517dbf3836989f867816aeef8c4b2bfcb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Mon, 21 Apr 2025 19:23:49 +0200 Subject: [PATCH 13/26] cargo-fmt'n stuff --- nucypher-core/src/dkg.rs | 57 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index fa41f23..1f659a0 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -14,7 +14,7 @@ use umbral_pre::serde_bytes; // TODO should this be in umbral? use crate::access_control::AccessControlPolicy; use crate::conditions::Context; -use crate::dkg::session::{SessionSharedSecret, SessionStaticKey, SessionSecretFactory}; +use crate::dkg::session::{SessionSecretFactory, SessionSharedSecret, SessionStaticKey}; use crate::versioning::{ messagepack_deserialize, messagepack_serialize, DeserializationError, ProtocolObject, ProtocolObjectInner, @@ -85,7 +85,7 @@ fn encrypt_with_shared_secret( ) -> Result, EncryptionError> { use rand::rngs::StdRng; use rand::SeedableRng; - let rng = ::from_seed([0u8; 32]); // TODO: Note that this seed is currently fixed for all tests + let rng = ::from_seed([0u8; 32]); // TODO: Note that this seed is currently fixed for all tests let nonce = ChaCha20Poly1305::generate_nonce(rng); encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) } @@ -100,7 +100,7 @@ fn encrypt_with_shared_secret_and_nonce( let cipher = ChaCha20Poly1305::new(key); let mut result = nonce.to_vec(); let ciphertext = cipher - .encrypt(&nonce, plaintext.as_ref()) + .encrypt(nonce, plaintext.as_ref()) .map_err(|_err| EncryptionError::PlaintextTooLarge)?; result.extend(ciphertext); Ok(result.into_boxed_slice()) @@ -620,29 +620,31 @@ impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} #[cfg(test)] mod tests { - use crate::dkg::session::{SessionSharedSecret, SessionStaticSecret, SessionSecretFactory, SessionStaticKey}; + use crate::dkg::session::{ + SessionSecretFactory, SessionSharedSecret, SessionStaticKey, SessionStaticSecret, + }; use crate::dkg::{ - decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, NonceSize, - ThresholdDecryptionRequest, EncryptedThresholdDecryptionRequest, - ThresholdDecryptionResponse, EncryptedThresholdDecryptionResponse, + decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, + EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, NonceSize, + ThresholdDecryptionRequest, ThresholdDecryptionResponse, }; use crate::{AuthenticatedData, Conditions}; + use alloc::boxed::Box; + #[cfg(feature = "deterministic_encryption")] + use alloc::format; + #[cfg(feature = "deterministic_encryption")] + use alloc::string::String; use alloc::vec; use alloc::vec::Vec; - use alloc::boxed::Box; use core::clone::Clone; - use ferveo::api::{DkgPublicKey, FerveoVariant, SecretBox, encrypt as ferveo_encrypt}; + use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; use generic_array::typenum::Unsigned; - use rand::SeedableRng; use rand::rngs::StdRng; + use rand::SeedableRng; use rand_core::RngCore; use serde::{Deserialize, Serialize}; use serde_json; use x25519_dalek::{PublicKey, StaticSecret}; - #[cfg(feature = "deterministic_encryption")] - use alloc::string::String; - #[cfg(feature = "deterministic_encryption")] - use alloc::format; use crate::access_control::AccessControlPolicy; use crate::conditions::Context; @@ -888,7 +890,7 @@ mod tests { use chacha20poly1305::{AeadCore, ChaCha20Poly1305}; let mut test_vectors = Vec::new(); - + // Generate test vectors with different seeds for seed in 0..3 { // Generate test plaintexts @@ -897,14 +899,14 @@ mod tests { b"another test".to_vec(), b"".to_vec(), // empty string test ]; - + // Generate ciphertexts for each plaintext for plaintext in plaintexts { let session_shared_secret = create_session_shared_secret_from_seed(seed); - + let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) .expect("Encryption failed"); - + // TODO: Note that this seed is currently fixed for all tests, and hence the nonce is also fixed let rng = ::from_seed([0u8; 32]); let nonce = ChaCha20Poly1305::generate_nonce(rng); @@ -917,7 +919,7 @@ mod tests { }); } } - + test_vectors } @@ -934,10 +936,10 @@ mod tests { #[test] #[cfg(feature = "deterministic_encryption")] fn test_encryption_deterministic() { - use rand_core::SeedableRng; + use crate::dkg::session::SessionSharedSecret; use rand::rngs::StdRng; + use rand_core::SeedableRng; use x25519_dalek::{PublicKey, StaticSecret}; - use crate::dkg::session::SessionSharedSecret; // Create a test session_shared_secret and test plaintext let mut rng0 = ::from_seed([0u8; 32]); @@ -961,8 +963,8 @@ mod tests { #[cfg(feature = "deterministic_encryption")] fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { - use rand_core::SeedableRng; use rand::rngs::StdRng; + use rand_core::SeedableRng; use x25519_dalek::{PublicKey, StaticSecret}; let mut rng = ::from_seed([seed; 32]); @@ -977,19 +979,20 @@ mod tests { #[cfg(feature = "deterministic_encryption")] fn test_encryption_vectors() { let test_vectors = generate_test_vectors(); - + // Verify each test vector for vector in test_vectors { let session_shared_secret = create_session_shared_secret_from_seed(vector.seed); - + // Verify decryption works let decrypted = decrypt_with_shared_secret(&session_shared_secret, &vector.ciphertext) .expect("Decryption failed"); assert_eq!(decrypted.as_ref(), vector.plaintext.as_slice()); - + // Verify encryption is deterministic - let new_ciphertext = encrypt_with_shared_secret(&session_shared_secret, &vector.plaintext) - .expect("Encryption failed"); + let new_ciphertext = + encrypt_with_shared_secret(&session_shared_secret, &vector.plaintext) + .expect("Encryption failed"); assert_eq!(new_ciphertext, vector.ciphertext); } } From 1c28d96f4b9e1686a730566f0cccb2e708774fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 22 Apr 2025 09:37:15 +0200 Subject: [PATCH 14/26] Separate utility executable that produces test vectors as files --- nucypher-core/Cargo.toml | 8 ++++++- .../src/bin/generate_test_vectors.rs | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 nucypher-core/src/bin/generate_test_vectors.rs diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 77de678..aef8d41 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -30,4 +30,10 @@ rand = "0.8.5" [features] default = ["deterministic_encryption"] -deterministic_encryption = [] \ No newline at end of file +deterministic_encryption = [] +test_vectors = [] + +[[bin]] +name = "generate-test-vectors" +path = "src/bin/generate_test_vectors.rs" +required-features = ["deterministic_encryption"] \ No newline at end of file diff --git a/nucypher-core/src/bin/generate_test_vectors.rs b/nucypher-core/src/bin/generate_test_vectors.rs new file mode 100644 index 0000000..cc74e3e --- /dev/null +++ b/nucypher-core/src/bin/generate_test_vectors.rs @@ -0,0 +1,21 @@ +use nucypher_core::dkg::tests::generate_test_vectors; +use std::fs; +use std::path::Path; + +fn main() { + // Generate test vectors + let test_vectors = generate_test_vectors(); + + // Create output directory if it doesn't exist + let output_dir = Path::new("test_vectors"); + fs::create_dir_all(output_dir).expect("Failed to create output directory"); + + // Save each test vector to a separate file + for (i, vector) in test_vectors.iter().enumerate() { + let filename = format!("test_vectors/vector_{}.json", i); + let json = serde_json::to_string_pretty(vector).expect("Failed to serialize test vector"); + fs::write(filename, json).expect("Failed to write test vector to file"); + } + + println!("Generated {} test vectors in the 'test_vectors' directory", test_vectors.len()); +} \ No newline at end of file From 1aaa2df33d5a7d7d9af0f1bc815a78bc538e23fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 22 Apr 2025 09:44:34 +0200 Subject: [PATCH 15/26] Relocate test vector specific logic to separate module --- nucypher-core/Cargo.toml | 2 +- .../src/bin/generate_test_vectors.rs | 4 +- nucypher-core/src/dkg.rs | 105 ++++-------------- nucypher-core/src/lib.rs | 4 + nucypher-core/src/test_vectors.rs | 93 ++++++++++++++++ 5 files changed, 124 insertions(+), 84 deletions(-) create mode 100644 nucypher-core/src/test_vectors.rs diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index aef8d41..e1681a2 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -36,4 +36,4 @@ test_vectors = [] [[bin]] name = "generate-test-vectors" path = "src/bin/generate_test_vectors.rs" -required-features = ["deterministic_encryption"] \ No newline at end of file +required-features = ["deterministic_encryption", "test_vectors"] \ No newline at end of file diff --git a/nucypher-core/src/bin/generate_test_vectors.rs b/nucypher-core/src/bin/generate_test_vectors.rs index cc74e3e..627a89d 100644 --- a/nucypher-core/src/bin/generate_test_vectors.rs +++ b/nucypher-core/src/bin/generate_test_vectors.rs @@ -1,10 +1,10 @@ -use nucypher_core::dkg::tests::generate_test_vectors; +use nucypher_core::test_vectors::{TestVector, generate_test_vectors}; use std::fs; use std::path::Path; fn main() { // Generate test vectors - let test_vectors = generate_test_vectors(); + let test_vectors: Vec = generate_test_vectors(); // Create output directory if it doesn't exist let output_dir = Path::new("test_vectors"); diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 1f659a0..394f0bf 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -68,8 +68,8 @@ impl fmt::Display for DecryptionError { type NonceSize = ::NonceSize; /// Encrypts data using a shared secret with the default OS RNG. -#[cfg(not(all(test, feature = "deterministic_encryption")))] -fn encrypt_with_shared_secret( +#[cfg(not(feature = "deterministic_encryption"))] +pub fn encrypt_with_shared_secret( shared_secret: &SessionSharedSecret, plaintext: &[u8], ) -> Result, EncryptionError> { @@ -78,8 +78,8 @@ fn encrypt_with_shared_secret( encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) } -#[cfg(all(test, feature = "deterministic_encryption"))] -fn encrypt_with_shared_secret( +#[cfg(feature = "deterministic_encryption")] +pub fn encrypt_with_shared_secret( shared_secret: &SessionSharedSecret, plaintext: &[u8], ) -> Result, EncryptionError> { @@ -618,6 +618,19 @@ impl ProtocolObjectInner<'_> for EncryptedThresholdDecryptionResponse { impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} +pub fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { + use rand::rngs::StdRng; + use rand_core::SeedableRng; + use x25519_dalek::{PublicKey, StaticSecret}; + + let mut rng = ::from_seed([seed; 32]); + let static_secret_a = StaticSecret::random_from_rng(&mut rng); + let static_secret_b = StaticSecret::random_from_rng(&mut rng); + let public_key_b = PublicKey::from(&static_secret_b); + let shared_secret = static_secret_a.diffie_hellman(&public_key_b); + SessionSharedSecret::new(shared_secret) +} + #[cfg(test)] mod tests { use crate::dkg::session::{ @@ -626,16 +639,17 @@ mod tests { use crate::dkg::{ decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, NonceSize, - ThresholdDecryptionRequest, ThresholdDecryptionResponse, + ThresholdDecryptionRequest, ThresholdDecryptionResponse, create_session_shared_secret_from_seed, }; + #[cfg(feature = "test_vectors")] + use crate::test_vectors::{TestVector, generate_test_vectors}; use crate::{AuthenticatedData, Conditions}; use alloc::boxed::Box; - #[cfg(feature = "deterministic_encryption")] + #[cfg(feature = "test_vectors")] use alloc::format; - #[cfg(feature = "deterministic_encryption")] + #[cfg(feature = "test_vectors")] use alloc::string::String; use alloc::vec; - use alloc::vec::Vec; use core::clone::Clone; use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox}; use generic_array::typenum::Unsigned; @@ -653,15 +667,6 @@ mod tests { ProtocolObjectInner, }; - #[cfg(feature = "deterministic_encryption")] - #[derive(Serialize, Deserialize)] - pub struct TestVector { - pub seed: u8, - pub plaintext: Vec, - pub nonce: [u8; 12], - pub ciphertext: Box<[u8]>, - } - #[test] fn decryption_with_shared_secret() { let service_secret = SessionStaticSecret::random(); @@ -885,56 +890,8 @@ mod tests { .is_err()); } - #[cfg(feature = "deterministic_encryption")] - pub fn generate_test_vectors() -> Vec { - use chacha20poly1305::{AeadCore, ChaCha20Poly1305}; - - let mut test_vectors = Vec::new(); - - // Generate test vectors with different seeds - for seed in 0..3 { - // Generate test plaintexts - let plaintexts = vec![ - b"test data".to_vec(), - b"another test".to_vec(), - b"".to_vec(), // empty string test - ]; - - // Generate ciphertexts for each plaintext - for plaintext in plaintexts { - let session_shared_secret = create_session_shared_secret_from_seed(seed); - - let ciphertext = encrypt_with_shared_secret(&session_shared_secret, &plaintext) - .expect("Encryption failed"); - - // TODO: Note that this seed is currently fixed for all tests, and hence the nonce is also fixed - let rng = ::from_seed([0u8; 32]); - let nonce = ChaCha20Poly1305::generate_nonce(rng); - - test_vectors.push(TestVector { - seed, - plaintext, - nonce: nonce.as_slice().try_into().unwrap(), - ciphertext, - }); - } - } - - test_vectors - } - - #[cfg(feature = "deterministic_encryption")] - pub fn serialize_test_vector_to_json(vector: &TestVector) -> String { - serde_json::to_string(vector).expect("Failed to serialize test vector to JSON") - } - - #[cfg(feature = "deterministic_encryption")] - pub fn deserialize_test_vector_from_json(json: &str) -> TestVector { - serde_json::from_str(json).expect("Failed to deserialize test vector from JSON") - } - #[test] - #[cfg(feature = "deterministic_encryption")] + #[cfg(feature = "test_vectors")] fn test_encryption_deterministic() { use crate::dkg::session::SessionSharedSecret; use rand::rngs::StdRng; @@ -961,22 +918,8 @@ mod tests { assert_eq!(ciphertext1, ciphertext2); } - #[cfg(feature = "deterministic_encryption")] - fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { - use rand::rngs::StdRng; - use rand_core::SeedableRng; - use x25519_dalek::{PublicKey, StaticSecret}; - - let mut rng = ::from_seed([seed; 32]); - let static_secret_a = StaticSecret::random_from_rng(&mut rng); - let static_secret_b = StaticSecret::random_from_rng(&mut rng); - let public_key_b = PublicKey::from(&static_secret_b); - let shared_secret = static_secret_a.diffie_hellman(&public_key_b); - SessionSharedSecret::new(shared_secret) - } - #[test] - #[cfg(feature = "deterministic_encryption")] + #[cfg(feature = "test_vectors")] fn test_encryption_vectors() { let test_vectors = generate_test_vectors(); diff --git a/nucypher-core/src/lib.rs b/nucypher-core/src/lib.rs index da0fb1a..92b0356 100644 --- a/nucypher-core/src/lib.rs +++ b/nucypher-core/src/lib.rs @@ -23,6 +23,8 @@ mod secret_box; mod threshold_message_kit; mod treasure_map; mod versioning; +#[cfg(feature = "test_vectors")] +pub mod test_vectors; /// Error returned by various `verify()` methods in the crate. pub struct VerificationError; @@ -49,6 +51,8 @@ pub use revocation_order::RevocationOrder; pub use threshold_message_kit::ThresholdMessageKit; pub use treasure_map::{EncryptedTreasureMap, TreasureMap}; pub use versioning::ProtocolObject; +#[cfg(feature = "test_vectors")] +pub use test_vectors::{TestVector, generate_test_vectors}; // Re-export umbral_pre so that the users don't have to version-match. pub use umbral_pre; diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs new file mode 100644 index 0000000..4befb6e --- /dev/null +++ b/nucypher-core/src/test_vectors.rs @@ -0,0 +1,93 @@ +//! Module for generating and handling test vectors for encryption/decryption testing. + +use alloc::vec::Vec; +use alloc::string::String; +use serde::{Deserialize, Serialize}; + +use crate::dkg::session::SessionSharedSecret; + +/// A test vector containing all necessary data for encryption/decryption testing. +#[derive(Serialize, Deserialize)] +pub struct TestVector { + /// The seed used to generate the session shared secret + pub seed: u8, + /// The plaintext to be encrypted + pub plaintext: Vec, + /// The nonce used for encryption + pub nonce: [u8; 12], + /// The resulting ciphertext + pub ciphertext: alloc::boxed::Box<[u8]>, +} + +/// Creates a session shared secret from a seed value. +/// +/// This is a helper function used by `generate_test_vectors` to create +/// deterministic session shared secrets for testing. +#[cfg(feature = "test_vectors")] +fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { + use rand::rngs::StdRng; + use rand_core::SeedableRng; + use x25519_dalek::{PublicKey, StaticSecret}; + + let mut rng = ::from_seed([seed; 32]); + let static_secret_a = StaticSecret::random_from_rng(&mut rng); + let static_secret_b = StaticSecret::random_from_rng(&mut rng); + let public_key_b = PublicKey::from(&static_secret_b); + let shared_secret = static_secret_a.diffie_hellman(&public_key_b); + SessionSharedSecret::new(shared_secret) +} + +/// Generates a set of test vectors for encryption/decryption testing. +/// +/// This function creates test vectors with different seeds and plaintexts, +/// encrypting them to produce ciphertexts that can be used for testing. +#[cfg(feature = "test_vectors")] +pub fn generate_test_vectors() -> Vec { + use chacha20poly1305::{AeadCore, ChaCha20Poly1305}; + use rand::rngs::StdRng; + use rand::SeedableRng; + use alloc::vec; + + let mut test_vectors = Vec::new(); + + // Generate test vectors with different seeds + for seed in 0..3 { + // Generate test plaintexts + let plaintexts: Vec> = vec![ + b"test data".to_vec(), + b"another test".to_vec(), + b"".to_vec(), // empty string test + ]; + + // Generate ciphertexts for each plaintext + for plaintext in plaintexts { + let session_shared_secret = create_session_shared_secret_from_seed(seed); + + let ciphertext = crate::dkg::encrypt_with_shared_secret(&session_shared_secret, &plaintext) + .expect("Encryption failed"); + + // TODO: Note that this seed is currently fixed for all tests, and hence the nonce is also fixed + let rng = ::from_seed([0u8; 32]); + let nonce = ChaCha20Poly1305::generate_nonce(rng); + + test_vectors.push(TestVector { + seed, + plaintext, + nonce: nonce.as_slice().try_into().unwrap(), + ciphertext, + }); + } + } + + test_vectors +} + +#[cfg(feature = "test_vectors")] +pub fn serialize_test_vector_to_json(vector: &TestVector) -> String { + serde_json::to_string(vector).expect("Failed to serialize test vector to JSON") +} + +#[cfg(feature = "test_vectors")] +pub fn deserialize_test_vector_from_json(json: &str) -> TestVector { + serde_json::from_str(json).expect("Failed to deserialize test vector from JSON") +} From 1d8814abc778ed912a02795913f405c2dbe15773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 22 Apr 2025 12:31:33 +0200 Subject: [PATCH 16/26] Use serde-encoded-bytes to produce test vectors files in hex format --- Cargo.lock | 11 +++++++++++ nucypher-core/Cargo.toml | 1 + nucypher-core/src/test_vectors.rs | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 1fa28c6..31b6bcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,6 +915,7 @@ dependencies = [ "rand_core 0.6.4", "rmp-serde", "serde", + "serde-encoded-bytes", "serde_json", "serde_with 1.14.0", "sha2", @@ -1319,6 +1320,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-encoded-bytes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71779be2e12f3000185ea21d821c44e7aa9ec1ff0ea8d3155b993fac5c9b170d" +dependencies = [ + "hex", + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.17" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index e1681a2..9808adc 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -14,6 +14,7 @@ umbral-pre = { version = "0.11.0", features = ["serde"] } ferveo = { package = "ferveo-pre-release", version = "0.3.0" } serde = { version = "1", default-features = false, features = ["derive"] } serde_json = "1.0" +serde-encoded-bytes = "0.1" generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" rmp-serde = "1" diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index 4befb6e..7792827 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -3,6 +3,7 @@ use alloc::vec::Vec; use alloc::string::String; use serde::{Deserialize, Serialize}; +use serde_encoded_bytes::{ArrayLike, SliceLike, Hex}; use crate::dkg::session::SessionSharedSecret; @@ -12,10 +13,13 @@ pub struct TestVector { /// The seed used to generate the session shared secret pub seed: u8, /// The plaintext to be encrypted + #[serde(with = "SliceLike::")] pub plaintext: Vec, /// The nonce used for encryption + #[serde(with = "ArrayLike::")] pub nonce: [u8; 12], /// The resulting ciphertext + #[serde(with = "SliceLike::")] pub ciphertext: alloc::boxed::Box<[u8]>, } From 6f3f733be948416fdfac4bf7e1d1e7032fccd114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 22 Apr 2025 12:34:13 +0200 Subject: [PATCH 17/26] Add usage docs and output a single test vector file --- nucypher-core/src/bin/generate_test_vectors.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nucypher-core/src/bin/generate_test_vectors.rs b/nucypher-core/src/bin/generate_test_vectors.rs index 627a89d..717fff2 100644 --- a/nucypher-core/src/bin/generate_test_vectors.rs +++ b/nucypher-core/src/bin/generate_test_vectors.rs @@ -1,7 +1,8 @@ -use nucypher_core::test_vectors::{TestVector, generate_test_vectors}; use std::fs; use std::path::Path; +use nucypher_core::test_vectors::{TestVector, generate_test_vectors}; +// Usage: cargo run --bin generate-test-vectors --features test_vectors deterministic_encryption fn main() { // Generate test vectors let test_vectors: Vec = generate_test_vectors(); @@ -10,12 +11,10 @@ fn main() { let output_dir = Path::new("test_vectors"); fs::create_dir_all(output_dir).expect("Failed to create output directory"); - // Save each test vector to a separate file - for (i, vector) in test_vectors.iter().enumerate() { - let filename = format!("test_vectors/vector_{}.json", i); - let json = serde_json::to_string_pretty(vector).expect("Failed to serialize test vector"); - fs::write(filename, json).expect("Failed to write test vector to file"); - } + // Save all test vectors to a single file + let filename = "test_vectors/encrypt_with_shared_secret.json"; + let json = serde_json::to_string_pretty(&test_vectors).expect("Failed to serialize test vectors"); + fs::write(filename, json).expect("Failed to write test vectors to file"); - println!("Generated {} test vectors in the 'test_vectors' directory", test_vectors.len()); + println!("Generated {} test vectors in '{}'", test_vectors.len(), filename); } \ No newline at end of file From ee1fc6a3d1d166bb753a5e7cbaad567f142179dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 22 Apr 2025 13:08:10 +0200 Subject: [PATCH 18/26] Make deterministic_encryption feature flag NOT a default Also, test vectors require deterministic encryption --- nucypher-core/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 9808adc..f3ba893 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -30,9 +30,9 @@ rand_chacha = "0.3.1" rand = "0.8.5" [features] -default = ["deterministic_encryption"] +default = [] deterministic_encryption = [] -test_vectors = [] +test_vectors = ["deterministic_encryption"] [[bin]] name = "generate-test-vectors" From a2ff4226a040eb9a6c411fb613c8d4a326f4c92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 23 Apr 2025 13:02:49 +0200 Subject: [PATCH 19/26] Fix incorrect feature flag in deterministic encryption test --- nucypher-core/src/dkg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 394f0bf..45d40e2 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -891,7 +891,7 @@ mod tests { } #[test] - #[cfg(feature = "test_vectors")] + #[cfg(feature = "deterministic_encryption")] fn test_encryption_deterministic() { use crate::dkg::session::SessionSharedSecret; use rand::rngs::StdRng; From b350af2fa2c33ac65c57cbe50c7dd258edcbfb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 23 Apr 2025 13:08:31 +0200 Subject: [PATCH 20/26] Apply deterministic feature flag to nonce generation, instead of encryption This is a more surgical approach --- nucypher-core/src/dkg.rs | 22 +++++++++++----------- nucypher-core/src/test_vectors.rs | 3 +-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 45d40e2..42c5afe 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -67,26 +67,26 @@ impl fmt::Display for DecryptionError { type NonceSize = ::NonceSize; -/// Encrypts data using a shared secret with the default OS RNG. #[cfg(not(feature = "deterministic_encryption"))] -pub fn encrypt_with_shared_secret( - shared_secret: &SessionSharedSecret, - plaintext: &[u8], -) -> Result, EncryptionError> { +pub fn generate_encryption_nonce() -> Nonce { use chacha20poly1305::aead::OsRng; - let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); - encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) + ChaCha20Poly1305::generate_nonce(&mut OsRng) } #[cfg(feature = "deterministic_encryption")] +pub fn generate_encryption_nonce() -> Nonce { + use rand::rngs::StdRng; + use rand::SeedableRng; + let rng = ::from_seed([0u8; 32]); // TODO: Note that this seed is currently fixed for all tests + ChaCha20Poly1305::generate_nonce(rng) +} + +/// Encrypts data using a shared secret with the default OS RNG. pub fn encrypt_with_shared_secret( shared_secret: &SessionSharedSecret, plaintext: &[u8], ) -> Result, EncryptionError> { - use rand::rngs::StdRng; - use rand::SeedableRng; - let rng = ::from_seed([0u8; 32]); // TODO: Note that this seed is currently fixed for all tests - let nonce = ChaCha20Poly1305::generate_nonce(rng); + let nonce = generate_encryption_nonce(); encrypt_with_shared_secret_and_nonce(shared_secret, &nonce, plaintext) } diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index 7792827..096594b 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -71,8 +71,7 @@ pub fn generate_test_vectors() -> Vec { .expect("Encryption failed"); // TODO: Note that this seed is currently fixed for all tests, and hence the nonce is also fixed - let rng = ::from_seed([0u8; 32]); - let nonce = ChaCha20Poly1305::generate_nonce(rng); + let nonce = crate::dkg::generate_encryption_nonce(); test_vectors.push(TestVector { seed, From 216deee8a4c0f82b16b99e1ea9d8e8dbb9154f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 23 Apr 2025 13:23:10 +0200 Subject: [PATCH 21/26] Remove duplicate of create_session_shared_secret_from_seed function --- nucypher-core/src/dkg.rs | 17 ++--------------- nucypher-core/src/test_vectors.rs | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 42c5afe..daf2790 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -618,19 +618,6 @@ impl ProtocolObjectInner<'_> for EncryptedThresholdDecryptionResponse { impl ProtocolObject<'_> for EncryptedThresholdDecryptionResponse {} -pub fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { - use rand::rngs::StdRng; - use rand_core::SeedableRng; - use x25519_dalek::{PublicKey, StaticSecret}; - - let mut rng = ::from_seed([seed; 32]); - let static_secret_a = StaticSecret::random_from_rng(&mut rng); - let static_secret_b = StaticSecret::random_from_rng(&mut rng); - let public_key_b = PublicKey::from(&static_secret_b); - let shared_secret = static_secret_a.diffie_hellman(&public_key_b); - SessionSharedSecret::new(shared_secret) -} - #[cfg(test)] mod tests { use crate::dkg::session::{ @@ -639,10 +626,10 @@ mod tests { use crate::dkg::{ decrypt_with_shared_secret, encrypt_with_shared_secret, DecryptionError, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, NonceSize, - ThresholdDecryptionRequest, ThresholdDecryptionResponse, create_session_shared_secret_from_seed, + ThresholdDecryptionRequest, ThresholdDecryptionResponse, }; #[cfg(feature = "test_vectors")] - use crate::test_vectors::{TestVector, generate_test_vectors}; + use crate::test_vectors::{TestVector, create_session_shared_secret_from_seed, generate_test_vectors}; use crate::{AuthenticatedData, Conditions}; use alloc::boxed::Box; #[cfg(feature = "test_vectors")] diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index 096594b..0a5e9e5 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -28,7 +28,7 @@ pub struct TestVector { /// This is a helper function used by `generate_test_vectors` to create /// deterministic session shared secrets for testing. #[cfg(feature = "test_vectors")] -fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { +pub fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { use rand::rngs::StdRng; use rand_core::SeedableRng; use x25519_dalek::{PublicKey, StaticSecret}; From 3ebd016e4f47ce95cbb096b59d362360b01e450b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 23 Apr 2025 16:21:08 +0200 Subject: [PATCH 22/26] Add session shared secret to test vectors --- nucypher-core/src/dkg.rs | 1 + nucypher-core/src/test_vectors.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index daf2790..974e5e6 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -913,6 +913,7 @@ mod tests { // Verify each test vector for vector in test_vectors { let session_shared_secret = create_session_shared_secret_from_seed(vector.seed); + assert_eq!(session_shared_secret.as_ref(), vector.session_shared_secret); // Verify decryption works let decrypted = decrypt_with_shared_secret(&session_shared_secret, &vector.ciphertext) diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index 0a5e9e5..3bd60f5 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -12,6 +12,9 @@ use crate::dkg::session::SessionSharedSecret; pub struct TestVector { /// The seed used to generate the session shared secret pub seed: u8, + /// The session shared secret used for encryption + #[serde(with = "ArrayLike::")] + pub session_shared_secret: [u8; 32], /// The plaintext to be encrypted #[serde(with = "SliceLike::")] pub plaintext: Vec, @@ -75,6 +78,7 @@ pub fn generate_test_vectors() -> Vec { test_vectors.push(TestVector { seed, + session_shared_secret: *session_shared_secret.as_bytes(), plaintext, nonce: nonce.as_slice().try_into().unwrap(), ciphertext, From 93457d2e1b6c93f7e2b061d8153f36522b842167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 24 Apr 2025 16:31:34 +0200 Subject: [PATCH 23/26] Add intermediate static secrets to test vectors --- nucypher-core/src/test_vectors.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index 3bd60f5..b9313bd 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -4,6 +4,7 @@ use alloc::vec::Vec; use alloc::string::String; use serde::{Deserialize, Serialize}; use serde_encoded_bytes::{ArrayLike, SliceLike, Hex}; +use x25519_dalek::StaticSecret; use crate::dkg::session::SessionSharedSecret; @@ -12,6 +13,12 @@ use crate::dkg::session::SessionSharedSecret; pub struct TestVector { /// The seed used to generate the session shared secret pub seed: u8, + /// The static secret A used to generate the session shared secret + #[serde(with = "ArrayLike::")] + pub static_secret_a: [u8; 32], + /// The static secret B used to generate the session shared secret + #[serde(with = "ArrayLike::")] + pub static_secret_b: [u8; 32], /// The session shared secret used for encryption #[serde(with = "ArrayLike::")] pub session_shared_secret: [u8; 32], @@ -32,14 +39,24 @@ pub struct TestVector { /// deterministic session shared secrets for testing. #[cfg(feature = "test_vectors")] pub fn create_session_shared_secret_from_seed(seed: u8) -> SessionSharedSecret { + let (static_secret_a, static_secret_b) = create_static_secrets_from_seed(seed); + create_session_shared_secret_from_static_secrets(&static_secret_a, &static_secret_b) +} + +pub fn create_static_secrets_from_seed(seed: u8) -> (StaticSecret, StaticSecret) { use rand::rngs::StdRng; use rand_core::SeedableRng; - use x25519_dalek::{PublicKey, StaticSecret}; let mut rng = ::from_seed([seed; 32]); let static_secret_a = StaticSecret::random_from_rng(&mut rng); let static_secret_b = StaticSecret::random_from_rng(&mut rng); - let public_key_b = PublicKey::from(&static_secret_b); + (static_secret_a, static_secret_b) +} + +pub fn create_session_shared_secret_from_static_secrets(static_secret_a: &StaticSecret, static_secret_b: &StaticSecret) -> SessionSharedSecret { + use x25519_dalek::PublicKey; + + let public_key_b = PublicKey::from(static_secret_b); let shared_secret = static_secret_a.diffie_hellman(&public_key_b); SessionSharedSecret::new(shared_secret) } @@ -68,8 +85,8 @@ pub fn generate_test_vectors() -> Vec { // Generate ciphertexts for each plaintext for plaintext in plaintexts { - let session_shared_secret = create_session_shared_secret_from_seed(seed); - + let (static_secret_a, static_secret_b) = create_static_secrets_from_seed(seed); + let session_shared_secret = create_session_shared_secret_from_static_secrets(&static_secret_a, &static_secret_b); let ciphertext = crate::dkg::encrypt_with_shared_secret(&session_shared_secret, &plaintext) .expect("Encryption failed"); @@ -78,6 +95,8 @@ pub fn generate_test_vectors() -> Vec { test_vectors.push(TestVector { seed, + static_secret_a: static_secret_a.to_bytes(), + static_secret_b: static_secret_b.to_bytes(), session_shared_secret: *session_shared_secret.as_bytes(), plaintext, nonce: nonce.as_slice().try_into().unwrap(), From 8a8992dcd2ee4f4a011eea9a6be9029f169ecc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 24 Apr 2025 16:48:17 +0200 Subject: [PATCH 24/26] Cleaning --- nucypher-core/src/dkg.rs | 1 - nucypher-core/src/test_vectors.rs | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 974e5e6..d160bae 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -9,7 +9,6 @@ use ferveo::api::{CiphertextHeader, FerveoVariant}; use generic_array::typenum::Unsigned; use rand_core::{CryptoRng, RngCore}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use serde_json; use umbral_pre::serde_bytes; // TODO should this be in umbral? use crate::access_control::AccessControlPolicy; diff --git a/nucypher-core/src/test_vectors.rs b/nucypher-core/src/test_vectors.rs index b9313bd..d1b4418 100644 --- a/nucypher-core/src/test_vectors.rs +++ b/nucypher-core/src/test_vectors.rs @@ -1,7 +1,6 @@ //! Module for generating and handling test vectors for encryption/decryption testing. use alloc::vec::Vec; -use alloc::string::String; use serde::{Deserialize, Serialize}; use serde_encoded_bytes::{ArrayLike, SliceLike, Hex}; use x25519_dalek::StaticSecret; @@ -68,8 +67,6 @@ pub fn create_session_shared_secret_from_static_secrets(static_secret_a: &Static #[cfg(feature = "test_vectors")] pub fn generate_test_vectors() -> Vec { use chacha20poly1305::{AeadCore, ChaCha20Poly1305}; - use rand::rngs::StdRng; - use rand::SeedableRng; use alloc::vec; let mut test_vectors = Vec::new(); @@ -107,13 +104,3 @@ pub fn generate_test_vectors() -> Vec { test_vectors } - -#[cfg(feature = "test_vectors")] -pub fn serialize_test_vector_to_json(vector: &TestVector) -> String { - serde_json::to_string(vector).expect("Failed to serialize test vector to JSON") -} - -#[cfg(feature = "test_vectors")] -pub fn deserialize_test_vector_from_json(json: &str) -> TestVector { - serde_json::from_str(json).expect("Failed to deserialize test vector from JSON") -} From 9e85d8b078d64bff0ea83c070e84bc1f791e9138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 24 Apr 2025 17:41:55 +0200 Subject: [PATCH 25/26] First test vector file for encrypt_with_shared_secret --- test_vectors/encrypt_with_shared_secret.json | 83 ++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test_vectors/encrypt_with_shared_secret.json diff --git a/test_vectors/encrypt_with_shared_secret.json b/test_vectors/encrypt_with_shared_secret.json new file mode 100644 index 0000000..0436acd --- /dev/null +++ b/test_vectors/encrypt_with_shared_secret.json @@ -0,0 +1,83 @@ +[ + { + "seed": 0, + "static_secret_a": "0x9bf49a6a0755f953811fce125f2683d50429c3bb49e074147e0089a52eae155f", + "static_secret_b": "0x0564f879d27ae3c02ce82834acfa8c793a629f2ca0de6919610be82f411326be", + "session_shared_secret": "0x1bb24dc4a7b287dc164c076b0c6e4fa97496f3bacfdef283acb3bb5415fd9323", + "plaintext": "0x746573742064617461", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce12d3fd8c12f86d23c407d35ddf21b5413541568842ea713d6351" + }, + { + "seed": 0, + "static_secret_a": "0x9bf49a6a0755f953811fce125f2683d50429c3bb49e074147e0089a52eae155f", + "static_secret_b": "0x0564f879d27ae3c02ce82834acfa8c793a629f2ca0de6919610be82f411326be", + "session_shared_secret": "0x1bb24dc4a7b287dc164c076b0c6e4fa97496f3bacfdef283acb3bb5415fd9323", + "plaintext": "0x616e6f746865722074657374", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce12c6f69012b06c309012a17c25c6766f3848fe40286ded1e0d48beac5f" + }, + { + "seed": 0, + "static_secret_a": "0x9bf49a6a0755f953811fce125f2683d50429c3bb49e074147e0089a52eae155f", + "static_secret_b": "0x0564f879d27ae3c02ce82834acfa8c793a629f2ca0de6919610be82f411326be", + "session_shared_secret": "0x1bb24dc4a7b287dc164c076b0c6e4fa97496f3bacfdef283acb3bb5415fd9323", + "plaintext": "0x", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce127222c41434c21f6737aa82689e28832e" + }, + { + "seed": 1, + "static_secret_a": "0x3301e8d7e754db2cf57b0a4ca73f253c7053ad2bc5398777ba039b258e59ad9d", + "static_secret_b": "0xff0e2c7652187dadf95a37b6c44327c0d2bab5ba3820f0f8984fbf706fa43549", + "session_shared_secret": "0x8b28582ec96d705df06c6ef9c42cb7182c28eec23b6539bed22afdb3f3711119", + "plaintext": "0x746573742064617461", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce128985434ebcba938f308ba9c8b9001cce59abcdb2103c030f83" + }, + { + "seed": 1, + "static_secret_a": "0x3301e8d7e754db2cf57b0a4ca73f253c7053ad2bc5398777ba039b258e59ad9d", + "static_secret_b": "0xff0e2c7652187dadf95a37b6c44327c0d2bab5ba3820f0f8984fbf706fa43549", + "session_shared_secret": "0x8b28582ec96d705df06c6ef9c42cb7182c28eec23b6539bed22afdb3f3711119", + "plaintext": "0x616e6f746865722074657374", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce129c8e5f4ef4bb80db250085f6b9cc44bf1d7c4643a6f7172bb3ae0fbf" + }, + { + "seed": 1, + "static_secret_a": "0x3301e8d7e754db2cf57b0a4ca73f253c7053ad2bc5398777ba039b258e59ad9d", + "static_secret_b": "0xff0e2c7652187dadf95a37b6c44327c0d2bab5ba3820f0f8984fbf706fa43549", + "session_shared_secret": "0x8b28582ec96d705df06c6ef9c42cb7182c28eec23b6539bed22afdb3f3711119", + "plaintext": "0x", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce12b745e54e02f0300f6bb5a7ec998f31fc" + }, + { + "seed": 2, + "static_secret_a": "0x462b6207545181dbd3adc8708af35b4ddb04168a80e920a9538988ec92f1f286", + "static_secret_b": "0x17c4ed47226fe5ff0e3b10510ad1d9bdccdcecf1d01b3ce8ccbaa6203b3c1b43", + "session_shared_secret": "0xdf0392ea39a9eb8dea083824d59f1b8b6259bd68c5ffe622e66ea1c1b2e05929", + "plaintext": "0x746573742064617461", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce121a57b7eaa713ba326af21d5b55067c2ade63002c6cc8b7f190" + }, + { + "seed": 2, + "static_secret_a": "0x462b6207545181dbd3adc8708af35b4ddb04168a80e920a9538988ec92f1f286", + "static_secret_b": "0x17c4ed47226fe5ff0e3b10510ad1d9bdccdcecf1d01b3ce8ccbaa6203b3c1b43", + "session_shared_secret": "0xdf0392ea39a9eb8dea083824d59f1b8b6259bd68c5ffe622e66ea1c1b2e05929", + "plaintext": "0x616e6f746865722074657374", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce120f5cabeaef12a9667f60615cece7fe09380bc67d9c61dc6f7c52b975" + }, + { + "seed": 2, + "static_secret_a": "0x462b6207545181dbd3adc8708af35b4ddb04168a80e920a9538988ec92f1f286", + "static_secret_b": "0x17c4ed47226fe5ff0e3b10510ad1d9bdccdcecf1d01b3ce8ccbaa6203b3c1b43", + "session_shared_secret": "0xdf0392ea39a9eb8dea083824d59f1b8b6259bd68c5ffe622e66ea1c1b2e05929", + "plaintext": "0x", + "nonce": "0x9bf49a6a0755f953811fce12", + "ciphertext": "0x9bf49a6a0755f953811fce125daf0633fcaf1e274b6c665bf0abe255" + } +] \ No newline at end of file From eab5a03320aa98d335f39219886dc6a4e22a9210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 24 Apr 2025 18:11:14 +0200 Subject: [PATCH 26/26] Change Cargo.lock version to 3 to fix CI errors --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 31b6bcc..b9db596 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "aead"