Improve crypto primitives

This commit is contained in:
Christoph Hagen 2024-02-10 11:32:16 +01:00
parent bd5a8d52cc
commit 6256b6ef33

View File

@ -10,10 +10,18 @@
struct PrivateKey { struct PrivateKey {
/// @brief The size of a private key /// @brief The size of a private key
static const int size = 32; static constexpr int size = 32;
uint8_t bytes[size]; uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
}; };
/** /**
@ -22,10 +30,18 @@ struct PrivateKey {
struct PublicKey { struct PublicKey {
/// @brief The size of a public key /// @brief The size of a public key
static const int size = 32; static constexpr int size = 32;
uint8_t bytes[size]; uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
}; };
/** /**
@ -34,7 +50,7 @@ struct PublicKey {
struct Signature { struct Signature {
/// @brief The size of a message signature /// @brief The size of a message signature
static const int size = 64; static constexpr int size = 64;
uint8_t bytes[size]; uint8_t bytes[size];