diff --git a/include/relay/CryptoPrimitives.h b/include/relay/CryptoPrimitives.h index 0af5bbb..278645a 100644 --- a/include/relay/CryptoPrimitives.h +++ b/include/relay/CryptoPrimitives.h @@ -10,10 +10,18 @@ struct PrivateKey { /// @brief The size of a private key - static const int size = 32; + static constexpr int size = 32; 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 { /// @brief The size of a public key - static const int size = 32; + static constexpr int size = 32; 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 { /// @brief The size of a message signature - static const int size = 64; + static constexpr int size = 64; uint8_t bytes[size];