36 #include <boost/optional.hpp> 37 #include <type_traits> 38 #include <boost/thread/mutex.hpp> 39 #include <boost/thread/lock_guard.hpp> 40 #include <boost/archive/iterators/binary_from_base64.hpp> 41 #include <boost/archive/iterators/base64_from_binary.hpp> 42 #include <boost/archive/iterators/transform_width.hpp> 43 #include <boost/algorithm/string.hpp> 44 #include <boost/algorithm/hex.hpp> 85 std::vector<public_key> keys;
90 std::vector<secret_key> keys;
138 sizeof(
signature) == 64,
"Invalid structure size");
180 static void generate_ring_signature(
const hash &,
const key_image &,
184 static bool check_ring_signature(
const hash &,
const key_image &,
196 static std::vector<std::string> create_ed25519_keypair();
217 typename std::remove_cv<T>::type
res;
237 std::uniform_int_distribution<T> dis(range_min, range_max);
245 return crypto::rand_range<T>(0, sz-1);
251 return crypto_ops::generate_keys(pub, sec, recovery_key, recover);
257 return crypto_ops::check_key(
key);
263 return crypto_ops::secret_key_to_public_key(sec, pub);
273 return crypto_ops::generate_key_derivation(key1, key2, derivation);
277 return crypto_ops::derive_public_key(derivation,
output_index, base, derived_key);
280 return crypto_ops::derivation_to_scalar(derivation,
output_index,
res);
284 crypto_ops::derive_secret_key(derivation,
output_index, base, derived_key);
287 return crypto_ops::derive_subaddress_public_key(out_key, derivation,
output_index, result);
293 crypto_ops::generate_signature(prefix_hash, pub, sec, sig);
296 return crypto_ops::check_signature(prefix_hash, pub, sig);
300 return crypto_ops::generate_input_signature(prefix_hash, input_index, sec_view, sec_spend, sig);
304 return crypto_ops::verify_input_signature(prefix_hash, input_index, pub_view, pub_spend, sig);
312 crypto_ops::generate_tx_proof(prefix_hash, R,
A, B, D, r, sig);
315 return crypto_ops::check_tx_proof(prefix_hash, R,
A, B, D, sig);
325 crypto_ops::generate_key_image(pub, sec, image);
328 const public_key *
const *pubs, std::size_t pubs_count,
331 crypto_ops::generate_ring_signature(prefix_hash, image, pubs, pubs_count, sec, sec_index, sig);
334 const public_key *
const *pubs, std::size_t pubs_count,
336 return crypto_ops::check_ring_signature(prefix_hash, image, pubs, pubs_count, sig);
340 return crypto_ops::addKeys(
A, B);
346 const std::vector<const public_key *> &pubs,
352 const std::vector<const public_key *> &pubs,
389 return crypto_ops::create_ed25519_keypair();
394 using It = transform_width<binary_from_base64<std::string::const_iterator>, 8, 6>;
395 return boost::algorithm::trim_right_copy_if(
std::string(It(std::begin(val)), It(std::end(val))), [](
char c) {
402 using It = base64_from_binary<transform_width<std::string::const_iterator, 6, 8>>;
403 auto tmp =
std::string(It(std::begin(val)), It(std::end(val)));
404 return tmp.append((3 - val.size() % 3) % 3,
'=');
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
#define CRYPTO_MAKE_COMPARABLE(type)
span< const std::uint8_t > as_byte_span(const T &src) noexcept
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
bool check_ring_signature(const hash &prefix_hash, const key_image &image, const public_key *const *pubs, std::size_t pubs_count, const signature *sig)
void generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
public_key addKeys(const public_key &A, const public_key &B)
void generate_input_signature(const hash prefix_hash, const uint32_t input_index, const secret_key sec_view, const secret_key sec_spend, signature &sig)
#define CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(type)
void hash_to_ec(const public_key &key, ge_p3 &res)
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
void hash_to_point(const crypto::hash &h, crypto::ec_point &res)
void random32_unbiased(unsigned char *bytes)
std::enable_if< std::is_unsigned< T >::value, T >::type rand_idx(T sz)
size_t rs_comm_size(size_t pubs_count)
const crypto::secret_key null_skey
std::enable_if< std::is_integral< T >::value, T >::type rand_range(T range_min, T range_max)
std::string base64_encode(const std::string &val)
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
void generate_tx_proof(const hash &prefix_hash, const public_key &R, const public_key &A, const boost::optional< public_key > &B, const public_key &D, const secret_key &r, signature &sig)
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
void rand(size_t N, uint8_t *bytes)
const crypto::public_key null_pkey
bool verify_signature(const std::string &message, const std::string &publicKey, const std::string &signature)
static constexpr result_type max()
bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
void generate_ring_signature(const hash &prefix_hash, const key_image &image, const public_key *const *pubs, std::size_t pubs_count, const secret_key &sec, std::size_t sec_index, signature *sig)
unsigned __int64 uint64_t
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
std::string base64_decode(const std::string &val)
std::string message("Message requiring signing")
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
bool check_tx_proof(const hash &prefix_hash, const public_key &R, const public_key &A, const boost::optional< public_key > &B, const public_key &D, const signature &sig)
static constexpr result_type min()
const GenericPointer< typename T::ValueType > T2 value
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
bool check_key(const public_key &key)
void hash_to_scalar(const void *data, size_t length, ec_scalar &res)
struct ec_point_pair ab[]
bool verify_input_signature(const hash &prefix_hash, const uint32_t input_index, const public_key pub_view, const public_key pub_spend, signature sig)
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
std::vector< std::string > create_ed25519_keypair()
std::vector< secret_keyV > column_vectors
std::ostream & operator<<(std::ostream &o, const crypto::public_key &v)
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
std::string sign_message(const std::string &message, const std::string &privateKey)
result_type operator()() const
#define CRYPTO_MAKE_HASHABLE(type)
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
bool check_signature(const hash &prefix_hash, const public_key &pub, const signature &sig)
void random_scalar(ec_scalar &res)