33secp256k1_context
const*
36 struct secp256k1Deleter {
37 void operator()(secp256k1_context* b) { secp256k1_context_destroy(b); }
39 static std::unique_ptr<secp256k1_context, secp256k1Deleter>
40 s_ctx(secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY));
49 static const h256 s_max {
"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"};
50 static const h256 s_zero;
52 return (v <= 1 && r > s_zero &&
s > s_zero &&
r < s_max &&
s < s_max);
59 secp256k1_pubkey rawPubkey;
61 if (!secp256k1_ec_pubkey_create(ctx, &rawPubkey, _secret.
data()))
63 std::array<uint8_t, 65> serializedPubkey;
64 size_t serializedPubkeySize = serializedPubkey.size();
65 secp256k1_ec_pubkey_serialize(ctx,
66 serializedPubkey.data(),
67 &serializedPubkeySize,
69 SECP256K1_EC_UNCOMPRESSED);
70 assert(serializedPubkeySize == serializedPubkey.size());
72 assert(serializedPubkey[0] == 0x04);
Simple class that represents a "key pair".
static KeyPair create()
Create a new, randomly generated object.
Address const & address() const
Retrieve the associated address of the public key.
static SecureFixedHash< T > random()
uint8_t const * data() const
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
Address toAddress(Public const &_public)
Convert a public key to address.
Public toPublic(Secret const &_secret)
Convert a secret key into the public key equivalent.
h160 right160(h256 const &_t)
Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.
bool isValid() const noexcept