Electroneum
crypto Namespace Reference

crypto namespace. More...

Namespaces

 ElectrumWords
 Mnemonic seed word generation and wallet restoration helper functions.
 

Classes

class  crypto_ops
 
struct  ec_point_pair
 
struct  ge_cached
 
struct  ge_p1p1
 
struct  ge_p2
 
struct  ge_p3
 
struct  ge_precomp
 
union  hash_state
 
struct  random_device
 
struct  rs_comm
 
struct  s_comm
 
struct  s_comm_2
 
struct  s_comm_3
 

Typedefs

typedef int32_t fe[10]
 
typedef ge_cached ge_dsmp[8]
 
using secret_key = epee::mlocked< tools::scrubbed< ec_scalar > >
 

Enumerations

enum  { HASH_SIZE = 32, HASH_DATA_AREA = 136 }
 

Functions

void ge_add (ge_p1p1 *, const ge_p3 *, const ge_cached *)
 
void ge_dsm_precomp (ge_dsmp r, const ge_p3 *s)
 
void ge_double_scalarmult_base_vartime (ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *)
 
void ge_double_scalarmult_base_vartime_p3 (ge_p3 *, const unsigned char *, const ge_p3 *, const unsigned char *)
 
int ge_frombytes_vartime (ge_p3 *, const unsigned char *)
 
void ge_p1p1_to_p2 (ge_p2 *, const ge_p1p1 *)
 
void ge_p1p1_to_p3 (ge_p3 *, const ge_p1p1 *)
 
void ge_p2_dbl (ge_p1p1 *, const ge_p2 *)
 
void ge_p3_to_cached (ge_cached *, const ge_p3 *)
 
void ge_p3_to_p2 (ge_p2 *, const ge_p3 *)
 
void ge_p3_tobytes (unsigned char *, const ge_p3 *)
 
void ge_scalarmult_base (ge_p3 *, const unsigned char *)
 
void ge_tobytes (unsigned char *, const ge_p2 *)
 
void sc_reduce (unsigned char *)
 
void ge_scalarmult (ge_p2 *, const unsigned char *, const ge_p3 *)
 
void ge_scalarmult_p3 (ge_p3 *, const unsigned char *, const ge_p3 *)
 
void ge_double_scalarmult_precomp_vartime (ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp)
 
void ge_double_scalarmult_precomp_vartime2 (ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp)
 
void ge_double_scalarmult_precomp_vartime2_p3 (ge_p3 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp)
 
void ge_mul8 (ge_p1p1 *, const ge_p2 *)
 
void ge_fromfe_frombytes_vartime (ge_p2 *, const unsigned char *)
 
void sc_0 (unsigned char *)
 
void sc_reduce32 (unsigned char *)
 
void sc_add (unsigned char *, const unsigned char *, const unsigned char *)
 
void sc_sub (unsigned char *, const unsigned char *, const unsigned char *)
 
void sc_mulsub (unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
 
void sc_mul (unsigned char *, const unsigned char *, const unsigned char *)
 
void sc_muladd (unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
int sc_check (const unsigned char *)
 
int sc_isnonzero (const unsigned char *)
 
uint64_t load_3 (const unsigned char *in)
 
uint64_t load_4 (const unsigned char *in)
 
void ge_sub (ge_p1p1 *r, const ge_p3 *p, const ge_cached *q)
 
void fe_add (fe h, const fe f, const fe g)
 
void fe_tobytes (unsigned char *, const fe)
 
void fe_invert (fe out, const fe z)
 
int ge_p3_is_point_at_infinity (const ge_p3 *p)
 
void generate_random_bytes_not_thread_safe (size_t n, void *result)
 
void generate_random_bytes_thread_safe (size_t N, uint8_t *bytes)
 
void random32_unbiased (unsigned char *bytes)
 
void random_scalar (ec_scalar &res)
 
void hash_to_scalar (const void *data, size_t length, ec_scalar &res)
 
void hash_to_ec (const public_key &key, ge_p3 &res)
 
void hash_to_ec (const hash &h, ge_p3 &res)
 
void hash_to_point (const crypto::hash &h, crypto::ec_point &res)
 
size_t rs_comm_size (size_t pubs_count)
 
void rand (size_t N, uint8_t *bytes)
 
template<typename T >
std::enable_if< std::is_pod< T >::value, T >::type rand ()
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type rand_range (T range_min, T range_max)
 
template<typename T >
std::enable_if< std::is_unsigned< T >::value, T >::type rand_idx (T sz)
 
secret_key generate_keys (public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
 
bool check_key (const public_key &key)
 
bool secret_key_to_public_key (const secret_key &sec, public_key &pub)
 
bool generate_key_derivation (const public_key &key1, const secret_key &key2, key_derivation &derivation)
 
bool derive_public_key (const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
 
void derivation_to_scalar (const key_derivation &derivation, size_t output_index, ec_scalar &res)
 
void derive_secret_key (const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
 
bool derive_subaddress_public_key (const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
 
void generate_signature (const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig)
 
bool check_signature (const hash &prefix_hash, const public_key &pub, const signature &sig)
 
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)
 
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)
 
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)
 
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)
 
void generate_key_image (const public_key &pub, const secret_key &sec, key_image &image)
 
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)
 
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)
 
