| 1 | // Copyright 2007,2008 Segher Boessenkool <[email protected]> |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <array> |
| 7 | |
| 8 | #include "Common/CommonTypes.h" |
| 9 | |
| 10 | namespace Common::ec |
| 11 | { |
| 12 | using Signature = std::array<u8, 60>; |
| 13 | using PublicKey = std::array<u8, 60>; |
| 14 | |
| 15 | /// Generate a signature using ECDSA. |
| 16 | Signature Sign(const u8* key, const u8* hash); |
| 17 | |
| 18 | /// Check a signature using ECDSA. |
| 19 | /// |
| 20 | /// @param public_key 30 byte ECC public key |
| 21 | /// @param signature 60 byte signature |
| 22 | /// @param hash Message hash |
| 23 | bool VerifySignature(const u8* public_key, const u8* signature, const u8* hash); |
| 24 | |
| 25 | /// Compute a shared secret from a private key (30 bytes) and public key (60 bytes). |
| 26 | std::array<u8, 60> ComputeSharedSecret(const u8* private_key, const u8* public_key); |
| 27 | |
| 28 | /// Convert a ECC private key (30 bytes) to a public key (60 bytes). |
| 29 | PublicKey PrivToPub(const u8* key); |
| 30 | } // namespace Common::ec |