Skip to content

Commit 6da00ec

Browse files
authored
Merge pull request #124 from apoelstra/2021-02--rename-klepto
ecdsa_s2c: rename anti-klepto to anti-exfil
2 parents ed69ea7 + e354c57 commit 6da00ec

File tree

4 files changed

+68
-68
lines changed

4 files changed

+68
-68
lines changed

include/secp256k1_ecdsa_s2c.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "secp256k1.h"
55

66
/** This module implements the sign-to-contract scheme for ECDSA signatures, as
7-
* well as the "ECDSA Anti-Klepto Protocol" that is based on sign-to-contract
7+
* well as the "ECDSA Anti-Exfil Protocol" that is based on sign-to-contract
88
* and is specified further down. The sign-to-contract scheme allows creating a
99
* signature that also commits to some data. This works by offsetting the public
1010
* nonce point of the signature R by hash(R, data)*G where G is the secp256k1
@@ -97,9 +97,9 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_s2c_verify_commit
9797
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
9898

9999

100-
/** ECDSA Anti-Klepto Protocol
100+
/** ECDSA Anti-Exfil Protocol
101101
*
102-
* The ecdsa_anti_klepto_* functions can be used to prevent a signing device from
102+
* The ecdsa_anti_exfil_* functions can be used to prevent a signing device from
103103
* exfiltrating the secret signing keys through biased signature nonces. The general
104104
* idea is that a host provides additional randomness to the signing device client
105105
* and the client commits to the randomness in the nonce using sign-to-contract.
@@ -113,9 +113,9 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_s2c_verify_commit
113113
* keys, or the signing device to bias the nonce despite the host's contributions,
114114
* the host and client must engage in a commit-reveal protocol as follows:
115115
* 1. The host draws randomness `rho` and computes a sha256 commitment to it using
116-
* `secp256k1_ecdsa_anti_klepto_host_commit`. It sends this to the signing device.
116+
* `secp256k1_ecdsa_anti_exfil_host_commit`. It sends this to the signing device.
117117
* 2. The signing device computes a public nonce `R` using the host's commitment
118-
* as auxiliary randomness, using `secp256k1_ecdsa_anti_klepto_signer_commit`.
118+
* as auxiliary randomness, using `secp256k1_ecdsa_anti_exfil_signer_commit`.
119119
* The signing device sends the resulting `R` to the host as a s2c_opening.
120120
*
121121
* If, at any point from this step onward, the hardware device fails, it is
@@ -135,10 +135,10 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_s2c_verify_commit
135135
* EVER, they should change hardware vendors and perhaps sweep their coins.
136136
*
137137
* 3. The host replies with `rho` generated in step 1.
138-
* 4. The device signs with `secp256k1_anti_klepto_sign`, using `rho` as `host_data32`,
138+
* 4. The device signs with `secp256k1_anti_exfil_sign`, using `rho` as `host_data32`,
139139
* and sends the signature to the host.
140140
* 5. The host verifies that the signature's public nonce matches the opening from
141-
* step 2 and its original randomness `rho`, using `secp256k1_anti_klepto_host_verify`.
141+
* step 2 and its original randomness `rho`, using `secp256k1_anti_exfil_host_verify`.
142142
*
143143
* Rationale:
144144
* - The reason for having a host commitment is to allow the signing device to
@@ -154,7 +154,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_s2c_verify_commit
154154
* maintain any state about the progress of the protocol.
155155
*/
156156

