-
Notifications
You must be signed in to change notification settings - Fork 5
/
faest_param.h.in
115 lines (99 loc) · 4.05 KB
/
faest_param.h.in
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* SPDX-License-Identifier: MIT
*/
#include "faest_defines.h"
#include <stddef.h>
#include <stdint.h>
#ifndef FAEST_@PARAM@_H
#define FAEST_@PARAM@_H
#ifdef __cplusplus
extern "C" {
#endif
#define FAEST_@PARAM@_PUBLIC_KEY_SIZE @PK_SIZE@
#define FAEST_@PARAM@_PRIVATE_KEY_SIZE @SK_SIZE@
#define FAEST_@PARAM@_SIGNATURE_SIZE @SIG_SIZE@
/* Signature API */
/**
* Key generation function.
* Generates a public and private key pair, for the specified parameter set.
*
* @param[out] pk The new public key.
* @param[out] sk The new private key.
*
* @return Returns 0 for success, or a nonzero value indicating an error.
*/
FAEST_EXPORT int FAEST_CALLING_CONVENTION faest_@PARAM_L@_keygen(uint8_t* pk, uint8_t* sk);
/**
* Signature function.
* Signs a message with the given keypair. Samples rho internally.
*
* @param[in] sk The signer's private key.
* @param[in] pk The signer's public key.
* @param[in] message The message to be signed.
* @param[in] message_len The length of the message, in bytes.
* @param[out] signature A buffer to hold the signature. The specific max number of
* bytes required for a parameter set is given by @PARAM_L@_signature_size().
* @param[in,out] signature_len The length of the provided signature buffer.
* On success, this is set to the number of bytes written to the signature buffer.
*
* @return Returns 0 for success, or a nonzero value indicating an error.
*
* @see faest_verify(), faest_keygen(), faest_signature_size()
*/
FAEST_EXPORT int FAEST_CALLING_CONVENTION faest_@PARAM_L@_sign(const uint8_t* sk, const uint8_t* message, size_t message_len, uint8_t* signature, size_t* signature_len);
/**
* Signature function (with custom randomness input).
* Signs a message with the given keypair.
*
* @param[in] sk The signer's private key.
* @param[in] pk The signer's public key.
* @param[in] message The message to be signed.
* @param[in] message_len The length of the message, in bytes.
* @param[in] rho Additonal randomness; providing randomness renders the signature non-determinstic
* @param[in] rho_len Length of rho, in bytes.
* @param[out] signature A buffer to hold the signature. The specific max number of
* bytes required for a parameter set is given by @PARAM_L@_signature_size().
* @param[in,out] signature_len The length of the provided signature buffer.
* On success, this is set to the number of bytes written to the signature buffer.
*
* @return Returns 0 for success, or a nonzero value indicating an error.
*
* @see faest_verify(), faest_keygen(), faest_signature_size()
*/
FAEST_EXPORT int FAEST_CALLING_CONVENTION faest_@PARAM_L@_sign_with_randomness(const uint8_t* sk, const uint8_t* message, size_t message_len, const uint8_t* rho, size_t rho_len, uint8_t* signature, size_t* signature_len);
/**
* Verification function.
* Verifies a signature is valid with respect to a public key and message.
*
* @param[in] pk The signer's public key.
* @param[in] message The message the signature purpotedly signs.
* @param[in] message_len The length of the message, in bytes.
* @param[in] signature The signature to verify.
* @param[in] signature_len The length of the signature.
*
* @return Returns 0 for success, indicating a valid signature, or a nonzero
* value indicating an error or an invalid signature.
*
* @see faest_sign(), faest_keygen()
*/
FAEST_EXPORT int FAEST_CALLING_CONVENTION faest_@PARAM_L@_verify(const uint8_t* pk, const uint8_t* message, size_t message_len, const uint8_t* signature, size_t signature_len);
/**
* Check that a key pair is valid.
*
* @param[in] sk The private key to check
* @param[in] pk The public key to check
*
* @return Returns 0 if the key pair is valid, or a nonzero value indicating an error
*/
FAEST_EXPORT int FAEST_CALLING_CONVENTION faest_@PARAM_L@_validate_keypair(const uint8_t* pk, const uint8_t* sk);
/**
* Clear data of a private key.
*
* @param[out] key The private key to clear
*/
FAEST_EXPORT void FAEST_CALLING_CONVENTION faest_@PARAM_L@_clear_private_key(uint8_t* key);
#ifdef __cplusplus
}
#endif
#endif
// vim: ft=c