Skip to content

Commit 586772c

Browse files
fixup! silentpayments: sending
This is slightly more pedantic because it avoids suppressing the warning value when not necessary, and I find it more readable. And it matches our current conventions, see for example secp256k1_ellswift_xswiftec_inv_var and see also my PR bitcoin-core#1485 (which I should rebase...)
1 parent 70cfdb5 commit 586772c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/modules/silentpayments/main_impl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ static void secp256k1_silentpayments_calculate_input_hash(unsigned char *input_h
6767
secp256k1_silentpayments_sha256_init_inputs(&hash);
6868
secp256k1_sha256_write(&hash, outpoint_smallest36, 36);
6969
ret = secp256k1_eckey_pubkey_serialize(pubkey_sum, pubkey_sum_ser, &len, 1);
70+
#ifdef VERFIY
7071
VERIFY_CHECK(ret && len == sizeof(pubkey_sum_ser));
72+
#else
7173
(void)ret;
74+
#endif
7275
secp256k1_sha256_write(&hash, pubkey_sum_ser, sizeof(pubkey_sum_ser));
7376
secp256k1_sha256_finalize(&hash, input_hash);
7477
}
@@ -88,8 +91,11 @@ static void secp256k1_silentpayments_create_shared_secret(const secp256k1_contex
8891
* the secret key being used
8992
*/
9093
ret = secp256k1_eckey_pubkey_serialize(&ss, shared_secret33, &len, 1);
94+
#ifdef VERIFY
9195
VERIFY_CHECK(ret && len == 33);
96+
#else
9297
(void)ret;
98+
#endif
9399
/* While not technically "secret" data, explicitly clear the shared secret since leaking this would allow an attacker
94100
* to identify the resulting transaction as a silent payments transaction and potentially link the transaction
95101
* back to the silent payment address
@@ -508,8 +514,11 @@ int secp256k1_silentpayments_recipient_public_data_serialize(const secp256k1_con
508514
secp256k1_scalar_set_b32(&input_hash_scalar, &public_data->data[5 + 64], NULL);
509515
ret = secp256k1_eckey_pubkey_tweak_mul(&ge, &input_hash_scalar);
510516
ret &= secp256k1_eckey_pubkey_serialize(&ge, output33, &pubkeylen, 1);
517+
#ifdef VERIFY
511518
VERIFY_CHECK(ret && pubkeylen == 33);
519+
#else
512520
(void)ret;
521+
#endif
513522
return 1;
514523
}
515524

0 commit comments

Comments
 (0)