Skip to content

Commit e869210

Browse files
committed
Encrypt ECDSA adaptor signatures in release builds
Previously, the adaptor signatures were not being encrypted due to the call being placed inside debug_assert! macro. Move the function call outside the macro, and debug_assert! the result instead.
1 parent 150669b commit e869210

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

src/zkp/ecdsa_adaptor.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,18 @@ impl EcdsaAdaptorSignature {
167167
) -> EcdsaAdaptorSignature {
168168
let mut adaptor_sig = ffi::EcdsaAdaptorSignature::new();
169169

170-
unsafe {
171-
debug_assert!(
172-
ffi::secp256k1_ecdsa_adaptor_encrypt(
173-
*secp.ctx(),
174-
&mut adaptor_sig,
175-
sk.as_c_ptr(),
176-
enckey.as_c_ptr(),
177-
msg.as_c_ptr(),
178-
ffi::secp256k1_nonce_function_ecdsa_adaptor,
179-
ptr::null_mut(),
180-
) == 1
181-
);
170+
let res = unsafe {
171+
ffi::secp256k1_ecdsa_adaptor_encrypt(
172+
*secp.ctx(),
173+
&mut adaptor_sig,
174+
sk.as_c_ptr(),
175+
enckey.as_c_ptr(),
176+
msg.as_c_ptr(),
177+
ffi::secp256k1_nonce_function_ecdsa_adaptor,
178+
ptr::null_mut(),
179+
)
182180
};
181+
debug_assert_eq!(res, 1);
183182

184183
EcdsaAdaptorSignature(adaptor_sig)
185184
}
@@ -197,19 +196,19 @@ impl EcdsaAdaptorSignature {
197196
) -> EcdsaAdaptorSignature {
198197
let mut adaptor_sig = ffi::EcdsaAdaptorSignature::new();
199198

200-
unsafe {
201-
debug_assert!(
202-
ffi::secp256k1_ecdsa_adaptor_encrypt(
203-
*secp.ctx(),
204-
&mut adaptor_sig,
205-
sk.as_c_ptr(),
206-
enckey.as_c_ptr(),
207-
msg.as_c_ptr(),
208-
ffi::secp256k1_nonce_function_ecdsa_adaptor,
209-
aux_rand.as_c_ptr() as *mut ffi::types::c_void,
210-
) == 1
211-
);
199+
let res = unsafe {
200+
ffi::secp256k1_ecdsa_adaptor_encrypt(
201+
*secp.ctx(),
202+
&mut adaptor_sig,
203+
sk.as_c_ptr(),
204+
enckey.as_c_ptr(),
205+
msg.as_c_ptr(),
206+
ffi::secp256k1_nonce_function_ecdsa_adaptor,
207+
aux_rand.as_c_ptr() as *mut ffi::types::c_void,
208+
)
212209
};
210+
debug_assert_eq!(res, 1);
211+
213212
EcdsaAdaptorSignature(adaptor_sig)
214213
}
215214

0 commit comments

Comments
 (0)