Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
key-store.hpp
Go to the documentation of this file.
1#pragma once
2
9#include "crypto/crypto.h"
10
11namespace ots {
18 class KeyStore {
19 public:
23 ~KeyStore() noexcept;
24
28 explicit KeyStore() noexcept;
29
33 explicit KeyStore(const std::array<uint8_t, 32>& key) noexcept;
34
41 explicit KeyStore(const uint8_t* key, size_t size);
42
47 explicit KeyStore(crypto::secret_key key) noexcept;
48
52 void set(const std::array<uint8_t, 32>& key) noexcept;
53
60 void set(const uint8_t* key, size_t size);
61
65 void set(crypto::secret_key key) noexcept;
66
70 void wipe() noexcept;
71
78 static KeyStore transfer(uint8_t* key, size_t size);
79 protected:
80 crypto::secret_key m_key;
81
82
87 void unlockInsecure(bool writeable = false) const noexcept;
88
94 void unlockInsecureOnce(bool writeable = false) const noexcept;
95
99 void lockInsecure() const noexcept;
100
114 explicit operator crypto::secret_key&();
115
134 operator const crypto::secret_key&() const;
135
148 operator const unsigned char*() const;
149
162 operator const char*() const;
163
176 operator std::array<unsigned char, 32>() const;
177
185 void insecureAccessRequest(bool write) const;
186
191 friend class LegacySeed;
192 friend class MoneroSeed;
193 friend class Polyseed;
194 friend class Account;
195
196 private:
198 mutable bool m_lock = true;
199
201 mutable bool m_writeable = false;
202
204 mutable bool m_unlock_once = false;
205
207 mutable bool m_writeable_once = false;
208 };
209}
holds monero internal account and internal functions
Definition account.hpp:40
essentialy wraps crypto::secret_key
Definition key-store.hpp:18
~KeyStore() noexcept
Destroy KeyStore.
Definition key-store.cpp:108
void set(const std::array< uint8_t, 32 > &key) noexcept
set key from byte array
Definition key-store.cpp:22
KeyStore() noexcept
empty KeyStore
Definition key-store.cpp:7
void insecureAccessRequest(bool write) const
guard the insecure access attempts
Definition key-store.cpp:64
crypto::secret_key m_key
Definition key-store.hpp:80
void unlockInsecureOnce(bool writeable=false) const noexcept
unlock insecure access once to the stored bytes in crypto::secret_key and locks the insecure access d...
Definition key-store.cpp:50
void wipe() noexcept
secure wipe of the keystore
Definition key-store.cpp:104
void lockInsecure() const noexcept
locks insecure access complete
Definition key-store.cpp:57
static KeyStore transfer(uint8_t *key, size_t size)
moves 32 bytes into the KeyStore and wipes the insecure memory
Definition key-store.cpp:37
void unlockInsecure(bool writeable=false) const noexcept
unlock insecure access to the stored bytes in crypto::secret_key
Definition key-store.cpp:43
Represents a monero 13-words seed type for backward compatibility.
Definition ots.hpp:482
Represents a Monero 25-words seed.
Definition ots.hpp:558
Represents a Polyseed type.
Definition ots.hpp:706
The library exists complete only in this namespace.
Definition account.hpp:39