Equity
Bitcoin Protocol Library
Typedefs | Functions | Variables
Crypto::Ecc Namespace Reference

ECC library. More...

Typedefs

typedef std::vector< uint8_t > PublicKey
 An ECC public key.
 
typedef std::array< uint8_t, PRIVATE_KEY_SIZEPrivateKey
 An ECC private key.
 
typedef std::vector< uint8_t > Signature
 An ECC signature.
 

Functions

bool publicKeyIsValid (uint8_t const *k, size_t size)
 Returns true if the public key is valid. More...
 
bool publicKeyIsValid (PublicKey const &k)
 Returns true if the public key is valid. More...
 
bool privateKeyIsValid (uint8_t const *k, size_t size)
 Returns true if the private key is valid. More...
 
bool privateKeyIsValid (PrivateKey const &k)
 Returns true if the private key is valid. More...
 
bool derivePublicKey (PrivateKey const &prvKey, PublicKey &pubKey, bool uncompressed=false)
 Derives a public key from a private key. More...
 
bool sign (uint8_t const *message, size_t size, PrivateKey const &prvKey, PublicKey const &pubKey, Signature &signature)
 Signs a message. More...
 
bool verify (uint8_t const *message, size_t size, PublicKey const &pubKey, Signature const &signature)
 Verifies a signed message. More...
 

Variables

size_t const COMPRESSED_PUBLIC_KEY_SIZE = 33
 Size of a compressed public key.
 
size_t const UNCOMPRESSED_PUBLIC_KEY_SIZE = 65
 Size of an uncompressed public key.
 
size_t const PRIVATE_KEY_SIZE = 256 / 8
 Size of a private key.
 

Detailed Description

ECC library.

Note
Key values are assumed to be big-endian.

Function Documentation

bool Crypto::Ecc::derivePublicKey ( PrivateKey const &  prvKey,
PublicKey pubKey,
bool  uncompressed = false 
)

Derives a public key from a private key.

Parameters
prvKeyprivate key
[out]pubKeyderived public key
uncompressedif true, then the resulting public key is uncompressed (default: false)
Returns
true if the returned key is valid
bool Crypto::Ecc::privateKeyIsValid ( uint8_t const *  k,
size_t  size 
)

Returns true if the private key is valid.

Parameters
kkey
sizesize of key
Returns
true if the key is valid
bool Crypto::Ecc::privateKeyIsValid ( PrivateKey const &  k)
inline

Returns true if the private key is valid.

Parameters
kkey
Returns
true if the key is valid
bool Crypto::Ecc::publicKeyIsValid ( uint8_t const *  k,
size_t  size 
)
inline

Returns true if the public key is valid.

Parameters
kkey
sizesize of key
Returns
true if the key is valid
bool Crypto::Ecc::publicKeyIsValid ( PublicKey const &  k)
inline

Returns true if the public key is valid.

Parameters
kkey
Returns
true if the key is valid
bool Crypto::Ecc::sign ( uint8_t const *  message,
size_t  size,
PrivateKey const &  prvKey,
PublicKey const &  pubKey,
Signature signature 
)

Signs a message.

Parameters
messagemessage to sign
sizesize of the message
prvKeyprivate key
pubKeypublic key
[out]signaturesignature
Returns
true if the returned signature is valid
bool Crypto::Ecc::verify ( uint8_t const *  message,
size_t  size,
PublicKey const &  pubKey,
Signature const &  signature 
)

Verifies a signed message.

Parameters
messagemessage to sign
sizesize of the message
pubKeypublic key
signaturesignature
Returns
true if the message's signature is valid and it matches the message
Parameters
messagesigned message
sizesize of the message
pubKeypublic key
signaturesignature to verify
Returns
true if the message's signature is vaid and it matches the message