9 #include "libp2p/crypto/random_generator.hpp" 13 : generator_(
std::move(generator)) {
24 const Sr25519Seed &seed)
const {
25 std::array<uint8_t, constants::sr25519::KEYPAIR_SIZE> kp{};
26 sr25519_keypair_from_seed(kp.data(), seed.data());
31 keypair.secret_key.begin());
35 keypair.public_key.begin());
40 const Sr25519Keypair &keypair, gsl::span<const uint8_t> message)
const {
41 Sr25519Signature signature{};
44 sr25519_sign(signature.data(),
57 const Sr25519Signature &signature,
58 gsl::span<const uint8_t> message,
59 const Sr25519PublicKey &public_key)
const {
62 result = sr25519_verify_deprecated(
63 signature.data(), message.data(), message.size(), public_key.data());
71 const Sr25519Signature &signature,
72 gsl::span<const uint8_t> message,
73 const Sr25519PublicKey &public_key)
const {
76 result = sr25519_verify(
77 signature.data(), message.data(), message.size(), public_key.data());
81 return outcome::success(result);
89 return "failed to sign message, unknown error occured";
91 return "failed to verify message, unknown error occured";
93 return "unknown Sr25519ProviderError";
Sr25519ProviderImpl(std::shared_ptr< CSPRNG > generator)
Sr25519SecretKey secret_key
std::shared_ptr< CSPRNG > generator_
Sr25519KeypairAndSeed generateKeypair() const override
outcome::result< Sr25519Signature > sign(const Sr25519Keypair &keypair, gsl::span< const uint8_t > message) const override
outcome::result< bool > verify(const Sr25519Signature &signature, gsl::span< const uint8_t > message, const Sr25519PublicKey &public_key) const override
Sr25519PublicKey public_key
OUTCOME_CPP_DEFINE_CATEGORY(kagome::crypto, Sr25519ProviderError, e)
outcome::result< bool > verify_deprecated(const Sr25519Signature &signature, gsl::span< const uint8_t > message, const Sr25519PublicKey &public_key) const override