From ddbda1a37620cc37607d87179269c63ba62094c4 Mon Sep 17 00:00:00 2001 From: Alekos Filini Date: Wed, 13 Mar 2024 15:09:23 +0100 Subject: [PATCH] Update dependencies, run `cargo fmt` --- Cargo.lock | 121 ++++---- README.md | 2 +- dummy-uniffi/src/lib.rs | 8 +- emulator/build.rs | 8 +- emulator/src/bin/gui.rs | 8 +- emulator/src/gui.rs | 10 +- emulator/src/lib.rs | 8 +- emulator/src/link.rs | 8 +- emulator/src/tests/bitcoin.rs | 8 +- emulator/src/tests/init.rs | 8 +- emulator/src/tests/mod.rs | 11 +- emulator/src/utils/mod.rs | 8 +- emulator/src/utils/model.rs | 8 +- emulator/src/utils/report.rs | 8 +- fetch-git-hash/src/lib.rs | 8 +- firmware/Cargo.lock | 358 +++++++++++++----------- firmware/Cargo.toml | 39 +-- firmware/build.rs | 10 +- firmware/linker-scripts/device/memory.x | 4 +- firmware/src/config.rs | 8 +- firmware/src/emulator/config.rs | 8 +- firmware/src/emulator/hw.rs | 10 +- firmware/src/emulator/mod.rs | 8 +- firmware/src/error.rs | 18 +- firmware/src/handlers/bitcoin.rs | 31 +- firmware/src/handlers/fwupdate.rs | 16 +- firmware/src/handlers/idle.rs | 8 +- firmware/src/handlers/init.rs | 12 +- firmware/src/handlers/mod.rs | 8 +- firmware/src/hw/mod.rs | 8 +- firmware/src/hw/nt3h.rs | 37 ++- firmware/src/hw/tsc.rs | 8 +- firmware/src/hw_common.rs | 8 +- firmware/src/main.rs | 17 +- functional-test-wrapper/src/lib.rs | 8 +- gui/src/bin/simulator.rs | 8 +- gui/src/lib.rs | 8 +- model/Cargo.toml | 12 +- model/src/emulator.rs | 8 +- model/src/encryption.rs | 12 +- model/src/lib.rs | 32 +-- model/src/reg.rs | 8 +- model/src/write_buffer.rs | 8 +- sdk/src/bin/cli.rs | 8 +- sdk/src/bin/pcsc.rs | 8 +- sdk/src/bin/uniffi-bindgen.rs | 8 +- sdk/src/inner_logic.rs | 8 +- sdk/src/lib.rs | 27 +- shell.nix | 4 +- 49 files changed, 538 insertions(+), 477 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1267b48..77d6b32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,30 +31,30 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] [[package]] name = "aes" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "opaque-debug", ] [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", "aes", @@ -64,12 +64,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - [[package]] name = "aho-corasick" version = "1.0.2" @@ -385,34 +379,47 @@ dependencies = [ [[package]] name = "bip39" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ - "bitcoin_hashes", - "rand_core 0.4.2", + "bitcoin_hashes 0.11.0", ] [[package]] name = "bitcoin" -version = "0.29.2" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" +checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" dependencies = [ "bech32", - "bitcoin_hashes", + "bitcoin-private", + "bitcoin_hashes 0.12.0", "core2", - "hashbrown", + "hex_lit", "secp256k1", "serde", ] +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + [[package]] name = "bitcoin_hashes" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" + +[[package]] +name = "bitcoin_hashes" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" dependencies = [ + "bitcoin-private", "core2", "serde", ] @@ -532,11 +539,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] @@ -704,9 +712,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ "cipher", ] @@ -1051,9 +1059,9 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" dependencies = [ "opaque-debug", "polyval", @@ -1127,16 +1135,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hashbrown" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "ahash", - "autocfg", -] - [[package]] name = "heck" version = "0.4.1" @@ -1149,6 +1147,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +[[package]] +name = "hex_lit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" + [[package]] name = "humantime" version = "2.1.0" @@ -1174,6 +1178,15 @@ dependencies = [ "tiff", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1348,9 +1361,9 @@ dependencies = [ [[package]] name = "minicbor" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d15f4203d71fdf90903c2696e55426ac97a363c67b218488a73b534ce7aca10" +checksum = "a3d732cecc693ad7c5ea353198182ff4d9bf92428af793c411102b175855ab04" dependencies = [ "minicbor-derive", ] @@ -1475,18 +1488,18 @@ dependencies = [ [[package]] name = "noise-protocol" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb474d36dfe51bb4d7e733fee2b0dfd92ee1b95c716030a70e92737dea1a52b" +checksum = "2473d39689a839f5a363aaef7d99f76d5611bf352286682b25a6644fec18b1d3" dependencies = [ "arrayvec", ] [[package]] name = "noise-rust-crypto" -version = "0.5.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e7cfeb8e6a63b4a5ccef34ed7a22d084a129b1e53a000c080bbc54c0da6f8c" +checksum = "b4c6159f60beb3bbbcdc266bc789bfc6c37fdad7d7ca7152d3e049ef5af633f0" dependencies = [ "aes-gcm", "noise-protocol", @@ -1762,9 +1775,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ "cfg-if", "cpufeatures", @@ -2087,20 +2100,20 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.3" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ - "bitcoin_hashes", + "bitcoin_hashes 0.12.0", "secp256k1-sys", "serde", ] [[package]] name = "secp256k1-sys" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" dependencies = [ "cc", ] @@ -2538,11 +2551,11 @@ dependencies = [ [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] diff --git a/README.md b/README.md index 4b3ad9f..e63b92a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This command should first compile the emulator, then the firmware, and then laun The dependencies you'll need are: -* **nightly** `cargo` with both the native (local) and `thumbv7em-none-eabihf` targets installed +* `cargo` (ideally >= 1.76) with both the native (local) and `thumbv7em-none-eabihf` targets installed * The C toolchain for ARM-v7 (`arm-none-eabi-*`) * `qemu-system-arm` to emulate the firmware * FLTK to run the emulator GUI diff --git a/dummy-uniffi/src/lib.rs b/dummy-uniffi/src/lib.rs index 5f29466..1f3528d 100644 --- a/dummy-uniffi/src/lib.rs +++ b/dummy-uniffi/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/build.rs b/emulator/build.rs index 6006d89..0650098 100644 --- a/emulator/build.rs +++ b/emulator/build.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/bin/gui.rs b/emulator/src/bin/gui.rs index a35f7ad..fcb1248 100644 --- a/emulator/src/bin/gui.rs +++ b/emulator/src/bin/gui.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/gui.rs b/emulator/src/gui.rs index f32241a..cbec100 100644 --- a/emulator/src/gui.rs +++ b/emulator/src/gui.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -181,7 +181,7 @@ pub fn init_gui( .send(format!("> DisplayAddress({})", value)) .unwrap(); match sdk_cloned.display_address(value).await { - Ok(v) => log_cloned.send(format!("< {}", v)).unwrap(), + Ok(v) => log_cloned.send(format!("< {:?}", v)).unwrap(), Err(e) => log::warn!("Display addr err: {:?}", e), } }); diff --git a/emulator/src/lib.rs b/emulator/src/lib.rs index af3b3c4..1719768 100644 --- a/emulator/src/lib.rs +++ b/emulator/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/link.rs b/emulator/src/link.rs index c82c7cb..b2e28b0 100644 --- a/emulator/src/link.rs +++ b/emulator/src/link.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/tests/bitcoin.rs b/emulator/src/tests/bitcoin.rs index 0323086..90709fe 100644 --- a/emulator/src/tests/bitcoin.rs +++ b/emulator/src/tests/bitcoin.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/tests/init.rs b/emulator/src/tests/init.rs index 70b6354..f4d3d8c 100644 --- a/emulator/src/tests/init.rs +++ b/emulator/src/tests/init.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/tests/mod.rs b/emulator/src/tests/mod.rs index e89d3ba..697893b 100644 --- a/emulator/src/tests/mod.rs +++ b/emulator/src/tests/mod.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -139,8 +139,7 @@ async fn run_script( } let actual_fb = emulator.display.to_rgb_output_image(&output_settings); - if actual_fb.as_image_buffer().as_raw().deref() == expected_fb.as_raw().deref() - { + if actual_fb.as_image_buffer().as_raw() == &expected_fb.as_raw().deref() { break None; } diff --git a/emulator/src/utils/mod.rs b/emulator/src/utils/mod.rs index 8d5a1c7..ba26342 100644 --- a/emulator/src/utils/mod.rs +++ b/emulator/src/utils/mod.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/utils/model.rs b/emulator/src/utils/model.rs index 0e22e56..d2f0bcd 100644 --- a/emulator/src/utils/model.rs +++ b/emulator/src/utils/model.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/emulator/src/utils/report.rs b/emulator/src/utils/report.rs index b0bae5f..6f912d4 100644 --- a/emulator/src/utils/report.rs +++ b/emulator/src/utils/report.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/fetch-git-hash/src/lib.rs b/fetch-git-hash/src/lib.rs index de987dd..f8a0798 100644 --- a/fetch-git-hash/src/lib.rs +++ b/fetch-git-hash/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/Cargo.lock b/firmware/Cargo.lock index fdb5717..e90437f 100644 --- a/firmware/Cargo.lock +++ b/firmware/Cargo.lock @@ -4,30 +4,30 @@ version = 3 [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] [[package]] name = "aes" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "opaque-debug", ] [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", "aes", @@ -37,12 +37,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - [[package]] name = "ahash" version = "0.7.6" @@ -60,15 +54,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "atomic-polyfill" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" -dependencies = [ - "critical-section", -] - [[package]] name = "atomic-polyfill" version = "1.0.3" @@ -107,8 +92,7 @@ checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" [[package]] name = "bdk" -version = "1.0.0-alpha.1" -source = "git+https://github.com/afilini/bdk.git?rev=ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64#ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64" +version = "1.0.0-alpha.7" dependencies = [ "bdk_chain", "bip39", @@ -123,8 +107,7 @@ dependencies = [ [[package]] name = "bdk_chain" -version = "0.5.0" -source = "git+https://github.com/afilini/bdk.git?rev=ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64#ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64" +version = "0.11.0" dependencies = [ "bitcoin", "miniscript", @@ -139,33 +122,39 @@ checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "bip39" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28" +version = "2.0.0" +source = "git+https://github.com/rust-bitcoin/rust-bip39.git?rev=a84eb0012e7caaef8f82a66de0da00b31d007725#a84eb0012e7caaef8f82a66de0da00b31d007725" dependencies = [ "bitcoin_hashes", - "rand_core 0.4.2", ] [[package]] name = "bitcoin" -version = "0.29.2" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" +checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" dependencies = [ "bech32", + "bitcoin-private", "bitcoin_hashes", "core2", - "hashbrown 0.8.2", + "hex_lit", "secp256k1", "serde", ] +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + [[package]] name = "bitcoin_hashes" -version = "0.11.0" -source = "git+https://github.com/afilini/bitcoin_hashes.git?rev=09580b264184da514ccc1954c768530132753b8d#09580b264184da514ccc1954c768530132753b8d" +version = "0.12.0" +source = "git+https://github.com/afilini/rust-bitcoin.git?rev=4ade866918522ab6c33950a9941e6fee8ed24ec4#4ade866918522ab6c33950a9941e6fee8ed24ec4" dependencies = [ + "bitcoin-private", "core2", "serde", ] @@ -182,12 +171,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - [[package]] name = "bumpalo" version = "3.13.0" @@ -200,7 +183,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b13b4b2ea9ab2ba924063ebb86ad895cb79f4a79bf90f27949eb20c335b30f9" dependencies = [ - "bitflags 1.3.2", + "bitflags", "nb 1.1.0", "vcell", ] @@ -240,11 +223,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] @@ -276,7 +260,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88c26033fe85d2c5f45a173a6dadf710db4a72eb7da81dbfb795d8d9ebfaaca7" dependencies = [ "cortex-m", - "cortex-m-semihosting 0.5.0", + "cortex-m-semihosting", "log", ] @@ -300,15 +284,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cortex-m-semihosting" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" -dependencies = [ - "cortex-m", -] - [[package]] name = "cortex-m-semihosting" version = "0.5.0" @@ -333,11 +308,21 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "ctr" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ "cipher", ] @@ -369,6 +354,15 @@ dependencies = [ "embedded-hal 0.2.7", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "embedded-alloc" version = "0.5.0" @@ -432,18 +426,65 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "1.0.0-alpha.8" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" + +[[package]] +name = "embedded-hal-async" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" +dependencies = [ + "embedded-hal 1.0.0", +] + +[[package]] +name = "embedded-hal-bus" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57b4e6ede84339ebdb418cd986e6320a34b017cdf99b5cc3efceec6450b06886" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", + "embedded-hal-async", +] + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3babfc7fd332142a0b11aebf592992f211f4e01b6222fb04b03aba1bd80018d" +checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605" dependencies = [ + "embedded-hal 1.0.0", "nb 1.1.0", ] [[package]] name = "embedded-storage" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723dce4e9f25b6e6c5f35628e144794e5b459216ed7da97b7c4b66cdb3fa82ca" +checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032" + +[[package]] +name = "enumflags2" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] [[package]] name = "equivalent" @@ -464,12 +505,13 @@ dependencies = [ "cortex-m", "cortex-m-log", "cortex-m-rt", - "cortex-m-semihosting 0.3.7", + "cortex-m-semihosting", "critical-section", "display-interface", "embedded-alloc", "embedded-graphics-core", "embedded-hal 0.2.7", + "embedded-hal 1.0.0", "fetch-git-hash", "futures", "gui", @@ -561,7 +603,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.52", ] [[package]] @@ -619,9 +661,9 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" dependencies = [ "opaque-debug", "polyval", @@ -637,30 +679,20 @@ dependencies = [ [[package]] name = "hash32" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "ahash 0.3.8", - "autocfg", -] - [[package]] name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.6", + "ahash", ] [[package]] @@ -671,17 +703,20 @@ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "heapless" -version = "0.7.16" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ - "atomic-polyfill 0.1.11", "hash32", - "rustc_version 0.4.0", - "spin", "stable_deref_trait", ] +[[package]] +name = "hex_lit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" + [[package]] name = "indexmap" version = "2.0.0" @@ -692,6 +727,15 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "itoa" version = "1.0.9" @@ -720,14 +764,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" [[package]] -name = "lock_api" -version = "0.4.10" +name = "litrs" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "log" @@ -749,9 +789,9 @@ checksum = "39617bc909d64b068dcffd0e3e31679195b5576d0c83fadc52690268cc2b2b55" [[package]] name = "minicbor" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d15f4203d71fdf90903c2696e55426ac97a363c67b218488a73b534ce7aca10" +checksum = "a3d732cecc693ad7c5ea353198182ff4d9bf92428af793c411102b175855ab04" dependencies = [ "minicbor-derive", ] @@ -769,11 +809,12 @@ dependencies = [ [[package]] name = "miniscript" -version = "9.0.2" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b106477a0709e2da253e5559ba4ab20a272f8577f1eefff72f3a905b5d35f5" +checksum = "1eb102b66b2127a872dbcc73095b7b47aeb9d92f7b03c2b2298253ffc82c7594" dependencies = [ "bitcoin", + "bitcoin-private", "hashbrown 0.11.2", ] @@ -831,18 +872,18 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "noise-protocol" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb474d36dfe51bb4d7e733fee2b0dfd92ee1b95c716030a70e92737dea1a52b" +checksum = "2473d39689a839f5a363aaef7d99f76d5611bf352286682b25a6644fec18b1d3" dependencies = [ "arrayvec", ] [[package]] name = "noise-rust-crypto" -version = "0.5.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e7cfeb8e6a63b4a5ccef34ed7a22d084a129b1e53a000c080bbc54c0da6f8c" +checksum = "b4c6159f60beb3bbbcdc266bc789bfc6c37fdad7d7ca7152d3e049ef5af633f0" dependencies = [ "aes-gcm", "noise-protocol", @@ -884,9 +925,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ "cfg-if", "cpufeatures", @@ -894,6 +935,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -926,18 +973,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -948,7 +995,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -958,15 +1005,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -975,11 +1016,11 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rtic" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857ce76a2517808a303bcb7e5b6d4a9c1d84e5de88b302aec2e53744633c0f4d" +checksum = "0f9472edf226fafcaec0af8afeac6d22b28bf4fdbe7c34762b82af540c081f9a" dependencies = [ - "atomic-polyfill 1.0.3", + "atomic-polyfill", "bare-metal 1.0.0", "cortex-m", "critical-section", @@ -1004,46 +1045,51 @@ checksum = "d9369355b04d06a3780ec0f51ea2d225624db777acbc60abd8ca4832da5c1a42" [[package]] name = "rtic-macros" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8617533990b728e31bc65fcec8fec51fa1b4000fb33189ebeb05fb9d8625444d" +checksum = "54053598ea24b1b74937724e366558412a1777eb2680b91ef646db540982789a" dependencies = [ "indexmap", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "rtic-monotonics" -version = "1.0.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7b43766f637098795e97a759006a09f79e710b3c8df9cb5070abdac59c158e" +checksum = "058c2397dbd5bb4c5650a0e368c3920953e458805ff5097a0511b8147b3619d7" dependencies = [ - "atomic-polyfill 1.0.3", + "atomic-polyfill", "cfg-if", "cortex-m", + "embedded-hal 1.0.0", "fugit", "rtic-time", ] [[package]] name = "rtic-sync" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb1b1b0ca716573360416a4f32e6eda76421e3695ad476ef44243c304748bfa" +checksum = "49b1200137ccb2bf272a1801fa6e27264535facd356cb2c1d5bc8e12aa211bad" dependencies = [ "critical-section", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-hal-bus", "heapless", + "portable-atomic", "rtic-common", ] [[package]] name = "rtic-time" -version = "1.0.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55127cfa37ad32522eca2b70a12298bdb035c75ee3a4e403af8773ffe1a64bd3" +checksum = "75b232e7aebc045cfea81cdd164bc2727a10aca9a4568d406d0a5661cdfd0f19" dependencies = [ "critical-section", "futures-util", @@ -1052,9 +1098,9 @@ dependencies = [ [[package]] name = "rtt-log" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e6ba09884211bb4594535abfbb24ad8cce2d07ab98d0687303c00a29d655105" +checksum = "934c5a2ab52e91070e60e400ed9c9f2f28d9469b06b974e5d463e98bc7c0e185" dependencies = [ "log", "rtt-target", @@ -1062,9 +1108,9 @@ dependencies = [ [[package]] name = "rtt-target" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afa12c77ba1b9bf560e4039a9b9a08bb9cde0e9e6923955eeb917dd8d5cf303" +checksum = "10b34c9e6832388e45f3c01f1bb60a016384a0a4ad80cdd7d34913bed25037f0" dependencies = [ "critical-section", "ufmt-write", @@ -1094,17 +1140,11 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "secp256k1" -version = "0.24.3" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ "bitcoin_hashes", "secp256k1-sys", @@ -1113,9 +1153,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" dependencies = [ "cc", ] @@ -1158,7 +1198,7 @@ checksum = "b23f7ade6f110613c0d63858ddb8b94c1041f550eab58a16b371bdf2c9c80ab4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.52", ] [[package]] @@ -1172,15 +1212,6 @@ dependencies = [ "serde", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "ssd1306" version = "0.8.0" @@ -1220,24 +1251,27 @@ dependencies = [ [[package]] name = "stm32f4xx-hal" -version = "0.16.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2877159274bc374744f10a4dd913b5175593ce02a94d70b8ba978e49db199b" +checksum = "10c41454f262c0be0c35b8cfc0d971e598281f7a9be32e894dc97a0b21deadfe" dependencies = [ "bare-metal 1.0.0", - "bitflags 2.3.3", "cortex-m", "cortex-m-rt", + "document-features", "embedded-dma 0.2.0", "embedded-hal 0.2.7", - "embedded-hal 1.0.0-alpha.8", + "embedded-hal 1.0.0", + "embedded-hal-nb", "embedded-storage", + "enumflags2", "fugit", "fugit-timer", "nb 1.1.0", - "rand_core 0.6.4", + "rand_core", "stm32f4", "time", + "vcell", "void", ] @@ -1266,7 +1300,7 @@ dependencies = [ "embedded-hal 0.2.7", "fugit", "nb 0.1.3", - "rand_core 0.6.4", + "rand_core", "stable_deref_trait", "stm32l4", "void", @@ -1291,9 +1325,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.27" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1335,11 +1369,11 @@ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] @@ -1397,7 +1431,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.52", "wasm-bindgen-shared", ] @@ -1419,7 +1453,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml index 2463221..9e9d142 100644 --- a/firmware/Cargo.toml +++ b/firmware/Cargo.toml @@ -5,49 +5,53 @@ edition = "2021" license = "GPL-3.0-or-later" [dependencies] -rtic = { version = "2.0", features = ["thumbv7-backend"] } -rtic-sync = "1.0" -rtic-monotonics = { version = "1.0", features = ["cortex-m-systick"] } +rtic = { version = "2.1", features = ["thumbv7-backend"] } +rtic-sync = "1.3" +rtic-monotonics = { version = "1.5", features = ["cortex-m-systick"] } critical-section = "1.1" cortex-m = { version = "^0.7.7", features = ["critical-section-single-core"] } # set-vtor: set vector table to the flash address rather than relying # on the default value of 0x0 which is fine when booting from bank 1 # (because memory is aliased) but would break with bank 2 -cortex-m-rt = { version = "0.7.2", features = ["set-vtor"] } +cortex-m-rt = { version = "0.7.3", features = ["set-vtor"] } embedded-alloc = "0.5" -embedded-hal = "0.2.7" display-interface = "^0.4.1" ssd1306 = "0.8" -minicbor = { version = "0.20", default-features = false, features = ["alloc"] } +minicbor = { version = "0.21", default-features = false, features = ["alloc", "derive"] } rand = { version = "0.8", default-features = false } rand_chacha = { version = "0.3", default-features = false } log = "0.4" futures = { version = "0.3", default-features = false, features = ["async-await"] } # bitcoin = { version = "0.30", default-features = false, features = ["no-std"] } -bdk = { git = "https://github.com/afilini/bdk.git", rev = "ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64", default-features = false, features = ["keys-bip39"] } -bitcoin_hashes = { version = "0.11.0", default-features = false, features = ["small-hash"] } -secp256k1 = { version = "0.24.3", default-features = false, features = ["alloc", "lowmemory"] } +# bdk = { git = "https://github.com/afilini/bdk.git", rev = "ea20dff9fadcf75b5b3c7520e0b3fa40a71d3b64", default-features = false, features = ["keys-bip39"] } +bdk = { path = "../../bdk/crates/bdk", default-features = false, features = ["keys-bip39"] } +bitcoin_hashes = { version = "0.12.0", default-features = false, features = ["small-hash"] } +secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "lowmemory"] } fetch-git-hash = { path = "../fetch-git-hash" } model = { path = "../model", features = ["stm32"] } gui = { path = "../gui", features = ["stm32"] } -rtt-target = { version = "0.4", optional = true } -rtt-log = { version = "0.2", optional = true } +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0", optional = true } +embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", optional = true } + +rtt-target = { version = "0.5", optional = true } +rtt-log = { version = "0.3", optional = true } stm32l4xx-hal = { version = "0.7.1", features = ["stm32l476", "rt"], optional = true } # panic-probe = { version = "0.2", features = ["print-rtt"], optional = true } -cortex-m-semihosting = { version = "0.3.5", optional = true } +cortex-m-semihosting = { version = "0.5", optional = true } cortex-m-log = { version = "0.8", features = ["log-integration", "semihosting"], optional = true} # panic-semihosting = { version = "0.6", optional = true } -stm32f4xx-hal = { version = "0.16.2", features = ["stm32f405"], optional = true } +stm32f4xx-hal = { version = "0.20", features = ["stm32f405"], optional = true } embedded-graphics-core = { version = "0.4", optional = true } [features] -default = ["emulator", "panic-log"] -emulator = ["cortex-m-semihosting", "cortex-m-log", "stm32f4xx-hal", "embedded-graphics-core", "model/emulator", "panic-log"] # "panic-semihosting", "panic-semihosting/exit" +# default = ["emulator", "panic-log"] +default = ["device"] +emulator = ["cortex-m-semihosting", "cortex-m-log", "stm32f4xx-hal", "embedded-graphics-core", "model/emulator", "panic-log", "embedded-hal-1"] # "panic-semihosting", "panic-semihosting/exit" emulator-fast-ticks = [] -device = ["rtt-target", "rtt-log", "stm32l4xx-hal"] # "panic-probe" +device = ["rtt-target", "rtt-log", "stm32l4xx-hal", "embedded-hal-02"] # "panic-probe" trace_memory = [] panic-log = [] @@ -75,4 +79,5 @@ debug = true inherits = "release" [patch.crates-io] -bitcoin_hashes = { git = "https://github.com/afilini/bitcoin_hashes.git", rev = "09580b264184da514ccc1954c768530132753b8d" } +bitcoin_hashes = { git = "https://github.com/afilini/rust-bitcoin.git", rev = "4ade866918522ab6c33950a9941e6fee8ed24ec4" } +bip39 = { git = "https://github.com/rust-bitcoin/rust-bip39.git", rev = "a84eb0012e7caaef8f82a66de0da00b31d007725" } # current latest releases uses bitcoin_hashes v0.11 diff --git a/firmware/build.rs b/firmware/build.rs index bd2e51e..ac925a1 100644 --- a/firmware/build.rs +++ b/firmware/build.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -21,4 +21,4 @@ fn main() { } else if cfg!(feature = "device") { println!("cargo:rustc-link-arg=-L./linker-scripts/device"); } -} \ No newline at end of file +} diff --git a/firmware/linker-scripts/device/memory.x b/firmware/linker-scripts/device/memory.x index 33071de..7738321 100644 --- a/firmware/linker-scripts/device/memory.x +++ b/firmware/linker-scripts/device/memory.x @@ -1,8 +1,8 @@ /* Linker script for the STM32L476 */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 510K - /* FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K */ + /* FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 510K */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K DATA (r) : ORIGIN = 0x0807F800, LENGTH = 2K /* Use the largest section of memory for the HEAP */ HEAP (rw) : ORIGIN = 0x20000000, LENGTH = 96K diff --git a/firmware/src/config.rs b/firmware/src/config.rs index dfa89e5..0ce5c26 100644 --- a/firmware/src/config.rs +++ b/firmware/src/config.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/emulator/config.rs b/firmware/src/emulator/config.rs index cc3651a..e0b0a8e 100644 --- a/firmware/src/emulator/config.rs +++ b/firmware/src/emulator/config.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/emulator/hw.rs b/firmware/src/emulator/hw.rs index 98ee7aa..ad668ba 100644 --- a/firmware/src/emulator/hw.rs +++ b/firmware/src/emulator/hw.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -80,7 +80,7 @@ pub fn init_peripherals( &clocks, ) .unwrap(); - serial.listen(serial::Event::Rxne); + serial.listen(serial::Event::RxNotEmpty); set_serial(serial); let (nfc, nfc_interrupt, nfc_finished) = NfcIc::new(); diff --git a/firmware/src/emulator/mod.rs b/firmware/src/emulator/mod.rs index 02adcfe..424f1c4 100644 --- a/firmware/src/emulator/mod.rs +++ b/firmware/src/emulator/mod.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/error.rs b/firmware/src/error.rs index 8f46c06..9f6d948 100644 --- a/firmware/src/error.rs +++ b/firmware/src/error.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -67,11 +67,11 @@ impl From for Error { Error::Display(e) } } -impl From for Error { - fn from(_: bdk::Error) -> Self { - Error::Wallet - } -} +// impl From for Error { +// fn from(_: bdk::Error) -> Self { +// Error::Wallet +// } +// } impl From> for Error { fn from(_: bdk::wallet::NewError) -> Self { Error::Wallet diff --git a/firmware/src/handlers/bitcoin.rs b/firmware/src/handlers/bitcoin.rs index e0a09f3..0db7627 100644 --- a/firmware/src/handlers/bitcoin.rs +++ b/firmware/src/handlers/bitcoin.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -22,13 +22,13 @@ use alloc::vec::Vec; use futures::prelude::*; -use bdk::bitcoin::util::{bip32, psbt, taproot}; -use bdk::bitcoin::{Address, Amount, PublicKey, TxOut, XOnlyPublicKey}; -use bdk::descriptor::{ - DerivedDescriptor, DescriptorError, DescriptorXKey, ExtendedDescriptor, TapKeyOrigins, Wildcard, -}; +// use bdk::bitcoin::util::{bip32, psbt, taproot}; +use bdk::bitcoin::key::XOnlyPublicKey; +use bdk::bitcoin::{bip32, psbt, taproot}; +use bdk::bitcoin::{Address, Amount, PublicKey, TxOut}; +use bdk::descriptor::{DerivedDescriptor, DescriptorError, ExtendedDescriptor, TapKeyOrigins}; use bdk::keys::SinglePubKey; -use bdk::miniscript::descriptor::{DescriptorType, InnerXKey}; +use bdk::miniscript::descriptor::{DescriptorType, DescriptorXKey, InnerXKey, Wildcard}; use bdk::miniscript::{DescriptorPublicKey, ForEachKey}; use bdk::HdKeyPaths; @@ -95,8 +95,7 @@ pub async fn handle_sign_request( .await .unwrap(); - let mut psbt: psbt::PartiallySignedTransaction = - bdk::bitcoin::consensus::encode::deserialize(&psbt).unwrap(); + let mut psbt = psbt::PartiallySignedTransaction::deserialize(&psbt).unwrap(); let allow_witness_utxo = matches!( wallet @@ -188,14 +187,14 @@ pub async fn handle_sign_request( let empty_tx = bdk::bitcoin::Transaction { input: alloc::vec![bdk::bitcoin::TxIn::default(); diff.len()], output: alloc::vec![], - lock_time: bdk::bitcoin::PackedLockTime::ZERO, + lock_time: bdk::bitcoin::locktime::absolute::LockTime::ZERO, version: 0, }; let mut empty_psbt = psbt::PartiallySignedTransaction::from_unsigned_tx(empty_tx).expect("Always succeed"); empty_psbt.inputs = diff; - let psbt = bdk::bitcoin::consensus::encode::serialize(&empty_psbt); + let psbt = empty_psbt.serialize(); peripherals .nfc @@ -479,7 +478,7 @@ impl DescriptorMeta for ExtendedDescriptor { false }); - path_found.map(|path| self.at_derivation_index(path)) + path_found.map(|path| self.at_derivation_index(path).expect("Able to derive")) } fn derive_from_hd_keypaths<'s>( @@ -531,7 +530,7 @@ impl DescriptorMeta for ExtendedDescriptor { return None; } - let descriptor = self.at_derivation_index(0); + let descriptor = self.at_derivation_index(0).expect("Able to derive"); match descriptor.desc_type() { // TODO: add pk() here DescriptorType::Pkh diff --git a/firmware/src/handlers/fwupdate.rs b/firmware/src/handlers/fwupdate.rs index fe2bc12..552e18a 100644 --- a/firmware/src/handlers/fwupdate.rs +++ b/firmware/src/handlers/fwupdate.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -202,7 +202,7 @@ impl<'h> FwUpdater<'h> { } }; let hash = sha256::HashEngine::from_midstate( - sha256::Midstate::from_inner(**midstate), + sha256::Midstate::from_byte_array(**midstate), midstate_len, ); @@ -286,7 +286,7 @@ impl<'h> FwUpdater<'h> { first_page_midstate: self.header.first_page_midstate.clone(), signature: self.header.signature.clone(), next_page: self.page, - midstate: Box::new(ByteArray::from(self.hash.midstate().into_inner())), + midstate: Box::new(ByteArray::from(self.hash.midstate().to_byte_array())), }; let mut data = alloc::vec![0x00, 0x00]; @@ -372,7 +372,7 @@ impl<'h> FwUpdater<'h> { let first_page_midstate = first_page_midstate.midstate(); log::debug!("First page midstate: {:02X?}", first_page_midstate); - if first_page_midstate.deref() != header.first_page_midstate.deref().deref() { + if &first_page_midstate.to_byte_array() != header.first_page_midstate.deref().deref() { return Err(Error::InvalidFirmware); } @@ -381,7 +381,7 @@ impl<'h> FwUpdater<'h> { let signing_key = secp256k1::XOnlyPublicKey::from_str(FIRMWARE_SIGNING_KEY) .expect("Valid signing pubkey"); - let message = secp256k1::Message::from_slice(&hash).expect("Correct length"); + let message = secp256k1::Message::from_slice(&hash.as_ref()).expect("Correct length"); let signature = secp256k1::schnorr::Signature::from_slice(header.signature.deref().deref()) .map_err(|_| Error::InvalidFirmware)?; let ctx = secp256k1::Secp256k1::verification_only(); diff --git a/firmware/src/handlers/idle.rs b/firmware/src/handlers/idle.rs index fcac840..5c6f3f5 100644 --- a/firmware/src/handlers/idle.rs +++ b/firmware/src/handlers/idle.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/handlers/init.rs b/firmware/src/handlers/init.rs index 75fc7d1..bc04e13 100644 --- a/firmware/src/handlers/init.rs +++ b/firmware/src/handlers/init.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -27,7 +27,7 @@ use model::InitializedConfig; use model::UnverifiedConfig; use rand::RngCore; -use bdk::bitcoin::util::bip32; +use bdk::bitcoin::bip32; use bdk::bitcoin::Network; use bdk::descriptor::template::DescriptorTemplate; use bdk::descriptor::IntoWalletDescriptor; @@ -256,7 +256,7 @@ pub async fn display_mnemonic( peripherals.tsc_enabled.enable(); let mnemonic = Mnemonic::from_entropy(&config.entropy.bytes).map_err(map_err_config)?; - let mnemonic_str = mnemonic.word_iter().collect::>(); + let mnemonic_str = mnemonic.words().collect::>(); for (chunk_index, words) in mnemonic_str.chunks(2).enumerate() { let mut page = MnemonicPage::new((chunk_index * 2) as u8, &words); page.init_display(&mut peripherals.display)?; diff --git a/firmware/src/handlers/mod.rs b/firmware/src/handlers/mod.rs index 4703bfa..f2458fd 100644 --- a/firmware/src/handlers/mod.rs +++ b/firmware/src/handlers/mod.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/hw/mod.rs b/firmware/src/hw/mod.rs index bd9b04b..a3c35e8 100644 --- a/firmware/src/hw/mod.rs +++ b/firmware/src/hw/mod.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/hw/nt3h.rs b/firmware/src/hw/nt3h.rs index b38f3bc..f7db4cc 100644 --- a/firmware/src/hw/nt3h.rs +++ b/firmware/src/hw/nt3h.rs @@ -1,22 +1,20 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use core::future::IntoFuture; - use hal::gpio; use hal::i2c::{self, I2c}; use hal::prelude::*; @@ -206,12 +204,17 @@ where Ok(fragment) } - async fn wait_for(&mut self, func: F, mode: WaitMode) -> Result<(), Error> - where - for<'a> F: Fn<(&'a mut Self,)> + 'a, - for<'a> >::Output: IntoFuture>, - { - while !func(self).await? { + async fn wait_for(&mut self, what: WaitFor, mode: WaitMode) -> Result<(), Error> { + macro_rules! do_wait { + ($s:expr, $what:expr) => { + match $what { + WaitFor::Read => $s.check_rf_read().await, + WaitFor::Write => $s.check_rf_write().await, + } + }; + } + + while !do_wait!(self, what)? { match mode { #[allow(deprecated)] WaitMode::Delay { ms } => Systick::delay(ms.millis()).await, @@ -282,7 +285,7 @@ where } async fn wait_for_rf_read(&mut self, mode: WaitMode) -> Result<(), Error> { - self.wait_for(Self::check_rf_read, mode).await + self.wait_for(WaitFor::Read, mode).await } async fn wait_for_rf_write(&mut self, mode: WaitMode) -> Result<(), Error> { @@ -301,7 +304,7 @@ where ) .await?; - self.wait_for(Self::check_rf_write, mode).await + self.wait_for(WaitFor::Write, mode).await } async fn read_raw_message(&mut self) -> Result { @@ -383,6 +386,12 @@ pub enum WaitMode { Interrupt, } +#[derive(Debug, Clone, Copy)] +pub enum WaitFor { + Read, + Write, +} + pub struct NfcInterrupt { pub sender: hw_common::ChannelSender<()>, pub fd_pin: P, diff --git a/firmware/src/hw/tsc.rs b/firmware/src/hw/tsc.rs index 4dfc9ab..97a65e6 100644 --- a/firmware/src/hw/tsc.rs +++ b/firmware/src/hw/tsc.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/hw_common.rs b/firmware/src/hw_common.rs index 81d636c..181479c 100644 --- a/firmware/src/hw_common.rs +++ b/firmware/src/hw_common.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/firmware/src/main.rs b/firmware/src/main.rs index fdc0d4a..0f06031 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -19,12 +19,14 @@ #![no_main] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -#![feature(type_alias_impl_trait)] -#![feature(unboxed_closures)] extern crate alloc; extern crate cortex_m; -extern crate embedded_hal as ehal; + +#[cfg(feature = "device")] +extern crate embedded_hal_02 as ehal; +#[cfg(feature = "emulator")] +extern crate embedded_hal_1 as ehal; #[cfg(all(feature = "device", feature = "emulator"))] compile_error!("Cannot enable both the `device` and `emulator` features at the same time"); @@ -181,6 +183,7 @@ mod app { // TODO: move this somewhere else dp.RCC.apb2enr.write(|w| w.syscfgen().set_bit()); + #[allow(unused_mut)] let (mut nfc, nfc_interrupt, nfc_finished, display, tsc, rng, flash) = hw::init_peripherals(dp, cp).unwrap(); diff --git a/functional-test-wrapper/src/lib.rs b/functional-test-wrapper/src/lib.rs index 96fc067..84fb53d 100644 --- a/functional-test-wrapper/src/lib.rs +++ b/functional-test-wrapper/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/gui/src/bin/simulator.rs b/gui/src/bin/simulator.rs index 3360f24..39f179f 100644 --- a/gui/src/bin/simulator.rs +++ b/gui/src/bin/simulator.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/gui/src/lib.rs b/gui/src/lib.rs index b430219..38a62c9 100644 --- a/gui/src/lib.rs +++ b/gui/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/model/Cargo.toml b/model/Cargo.toml index 9e00fbd..136a354 100644 --- a/model/Cargo.toml +++ b/model/Cargo.toml @@ -7,13 +7,13 @@ license = "GPL-3.0-or-later" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -minicbor = { version = "0.20", default-features = false, features = ["derive", "alloc"] } +minicbor = { version = "0.21", default-features = false, features = ["derive", "alloc"] } modular-bitfield = "0.11.2" -bitcoin = { version = "0.29.2", default-features = false, features = ["no-std", "serde"] } -bip39 = { version = "1.2.0", default-features = false } -noise-protocol = { version = "0.1.4", default-features = false, features = ["use_alloc"] } -noise-rust-crypto = { version = "0.5.0", default-features = false, features = ["use-aes-256-gcm"] } -aes-gcm = { version = "0.9.4" } +bitcoin = { version = "0.30.2", default-features = false, features = ["no-std", "serde"] } +bip39 = { version = "2.0", default-features = false } +noise-protocol = { version = "0.2.0", default-features = false, features = ["use_alloc"] } +noise-rust-crypto = { version = "0.6.2", default-features = false, features = ["use-aes-256-gcm"] } +aes-gcm = { version = "0.10.3", default-features = false, features = ["aes", "alloc"] } log = "0.4" serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true } diff --git a/model/src/emulator.rs b/model/src/emulator.rs index 4115270..8ed877c 100644 --- a/model/src/emulator.rs +++ b/model/src/emulator.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/model/src/encryption.rs b/model/src/encryption.rs index 4f50bd6..a8fa109 100644 --- a/model/src/encryption.rs +++ b/model/src/encryption.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -72,7 +72,9 @@ impl noise_protocol::Hash for BitcoinHashesSha256 { self.0.input(data) } fn result(&mut self) -> Self::Output { - let hash = sha256::Hash::from_engine(self.0.clone()).into_inner(); + let hash = sha256::Hash::from_engine(self.0.clone()) + .as_byte_array() + .clone(); Sensitive::from(From::from(hash)) } } diff --git a/model/src/lib.rs b/model/src/lib.rs index 1681c6a..91d031d 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -30,14 +30,14 @@ use minicbor::{Decode, Encode}; use noise_protocol::{Cipher, CipherState}; -use aes_gcm::aead::Aead; -use aes_gcm::{Aes256Gcm, Key, NewAead, Nonce}; +use aes_gcm::aead::AeadMut; +use aes_gcm::{Aes256Gcm, KeyInit, Nonce}; use modular_bitfield::prelude::*; pub use bitcoin; +use bitcoin::bip32; use bitcoin::hashes::{sha256, Hash, HashEngine}; -use bitcoin::util::bip32; pub const MAX_FRAGMENT_LEN: usize = 64; @@ -264,7 +264,7 @@ pub struct SerializedXprv { pub bytes: [u8; 78], } impl SerializedXprv { - pub fn as_xprv(&self) -> Result { + pub fn as_xprv(&self) -> Result { bip32::ExtendedPrivKey::decode(&self.bytes) } } @@ -355,12 +355,10 @@ impl InitializedConfig { MaybeEncrypted::Encrypted { data, nonce } => { let mut hash = sha256::Hash::hash(password.as_bytes()); for _ in 0..DEFAULT_PASSWORD_ITERATIONS { - hash = sha256::Hash::hash(&hash); + hash = sha256::Hash::hash(hash.as_ref()); } - let key = hash.into_inner(); - let key = Key::from_slice(&key); - let cipher = Aes256Gcm::new(key); + let mut cipher = Aes256Gcm::new_from_slice(hash.as_ref()).expect("Correct length"); let mut nonce_bytes = [0; 12]; nonce_bytes[..4].copy_from_slice(&nonce.to_be_bytes()); @@ -401,12 +399,10 @@ impl UnlockedConfig { Some(password) => { let mut hash = sha256::Hash::hash(password.as_bytes()); for _ in 0..DEFAULT_PASSWORD_ITERATIONS { - hash = sha256::Hash::hash(&hash); + hash = sha256::Hash::hash(hash.as_ref()); } - let key = hash.into_inner(); - let key = Key::from_slice(&key); - let cipher = Aes256Gcm::new(key); + let mut cipher = Aes256Gcm::new_from_slice(hash.as_ref()).expect("Correct length"); let nonce = self.nonce + 1; let mut nonce_bytes = [0; 12]; @@ -479,11 +475,11 @@ impl Password { let mut hash = sha256::Hash::from_engine(hash); for _ in 0..DEFAULT_PASSWORD_ITERATIONS { - hash = sha256::Hash::hash(&hash); + hash = sha256::Hash::hash(hash.as_ref()); } Password { - hash: hash.into_inner(), + hash: *hash.as_byte_array(), salt, iterations: DEFAULT_PASSWORD_ITERATIONS, } diff --git a/model/src/reg.rs b/model/src/reg.rs index df8181d..8646c20 100644 --- a/model/src/reg.rs +++ b/model/src/reg.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/model/src/write_buffer.rs b/model/src/write_buffer.rs index 3882260..04e2763 100644 --- a/model/src/write_buffer.rs +++ b/model/src/write_buffer.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/sdk/src/bin/cli.rs b/sdk/src/bin/cli.rs index 25f29cf..2138232 100644 --- a/sdk/src/bin/cli.rs +++ b/sdk/src/bin/cli.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/sdk/src/bin/pcsc.rs b/sdk/src/bin/pcsc.rs index 66cec4d..0e9394f 100644 --- a/sdk/src/bin/pcsc.rs +++ b/sdk/src/bin/pcsc.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/sdk/src/bin/uniffi-bindgen.rs b/sdk/src/bin/uniffi-bindgen.rs index 48e8f59..5c05a09 100644 --- a/sdk/src/bin/uniffi-bindgen.rs +++ b/sdk/src/bin/uniffi-bindgen.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/sdk/src/inner_logic.rs b/sdk/src/inner_logic.rs index bb891c2..d59f14d 100644 --- a/sdk/src/inner_logic.rs +++ b/sdk/src/inner_logic.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index efa67d5..0a9d814 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -1,17 +1,17 @@ // Portal Hardware Wallet firmware and supporting software libraries -// +// // Copyright (C) 2024 Alekos Filini -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -236,7 +236,10 @@ impl PortalSdk { Ok(()) } - pub async fn display_address(&self, index: u32) -> Result { + pub async fn display_address( + &self, + index: u32, + ) -> Result, SdkError> { let address = send_with_retry!(self.requests, Request::DisplayAddress(index), Ok(Reply::Address(s)) => break Ok(s))?; let address = address .parse() @@ -245,24 +248,22 @@ impl PortalSdk { } pub async fn sign_psbt(&self, psbt: String) -> Result { - use model::bitcoin::consensus::{deserialize, serialize}; - let psbt = base64::decode(&psbt)?; - let mut original_psbt: model::bitcoin::util::psbt::Psbt = - deserialize(&psbt).map_err(|_| SdkError::DeserializationError)?; + let mut original_psbt = model::bitcoin::psbt::Psbt::deserialize(&psbt) + .map_err(|_| SdkError::DeserializationError)?; send_with_retry!(self.requests, Request::BeginSignPsbt, Ok(Reply::Ok) => break Ok(()))?; let psbt = send_with_retry!(self.requests, Request::SignPsbt(psbt.clone().into()), Ok(Reply::SignedPsbt(s)) => break Ok(s))?; - let mut psbt: model::bitcoin::util::psbt::Psbt = - deserialize(psbt.deref()).map_err(|_| SdkError::CommunicationError)?; + let mut psbt = model::bitcoin::psbt::Psbt::deserialize(psbt.deref()) + .map_err(|_| SdkError::CommunicationError)?; psbt.unsigned_tx = original_psbt.unsigned_tx.clone(); original_psbt .combine(psbt) .map_err(|_| SdkError::DeserializationError)?; - let original_psbt = serialize(&original_psbt); + let original_psbt = original_psbt.serialize(); Ok(base64::encode(&original_psbt)) } @@ -316,7 +317,7 @@ impl PortalSdk { variant: model::FwVariant::VANILLA, signature: Box::new(signature.into()), size: binary.len(), - first_page_midstate: Box::new(first_page_midstate.into_inner().into()), + first_page_midstate: Box::new(first_page_midstate.to_byte_array().into()), }; let mut page = send_with_retry!(self.requests, model::Request::BeginFwUpdate(header.clone()), Ok(Reply::NextPage(page)) => break Ok(Some(page)), Ok(Reply::Ok) => break Ok(None))?; diff --git a/shell.nix b/shell.nix index ba05112..15883ae 100644 --- a/shell.nix +++ b/shell.nix @@ -9,8 +9,8 @@ let rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"); pkgs = import { overlays = [ rust_overlay ]; config.android_sdk.accept_license = true; config.allowUnfree = true; }; lib = pkgs.lib; - rustVersion = "2023-07-07"; - rust = pkgs.rust-bin.nightly.${rustVersion}.default.override { + rustVersion = "1.76.0"; + rust = pkgs.rust-bin.stable.${rustVersion}.default.override { extensions = [ "rust-src" # for rust-analyzer ];