157-
/** Create the initial host commitment to `rho`. Part of the ECDSA Anti-Klepto Protocol.
157+
/** Create the initial host commitment to `rho`. Part of the ECDSA Anti-Exfil Protocol.
158158
*
159159
* Returns 1 on success, 0 on failure.
160160
* Args: ctx: pointer to a context object (cannot be NULL)
@@ -164,13 +164,13 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_s2c_verify_commit
164164
* be revealed to the client until after the host has received the client
165165
* commitment.
166166
*/
167-
SECP256K1_API int secp256k1_ecdsa_anti_klepto_host_commit(
167+
SECP256K1_API int secp256k1_ecdsa_anti_exfil_host_commit(
168168
const secp256k1_context* ctx,
169169
unsigned char* rand_commitment32,
170170
const unsigned char* rand32
171171
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
172172

173-
/** Compute signer's original nonce. Part of the ECDSA Anti-Klepto Protocol.
173+
/** Compute signer's original nonce. Part of the ECDSA Anti-Exfil Protocol.
174174
*
175175
* Returns 1 on success, 0 on failure.
176176
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
@@ -180,7 +180,7 @@ SECP256K1_API int secp256k1_ecdsa_anti_klepto_host_commit(
180180
* seckey32: the 32-byte secret key used for signing (cannot be NULL)
181181
* rand_commitment32: the 32-byte randomness commitment from the host (cannot be NULL)
182182
*/
183-
SECP256K1_API int secp256k1_ecdsa_anti_klepto_signer_commit(
183+
SECP256K1_API int secp256k1_ecdsa_anti_exfil_signer_commit(
184184
const secp256k1_context* ctx,
185185
secp256k1_ecdsa_s2c_opening* s2c_opening,
186186
const unsigned char* msg32,
@@ -189,7 +189,7 @@ SECP256K1_API int secp256k1_ecdsa_anti_klepto_signer_commit(
189189
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5);
190190

191191
/** Same as secp256k1_ecdsa_sign, but commits to host randomness in the nonce. Part of the
192-
* ECDSA Anti-Klepto Protocol.
192+
* ECDSA Anti-Exfil Protocol.
193193
*
194194
* Returns: 1: signature created
195195
* 0: the nonce generation function failed, or the private key was invalid.
@@ -199,15 +199,15 @@ SECP256K1_API int secp256k1_ecdsa_anti_klepto_signer_commit(
199199
* seckey: pointer to a 32-byte secret key (cannot be NULL)
200200
* host_data32: pointer to 32-byte host-provided randomness (cannot be NULL)
201201
*/
202-
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_anti_klepto_sign(
202+
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_anti_exfil_sign(
203203
const secp256k1_context* ctx,
204204
secp256k1_ecdsa_signature* sig,
205205
const unsigned char* msg32,
206206
const unsigned char* seckey,
207207
const unsigned char* host_data32
208208
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5);
209209

210-
/** Verify a signature was correctly constructed using the ECDSA Anti-Klepto Protocol.
210+
/** Verify a signature was correctly constructed using the ECDSA Anti-Exfil Protocol.
211211
*
212212
* Returns: 1: the signature is valid and contains a commitment to host_data32
213213
* 0: incorrect opening
@@ -218,7 +218,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_anti_klepto_sign(
218218
* host_data32: the 32-byte data provided by the host (cannot be NULL)
219219
* opening: the s2c opening provided by the signer (cannot be NULL)
220220
*/
221-
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_anti_klepto_host_verify(
221+
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_anti_exfil_host_verify(
222222
const secp256k1_context* ctx,
223223
const secp256k1_ecdsa_signature *sig,
224224
const unsigned char *msg32,

src/modules/ecdsa_s2c/main_impl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int secp256k1_ecdsa_s2c_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signa
8282
/* Provide `s2c_data32` to the nonce function as additional data to
8383
* derive the nonce. It is first hashed because it should be possible
8484
* to derive nonces even if only a SHA256 commitment to the data is
85-
* known. This is important in the ECDSA anti-klepto protocol. */
85+
* known. This is important in the ECDSA anti-exfil protocol. */
8686
secp256k1_s2c_ecdsa_data_sha256_tagged(&s2c_sha);
8787
secp256k1_sha256_write(&s2c_sha, s2c_data32, 32);
8888
secp256k1_sha256_finalize(&s2c_sha, ndata);
@@ -130,15 +130,15 @@ int secp256k1_ecdsa_s2c_verify_commit(const secp256k1_context* ctx, const secp25
130130
/* Do not check overflow; overflowing a scalar does not affect whether
131131
* or not the R value is a cryptographic commitment, only whether it
132132
* is a valid R value for an ECDSA signature. If users care about that
133-
* they should use `ecdsa_verify` or `anti_klepto_host_verify`. In other
133+
* they should use `ecdsa_verify` or `anti_exfil_host_verify`. In other
134134
* words, this check would be (at best) unnecessary, and (at worst)
135135
* insufficient. */
136136
secp256k1_scalar_set_b32(&x_scalar, x_bytes, NULL);
137137
return secp256k1_scalar_eq(&sigr, &x_scalar);
138138
}
139139

140-
/*** anti-klepto ***/
141-
int secp256k1_ecdsa_anti_klepto_host_commit(const secp256k1_context* ctx, unsigned char* rand_commitment32, const unsigned char* rand32) {
140+
/*** anti-exfil ***/
141+
int secp256k1_ecdsa_anti_exfil_host_commit(const secp256k1_context* ctx, unsigned char* rand_commitment32, const unsigned char* rand32) {
142142
secp256k1_sha256 sha;
143143

144144
VERIFY_CHECK(ctx != NULL);
@@ -151,7 +151,7 @@ int secp256k1_ecdsa_anti_klepto_host_commit(const secp256k1_context* ctx, unsign
151151
return 1;
152152
}
153153

154-
int secp256k1_ecdsa_anti_klepto_signer_commit(const secp256k1_context* ctx, secp256k1_ecdsa_s2c_opening* opening, const unsigned char* msg32, const unsigned char* seckey32, const unsigned char* rand_commitment32) {
154+
int secp256k1_ecdsa_anti_exfil_signer_commit(const secp256k1_context* ctx, secp256k1_ecdsa_s2c_opening* opening, const unsigned char* msg32, const unsigned char* seckey32, const unsigned char* rand_commitment32) {
155155
unsigned char nonce32[32];
156156
secp256k1_scalar k;
157157
secp256k1_gej rj;
@@ -186,11 +186,11 @@ int secp256k1_ecdsa_anti_klepto_signer_commit(const secp256k1_context* ctx, secp
186186
return 1;
187187
}
188188

189-
int secp256k1_anti_klepto_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char* msg32, const unsigned char* seckey, const unsigned char* host_data32) {
189+
int secp256k1_anti_exfil_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char* msg32, const unsigned char* seckey, const unsigned char* host_data32) {
190190
return secp256k1_ecdsa_s2c_sign(ctx, sig, NULL, msg32, seckey, host_data32);
191191
}
192192

193-
int secp256k1_anti_klepto_host_verify(const secp256k1_context* ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey, const unsigned char *host_data32, const secp256k1_ecdsa_s2c_opening *opening) {
193+
int secp256k1_anti_exfil_host_verify(const secp256k1_context* ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey, const unsigned char *host_data32, const secp256k1_ecdsa_s2c_opening *opening) {
194194
return secp256k1_ecdsa_s2c_verify_commit(ctx, sig, host_data32, opening) &&
195195
secp256k1_ecdsa_verify(ctx, sig, msg32, pubkey);
196196
}

0 commit comments

Comments
 (0)