aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/xmss
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-20 11:01:03 -0500
committerJack Lloyd <[email protected]>2020-11-28 08:03:14 -0500
commit0c76f906a3083b9f4662e89508325e1dd474c7c3 (patch)
treef4c846c132feaaa22c9f5ff5563429671bea0668 /src/lib/pubkey/xmss
parentb00cd7cea9233b782697f645a5aa54fd59ecacd9 (diff)
Add Private_Key::public_key
Diffstat (limited to 'src/lib/pubkey/xmss')
-rw-r--r--src/lib/pubkey/xmss/xmss.h2
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots.h5
3 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/pubkey/xmss/xmss.h b/src/lib/pubkey/xmss/xmss.h
index af8e8a41e..566f58282 100644
--- a/src/lib/pubkey/xmss/xmss.h
+++ b/src/lib/pubkey/xmss/xmss.h
@@ -314,6 +314,8 @@ class BOTAN_PUBLIC_API(2,0) XMSS_PrivateKey final : public virtual XMSS_PublicKe
bool stateful_operation() const override { return true; }
+ std::unique_ptr<Public_Key> public_key() const override;
+
/**
* Retrieves the last unused leaf index of the private key. Reusing a leaf
* by utilizing leaf indices lower than the last unused leaf index will
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index c497be003..5d2171266 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -390,6 +390,12 @@ secure_vector<uint8_t> XMSS_PrivateKey::raw_private_key() const
return result;
}
+std::unique_ptr<Public_Key> XMSS_PrivateKey::public_key() const
+ {
+ return std::unique_ptr<Public_Key>(
+ new XMSS_PublicKey(xmss_oid(), root(), public_seed()));
+ }
+
std::unique_ptr<PK_Ops::Signature>
XMSS_PrivateKey::create_signature_op(RandomNumberGenerator&,
const std::string&,
diff --git a/src/lib/pubkey/xmss/xmss_wots.h b/src/lib/pubkey/xmss/xmss_wots.h
index d85e889bf..060d54711 100644
--- a/src/lib/pubkey/xmss/xmss_wots.h
+++ b/src/lib/pubkey/xmss/xmss_wots.h
@@ -536,6 +536,11 @@ class XMSS_WOTS_PrivateKey final : public virtual XMSS_WOTS_PublicKey,
set_key_data(generate(private_seed));
}
+ std::unique_ptr<Public_Key> public_key() const override
+ {
+ throw Not_Implemented("Not possible to derive WOTS public key from private key");
+ }
+
/**
* Retrieves the i-th WOTS private key using pseudo random key
* (re-)generation.