diff options
author | Francis Dupont <[email protected]> | 2017-06-12 15:22:07 +0200 |
---|---|---|
committer | Francis Dupont <[email protected]> | 2017-06-12 15:22:07 +0200 |
commit | c5cd562791fcaba78e1fdffc2844b3e0474c4dbe (patch) | |
tree | eba955f05b3ee5c9a715b4e73e272d4fb62cec69 /src/lib/pubkey | |
parent | 638c3178cb9a100c1b427cb31be07ff979d0a83e (diff) |
Added Curve25519_PrivateKey constructor from secret_key
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp index 070b8e841..341736be4 100644 --- a/src/lib/pubkey/curve25519/curve25519.cpp +++ b/src/lib/pubkey/curve25519/curve25519.cpp @@ -66,6 +66,18 @@ std::vector<uint8_t> Curve25519_PublicKey::public_key_bits() const .get_contents_unlocked(); } +Curve25519_PrivateKey::Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key) + { + if(secret_key.size() == 32) + { + m_public.resize(32); + m_private = secret_key; + curve25519_basepoint(m_public.data(), m_private.data()); + } + else + throw Decoding_Error("Invalid size for Curve25519 private key"); + } + Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng) { m_private = rng.random_vec(32); |