From dc2d7eb810ef95b06620f334c198687579916435 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 31 Aug 2023 10:00:05 -0400 Subject: [PATCH] crypto: Spanify EllSwiftPubKey constructor --- src/pubkey.cpp | 6 ++++++ src/pubkey.h | 3 +-- src/test/bip324_tests.cpp | 10 ++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/pubkey.cpp b/src/pubkey.cpp index 4866feed67..05808e4c22 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -336,6 +336,12 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi return true; } +EllSwiftPubKey::EllSwiftPubKey(Span ellswift) noexcept +{ + assert(ellswift.size() == SIZE); + std::copy(ellswift.begin(), ellswift.end(), m_pubkey.begin()); +} + CPubKey EllSwiftPubKey::Decode() const { secp256k1_pubkey pubkey; diff --git a/src/pubkey.h b/src/pubkey.h index 00defa25a0..274779f9a4 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -303,8 +303,7 @@ public: EllSwiftPubKey() noexcept = default; /** Construct a new ellswift public key from a given serialization. */ - EllSwiftPubKey(const std::array& ellswift) : - m_pubkey(ellswift) {} + EllSwiftPubKey(Span ellswift) noexcept; /** Decode to normal compressed CPubKey (for debugging purposes). */ CPubKey Decode() const; diff --git a/src/test/bip324_tests.cpp b/src/test/bip324_tests.cpp index 04472611ec..1ed7e23bcf 100644 --- a/src/test/bip324_tests.cpp +++ b/src/test/bip324_tests.cpp @@ -38,14 +38,8 @@ void TestBIP324PacketVector( { // Convert input from hex to char/byte vectors/arrays. const auto in_priv_ours = ParseHex(in_priv_ours_hex); - const auto in_ellswift_ours_vec = ParseHex(in_ellswift_ours_hex); - assert(in_ellswift_ours_vec.size() == 64); - std::array in_ellswift_ours; - std::copy(in_ellswift_ours_vec.begin(), in_ellswift_ours_vec.end(), in_ellswift_ours.begin()); - const auto in_ellswift_theirs_vec = ParseHex(in_ellswift_theirs_hex); - assert(in_ellswift_theirs_vec.size() == 64); - std::array in_ellswift_theirs; - std::copy(in_ellswift_theirs_vec.begin(), in_ellswift_theirs_vec.end(), in_ellswift_theirs.begin()); + const auto in_ellswift_ours = ParseHex(in_ellswift_ours_hex); + const auto in_ellswift_theirs = ParseHex(in_ellswift_theirs_hex); const auto in_contents = ParseHex(in_contents_hex); const auto in_aad = ParseHex(in_aad_hex); const auto mid_send_garbage = ParseHex(mid_send_garbage_hex);