summaryrefslogtreecommitdiff
path: root/libs/libsodium/src/include/sodium/crypto_vrf.h
blob: e3b65b94e9076ad60067f717725ce7f072123203 (plain)
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
#ifndef crypto_vrf_H
#define crypto_vrf_H

/*
 * THREAD SAFETY: crypto_vrf_keypair() is thread-safe,
 * provided that sodium_init() was called before.
 *
 * Other functions, including crypto_vrf_keypair_from_seed(), are always thread-safe.
 */

#include <stddef.h>

#include "crypto_vrf_rfc9381.h"
#include "export.h"

#ifdef __cplusplus
# ifdef __GNUC__
#  pragma GCC diagnostic ignored "-Wlong-long"
# endif
extern "C" {
#endif

#define crypto_vrf_PROOFBYTES crypto_vrf_rfc9381_BYTES
SODIUM_EXPORT
size_t crypto_vrf_bytes(void);

#define crypto_vrf_OUTPUTBYTES crypto_vrf_rfc9381_OUTPUTBYTES
SODIUM_EXPORT
size_t crypto_vrf_outputbytes(void);

#define crypto_vrf_SEEDBYTES crypto_vrf_rfc9381_SEEDBYTES
SODIUM_EXPORT
size_t crypto_vrf_seedbytes(void);

#define crypto_vrf_PUBLICKEYBYTES crypto_vrf_rfc9381_PUBLICKEYBYTES
SODIUM_EXPORT
size_t crypto_vrf_publickeybytes(void);

#define crypto_vrf_SECRETKEYBYTES crypto_vrf_rfc9381_SECRETKEYBYTES
SODIUM_EXPORT
size_t crypto_vrf_secretkeybytes(void);

#define crypto_vrf_PRIMITIVE "rfc9381"
SODIUM_EXPORT
const char *crypto_vrf_primitive(void);

SODIUM_EXPORT
int crypto_vrf_keypair(unsigned char *pk, unsigned char *sk)
                       __attribute__ ((nonnull));

SODIUM_EXPORT
int crypto_vrf_seed_keypair(unsigned char *pk, unsigned char *sk,
				            const unsigned char *seed)
                            __attribute__ ((nonnull));

SODIUM_EXPORT
int crypto_vrf_prove(unsigned char *proof, const unsigned char *m,
                     unsigned long long mlen, const unsigned char *sk)
                     __attribute__ ((nonnull));

SODIUM_EXPORT
int crypto_vrf_verify(unsigned char *output,
                      const unsigned char *pk,
                      const unsigned char *proof,
                      const unsigned char *m, unsigned long long mlen)
                      __attribute__ ((warn_unused_result))  __attribute__ ((nonnull));

SODIUM_EXPORT
int crypto_vrf_proof_to_hash(unsigned char *hash, const unsigned char *proof);

#ifdef __cplusplus
}
#endif

#endif