public_key addKeys (const public_key &A, const public_key &B)
 
void generate_ring_signature (const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const secret_key &sec, std::size_t sec_index, signature *sig)
 
bool check_ring_signature (const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const signature *sig)
 
std::ostream & operator<< (std::ostream &o, const crypto::public_key &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::secret_key &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::key_derivation &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::key_image &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::signature &v)
 
std::string sign_message (const std::string &message, const std::string &privateKey)
 
bool verify_signature (const std::string &message, const std::string &publicKey, const std::string &signature)
 
bool verify_signature (const std::string &message, std::vector< std::string > publicKey, const std::string &signature)
 
std::vector< std::string > create_ed25519_keypair ()
 
std::string base64_decode (const std::string &val)
 
std::string base64_encode (const std::string &val)
 
void hash_permutation (union hash_state *state)
 
void hash_process (union hash_state *state, const uint8_t *buf, size_t count)
 
void cn_fast_hash (const void *data, size_t length, char *hash)
 
void cn_slow_hash (const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
 
void hash_extra_blake (const void *data, size_t length, char *hash)
 
void hash_extra_groestl (const void *data, size_t length, char *hash)
 
void hash_extra_jh (const void *data, size_t length, char *hash)
 
void hash_extra_skein (const void *data, size_t length, char *hash)
 
void tree_hash (const char(*hashes)[HASH_SIZE], size_t count, char *root_hash)
 
void cn_fast_hash (const void *data, std::size_t length, hash &hash)
 
hash cn_fast_hash (const void *data, std::size_t length)
 
void cn_slow_hash (const void *data, std::size_t length, hash &hash, int variant=0, uint64_t height=0)
 
void cn_slow_hash_prehashed (const void *data, std::size_t length, hash &hash, int variant=0, uint64_t height=0)
 
void tree_hash (const hash *hashes, std::size_t count, hash &root_hash)
 
std::ostream & operator<< (std::ostream &o, const crypto::hash &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::hash8 &v)
 
std::ostream & operator<< (std::ostream &o, const crypto::hash64 &v)
 

Variables

const ge_precomp ge_Bi [8]
 
const fe fe_sqrtm1
 
const fe fe_d
 
const fe fe_d2
 
const ge_precomp ge_base [32][8]
 
const fe fe_ma2
 
const fe fe_ma
 
const fe fe_fffb1
 
const fe fe_fffb2
 
const fe fe_fffb3
 
const fe fe_fffb4
 
const ge_p3 ge_p3_identity
 
const ge_p3 ge_p3_H
 
const crypto::public_key null_pkey = crypto::public_key{}
 
const crypto::secret_key null_skey = crypto::secret_key{}
 
POD_CLASS ec_point
 
POD_CLASS ec_scalar
 
POD_CLASS public_key
 
POD_CLASS public_keyV
 
int rows
 
POD_CLASS secret_keyV
 
POD_CLASS public_keyM
 
std::vector< secret_keyVcolumn_vectors
 
POD_CLASS key_derivation
 
POD_CLASS key_image
 
POD_CLASS signature
 
 PUSH_WARNINGS
 
POD_CLASS hash
 
POD_CLASS hash8
 
POD_CLASS hash64
 

Detailed Description

crypto namespace.

Typedef Documentation

◆ fe

typedef int32_t crypto::fe[10]

Definition at line 37 of file crypto.cpp.

◆ ge_dsmp

typedef ge_cached crypto::ge_dsmp[8]

Definition at line 80 of file crypto.cpp.

◆ secret_key

using crypto::secret_key = typedef epee::mlocked<tools::scrubbed<ec_scalar> >

Definition at line 82 of file crypto.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HASH_SIZE 
HASH_DATA_AREA 

Definition at line 78 of file hash.h.

79  {
80  cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
81  }
uint64_t height
Definition: blockchain.cpp:91
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
POD_CLASS hash
Definition: hash.h:50

Function Documentation

◆ addKeys()

public_key crypto::addKeys ( const public_key A,
const public_key B 
)
inline

Definition at line 339 of file crypto.h.

339  {
340  return crypto_ops::addKeys(A, B);
341  }
public_key addKeys(const public_key &A, const public_key &B)
Definition: crypto.h:339
Matcher< T > A()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ base64_decode()

std::string crypto::base64_decode ( const std::string &  val)
inline

Definition at line 392 of file crypto.h.

392  {
393  using namespace boost::archive::iterators;
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) {
396  return c == '\0';
397  });
398  }
::std::string string
Definition: gtest-port.h:1097

