What changed, and why it matters
This commit is a small performance and code-quality change. It changes several functions that return copies of fixed cryptographic 'generator' values so that they return constant references instead. This avoids making unnecessary copies of values that never change. There is no security issue visible in the diff itself.
No security action required. Treat as a normal refactoring/optimization commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies src/crypto/generators.cpp and src/crypto/generators.h to return const T& instead of by-value T for the get_G, get_H, get_T, get_U, get_V, get_*_p3, and get_*_cached accessor functions. The returned objects are static constants initialized once by init_gens(). Returning a const reference to an immutable static object is safe and eliminates copy overhead. No logic, initialization order, lifetime, or access-control changes are introduced.
Changed components
src/crypto/generators.cppsrc/crypto/generators.hInspect captured patch +30 / −30
diff --git a/src/crypto/generators.cpp b/src/crypto/generators.cpp
index 80c6e9f..f2fbd4b 100644
--- a/src/crypto/generators.cpp
+++ b/src/crypto/generators.cpp
@@ -227,86 +227,86 @@ static void init_gens()
});
}
//-------------------------------------------------------------------------------------------------------------------
-public_key get_G()
+const public_key &get_G()
{
return G;
}
//-------------------------------------------------------------------------------------------------------------------
-public_key get_H()
+const public_key &get_H()
{
return H;
}
//-------------------------------------------------------------------------------------------------------------------
-public_key get_T()
+const public_key &get_T()
{
return T;
}
//-------------------------------------------------------------------------------------------------------------------
-public_key get_U()
+const public_key &get_U()
{
return U;
}
//-------------------------------------------------------------------------------------------------------------------
-public_key get_V()
+const public_key &get_V()
{
return V;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_p3 get_G_p3()
+const ge_p3 &get_G_p3()
{
init_gens();
return G_p3;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_p3 get_H_p3()
+const ge_p3 &get_H_p3()
{
init_gens();
return H_p3;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_p3 get_T_p3()
+const ge_p3 &get_T_p3()
{
init_gens();
return T_p3;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_p3 get_U_p3()
+const ge_p3 &get_U_p3()
{
init_gens();
return U_p3;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_p3 get_V_p3()
+const ge_p3 &get_V_p3()
{
init_gens();
return V_p3;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_cached get_G_cached()
+const ge_cached &get_G_cached()
{
init_gens();
return G_cached;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_cached get_H_cached()
+const ge_cached &get_H_cached()
{
init_gens();
return H_cached;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_cached get_T_cached()
+const ge_cached &get_T_cached()
{
init_gens();
return T_cached;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_cached get_U_cached()
+const ge_cached &get_U_cached()
{
init_gens();
return U_cached;
}
//-------------------------------------------------------------------------------------------------------------------
-ge_cached get_V_cached()
+const ge_cached &get_V_cached()
{
init_gens();
return V_cached;
diff --git a/src/crypto/generators.h b/src/crypto/generators.h
index 8e2995a..56412dc 100644
--- a/src/crypto/generators.h
+++ b/src/crypto/generators.h
@@ -37,20 +37,20 @@ extern "C"
namespace crypto
{
-public_key get_G();
-public_key get_H();
-public_key get_T();
-public_key get_U();
-public_key get_V();
-ge_p3 get_G_p3();
-ge_p3 get_H_p3();
-ge_p3 get_T_p3();
-ge_p3 get_U_p3();
-ge_p3 get_V_p3();
-ge_cached get_G_cached();
-ge_cached get_H_cached();
-ge_cached get_T_cached();
-ge_cached get_U_cached();
-ge_cached get_V_cached();
+const public_key &get_G();
+const public_key &get_H();
+const public_key &get_T();
+const public_key &get_U();
+const public_key &get_V();
+const ge_p3 &get_G_p3();
+const ge_p3 &get_H_p3();
+const ge_p3 &get_T_p3();
+const ge_p3 &get_U_p3();
+const ge_p3 &get_V_p3();
+const ge_cached &get_G_cached();
+const ge_cached &get_H_cached();
+const ge_cached &get_T_cached();
+const ge_cached &get_U_cached();
+const ge_cached &get_V_cached();
} //namespace crypto
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.