mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
ec: Improve readability and clarity
- Move all of the ec functions into the Common::ec namespace. - Give the public functions better names and some usage information. - Move all of the "elt" related functions into an "elt" class including all of the arithmetic operations, so that the logic becomes clearer and feels less like assembly. This also makes it much more obvious what the parameters are, instead of only using unsigned char* (which doesn't tell anything about what the pointer is used for or the size). - Similarly, add a new "Point" class and move point functions there. Overload the arithmetic operators to make calculations easier to read
This commit is contained in:
@ -8,8 +8,14 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
void generate_ecdsa(u8* R, u8* S, const u8* k, const u8* hash);
|
||||
|
||||
void ec_priv_to_pub(const u8* k, u8* Q);
|
||||
namespace Common::ec
|
||||
{
|
||||
/// Generate a signature using ECDSA.
|
||||
std::array<u8, 60> Sign(const u8* key, const u8* hash);
|
||||
|
||||
/// Compute a shared secret from a private key (30 bytes) and public key (60 bytes).
|
||||
std::array<u8, 60> ComputeSharedSecret(const u8* private_key, const u8* public_key);
|
||||
|
||||
/// Convert a ECC private key (30 bytes) to a public key (60 bytes).
|
||||
std::array<u8, 60> PrivToPub(const u8* key);
|
||||
} // namespace Common::ec
|
||||
|
Reference in New Issue
Block a user