◆ base64_encode()

std::string crypto::base64_encode ( const std::string &  val)
inline

Definition at line 400 of file crypto.h.

400  {
401  using namespace boost::archive::iterators;
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, '=');
405  }
::std::string string
Definition: gtest-port.h:1097

◆ check_key()

bool crypto::check_key ( const public_key key)
inline

Definition at line 256 of file crypto.h.

256  {
257  return crypto_ops::check_key(key);
258  }
const char * key
Definition: hmac_keccak.cpp:39
bool check_key(const public_key &key)
Definition: crypto.h:256
Here is the caller graph for this function:

◆ check_ring_signature() [1/2]

bool crypto::check_ring_signature ( const hash prefix_hash,
const key_image image,
const public_key *const *  pubs,
std::size_t  pubs_count,
const signature sig 
)
inline

Definition at line 333 of file crypto.h.

335  {
336  return crypto_ops::check_ring_signature(prefix_hash, image, pubs, pubs_count, sig);
337  }
bool check_ring_signature(const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const signature *sig)
Definition: crypto.h:351
Here is the caller graph for this function:

◆ check_ring_signature() [2/2]

bool crypto::check_ring_signature ( const hash prefix_hash,
const key_image image,
const std::vector< const public_key *> &  pubs,
const signature sig 
)
inline

Definition at line 351 of file crypto.h.

353  {
354  return check_ring_signature(prefix_hash, image, pubs.data(), pubs.size(), sig);
355  }
bool check_ring_signature(const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const signature *sig)
Definition: crypto.h:351
Here is the call graph for this function:

◆ check_signature()

bool crypto::check_signature ( const hash prefix_hash,
const public_key pub,
const signature sig 
)
inline

Definition at line 295 of file crypto.h.

295  {
296  return crypto_ops::check_signature(prefix_hash, pub, sig);
297  }
bool check_signature(const hash &prefix_hash, const public_key &pub, const signature &sig)
Definition: crypto.h:295
Here is the caller graph for this function:

◆ check_tx_proof()

bool crypto::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 
)
inline

Definition at line 314 of file crypto.h.

314  {
315  return crypto_ops::check_tx_proof(prefix_hash, R, A, B, D, sig);
316  }
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)
Definition: crypto.h:314
Matcher< T > A()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cn_fast_hash() [1/3]

void crypto::cn_fast_hash ( const void *  data,
std::size_t  length,
hash hash 
)
inline

Definition at line 69 of file hash.h.

69  {
70  cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
71  }
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ cn_fast_hash() [2/3]

hash crypto::cn_fast_hash ( const void *  data,
std::size_t  length 
)
inline

Definition at line 73 of file hash.h.

73  {
74  hash h;
75  cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
76  return h;
77  }
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ cn_fast_hash() [3/3]

void crypto::cn_fast_hash ( const void *  data,
size_t  length,
char *  hash 
)
Here is the caller graph for this function:

◆ cn_slow_hash() [1/2]

void crypto::cn_slow_hash ( const void *  data,
std::size_t  length,
hash hash,
int  variant = 0,
uint64_t  height = 0 
)
inline

Definition at line 79 of file hash.h.

79  {
80  cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
81  }
uint64_t height
Definition: blockchain.cpp:91
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
POD_CLASS hash
Definition: hash.h:50

◆ cn_slow_hash() [2/2]

void crypto::cn_slow_hash ( const void *  data,
size_t  length,
char *  hash,
int  variant,
int  prehashed,
uint64_t  height 
)
Here is the caller graph for this function:

◆ cn_slow_hash_prehashed()

void crypto::cn_slow_hash_prehashed ( const void *  data,
std::size_t  length,
hash hash,
int  variant = 0,
uint64_t  height = 0 
)
inline

Definition at line 83 of file hash.h.

83  {
84  cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
85  }
uint64_t height
Definition: blockchain.cpp:91
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ create_ed25519_keypair()

std::vector<std::string> crypto::create_ed25519_keypair ( )
inline

Definition at line 388 of file crypto.h.

388  {
390  }
std::vector< std::string > create_ed25519_keypair()
Definition: crypto.h:388
Here is the caller graph for this function:

◆ derivation_to_scalar()

