reuse previously calculated peer ordering group

This commit is contained in:
orignal
2026-05-26 21:48:21 -04:00
parent b37e0572d8
commit e9f7477fcf
8 changed files with 83 additions and 33 deletions
-18
View File
@@ -16,7 +16,6 @@
#include "I2PEndian.h"
#include "Base.h"
#include "Crypto.h"
#include "Siphash.h"
#include "Log.h"
#include "Timestamp.h"
#include "I2NPProtocol.h"
@@ -1407,22 +1406,5 @@ namespace data
if (r->GetBuffer ()) return true;
return r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
}
int CalculatePeerOrderingGroup (i2p::data::Tag<16> key, const i2p::data::IdentHash& routerIdent)
{
uint8_t hash[16];
#if OPENSSL_SIPHASH
EVP_PKEY * sipKey = EVP_PKEY_new_raw_private_key (EVP_PKEY_SIPHASH, nullptr, key, 16);
EVP_MD_CTX * ctx = EVP_MD_CTX_create ();
EVP_DigestSignInit (ctx, nullptr, nullptr, nullptr, sipKey);
size_t l = 16;
EVP_DigestSign (ctx, hash, &l, routerIdent, 32);
EVP_MD_CTX_destroy (ctx);
EVP_PKEY_free (sipKey);
#else
i2p::crypto::Siphash<16> (hash, routerIdent, 32, key);
#endif
return hash[0] & 0x03;
}
}
}