From 56e1e5dd10cbe51d3abc3fbf532b6b41bf62a889 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 6 Apr 2024 15:46:53 +0100 Subject: [PATCH] refactor, bench, fuzz: Drop unneeded `UCharCast` calls The `CKey::Set()` template function handles `std::byte` just fine. --- src/bench/bip324_ecdh.cpp | 2 +- src/bench/ellswift.cpp | 2 +- src/test/fuzz/util/descriptor.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bench/bip324_ecdh.cpp b/src/bench/bip324_ecdh.cpp index 659da0f08e6..fb10c2957e0 100644 --- a/src/bench/bip324_ecdh.cpp +++ b/src/bench/bip324_ecdh.cpp @@ -27,7 +27,7 @@ static void BIP324_ECDH(benchmark::Bench& bench) bench.batch(1).unit("ecdh").run([&] { CKey key; - key.Set(UCharCast(key_data.data()), UCharCast(key_data.data()) + 32, true); + key.Set(key_data.data(), key_data.data() + 32, true); EllSwiftPubKey our_ellswift(our_ellswift_data); EllSwiftPubKey their_ellswift(their_ellswift_data); diff --git a/src/bench/ellswift.cpp b/src/bench/ellswift.cpp index 82e8dec9826..9441b4863e2 100644 --- a/src/bench/ellswift.cpp +++ b/src/bench/ellswift.cpp @@ -17,7 +17,7 @@ static void EllSwiftCreate(benchmark::Bench& bench) bench.batch(1).unit("pubkey").run([&] { auto ret = key.EllSwiftCreate(MakeByteSpan(entropy)); /* Use the first 32 bytes of the ellswift encoded public key as next private key. */ - key.Set(UCharCast(ret.data()), UCharCast(ret.data()) + 32, true); + key.Set(ret.data(), ret.data() + 32, true); assert(key.IsValid()); /* Use the last 32 bytes of the ellswift encoded public key as next entropy. */ std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin()); diff --git a/src/test/fuzz/util/descriptor.cpp b/src/test/fuzz/util/descriptor.cpp index df78bdf314b..0fed2bc5e1d 100644 --- a/src/test/fuzz/util/descriptor.cpp +++ b/src/test/fuzz/util/descriptor.cpp @@ -15,7 +15,7 @@ void MockedDescriptorConverter::Init() { // an extended one. if (IdIsCompPubKey(i) || IdIsUnCompPubKey(i) || IdIsXOnlyPubKey(i) || IdIsConstPrivKey(i)) { CKey privkey; - privkey.Set(UCharCast(key_data.begin()), UCharCast(key_data.end()), !IdIsUnCompPubKey(i)); + privkey.Set(key_data.begin(), key_data.end(), !IdIsUnCompPubKey(i)); if (IdIsCompPubKey(i) || IdIsUnCompPubKey(i)) { CPubKey pubkey{privkey.GetPubKey()}; keys_str[i] = HexStr(pubkey);