void crypto::derivation_to_scalar ( const key_derivation derivation,
size_t  output_index,
ec_scalar res 
)
inline

Definition at line 279 of file crypto.h.

279  {
281  }
const char * res
Definition: hmac_keccak.cpp:41
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
Definition: crypto.h:279
Here is the caller graph for this function:

◆ derive_public_key()

bool crypto::derive_public_key ( const key_derivation derivation,
std::size_t  output_index,
const public_key base,
public_key derived_key 
)
inline

Definition at line 275 of file crypto.h.

276  {
277  return crypto_ops::derive_public_key(derivation, output_index, base, derived_key);
278  }
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition: crypto.h:275
Here is the caller graph for this function:

◆ derive_secret_key()

void crypto::derive_secret_key ( const key_derivation derivation,
std::size_t  output_index,
const secret_key base,
secret_key derived_key 
)
inline

Definition at line 282 of file crypto.h.

283  {
284  crypto_ops::derive_secret_key(derivation, output_index, base, derived_key);
285  }
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
Definition: crypto.h:282
Here is the caller graph for this function:

◆ derive_subaddress_public_key()

bool crypto::derive_subaddress_public_key ( const public_key out_key,
const key_derivation derivation,
std::size_t  output_index,
public_key result 
)
inline

Definition at line 286 of file crypto.h.

286  {
287  return crypto_ops::derive_subaddress_public_key(out_key, derivation, output_index, result);
288  }
bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
Definition: crypto.h:286
Here is the caller graph for this function:

◆ fe_add()

void crypto::fe_add ( fe  h,
const fe  f,
const fe  g 
)

◆ fe_invert()

void crypto::fe_invert ( fe  out,
const fe  z 
)

◆ fe_tobytes()

void crypto::fe_tobytes ( unsigned char *  ,
const fe   
)

◆ ge_add()

void crypto::ge_add ( ge_p1p1 ,
const ge_p3 ,
const ge_cached  
)
Here is the caller graph for this function:

◆ ge_double_scalarmult_base_vartime()

