diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-03-04 17:08:30 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-03-04 17:45:22 +0100 |
commit | af7cdb1096dd12f0ca06d78f5e5a3f5e9f57b3a8 (patch) | |
tree | 1b8ff00a1183f12cd5d8f8b8ea445ec7d34c1d72 /src/libstore/crypto.cc | |
parent | 42bc395b63260e13f42e4bf348823799e78e445f (diff) |
BinaryCacheStore: Remove publicKeyFile argument
The public key can be derived from the secret key, so there's no need
for the user to supply it separately.
Diffstat (limited to 'src/libstore/crypto.cc')
-rw-r--r-- | src/libstore/crypto.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstore/crypto.cc b/src/libstore/crypto.cc index c1b57e51d..53e94e1f5 100644 --- a/src/libstore/crypto.cc +++ b/src/libstore/crypto.cc @@ -55,6 +55,17 @@ std::string SecretKey::signDetached(const std::string & data) const #endif } +PublicKey SecretKey::toPublicKey() const +{ +#if HAVE_SODIUM + unsigned char pk[crypto_sign_PUBLICKEYBYTES]; + crypto_sign_ed25519_sk_to_pk(pk, (unsigned char *) key.data()); + return PublicKey(name, std::string((char *) pk, crypto_sign_PUBLICKEYBYTES)); +#else + noSodium(); +#endif +} + PublicKey::PublicKey(const string & s) : Key(s) { |