with all security checks in place, the code is now accepting protocol_tx outputs as valid in-wallet; only the asset_type is misreported now

This commit is contained in:
Some Random Crypto Guy
2023-11-27 23:06:35 +00:00
parent be8e0f7327
commit ccdbfbe397
16 changed files with 586 additions and 842 deletions
+33
View File
@@ -135,6 +135,20 @@ namespace crypto {
friend void derive_secret_key(const key_derivation &, std::size_t, const secret_key &, secret_key &);
static bool derive_subaddress_public_key(const public_key &, const key_derivation &, std::size_t, public_key &);
friend bool derive_subaddress_public_key(const public_key &, const key_derivation &, std::size_t, public_key &);
/**
* The following functions are designed to perform the correct encoding / decoding for protocol_tx outputs,
* which use a hash of a crypto::key_image for uniqueness
*/
static void derivation_to_scalar(const key_derivation &derivation, const hash& uniqueness, ec_scalar &res);
friend void derivation_to_scalar(const key_derivation &derivation, const hash& uniqueness, ec_scalar &res);
static bool derive_public_key(const key_derivation &, const hash&, const public_key &, public_key &);
friend bool derive_public_key(const key_derivation &, const hash&, const public_key &, public_key &);
static void derive_secret_key(const key_derivation &, const hash&, const secret_key &, secret_key &);
friend void derive_secret_key(const key_derivation &, const hash&, const secret_key &, secret_key &);
static bool derive_subaddress_public_key(const public_key &, const key_derivation &, const hash&, public_key &);
friend bool derive_subaddress_public_key(const public_key &, const key_derivation &, const hash&, public_key &);
static void generate_signature(const hash &, const public_key &, const secret_key &, signature &);
friend void generate_signature(const hash &, const public_key &, const secret_key &, signature &);
static bool check_signature(const hash &, const public_key &, const signature &);
@@ -245,6 +259,25 @@ namespace crypto {
return crypto_ops::derive_subaddress_public_key(out_key, derivation, output_index, result);
}
/**
* The following functions are designed to perform the correct encoding / decoding for protocol_tx outputs,
* which use a hash of a crypto::key_image for uniqueness
*/
inline bool derive_public_key(const key_derivation &derivation, const hash& uniqueness,
const public_key &base, public_key &derived_key) {
return crypto_ops::derive_public_key(derivation, uniqueness, base, derived_key);
}
inline void derivation_to_scalar(const key_derivation &derivation, const hash& uniqueness, ec_scalar &res) {
return crypto_ops::derivation_to_scalar(derivation, uniqueness, res);
}
inline void derive_secret_key(const key_derivation &derivation, const hash& uniqueness,
const secret_key &base, secret_key &derived_key) {
crypto_ops::derive_secret_key(derivation, uniqueness, base, derived_key);
}
inline bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, const hash& uniqueness, public_key &result) {
return crypto_ops::derive_subaddress_public_key(out_key, derivation, uniqueness, result);
}
/* Generation and checking of a standard signature.
*/
inline void generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig) {