void crypto::ge_double_scalarmult_base_vartime ( ge_p2 ,
const unsigned char *  ,
const ge_p3 ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ ge_double_scalarmult_base_vartime_p3()

void crypto::ge_double_scalarmult_base_vartime_p3 ( ge_p3 ,
const unsigned char *  ,
const ge_p3 ,
const unsigned char *   
)

◆ ge_double_scalarmult_precomp_vartime()

void crypto::ge_double_scalarmult_precomp_vartime ( ge_p2 ,
const unsigned char *  ,
const ge_p3 ,
const unsigned char *  ,
const ge_dsmp   
)
Here is the caller graph for this function:

◆ ge_double_scalarmult_precomp_vartime2()

void crypto::ge_double_scalarmult_precomp_vartime2 ( ge_p2 ,
const unsigned char *  ,
const ge_dsmp  ,
const unsigned char *  ,
const ge_dsmp   
)
Here is the caller graph for this function:

◆ ge_double_scalarmult_precomp_vartime2_p3()

void crypto::ge_double_scalarmult_precomp_vartime2_p3 ( ge_p3 ,
const unsigned char *  ,
const ge_dsmp  ,
const unsigned char *  ,
const ge_dsmp   
)

◆ ge_dsm_precomp()

void crypto::ge_dsm_precomp ( ge_dsmp  r,
const ge_p3 s 
)
Here is the caller graph for this function:

◆ ge_frombytes_vartime()

int crypto::ge_frombytes_vartime ( ge_p3 ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ ge_fromfe_frombytes_vartime()

void crypto::ge_fromfe_frombytes_vartime ( ge_p2 ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ ge_mul8()

void crypto::ge_mul8 ( ge_p1p1 ,
const ge_p2  
)
Here is the caller graph for this function:

◆ ge_p1p1_to_p2()

void crypto::ge_p1p1_to_p2 ( ge_p2 ,
const ge_p1p1  
)
Here is the caller graph for this function:

◆ ge_p1p1_to_p3()

void crypto::ge_p1p1_to_p3 ( ge_p3 ,
const ge_p1p1  
)
Here is the caller graph for this function:

◆ ge_p2_dbl()

void crypto::ge_p2_dbl ( ge_p1p1 ,
const ge_p2  
)

◆ ge_p3_is_point_at_infinity()

int crypto::ge_p3_is_point_at_infinity ( const ge_p3 p)

◆ ge_p3_to_cached()

void crypto::ge_p3_to_cached ( ge_cached ,
const ge_p3  
)
Here is the caller graph for this function:

◆ ge_p3_to_p2()

void crypto::ge_p3_to_p2 ( ge_p2 ,
const ge_p3  
)
Here is the caller graph for this function:

◆ ge_p3_tobytes()

void crypto::ge_p3_tobytes ( unsigned char *  ,
const ge_p3  
)
Here is the caller graph for this function:

◆ ge_scalarmult()

void crypto::ge_scalarmult ( ge_p2 ,
const unsigned char *  ,
const ge_p3  
)
Here is the caller graph for this function:

◆ ge_scalarmult_base()

void crypto::ge_scalarmult_base ( ge_p3 ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ ge_scalarmult_p3()

void crypto::ge_scalarmult_p3 ( ge_p3 ,
const unsigned char *  ,
const ge_p3  
)

◆ ge_sub()

void crypto::ge_sub ( ge_p1p1 r,
const ge_p3 p,
const ge_cached q 
)
Here is the caller graph for this function:

◆ ge_tobytes()

void crypto::ge_tobytes ( unsigned char *  ,
const ge_p2  
)
Here is the caller graph for this function:

◆ generate_input_signature()

void crypto::generate_input_signature ( const hash  prefix_hash,
const uint32_t  input_index,
const secret_key  sec_view,
const secret_key  sec_spend,
signature sig 
)
inline

Definition at line 299 of file crypto.h.

299  {
300  return crypto_ops::generate_input_signature(prefix_hash, input_index, sec_view, sec_spend, sig);
301  }
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)
Definition: crypto.h:299

◆ generate_key_derivation()

bool crypto::generate_key_derivation ( const public_key key1,
const secret_key key2,
key_derivation derivation 
)
inline

Definition at line 272 of file crypto.h.

272  {
273  return crypto_ops::generate_key_derivation(key1, key2, derivation);
274  }
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition: crypto.h:272
Here is the caller graph for this function:

◆ generate_key_image()

void crypto::generate_key_image ( const public_key pub,
const secret_key sec,
key_image image 
)
inline

Definition at line 324 of file crypto.h.

324  {
325  crypto_ops::generate_key_image(pub, sec, image);
326  }
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
Definition: crypto.h:324
Here is the caller graph for this function:

◆ generate_keys()

secret_key crypto::generate_keys ( public_key pub,
secret_key sec,
const secret_key recovery_key = secret_key(),
bool  recover = false 
)
inline

Definition at line 250 of file crypto.h.

250  {
251  return crypto_ops::generate_keys(pub, sec, recovery_key, recover);
252  }
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition: crypto.h:250
Here is the caller graph for this function:

◆ generate_random_bytes_not_thread_safe()

void crypto::generate_random_bytes_not_thread_safe ( size_t  n,
void *  result 
)
Here is the caller graph for this function:

◆ generate_random_bytes_thread_safe()

void crypto::generate_random_bytes_thread_safe ( size_t  N,
uint8_t bytes 
)

Definition at line 91 of file crypto.cpp.

92  {
93  static boost::mutex random_lock;
94  boost::lock_guard<boost::mutex> lock(random_lock);
96  }
void generate_random_bytes_not_thread_safe(size_t n, void *result)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_ring_signature() [1/2]

void crypto::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 
)
inline

Definition at line 327 of file crypto.h.

330  {
331  crypto_ops::generate_ring_signature(prefix_hash, image, pubs, pubs_count, sec, sec_index, sig);
332  }
void generate_ring_signature(const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const secret_key &sec, std::size_t sec_index, signature *sig)
Definition: crypto.h:345
Here is the caller graph for this function:

◆ generate_ring_signature() [2/2]

void crypto::generate_ring_signature ( const hash prefix_hash,
const key_image image,
const std::vector< const public_key *> &  pubs,
const secret_key sec,
std::size_t  sec_index,
signature sig 
)
inline

Definition at line 345 of file crypto.h.

348  {
349  generate_ring_signature(prefix_hash, image, pubs.data(), pubs.size(), sec, sec_index, sig);
350  }
void generate_ring_signature(const hash &prefix_hash, const key_image &image, const std::vector< const public_key *> &pubs, const secret_key &sec, std::size_t sec_index, signature *sig)
Definition: crypto.h:345
Here is the call graph for this function:

◆ generate_signature()

void crypto::generate_signature ( const hash prefix_hash,
const public_key pub,
const secret_key sec,
signature sig 
)
inline

Definition at line 292 of file crypto.h.

292  {
293  crypto_ops::generate_signature(prefix_hash, pub, sec, sig);
294  }
void generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig)
Definition: crypto.h:292
Here is the caller graph for this function:

◆ generate_tx_proof()

void crypto::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 
)
inline

Definition at line 311 of file crypto.h.

311  {
312  crypto_ops::generate_tx_proof(prefix_hash, R, A, B, D, r, sig);
313  }
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)
Definition: crypto.h:311
Matcher< T > A()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_extra_blake()

