LibCrypto: Copy the cached hash in SignedBigInteger / UnsignedBigInteger

The hash computation for big integers is pretty expensive, so if we have
a cached hash when copying a big int, let's also copy the hash.
This commit is contained in:
Timothy Flynn
2025-07-21 07:33:40 -04:00
committed by Jelle Raaijmakers
parent 0faf96fa1b
commit cd73c70ad6
Notes: github-actions[bot] 2025-07-21 13:23:51 +00:00
2 changed files with 8 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ SignedBigInteger::SignedBigInteger(i64 value)
}
SignedBigInteger::SignedBigInteger(SignedBigInteger const& other)
: m_hash(other.m_hash)
{
MP_MUST(mp_init_copy(&m_mp, &other.m_mp));
}
@@ -55,8 +56,11 @@ SignedBigInteger& SignedBigInteger::operator=(SignedBigInteger const& other)
{
if (this == &other)
return *this;
mp_clear(&m_mp);
MP_MUST(mp_init_copy(&m_mp, &other.m_mp));
m_hash = other.m_hash;
return *this;
}