Skip to content

Commit

Permalink
add SerializeToArray for PrivateKey
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Oct 13, 2023
1 parent 20cd441 commit 2efa4f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/dashbls/privatekey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class PrivateKey {
// Serialize the key into bytes
void Serialize(uint8_t *buffer) const;
std::vector<uint8_t> Serialize(bool fLegacy = false) const;
std::array<uint8_t, PrivateKey::PRIVATE_KEY_SIZE> SerializeToArray(bool fLegacy = false) const;

G2Element SignG2(
const uint8_t *msg,
Expand Down
7 changes: 7 additions & 0 deletions src/privatekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ std::vector<uint8_t> PrivateKey::Serialize(const bool fLegacy) const
return data;
}

std::array<uint8_t, PrivateKey::PRIVATE_KEY_SIZE> PrivateKey::SerializeToArray(bool fLegacy) const
{
std::array<uint8_t, PRIVATE_KEY_SIZE> data{};
Serialize(data.data());
return data;
}

G2Element PrivateKey::SignG2(
const uint8_t *msg,
size_t len,
Expand Down

0 comments on commit 2efa4f2

Please sign in to comment.