void crypto::hash_extra_blake ( const void *  data,
size_t  length,
char *  hash 
)

◆ hash_extra_groestl()

void crypto::hash_extra_groestl ( const void *  data,
size_t  length,
char *  hash 
)

◆ hash_extra_jh()

void crypto::hash_extra_jh ( const void *  data,
size_t  length,
char *  hash 
)

◆ hash_extra_skein()

void crypto::hash_extra_skein ( const void *  data,
size_t  length,
char *  hash 
)

◆ hash_permutation()

void crypto::hash_permutation ( union hash_state state)

◆ hash_process()

void crypto::hash_process ( union hash_state state,
const uint8_t buf,
size_t  count 
)

◆ hash_to_ec() [1/2]

POP_WARNINGS void crypto::hash_to_ec ( const public_key key,
ge_p3 res 
)

Definition at line 479 of file crypto.cpp.

479  {
480  hash h;
481  ge_p2 point;
482  ge_p1p1 point2;
483  cn_fast_hash(std::addressof(key), sizeof(public_key), h);
484  ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
485  ge_mul8(&point2, &point);
486  ge_p1p1_to_p3(&res, &point2);
487  }
const char * res
Definition: hmac_keccak.cpp:41
const char * key
Definition: hmac_keccak.cpp:39
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *)
void cn_fast_hash(const void *data, size_t length, char *hash)
void ge_mul8(ge_p1p1 *, const ge_p2 *)
POD_CLASS public_key
Definition: crypto.h:76
void ge_p1p1_to_p3(ge_p3 *, const ge_p1p1 *)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_to_ec() [2/2]

void crypto::hash_to_ec ( const hash h,
ge_p3 res 
)

Definition at line 488 of file crypto.cpp.

488  {
489  ge_p2 point;
490  ge_p1p1 point2;
491  ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
492  ge_mul8(&point2, &point);
493  ge_p1p1_to_p3(&res, &point2);
494  }
const char * res
Definition: hmac_keccak.cpp:41
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *)
void ge_mul8(ge_p1p1 *, const ge_p2 *)
void ge_p1p1_to_p3(ge_p3 *, const ge_p1p1 *)
Here is the call graph for this function:

◆ hash_to_point()

void crypto::hash_to_point ( const crypto::hash h,
crypto::ec_point res 
)

Definition at line 496 of file crypto.cpp.

496  {
497  ge_p2 point;
498  ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
499  ge_tobytes(crypto::operator&(res), &point);
500  }
const char * res
Definition: hmac_keccak.cpp:41
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *)
void ge_tobytes(unsigned char *, const ge_p2 *)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_to_scalar()

void crypto::hash_to_scalar ( const void *  data,
size_t  length,
ec_scalar res 
)

Definition at line 126 of file crypto.cpp.

126  {
127  cn_fast_hash(data, length, reinterpret_cast<hash &>(res));
128  sc_reduce32(&res);
129  }
const char * res
Definition: hmac_keccak.cpp:41
void cn_fast_hash(const void *data, size_t length, char *hash)
void sc_reduce32(unsigned char *)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_3()

uint64_t crypto::load_3 ( const unsigned char *  in)

◆ load_4()

uint64_t crypto::load_4 ( const unsigned char *  in)

◆ operator<<() [1/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::hash v 
)
inline

Definition at line 91 of file hash.h.

