-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathed25519.h
More file actions
44 lines (39 loc) · 1.37 KB
/
ed25519.h
File metadata and controls
44 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <stdint.h>
#include <stddef.h>
#define ED25519_PUBLIC_KEY_SIZE 32
#define ED25519_PRIVATE_KEY_SIZE 64
#define ED25519_SIGNATURE_SIZE 64
/**
* Generate a new Ed25519 keypair
*
* @param public_key Output buffer for 32-byte public key
* @param private_key Output buffer for 64-byte private key
* @return true on success, false on failure
*/
bool ed25519_generate_keypair(uint8_t public_key[ED25519_PUBLIC_KEY_SIZE],
uint8_t private_key[ED25519_PRIVATE_KEY_SIZE]);
/**
* Sign a message using Ed25519
*
* @param signature Output buffer for 64-byte signature
* @param msg Message to sign
* @param len Length of message
* @param private_key 64-byte private key
* @return true on success, false on failure
*/
bool ed25519_sign(uint8_t signature[ED25519_SIGNATURE_SIZE],
const uint8_t *msg, size_t len,
const uint8_t private_key[ED25519_PRIVATE_KEY_SIZE]);
/**
* Verify an Ed25519 signature
*
* @param signature 64-byte signature to verify
* @param msg Message that was signed
* @param len Length of message
* @param public_key 32-byte public key
* @return true if signature is valid, false otherwise
*/
bool ed25519_verify(const uint8_t signature[ED25519_SIGNATURE_SIZE],
const uint8_t *msg, size_t len,
const uint8_t public_key[ED25519_PUBLIC_KEY_SIZE]);