MCPcopy Create free account
hub / github.com/ElementsProject/elements / SeedEvents

Method SeedEvents

src/random.cpp:390–403  ·  view source on GitHub ↗

* Feed (the hash of) all events added through AddEvent() to hasher. */

Source from the content-addressed store, hash-verified

388 * Feed (the hash of) all events added through AddEvent() to hasher.
389 */
390 void SeedEvents(CSHA512& hasher) noexcept
391 {
392 // We use only SHA256 for the events hashing to get the ASM speedups we have for SHA256,
393 // since we want it to be fast as network peers may be able to trigger it repeatedly.
394 LOCK(m_events_mutex);
395
396 unsigned char events_hash[32];
397 m_events_hasher.Finalize(events_hash);
398 hasher.Write(events_hash, 32);
399
400 // Re-initialize the hasher with the finalized state to use later.
401 m_events_hasher.Reset();
402 m_events_hasher.Write(events_hash, 32);
403 }
404
405 /** Extract up to 32 bytes of entropy from the RNG state, mixing in new entropy from hasher.
406 *

Callers 2

SeedSlowFunction · 0.80
SeedPeriodicFunction · 0.80

Calls 3

FinalizeMethod · 0.45
WriteMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected