DiceKeys Seeded Cryptography Library
secret.hpp
1 #pragma once
2 
3 #include "sodium-buffer.hpp"
4 #include <string>
5 
19 class Secret {
20 public:
30  const std::string recipe;
31 
37  Secret(
38  const Secret &other
39  );
40 
48  Secret(
50  const std::string& recipe = {}
51  );
52 
62  Secret(
63  const std::string& seedString,
64  const std::string& recipe
65  );
66 
76  static Secret deriveFromSeed(
77  const std::string& seedString,
78  const std::string& recipe
79  );
80 
81 
91  const std::string toJson(
92  int indent = -1,
93  const char indent_char = ' '
94  ) const;
95 
103  const SodiumBuffer toSerializedBinaryForm() const;
104 
112  static Secret fromSerializedBinaryForm(const SodiumBuffer &serializedBinaryForm);
113 
121  static Secret fromJson(
122  const std::string& seedAsJson
123  );
124 
125 };
SodiumBuffer
A byte array containing a length and a pointer to memory (the data field), which ensures data is eras...
Definition: sodium-buffer.hpp:27
Secret::toSerializedBinaryForm
const SodiumBuffer toSerializedBinaryForm() const
Serialize to byte array as a list of: (secretBytes, recipe)
Definition: secret.cpp:70
Secret::recipe
const std::string recipe
A string in JSON Format for Recipes string which specifies how the constructor will derive the secret...
Definition: secret.hpp:30
Secret::toJson
const std::string toJson(int indent=-1, const char indent_char=' ') const
Serialize this object to a JSON-formatted string.
Definition: secret.cpp:57
Secret::deriveFromSeed
static Secret deriveFromSeed(const std::string &seedString, const std::string &recipe)
Derive a secret from a seed secret and a set of recipe in JSON Format for Recipes.
Definition: secret.cpp:21
Secret::fromSerializedBinaryForm
static Secret fromSerializedBinaryForm(const SodiumBuffer &serializedBinaryForm)
Deserialize from a byte array stored as a list of: (secretBytes, recipe)
Definition: secret.cpp:78
Secret::fromJson
static Secret fromJson(const std::string &seedAsJson)
Construct (reconstitute) a Secret from its JSON representation.
Definition: secret.cpp:44
Secret::Secret
Secret(const Secret &other)
Construct this object as a copy of another object.
Definition: secret.cpp:36
Secret
A secret derived from a seed string and set of options in JSON Format for Recipes.
Definition: secret.hpp:19
Secret::secretBytes
const SodiumBuffer secretBytes
The binary representation of the derived secret.
Definition: secret.hpp:24