summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 17:34:39 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 17:34:39 -0800
commit5fa1d9796cbed473bdac1f1a4b84d5f6e5a1c69c (patch)
treefaa85932589ee1de79b32af9e0a3e6cb926de29f /node
parent77a1dd4737cfaccfd013f85a5feaa786c58a9a35 (diff)
downloadinfinitytier-5fa1d9796cbed473bdac1f1a4b84d5f6e5a1c69c.tar.gz
infinitytier-5fa1d9796cbed473bdac1f1a4b84d5f6e5a1c69c.zip
zerotier-idtool commands to init and generate moons
Diffstat (limited to 'node')
-rw-r--r--node/World.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/node/World.hpp b/node/World.hpp
index 06dcb981..8fe6dd2e 100644
--- a/node/World.hpp
+++ b/node/World.hpp
@@ -227,6 +227,33 @@ public:
inline bool operator<(const World &w) const { return (((int)_type < (int)w._type) ? true : ((_type == w._type) ? (_id < w._id) : false)); }
+ /**
+ * Create a World object signed with a key pair
+ *
+ * @param t World type
+ * @param id World ID
+ * @param ts World timestamp / revision
+ * @param sk Key that must be used to sign the next future update to this world
+ * @param roots Roots and their stable endpoints
+ * @param signWith Key to sign this World with (can have the same public as the next-update signing key, but doesn't have to)
+ * @return Signed World object
+ */
+ static inline World make(World::Type t,uint64_t id,uint64_t ts,const C25519::Public &sk,const std::vector<World::Root> &roots,const C25519::Pair &signWith)
+ {
+ World w;
+ w._id = id;
+ w._ts = ts;
+ w._type = t;
+ w._updatesMustBeSignedBy = sk;
+ w._roots = roots;
+
+ Buffer<ZT_WORLD_MAX_SERIALIZED_LENGTH> tmp;
+ w.serialize(tmp,true);
+ w._signature = C25519::sign(signWith,tmp.data(),tmp.size());
+
+ return w;
+ }
+
protected:
uint64_t _id;
uint64_t _ts;