@ -33,7 +33,7 @@ static_assert(dev::Secret::size == 32, "Secret key must be 32 bytes.");
static_assert ( dev : : Public : : size = = 64 , " Public key must be 64 bytes. " ) ;
static_assert ( dev : : Signature : : size = = 65 , " Signature must be 65 bytes. " ) ;
bytes Secp256k1 : : eciesKDF ( Secret _z , bytes _s1 , unsigned kdByteLen )
bytes Secp256k1PP : : eciesKDF ( Secret _z , bytes _s1 , unsigned kdByteLen )
{
// interop w/go ecies implementation
@ -64,7 +64,7 @@ bytes Secp256k1::eciesKDF(Secret _z, bytes _s1, unsigned kdByteLen)
return k ;
}
void Secp256k1 : : encryptECIES ( Public const & _k , bytes & io_cipher )
void Secp256k1PP : : encryptECIES ( Public const & _k , bytes & io_cipher )
{
// interop w/go ecies implementation
auto r = KeyPair : : create ( ) ;
@ -98,7 +98,7 @@ void Secp256k1::encryptECIES(Public const& _k, bytes& io_cipher)
io_cipher . swap ( msg ) ;
}
bool Secp256k1 : : decryptECIES ( Secret const & _k , bytes & io_text )
bool Secp256k1PP : : decryptECIES ( Secret const & _k , bytes & io_text )
{
// interop w/go ecies implementation
@ -145,7 +145,7 @@ bool Secp256k1::decryptECIES(Secret const& _k, bytes& io_text)
return true ;
}
void Secp256k1 : : encrypt ( Public const & _k , bytes & io_cipher )
void Secp256k1PP : : encrypt ( Public const & _k , bytes & io_cipher )
{
ECIES < ECP > : : Encryptor e ;
initializeDLScheme ( _k , e ) ;
@ -163,7 +163,7 @@ void Secp256k1::encrypt(Public const& _k, bytes& io_cipher)
io_cipher = std : : move ( ciphertext ) ;
}
void Secp256k1 : : decrypt ( Secret const & _k , bytes & io_text )
void Secp256k1PP : : decrypt ( Secret const & _k , bytes & io_text )
{
CryptoPP : : ECIES < CryptoPP : : ECP > : : Decryptor d ;
initializeDLScheme ( _k , d ) ;
@ -194,12 +194,12 @@ void Secp256k1::decrypt(Secret const& _k, bytes& io_text)
io_text = std : : move ( plain ) ;
}
Signature Secp256k1 : : sign ( Secret const & _k , bytesConstRef _message )
Signature Secp256k1PP : : sign ( Secret const & _k , bytesConstRef _message )
{
return sign ( _k , sha3 ( _message ) ) ;
}
Signature Secp256k1 : : sign ( Secret const & _key , h256 const & _hash )
Signature Secp256k1PP : : sign ( Secret const & _key , h256 const & _hash )
{
// assumption made by signing alogrithm
asserts ( m_q = = m_qs ) ;
@ -240,18 +240,18 @@ Signature Secp256k1::sign(Secret const& _key, h256 const& _hash)
return sig ;
}
bool Secp256k1 : : verify ( Signature const & _signature , bytesConstRef _message )
bool Secp256k1PP : : verify ( Signature const & _signature , bytesConstRef _message )
{
return ! ! recover ( _signature , _message ) ;
}
bool Secp256k1 : : verify ( Public const & _p , Signature const & _sig , bytesConstRef _message , bool _hashed )
bool Secp256k1PP : : verify ( Public const & _p , Signature const & _sig , bytesConstRef _message , bool _hashed )
{
// todo: verify w/o recovery (if faster)
return ( bool ) _p = = _hashed ? ( bool ) recover ( _sig , _message ) : ( bool ) recover ( _sig , sha3 ( _message ) . ref ( ) ) ;
return _p = = ( _hashed ? recover ( _sig , _message ) : recover ( _sig , sha3 ( _message ) . ref ( ) ) ) ;
}
Public Secp256k1 : : recover ( Signature _signature , bytesConstRef _message )
Public Secp256k1PP : : recover ( Signature _signature , bytesConstRef _message )
{
Public recovered ;
@ -293,7 +293,7 @@ Public Secp256k1::recover(Signature _signature, bytesConstRef _message)
return recovered ;
}
bool Secp256k1 : : verifySecret ( Secret const & _s , Public & _p )
bool Secp256k1PP : : verifySecret ( Secret const & _s , Public & _p )
{
DL_PrivateKey_EC < ECP > k ;
k . Initialize ( m_params , secretToExponent ( _s ) ) ;
@ -309,7 +309,7 @@ bool Secp256k1::verifySecret(Secret const& _s, Public& _p)
return true ;
}
void Secp256k1 : : agree ( Secret const & _s , Public const & _r , h256 & o_s )
void Secp256k1PP : : agree ( Secret const & _s , Public const & _r , h256 & o_s )
{
// TODO: mutex ASN1::secp256k1() singleton
// Creating Domain is non-const for m_oid and m_oid is not thread-safe
@ -320,7 +320,7 @@ void Secp256k1::agree(Secret const& _s, Public const& _r, h256& o_s)
d . Agree ( o_s . data ( ) , _s . data ( ) , remote ) ;
}
void Secp256k1 : : exportPublicKey ( CryptoPP : : DL_PublicKey_EC < CryptoPP : : ECP > const & _k , Public & o_p )
void Secp256k1PP : : exportPublicKey ( CryptoPP : : DL_PublicKey_EC < CryptoPP : : ECP > const & _k , Public & o_p )
{
bytes prefixedKey ( _k . GetGroupParameters ( ) . GetEncodedElementSize ( true ) ) ;
@ -333,7 +333,7 @@ void Secp256k1::exportPublicKey(CryptoPP::DL_PublicKey_EC<CryptoPP::ECP> const&
memcpy ( o_p . data ( ) , & prefixedKey [ 1 ] , Public : : size ) ;
}
void Secp256k1 : : exponentToPublic ( Integer const & _e , Public & o_p )
void Secp256k1PP : : exponentToPublic ( Integer const & _e , Public & o_p )
{
CryptoPP : : DL_PublicKey_EC < CryptoPP : : ECP > pk ;