Skip to content

Commit 3af6dc4

Browse files
committed
rust: reduce binary size by enabling the keccak no_unroll flag
Currently, firmware multi on master is 767888 bytes. By enabling this feature, it's reduced to 766360 (1528 bytes savings). https://docs.rs/keccak/latest/keccak/ also mentions tiny-keccak. I tried this too and it resulted in a binary size of 766788 bytes, so slightly larger than using the current sha3 crate we use.
1 parent 5673a29 commit 3af6dc4

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/rust/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ hex = { version = "0.4", default-features = false, features = ["alloc"] }
3434
num-bigint = { version = "0.4.6", default-features = false }
3535
sha2 = { version = "0.10.8", default-features = false }
3636
sha3 = { version = "0.10.8", default-features = false }
37+
# We don't rely on this dep directly, the sha3 dep does. We list it here to enable the
38+
# no_unroll feature to reduce the binary size, saving around 1528 bytes (as measured at time of
39+
# writing, this might fluctuate over time).
40+
keccak = { version = "0.1.4", default-features = false, features = ["no_unroll"] }
3741
zeroize = "1.7.0"
3842

3943
[patch.crates-io]

src/rust/bitbox02-rust/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ streaming-silent-payments = { path = "../streaming-silent-payments", optional =
3636
hex = { workspace = true }
3737
sha2 = { workspace = true }
3838
sha3 = { workspace = true, optional = true }
39+
keccak = { workspace = true, optional = true }
3940
digest = "0.10.6"
4041
zeroize = { workspace = true }
4142
num-bigint = { workspace = true, optional = true }
@@ -71,6 +72,7 @@ ed25519 = [
7172
app-ethereum = [
7273
"dep:erc20_params",
7374
"dep:sha3",
75+
"dep:keccak",
7476
"dep:num-bigint",
7577
"bitbox02/app-ethereum",
7678
]

0 commit comments

Comments
 (0)