summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/identity.cpp12
-rw-r--r--src/pubkey.h12
2 files changed, 23 insertions, 1 deletions
diff --git a/src/identity.cpp b/src/identity.cpp
index 7364a8b..d7dd1f9 100644
--- a/src/identity.cpp
+++ b/src/identity.cpp
@@ -117,8 +117,18 @@ Identity Identity::Builder::commit() const
throw runtime_error("failed to load secret key");
auto sdata = key->sign(idata);
+ if (idata->owner) {
+ if (auto okey = SecretKey::load((*idata->owner)->data->keyIdentity))
+ sdata = okey->signAdd(sdata);
+ else
+ throw runtime_error("failed to load secret key");
+ }
+
+ auto p = Identity::Priv::validate({ sdata });
+ if (!p)
+ throw runtime_error("failed to validate committed identity");
- return Identity(Identity::Priv::validate({ sdata }));
+ return Identity(std::move(p));
}
void Identity::Builder::name(const string & val)
diff --git a/src/pubkey.h b/src/pubkey.h
index 7b80752..ef7e322 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -38,6 +38,8 @@ public:
template<class T>
Stored<Signed<T>> sign(const Stored<T> &) const;
+ template<class T>
+ Stored<Signed<T>> signAdd(const Stored<Signed<T>> &) const;
private:
vector<uint8_t> sign(const Digest &) const;
@@ -89,6 +91,16 @@ Stored<Signed<T>> SecretKey::sign(const Stored<T> & val) const
return st.store(Signed(val, { sig }));
}
+template<class T>
+Stored<Signed<T>> SecretKey::signAdd(const Stored<Signed<T>> & val) const
+{
+ auto st = val.ref().storage();
+ auto sig = st.store(Signature(pub(), sign(val.ref().digest())));
+ auto sigs = val->sigs;
+ sigs.push_back(st.store(Signature(pub(), sign(val->data.ref().digest()))));
+ return st.store(Signed(val->data, sigs));
+}
+
template<typename T>
Signed<T> Signed<T>::load(const Ref & ref)
{