DiceKeys Seeded Cryptography Library
|
A secret derived from a seed string and set of options in JSON Format for Recipes. More...
#include <secret.hpp>
Public Member Functions | |
Secret (const Secret &other) | |
Construct this object as a copy of another object. More... | |
Secret (const SodiumBuffer &secretBytes, const std::string &recipe={}) | |
Secret (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. More... | |
const std::string | toJson (int indent=-1, const char indent_char=' ') const |
Serialize this object to a JSON-formatted string. More... | |
const SodiumBuffer | toSerializedBinaryForm () const |
Serialize to byte array as a list of: (secretBytes, recipe) More... | |
Static Public Member Functions | |
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. More... | |
static Secret | fromSerializedBinaryForm (const SodiumBuffer &serializedBinaryForm) |
Deserialize from a byte array stored as a list of: (secretBytes, recipe) More... | |
static Secret | fromJson (const std::string &seedAsJson) |
Construct (reconstitute) a Secret from its JSON representation. More... | |
Public Attributes | |
const SodiumBuffer | secretBytes |
The binary representation of the derived secret. | |
const std::string | recipe |
A string in JSON Format for Recipes string which specifies how the constructor will derive the secretBytes from the original secret seed. | |
A secret derived from a seed string and set of options in JSON Format for Recipes.
Because the secret is derived using a one-way function, its value does not reveal the secret seed used to derive it. Rather, clients can use this secret knowing that, if lost, it can be re-derived from the same seed and recipe that were first used to derive it.
Secret::Secret | ( | const Secret & | other | ) |
Construct this object as a copy of another object.
other | The Secret to copy into this new object |
Secret::Secret | ( | const SodiumBuffer & | secretBytes, |
const std::string & | recipe = {} |
||
) |
Construct a secret from its two fields: the secretBytes and the recipe.
secretBytes | The derived secret. |
recipe | The recipe in JSON Format for Recipes. |
Secret::Secret | ( | 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.
seedString | The secret seed string from which this secret should be derived. Once the secret is derived, you won't need the secretSeedBytes again unless you need to re-derive this secret. |
recipe | The recipe in JSON Format for Recipes. |
|
static |
Derive a secret from a seed secret and a set of recipe in JSON Format for Recipes.
seedString | The secret seed string from which this secret should be derived. Once the secret is derived, you won't need the secretSeedBytes again unless you need to re-derive this secret. |
recipe | The recipe in JSON Format for Recipes. |
|
static |
|
static |
Deserialize from a byte array stored as a list of: (secretBytes, recipe)
Stored in SodiumBuffer's fixed-length list format. Strings are stored as UTF8 byte arrays.
const std::string Secret::toJson | ( | int | indent = -1 , |
const char | indent_char = ' ' |
||
) | const |
Serialize this object to a JSON-formatted string.
It can be reconstituted by calling the constructor with this string.
indent | The number of characters to indent the JSON (optional) |
indent_char | The character with which to indent the JSON (optional) |
const SodiumBuffer Secret::toSerializedBinaryForm | ( | ) | const |
Serialize to byte array as a list of: (secretBytes, recipe)
Stored in SodiumBuffer's fixed-length list format. Strings are stored as UTF8 byte arrays.