Skip to content

Commit 779458a

Browse files
committed
f some comments and add explanation about why an s2c_opening has a nonce_is_negated field
1 parent 5c63646 commit 779458a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

include/secp256k1.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ typedef struct {
8181
unsigned char data[64];
8282
} secp256k1_ecdsa_signature;
8383

84-
/** Data structure that holds a sign-to-contract ("s2c") opening. Sign-to-contract
85-
* allows a signer to commit to some data as part of a signature. It can be used as
86-
* an Out-argument in certain signing functions.
84+
/** Data structure that holds a sign-to-contract ("s2c") opening information.
85+
* Sign-to-contract allows a signer to commit to some data as part of a signature. It
86+
* can be used as an Out-argument in certain signing functions.
8787
*
8888
* This structure is not opaque, but it is strongly discouraged to read or write to
8989
* it directly.
@@ -97,7 +97,10 @@ typedef struct {
9797
uint64_t magic;
9898
/* Public nonce before applying the sign-to-contract commitment */
9999
secp256k1_pubkey original_pubnonce;
100-
/* Integer indicating if signing algorithm negated the nonce */
100+
/* Byte indicating if signing algorithm negated the nonce. Alternatively when
101+
* verifying we could compute the EC commitment of original_pubnonce and the
102+
* data and negate if this would not be a valid nonce. But this would prevent
103+
* batch verification of sign-to-contract commitments. */
101104
unsigned char nonce_is_negated;
102105
} secp256k1_s2c_opening;
103106

src/modules/schnorrsig/main_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int secp256k1_schnorrsig_sign(const secp256k1_context* ctx, secp256k1_schnorrsig
7474
ARG_CHECK(seckey != NULL);
7575
/* sign-to-contract commitments only work with the default nonce function,
7676
* because we need to ensure that s2c_data is actually hashed into the nonce and
77-
* not just ignored. */
77+
* not just ignored because otherwise this could result in nonce reuse. */
7878
ARG_CHECK(s2c_data32 == NULL || (noncefp == NULL || noncefp == secp256k1_nonce_function_bipschnorr));
7979
/* s2c_opening and s2c_data32 should be either both non-NULL or both NULL. */
8080
ARG_CHECK((s2c_opening != NULL) == (s2c_data32 != NULL));

0 commit comments

Comments
 (0)