-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathblinding.h
More file actions
161 lines (149 loc) · 6.87 KB
/
blinding.h
File metadata and controls
161 lines (149 loc) · 6.87 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#include "export.h"
#include "platform.h"
/// API: crypto/session_blind15_key_pair
///
/// This function attempts to generate a blind15 key pair.
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `blinded_pk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_pk will
/// be written if generation was successful.
/// - `blinded_sk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_sk will
/// be written if generation was successful.
///
/// Outputs:
/// - `bool` -- True if the key was successfully generated, false if generation failed.
LIBSESSION_EXPORT bool session_blind15_key_pair(
const unsigned char* ed25519_seckey, /* 64 bytes */
const unsigned char* server_pk, /* 32 bytes */
unsigned char* blinded_pk_out, /* 32 byte output buffer */
unsigned char* blinded_sk_out /* 32 byte output buffer */);
/// API: crypto/session_blind25_key_pair
///
/// This function attempts to generate a blind25 key pair.
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `blinded_pk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_pk will
/// be written if generation was successful.
/// - `blinded_sk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_sk will
/// be written if generation was successful.
///
/// Outputs:
/// - `bool` -- True if the key was successfully generated, false if generation failed.
LIBSESSION_EXPORT bool session_blind25_key_pair(
const unsigned char* ed25519_seckey, /* 64 bytes */
const unsigned char* server_pk, /* 32 bytes */
unsigned char* blinded_pk_out, /* 32 byte output buffer */
unsigned char* blinded_sk_out /* 32 byte output buffer */);
/// API: crypto/session_blind_version_key_pair
///
/// This function attempts to generate a blind-version key pair.
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the user (64 bytes).
/// - `blinded_pk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_pk will
/// be written if generation was successful.
/// - `blinded_sk_out` -- [out] pointer to a buffer of at least 64 bytes where the blinded_sk will
/// be written if generation was successful.
///
/// Outputs:
/// - `bool` -- True if the key was successfully generated, false if generation failed.
LIBSESSION_EXPORT bool session_blind_version_key_pair(
const unsigned char* ed25519_seckey, /* 64 bytes */
unsigned char* blinded_pk_out, /* 32 byte output buffer */
unsigned char* blinded_sk_out /* 64 byte output buffer */);
/// API: crypto/session_blind15_sign
///
/// This function attempts to generate a signature for a message using a blind15 private key.
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `msg` -- [in] Pointer to a data buffer containing the message to generate a signature for.
/// - `msg_len` -- [in] Length of `msg`
/// - `blinded_sig_out` -- [out] pointer to a buffer of at least 64 bytes where the signature will
/// be written if generation was successful.
///
/// Outputs:
/// - `bool` -- True if the signature was successfully generated, false if generation failed.
LIBSESSION_EXPORT bool session_blind15_sign(
const unsigned char* ed25519_seckey, /* 64 bytes */
const unsigned char* server_pk, /* 32 bytes */
const unsigned char* msg,
size_t msg_len,
unsigned char* blinded_sig_out /* 64 byte output buffer */);
/// API: crypto/session_blind25_sign
///
/// This function attempts to generate a signature for a message using a blind25 private key.
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `msg` -- [in] Pointer to a data buffer containing the message to generate a signature for.
/// - `msg_len` -- [in] Length of `msg`
/// - `blinded_sig_out` -- [out] pointer to a buffer of at least 64 bytes where the signature will
/// be written if generation was successful.
///
/// Outputs:
/// - `bool` -- True if the signature was successfully generated, false if generation failed.
LIBSESSION_EXPORT bool session_blind25_sign(
const unsigned char* ed25519_seckey, /* 64 bytes */
const unsigned char* server_pk, /* 32 bytes */
const unsigned char* msg,
size_t msg_len,
unsigned char* blinded_sig_out /* 64 byte output buffer */);
/// Computes a verifiable version-blinded signature that validates with the version-blinded pubkey
/// that would be returned from blind_version_key_pair.
///
/// Takes the Ed25519 secret key (64 bytes), unix timestamp, method, path, and optional body.
/// Returns a version-blinded signature.
LIBSESSION_EXPORT bool session_blind_version_sign_request(
const unsigned char* ed25519_seckey, /* 64 bytes */
uint64_t timestamp,
const char* method,
const char* path,
const unsigned char* body, /* optional */
size_t body_len,
unsigned char* blinded_sig_out /* 64 byte output buffer */);
/// Computes a verifiable version-blinded signature that validates with the version-blinded pubkey
/// that would be returned from blind_version_key_pair.
///
/// Takes the Ed25519 secret key (64 bytes), platform and unix timestamp. Returns a version-blinded
/// signature.
LIBSESSION_EXPORT bool session_blind_version_sign(
const unsigned char* ed25519_seckey, /* 64 bytes */
CLIENT_PLATFORM platform,
uint64_t timestamp,
unsigned char* blinded_sig_out /* 64 byte output buffer */);
/// API: crypto/session_blind25_sign
///
/// This function attempts to generate a signature for a message using a blind25 private key.
///
/// Inputs:
/// - `session_id` -- [in] the session_id to compare (66 bytes with a 05 prefix).
/// - `blinded_id` -- [in] the blinded_id to compare, can be either 15 or 25 blinded (66 bytes).
/// - `server_pk` -- [in] the public key of the community server to the blinded id came from (64
/// bytes).
///
/// Outputs:
/// - `bool` -- True if the session_id matches the blinded_id, false if not.
LIBSESSION_EXPORT bool session_id_matches_blinded_id(
const char* session_id, /* 66 bytes */
const char* blinded_id, /* 66 bytes */
const char* server_pk /* 64 bytes */);
#ifdef __cplusplus
}
#endif