rebase to 0.18.3.3 completed

This commit is contained in:
Some Random Crypto Guy
2024-06-05 14:03:44 +01:00
parent e23423c16d
commit d39c20bb2d
160 changed files with 4209 additions and 3394 deletions
-68
View File
@@ -74,13 +74,6 @@ namespace crypto {
const crypto::public_key null_pkey = crypto::public_key{};
const crypto::secret_key null_skey = crypto::secret_key{};
static inline crypto::key_image get_null_ki() {
crypto::key_image ki;
std::memset(ki.data, 0, sizeof(ki.data));
return ki;
}
const crypto::key_image null_ki = get_null_ki();
static inline unsigned char *operator &(ec_point &point) {
return &reinterpret_cast<unsigned char &>(point);
}
@@ -268,67 +261,6 @@ namespace crypto {
return true;
}
/**
* The following functions are designed to perform the correct encoding / decoding for protocol_tx outputs,
* which use an ec_scalar to provide uniqueness
*/
void crypto_ops::derivation_to_scalar(const key_derivation &derivation, const ec_scalar& uniqueness, ec_scalar &res) {
struct {
ec_scalar uniqueness;
key_derivation derivation;
} buf;
buf.uniqueness = uniqueness;
buf.derivation = derivation;
hash_to_scalar(&buf, sizeof(buf), res);
}
bool crypto_ops::derive_public_key(const key_derivation &derivation, const ec_scalar& uniqueness,
const public_key &base, public_key &derived_key) {
ec_scalar scalar;
ge_p3 point1;
ge_p3 point2;
ge_cached point3;
ge_p1p1 point4;
ge_p2 point5;
if (ge_frombytes_vartime(&point1, &base) != 0) {
return false;
}
derivation_to_scalar(derivation, uniqueness, scalar);
ge_scalarmult_base(&point2, &scalar);
ge_p3_to_cached(&point3, &point2);
ge_add(&point4, &point1, &point3);
ge_p1p1_to_p2(&point5, &point4);
ge_tobytes(&derived_key, &point5);
return true;
}
void crypto_ops::derive_secret_key(const key_derivation &derivation, const ec_scalar& uniqueness,
const secret_key &base, secret_key &derived_key) {
ec_scalar scalar;
assert(sc_check(&base) == 0);
derivation_to_scalar(derivation, uniqueness, scalar);
sc_add(&unwrap(derived_key), &unwrap(base), &scalar);
}
bool crypto_ops::derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, const ec_scalar& uniqueness, public_key &derived_key) {
ec_scalar scalar;
ge_p3 point1;
ge_p3 point2;
ge_cached point3;
ge_p1p1 point4;
ge_p2 point5;
if (ge_frombytes_vartime(&point1, &out_key) != 0) {
return false;
}
derivation_to_scalar(derivation, uniqueness, scalar);
ge_scalarmult_base(&point2, &scalar);
ge_p3_to_cached(&point3, &point2);
ge_sub(&point4, &point1, &point3);
ge_p1p1_to_p2(&point5, &point4);
ge_tobytes(&derived_key, &point5);
return true;
}
struct s_comm {
hash h;
ec_point key;