rust: remove unused rust_base58_encode_check
What changed, and why it matters
This commit simply deletes an unused helper function for Base58Check encoding and its associated test. It is a cleanup change with no security relevance.
No action needed; this is a benign dead-code removal.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes rust_base58_encode_check, an extern “C” wrapper around bitcoin::base58::encode_check, because the last caller was removed in a prior commit. It also removes the corresponding unit test and the now-unnecessary ‘bitcoin’ dependency from the target-c-unit-tests feature. No functional behavior changes.
Changed components
src/rust/bitbox02-rust-c/Cargo.tomlsrc/rust/util/src/base58.rssrc/rust/util/src/lib.rsInspect captured patch +0 / −50
diff --git a/src/rust/bitbox02-rust-c/Cargo.toml b/src/rust/bitbox02-rust-c/Cargo.toml
index 24d3ccc..cb35f5d 100644
--- a/src/rust/bitbox02-rust-c/Cargo.toml
+++ b/src/rust/bitbox02-rust-c/Cargo.toml
@@ -60,7 +60,6 @@ target-factory-setup = [
]
# add Rust features which are called in the C unit tests (currently there is only one target for C tests).
target-c-unit-tests = [
- "dep:bitcoin", # for rust_base58_encode_check()
"app-bitcoin",
"app-litecoin",
"app-ethereum",
diff --git a/src/rust/util/src/base58.rs b/src/rust/util/src/base58.rs
deleted file mode 100644
index ddc52f1..0000000
--- a/src/rust/util/src/base58.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2020 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/// Base58Check-encode the input.
-#[cfg(feature = "c-unit-testing")]
-#[unsafe(no_mangle)]
-pub extern "C" fn rust_base58_encode_check(
- buf: crate::bytes::Bytes,
- mut out: crate::bytes::BytesMut,
-) -> bool {
- if buf.is_empty() {
- return false;
- }
- let encoded = bitcoin::base58::encode_check(buf.as_ref());
- out.as_mut()[..encoded.len()].copy_from_slice(encoded.as_bytes());
- // Null-terminator.
- out.as_mut()[encoded.len()] = 0;
- true
-}
-
-#[cfg(all(test, feature = "c-unit-testing"))]
-mod tests {
- use super::*;
- use std::prelude::v1::*;
-
- #[test]
- fn test_rust_base58_encode_check() {
- let buf = b"test";
- let mut result_buf = [0u8; 100];
- assert!(rust_base58_encode_check(
- unsafe { crate::bytes::rust_util_bytes(buf.as_ptr(), buf.len()) },
- unsafe { crate::bytes::rust_util_bytes_mut(result_buf.as_mut_ptr(), result_buf.len()) },
- ));
- let expected = b"LUC1eAJa5jW\0";
- assert_eq!(&result_buf[..expected.len()], expected);
- }
-}
diff --git a/src/rust/util/src/lib.rs b/src/rust/util/src/lib.rs
index 22ffecf..0c784b1 100644
--- a/src/rust/util/src/lib.rs
+++ b/src/rust/util/src/lib.rs
@@ -23,7 +23,6 @@ pub mod log;
pub mod name;
mod waker_fn;
-mod base58;
#[cfg(feature = "p256")]
mod p256;
#[cfg(feature = "sha2")]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.