mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Support message separation for multiple inputs from same user. (#142)
This commit is contained in:
committed by
GitHub
parent
202a6a2715
commit
51173e37f2
@@ -35,8 +35,8 @@ namespace crypto
|
||||
seckey[0] = KEYPFX_ed25519;
|
||||
|
||||
crypto_sign_ed25519_keypair(
|
||||
reinterpret_cast<unsigned char *>(pubkey.data() + 1), // +1 to skip the prefix byte.
|
||||
reinterpret_cast<unsigned char *>(seckey.data() + 1)); // +1 to skip the prefix byte.
|
||||
reinterpret_cast<unsigned char *>(pubkey.data() + 1), // +1 to skip the prefix byte.
|
||||
reinterpret_cast<unsigned char *>(seckey.data() + 1)); // +1 to skip the prefix byte.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,4 +196,26 @@ namespace crypto
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates blake3 hash for the given string view vector using stream hashing.
|
||||
*/
|
||||
std::string get_hash(const std::vector<std::string_view> &sw_vect)
|
||||
{
|
||||
std::string hash;
|
||||
hash.resize(BLAKE3_OUT_LEN);
|
||||
|
||||
// Init stream hashing.
|
||||
blake3_hasher hasher;
|
||||
blake3_hasher_init(&hasher);
|
||||
|
||||
// Hash is generated only using message in contract output struct.
|
||||
for (std::string_view sw : sw_vect)
|
||||
blake3_hasher_update(&hasher, reinterpret_cast<const unsigned char *>(sw.data()), sw.length());
|
||||
|
||||
// Get the final hash.
|
||||
blake3_hasher_finalize(&hasher, reinterpret_cast<unsigned char *>(hash.data()), hash.length());
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
Reference in New Issue
Block a user