Skip to content

Commit dc2d7eb

Browse files
committed
crypto: Spanify EllSwiftPubKey constructor
1 parent 5f4b2c6 commit dc2d7eb

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/pubkey.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
336336
return true;
337337
}
338338

339+
EllSwiftPubKey::EllSwiftPubKey(Span<const std::byte> ellswift) noexcept
340+
{
341+
assert(ellswift.size() == SIZE);
342+
std::copy(ellswift.begin(), ellswift.end(), m_pubkey.begin());
343+
}
344+
339345
CPubKey EllSwiftPubKey::Decode() const
340346
{
341347
secp256k1_pubkey pubkey;

src/pubkey.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ struct EllSwiftPubKey
303303
EllSwiftPubKey() noexcept = default;
304304

305305
/** Construct a new ellswift public key from a given serialization. */
306-
EllSwiftPubKey(const std::array<std::byte, SIZE>& ellswift) :
307-
m_pubkey(ellswift) {}
306+
EllSwiftPubKey(Span<const std::byte> ellswift) noexcept;
308307

309308
/** Decode to normal compressed CPubKey (for debugging purposes). */
310309
CPubKey Decode() const;

src/test/bip324_tests.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,8 @@ void TestBIP324PacketVector(
3838
{
3939
// Convert input from hex to char/byte vectors/arrays.
4040
const auto in_priv_ours = ParseHex(in_priv_ours_hex);
41-
const auto in_ellswift_ours_vec = ParseHex<std::byte>(in_ellswift_ours_hex);
42-
assert(in_ellswift_ours_vec.size() == 64);
43-
std::array<std::byte, 64> in_ellswift_ours;
44-
std::copy(in_ellswift_ours_vec.begin(), in_ellswift_ours_vec.end(), in_ellswift_ours.begin());
45-
const auto in_ellswift_theirs_vec = ParseHex<std::byte>(in_ellswift_theirs_hex);
46-
assert(in_ellswift_theirs_vec.size() == 64);
47-
std::array<std::byte, 64> in_ellswift_theirs;
48-
std::copy(in_ellswift_theirs_vec.begin(), in_ellswift_theirs_vec.end(), in_ellswift_theirs.begin());
41+
const auto in_ellswift_ours = ParseHex<std::byte>(in_ellswift_ours_hex);
42+
const auto in_ellswift_theirs = ParseHex<std::byte>(in_ellswift_theirs_hex);
4943
const auto in_contents = ParseHex<std::byte>(in_contents_hex);
5044
const auto in_aad = ParseHex<std::byte>(in_aad_hex);
5145
const auto mid_send_garbage = ParseHex<std::byte>(mid_send_garbage_hex);

0 commit comments

Comments
 (0)