From 49a827a1fb208f4dec70d9658f4ea8d0bd85e373 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 21 Feb 2024 13:19:11 -0800 Subject: [PATCH] Update crypto_box and tiny-bip39 to the latest version The goal is to have only one version of `rand` and `rand_core` in our dependency tree. --- Cargo.lock | 281 +++++++++++-------------------- ironfish-rust-nodejs/src/nacl.rs | 4 +- ironfish-rust/Cargo.toml | 4 +- ironfish-rust/src/nacl.rs | 19 +-- 4 files changed, 107 insertions(+), 201 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 438c87978b..2d27ee82dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,7 +137,7 @@ dependencies = [ "log", "num_cpus", "pairing 0.22.0", - "rand_core 0.6.4", + "rand_core", "rayon", "subtle", ] @@ -160,8 +160,8 @@ dependencies = [ "log", "memmap2", "pairing 0.22.0", - "rand 0.8.5", - "rand_core 0.6.4", + "rand", + "rand_core", "rayon", "rustversion", "serde", @@ -194,7 +194,7 @@ checksum = "d0830ae4cc96b0617cc912970c2b17e89456fecbf55e8eed53a956f37ab50c41" dependencies = [ "hmac 0.11.0", "pbkdf2 0.9.0", - "rand 0.8.5", + "rand", "sha2 0.9.9", "unicode-normalization", "zeroize", @@ -311,7 +311,7 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "pairing 0.22.0", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -322,7 +322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ "ff 0.13.0", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -350,7 +350,7 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "pairing 0.22.0", - "rand_core 0.6.4", + "rand_core", "serde", "subtle", ] @@ -685,42 +685,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "typenum", ] [[package]] name = "crypto-mac" -version = "0.8.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ "generic-array", "subtle", ] [[package]] -name = "crypto-mac" -version = "0.11.1" +name = "crypto_box" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "16182b4f39a82ec8a6851155cc4c0cda3065bb1db33651726a29e1951de0f009" dependencies = [ - "generic-array", + "aead 0.5.2", + "crypto_secretbox", + "curve25519-dalek", + "salsa20", "subtle", + "zeroize", ] [[package]] -name = "crypto_box" -version = "0.8.2" +name = "crypto_secretbox" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd26c32de5307fd08aac445a75c43472b14559d5dccdfba8022dbcd075838ebc" +checksum = "b9d6cf87adf719ddf43a805e92c6870a531aedda35ff640442cbaf8674e141e1" dependencies = [ "aead 0.5.2", - "chacha20 0.9.1", - "chacha20poly1305 0.10.1", + "cipher 0.4.4", + "generic-array", + "poly1305 0.8.0", "salsa20", - "x25519-dalek 1.1.1", - "xsalsa20poly1305", + "subtle", "zeroize", ] @@ -734,19 +738,6 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" version = "4.0.0" @@ -895,9 +886,9 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" dependencies = [ - "curve25519-dalek 4.0.0", + "curve25519-dalek", "ed25519", - "rand_core 0.6.4", + "rand_core", "serde", "sha2 0.10.6", "subtle", @@ -1007,7 +998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "bitvec", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1017,7 +1008,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1104,7 +1095,7 @@ dependencies = [ "hex", "itertools 0.12.0", "postcard", - "rand_core 0.6.4", + "rand_core", "serde", "serdect", "thiserror", @@ -1121,7 +1112,7 @@ dependencies = [ "derive-getters", "document-features", "frost-core", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1180,25 +1171,13 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", + "zeroize", ] [[package]] @@ -1209,7 +1188,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -1225,8 +1204,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff 0.12.1", - "rand 0.8.5", - "rand_core 0.6.4", + "rand", + "rand_core", "rand_xorshift", "subtle", ] @@ -1238,7 +1217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.0", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1280,7 +1259,7 @@ dependencies = [ "halo2_proofs", "lazy_static", "pasta_curves 0.4.1", - "rand 0.8.5", + "rand", "subtle", "uint", ] @@ -1295,7 +1274,7 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "pasta_curves 0.4.1", - "rand_core 0.6.4", + "rand_core", "rayon", "tracing", ] @@ -1378,22 +1357,21 @@ dependencies = [ [[package]] name = "hmac" -version = "0.8.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac 0.8.0", + "crypto-mac", "digest 0.9.0", ] [[package]] name = "hmac" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "crypto-mac 0.11.1", - "digest 0.9.0", + "digest 0.10.6", ] [[package]] @@ -1533,7 +1511,7 @@ dependencies = [ "jubjub 0.9.0 (git+https://github.com/iron-fish/jubjub.git?branch=blstrs)", "lazy_static", "libc", - "rand 0.8.5", + "rand", "reqwest", "sha2 0.10.6", "tiny-bip39", @@ -1550,10 +1528,10 @@ dependencies = [ "chacha20poly1305 0.10.1", "ed25519-dalek", "once_cell", - "rand_chacha 0.3.1", - "rand_core 0.6.4", + "rand_chacha", + "rand_core", "reddsa 0.5.1", - "x25519-dalek 2.0.0", + "x25519-dalek", ] [[package]] @@ -1567,8 +1545,8 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "pairing 0.22.0", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rayon", ] @@ -1585,7 +1563,7 @@ dependencies = [ "napi", "napi-build", "napi-derive", - "rand 0.8.5", + "rand", ] [[package]] @@ -1598,8 +1576,8 @@ dependencies = [ "ironfish-phase2", "ironfish_zkp", "pairing 0.23.0", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_seeder", ] @@ -1615,7 +1593,7 @@ dependencies = [ "group 0.12.1", "jubjub 0.9.0 (git+https://github.com/iron-fish/jubjub.git?branch=blstrs)", "lazy_static", - "rand 0.8.5", + "rand", "zcash_primitives", "zcash_proofs", ] @@ -1663,7 +1641,7 @@ dependencies = [ "bls12_381 0.7.1", "ff 0.12.1", "group 0.12.1", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1678,7 +1656,7 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "lazy_static", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1692,7 +1670,7 @@ dependencies = [ "bls12_381 0.8.0", "ff 0.13.0", "group 0.13.0", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1801,7 +1779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -2008,7 +1986,7 @@ dependencies = [ "memuse", "nonempty", "pasta_curves 0.4.1", - "rand 0.8.5", + "rand", "reddsa 0.3.0", "serde", "subtle", @@ -2047,7 +2025,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" dependencies = [ "base64ct", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2061,7 +2039,7 @@ dependencies = [ "ff 0.12.1", "group 0.12.1", "lazy_static", - "rand 0.8.5", + "rand", "static_assertions", "subtle", ] @@ -2074,28 +2052,28 @@ checksum = "7c5d606dd609c7529139cd890a365974e61d9deb62df02570b0c2ab3afbc615a" dependencies = [ "ff 0.13.0", "group 0.13.0", - "rand 0.8.5", + "rand", "static_assertions", "subtle", ] [[package]] name = "pbkdf2" -version = "0.4.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" dependencies = [ - "crypto-mac 0.8.0", + "crypto-mac", + "password-hash", ] [[package]] name = "pbkdf2" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "crypto-mac 0.11.1", - "password-hash", + "digest 0.10.6", ] [[package]] @@ -2244,19 +2222,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -2264,18 +2229,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -2285,16 +2240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -2303,16 +2249,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -2321,7 +2258,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf2890aaef0aa82719a50e808de264f9484b74b442e1a3a0e5ee38243ac40bdb" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2330,7 +2267,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2366,7 +2303,7 @@ dependencies = [ "group 0.12.1", "jubjub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pasta_curves 0.4.1", - "rand_core 0.6.4", + "rand_core", "serde", "thiserror", "zeroize", @@ -2384,7 +2321,7 @@ dependencies = [ "hex", "jubjub 0.10.0", "pasta_curves 0.5.0", - "rand_core 0.6.4", + "rand_core", "serde", "thiserror", "zeroize", @@ -2400,7 +2337,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "jubjub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.6.4", + "rand_core", "serde", "thiserror", "zeroize", @@ -2430,7 +2367,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", + "getrandom", "redox_syscall 0.2.16", "thiserror", ] @@ -2820,17 +2757,17 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.8.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" dependencies = [ "anyhow", - "hmac 0.8.1", + "hmac 0.12.1", "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", + "pbkdf2 0.11.0", + "rand", "rustc-hash", - "sha2 0.9.9", + "sha2 0.10.6", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -3080,12 +3017,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3351,42 +3282,18 @@ dependencies = [ "tap", ] -[[package]] -name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.5.1", - "zeroize", -] - [[package]] name = "x25519-dalek" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 4.0.0", - "rand_core 0.6.4", + "curve25519-dalek", + "rand_core", "serde", "zeroize", ] -[[package]] -name = "xsalsa20poly1305" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a6dad357567f81cd78ee75f7c61f1b30bb2fe4390be8fb7c69e2ac8dffb6c7" -dependencies = [ - "aead 0.5.2", - "poly1305 0.8.0", - "salsa20", - "subtle", - "zeroize", -] - [[package]] name = "xxhash-rust" version = "0.8.6" @@ -3431,7 +3338,7 @@ checksum = "33f84ae538f05a8ac74c82527f06b77045ed9553a0871d9db036166a4c344e3a" dependencies = [ "chacha20 0.8.2", "chacha20poly1305 0.9.1", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -3442,7 +3349,7 @@ source = "git+https://github.com/iron-fish/librustzcash.git?branch=blstrs#d55182 dependencies = [ "chacha20 0.8.2", "chacha20poly1305 0.9.1", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -3470,8 +3377,8 @@ dependencies = [ "memuse", "nonempty", "orchard", - "rand 0.8.5", - "rand_core 0.6.4", + "rand", + "rand_core", "sha2 0.9.9", "subtle", "zcash_address", @@ -3493,7 +3400,7 @@ dependencies = [ "group 0.12.1", "jubjub 0.9.0 (git+https://github.com/iron-fish/jubjub.git?branch=blstrs)", "lazy_static", - "rand_core 0.6.4", + "rand_core", "redjubjub", "tracing", "zcash_primitives", diff --git a/ironfish-rust-nodejs/src/nacl.rs b/ironfish-rust-nodejs/src/nacl.rs index bb611cafd8..91ff5ee9c0 100644 --- a/ironfish-rust-nodejs/src/nacl.rs +++ b/ironfish-rust-nodejs/src/nacl.rs @@ -32,7 +32,7 @@ impl BoxKeyPair { BoxKeyPair { public_key: secret_key.public_key().as_bytes().to_vec(), - secret_key: secret_key.as_bytes().to_vec(), + secret_key: secret_key.to_bytes().to_vec(), } } @@ -45,7 +45,7 @@ impl BoxKeyPair { Ok(BoxKeyPair { public_key: secret_key.public_key().as_bytes().to_vec(), - secret_key: secret_key.as_bytes().to_vec(), + secret_key: secret_key.to_bytes().to_vec(), }) } diff --git a/ironfish-rust/Cargo.toml b/ironfish-rust/Cargo.toml index 5795c19f2d..593487bf41 100644 --- a/ironfish-rust/Cargo.toml +++ b/ironfish-rust/Cargo.toml @@ -39,7 +39,7 @@ blake3 = "1.5.0" blstrs = { version = "0.6.0", features = ["portable"] } byteorder = "1.4.3" chacha20poly1305 = "0.9.0" -crypto_box = { version = "0.8", features = ["std"] } +crypto_box = { version = "0.9", features = ["std"] } ff = "0.12.0" group = "0.12.0" ironfish-frost = { git = "https://github.com/iron-fish/ironfish-frost.git", branch = "main" } @@ -49,7 +49,7 @@ jubjub = { git = "https://github.com/iron-fish/jubjub.git", branch = "blstrs" } lazy_static = "1.4.0" libc = "0.2.126" # sub-dependency that needs a pinned version until a new release of cpufeatures: https://github.com/RustCrypto/utils/pull/789 rand = "0.8.5" -tiny-bip39 = "0.8" +tiny-bip39 = "1.0" xxhash-rust = { version = "0.8.5", features = ["xxh3"] } [dev-dependencies] diff --git a/ironfish-rust/src/nacl.rs b/ironfish-rust/src/nacl.rs index 42a3d17d4c..ad69500035 100644 --- a/ironfish-rust/src/nacl.rs +++ b/ironfish-rust/src/nacl.rs @@ -4,10 +4,9 @@ use crypto_box::{ aead::{generic_array::GenericArray, Aead, AeadCore}, - rand_core::OsRng, PublicKey, SalsaBox, SecretKey, }; -use rand::RngCore; +use rand::{rngs::OsRng, RngCore}; use crate::errors::{IronfishError, IronfishErrorKind}; @@ -15,7 +14,7 @@ pub const KEY_LENGTH: usize = crypto_box::KEY_SIZE; pub const NONCE_LENGTH: usize = 24; pub fn new_secret_key() -> SecretKey { - let mut rng = crypto_box::rand_core::OsRng; + let mut rng = OsRng; SecretKey::generate(&mut rng) } @@ -79,9 +78,9 @@ mod test { #[test] fn test_secret_key() { let key = new_secret_key(); - let key2 = bytes_to_secret_key(*key.as_bytes()); + let key2 = bytes_to_secret_key(key.to_bytes()); - assert_eq!(key.as_bytes(), key2.as_bytes()); + assert_eq!(key.to_bytes(), key2.to_bytes()); } #[test] @@ -111,22 +110,22 @@ mod test { let secret3 = new_secret_key(); let (nonce, boxed_message) = - box_message(plaintext.clone(), *secret1.as_bytes(), *public2.as_bytes()) + box_message(plaintext.clone(), secret1.to_bytes(), public2.to_bytes()) .expect("Can box message"); let unboxed_message = unbox_message( &boxed_message, &nonce, - *public1.as_bytes(), - *secret2.as_bytes(), + public1.to_bytes(), + secret2.to_bytes(), ) .expect("Can unbox message"); let failed_unbox = unbox_message( &boxed_message, &nonce, - *public1.as_bytes(), - *secret3.as_bytes(), + public1.to_bytes(), + secret3.to_bytes(), ); assert_eq!(plaintext, unboxed_message);