mirror of https://github.com/oxen-io/oxen-core.git
Use libsodium to hash the contents for signatures
Prefer libsodium so that external libraries don't have to link against Monero crypto and can instead opt for more standardized cryptography libraries.
This commit is contained in:
parent
0b695592ec
commit
7a584a45a0
|
@ -293,14 +293,15 @@ uint64_t lokinet_expiry_blocks(cryptonote::network_type nettype, uint64_t *renew
|
|||
|
||||
crypto::hash tx_extra_signature_hash(epee::span<const uint8_t> blob, crypto::hash const &prev_txid)
|
||||
{
|
||||
static_assert(sizeof(crypto::hash) == crypto_generichash_BYTES, "Using libsodium generichash for signature hash, require we fit into crypto::hash");
|
||||
crypto::hash result = {};
|
||||
if (blob.size() <= lns::GENERIC_VALUE_MAX)
|
||||
{
|
||||
char buffer[lns::GENERIC_VALUE_MAX + sizeof(prev_txid)] = {};
|
||||
size_t buffer_len = blob.size() + sizeof(prev_txid);
|
||||
unsigned char buffer[lns::GENERIC_VALUE_MAX + sizeof(prev_txid)] = {};
|
||||
size_t buffer_len = blob.size() + sizeof(prev_txid);
|
||||
memcpy(buffer, blob.data(), blob.size());
|
||||
memcpy(buffer + blob.size(), prev_txid.data, sizeof(prev_txid));
|
||||
result = crypto::cn_fast_hash(buffer, buffer_len);
|
||||
crypto_generichash(reinterpret_cast<unsigned char *>(result.data), sizeof(result), buffer, buffer_len, NULL /*key*/, 0 /*key_len*/);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3236,7 +3236,7 @@ simple_wallet::simple_wallet()
|
|||
stream << "Update a Loki Name Service mapping's value field in the name->value mapping, you must be the owner of the the mapping by providing a signature that can be verified by the owner's public key."
|
||||
<< OWNER_KEY_EXPLANATION
|
||||
<< AVAILABLE_LNS_RECORDS
|
||||
<< "The signature is derived from the hash of the current {txid blob, value} of the mapping to update. By default signature is an optional field and is signed using the wallet's spend key as an ed25519 keypair";
|
||||
<< "The signature is derived using libsodium generichash on the {current txid blob, new value blob} of the mapping to update. Signature is an optional field and is signed using the wallet's spend key as an ed25519 keypair if it is not specified.";
|
||||
m_cmd_binder.set_handler("update_lns_mapping",
|
||||
boost::bind(&simple_wallet::update_lns_mapping, this, _1),
|
||||
tr(USAGE_UPDATE_LNS_MAPPING),
|
||||
|
|
|
@ -2933,7 +2933,7 @@ namespace wallet_rpc
|
|||
std::string type; // The mapping type, currently only "session" is supported.
|
||||
std::string name; // The name to update via Loki Name Service
|
||||
std::string value; // The new value that the name maps to via Loki Name Service, (i.e. For session: display name -> session public key).
|
||||
std::string signature; // (Optional): Signature derived from the hash of the previous txid blob and previous value blob of the mapping. By default this is signed using the wallet's spend key as an ed25519 keypair, if signature is empty.
|
||||
std::string signature; // (Optional): Signature derived using libsodium generichash on {current txid blob, new value blob} of the mapping to update. By default the hash is signed using the wallet's spend key as an ed25519 keypair, if signature is specified.
|
||||
|
||||
uint32_t account_index; // (Optional) Transfer from this account index. (Defaults to 0)
|
||||
std::set<uint32_t> subaddr_indices; // (Optional) Transfer from this set of subaddresses. (Defaults to 0)
|
||||
|
|
Loading…
Reference in New Issue