91  {
93  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [2/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::hash8 v 
)
inline

Definition at line 94 of file hash.h.

94  {
96  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [3/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::hash64 v 
)
inline

Definition at line 97 of file hash.h.

97  {
99  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [4/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::public_key v 
)
inline

Definition at line 357 of file crypto.h.

357  {
359  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [5/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::secret_key v 
)
inline

Definition at line 360 of file crypto.h.

360  {
362  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [6/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::key_derivation v 
)
inline

Definition at line 363 of file crypto.h.

363  {
365  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [7/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::key_image v 
)
inline

Definition at line 366 of file crypto.h.

366  {
368  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ operator<<() [8/8]

std::ostream& crypto::operator<< ( std::ostream &  o,
const crypto::signature v 
)
inline

Definition at line 369 of file crypto.h.

369  {
371  }
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition: span.h:153
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition: hex.cpp:76
Here is the call graph for this function:

◆ rand() [1/2]

void crypto::rand ( size_t  N,
uint8_t bytes 
)
inline

Definition at line 209 of file crypto.h.

209  {
211  }
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
Definition: crypto.cpp:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand() [2/2]

template<typename T >
std::enable_if<std::is_pod<T>::value, T>::type crypto::rand ( )

Definition at line 216 of file crypto.h.

216  {
217  typename std::remove_cv<T>::type res;
219  return res;
220  }
const char * res
Definition: hmac_keccak.cpp:41
const uint32_t T[512]
unsigned char uint8_t
Definition: stdint.h:124
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
Definition: crypto.cpp:91
Here is the call graph for this function:

◆ rand_idx()

template<typename T >
std::enable_if<std::is_unsigned<T>::value, T>::type crypto::rand_idx ( T  sz)

Definition at line 244 of file crypto.h.

244  {
245  return crypto::rand_range<T>(0, sz-1);
246  }
Here is the caller graph for this function:

◆ rand_range()

template<typename T >
std::enable_if<std::is_integral<T>::value, T>::type crypto::rand_range ( T  range_min,
T  range_max 
)

Definition at line 235 of file crypto.h.

235  {
237  std::uniform_int_distribution<T> dis(range_min, range_max);
238  return dis(rd);
239  }

◆ random32_unbiased()

void crypto::random32_unbiased ( unsigned char *  bytes)

Definition at line 110 of file crypto.cpp.

111  {
112  // l = 2^252 + 27742317777372353535851937790883648493.
113  // it fits 15 in 32 bytes
114  static const unsigned char limit[32] = { 0xe3, 0x6a, 0x67, 0x72, 0x8b, 0xce, 0x13, 0x29, 0x8f, 0x30, 0x82, 0x8c, 0x0b, 0xa4, 0x10, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0 };
115  do
116  {
118  } while (!sc_isnonzero(bytes) && !less32(bytes, limit)); // should be good about 15/16 of the time
119  sc_reduce32(bytes);
120  }
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
Definition: crypto.cpp:91
int sc_isnonzero(const unsigned char *)
void sc_reduce32(unsigned char *)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_scalar()

void crypto::random_scalar ( ec_scalar res)

Definition at line 122 of file crypto.cpp.

122  {
123  random32_unbiased((unsigned char*)res.data);
124  }
const char * res
Definition: hmac_keccak.cpp:41
void random32_unbiased(unsigned char *bytes)
Definition: crypto.cpp:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rs_comm_size()

size_t crypto::rs_comm_size ( size_t  pubs_count)

Definition at line 511 of file crypto.cpp.

511  {
512  return sizeof(rs_comm) + pubs_count * sizeof(ec_point_pair);
513  }

◆ sc_0()

void crypto::sc_0 ( unsigned char *  )
Here is the caller graph for this function:

◆ sc_add()

void crypto::sc_add ( unsigned char *  ,
const unsigned char *  ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ sc_check()

int crypto::sc_check ( const unsigned char *  )
Here is the caller graph for this function:

◆ sc_isnonzero()

int crypto::sc_isnonzero ( const unsigned char *  )
Here is the caller graph for this function:

◆ sc_mul()

void crypto::sc_mul ( unsigned char *  ,
const unsigned char *  ,
const unsigned char *   
)

◆ sc_muladd()

void crypto::sc_muladd ( unsigned char *  s,
const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)

◆ sc_mulsub()

void crypto::sc_mulsub ( unsigned char *  ,
const unsigned char *  ,
const unsigned char *  ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ sc_reduce()

void crypto::sc_reduce ( unsigned char *  )

◆ sc_reduce32()

void crypto::sc_reduce32 ( unsigned char *  )
Here is the caller graph for this function:

◆ sc_sub()

void crypto::sc_sub ( unsigned char *  ,
const unsigned char *  ,
const unsigned char *   
)
Here is the caller graph for this function:

◆ secret_key_to_public_key()

bool crypto::secret_key_to_public_key ( const secret_key sec,
public_key pub 
)
inline

Definition at line 262 of file crypto.h.

262  {
263  return crypto_ops::secret_key_to_public_key(sec, pub);
264  }
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition: crypto.h:262
Here is the caller graph for this function:

◆ sign_message()

std::string crypto::sign_message ( const std::string &  message,
const std::string &  privateKey 
)
inline

Definition at line 376 of file crypto.h.

376  {
378  }
std::string privateKey
std::string message("Message requiring signing")
std::string sign_message(const std::string &message, const std::string &privateKey)
Definition: crypto.h:376
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tree_hash() [1/2]

void crypto::tree_hash ( const hash hashes,
std::size_t  count,
hash root_hash 
)
inline

Definition at line 87 of file hash.h.

87  {
88  tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
89  }
struct hash_func hashes[]
mdb_size_t count(MDB_cursor *cur)
void tree_hash(const char(*hashes)[HASH_SIZE], size_t count, char *root_hash)
Here is the call graph for this function:

◆ tree_hash() [2/2]

void crypto::tree_hash ( const char(*)  hashes[HASH_SIZE],
size_t  count,
char *  root_hash 
)
Here is the caller graph for this function:

◆ verify_input_signature()

bool crypto::verify_input_signature ( const hash prefix_hash,
const uint32_t  input_index,
const public_key  pub_view,
const public_key  pub_spend,
signature  sig 
)
inline

Definition at line 303 of file crypto.h.

303  {
304  return crypto_ops::verify_input_signature(prefix_hash, input_index, pub_view, pub_spend, sig);
305  }
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)
Definition: crypto.h:303

◆ verify_signature() [1/2]

bool crypto::verify_signature ( const std::string &  message,
const std::string &  publicKey,
const std::string &  signature 
)
inline

Definition at line 380 of file crypto.h.

380  {
382  }
std::string publicKey
std::string message("Message requiring signing")
bool verify_signature(const std::string &message, std::vector< std::string > publicKey, const std::string &signature)
Definition: crypto.h:384
POD_CLASS signature
Definition: crypto.h:108
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_signature() [2/2]

bool crypto::verify_signature ( const std::string &  message,
std::vector< std::string >  publicKey,
const std::string &  signature 
)
inline

Definition at line 384 of file crypto.h.

384  {
386  }
std::string publicKey
std::string message("Message requiring signing")
bool verify_signature(const std::string &message, std::vector< std::string > publicKey, const std::string &signature)
Definition: crypto.h:384
POD_CLASS signature
Definition: crypto.h:108
Here is the call graph for this function:

Variable Documentation

◆ column_vectors

std::vector<secret_keyV> crypto::column_vectors

Definition at line 97 of file crypto.h.

◆ ec_point

POD_CLASS crypto::ec_point
Initial value:
{
char data[32]

Definition at line 70 of file crypto.h.

◆ ec_scalar

POD_CLASS crypto::ec_scalar
Initial value:
{
char data[32]

Definition at line 74 of file crypto.h.

◆ fe_d

const fe crypto::fe_d

◆ fe_d2

const fe crypto::fe_d2

◆ fe_fffb1

const fe crypto::fe_fffb1

◆ fe_fffb2

const fe crypto::fe_fffb2

◆ fe_fffb3

const fe crypto::fe_fffb3

◆ fe_fffb4

const fe crypto::fe_fffb4

◆ fe_ma

const fe crypto::fe_ma

◆ fe_ma2

const fe crypto::fe_ma2

◆ fe_sqrtm1

const fe crypto::fe_sqrtm1

◆ ge_base

const ge_precomp crypto::ge_base[32][8]

◆ ge_Bi

const ge_precomp crypto::ge_Bi[8]

◆ ge_p3_H

const ge_p3 crypto::ge_p3_H

◆ ge_p3_identity

const ge_p3 crypto::ge_p3_identity

◆ hash

POD_CLASS crypto::hash
Initial value:
{
char data[HASH_SIZE]

Definition at line 50 of file hash.h.

◆ hash64

POD_CLASS crypto::hash64
Initial value:
{
char data[64]

Definition at line 56 of file hash.h.

◆ hash8

POD_CLASS crypto::hash8
Initial value:
{
char data[8]

Definition at line 53 of file hash.h.

◆ key_derivation

POD_CLASS crypto::key_derivation

Definition at line 98 of file crypto.h.

◆ key_image

POD_CLASS crypto::key_image

Definition at line 102 of file crypto.h.

◆ null_pkey

const crypto::public_key crypto::null_pkey = crypto::public_key{}

Definition at line 72 of file crypto.cpp.

◆ null_skey

const crypto::secret_key crypto::null_skey = crypto::secret_key{}

Definition at line 73 of file crypto.cpp.

◆ public_key

POD_CLASS crypto::public_key

Definition at line 76 of file crypto.h.

◆ public_keyM

POD_CLASS crypto::public_keyM
Initial value:
{
int cols

Definition at line 94 of file crypto.h.

◆ public_keyV

POD_CLASS crypto::public_keyV
Initial value:
{
std::vector<public_key> keys

Definition at line 84 of file crypto.h.

◆ PUSH_WARNINGS

crypto::PUSH_WARNINGS

Definition at line 55 of file hash.h.

◆ rows

int crypto::rows

Definition at line 86 of file crypto.h.

◆ secret_keyV

POD_CLASS crypto::secret_keyV
Initial value:
{
std::vector<secret_key> keys

Definition at line 89 of file crypto.h.

◆ signature

POD_CLASS crypto::signature
Initial value:
{
ec_scalar c, r
POD_CLASS ec_scalar
Definition: crypto.h:74

Definition at line 108 of file crypto.h.