Skip to content

Commit affa6e8

Browse files
committed
f rename is_positive in xonly_pubkey api to has_square_y
1 parent b5fcf54 commit affa6e8

File tree

3 files changed

+71
-74
lines changed

3 files changed

+71
-74
lines changed

include/secp256k1.h

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,9 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine(
714714
) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
715715

716716
/** Opaque data structure that holds a parsed and valid "x-only" public key.
717-
* An x-only pubkey encodes a positive point. That is a point whose Y
718-
* coordinate is square. It is serialized using only its X coordinate (32
719-
* bytes).
717+
* An x-only pubkey encodes a point whose Y coordinate is square. It is
718+
* serialized using only its X coordinate (32 bytes). See bip-schnorr for more
719+
* information about x-only pubkeys.
720720
*
721721
* The exact representation of data inside is implementation defined and not
722722
* guaranteed to be portable between different platforms or versions. It is
@@ -777,27 +777,24 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_create(
777777
const unsigned char *seckey
778778
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
779779

780-
/** Converts a secp256k1_pubkey into a secp256k1_xonly_pubkey. This
781-
* function optionally outputs a sign bit that can be used to convert
782-
* the secp256k1_xonly_pubkey back into the same secp256k1_pubkey.
783-
* The sign bit is 0 if the input pubkey encodes a positive point (has a Y
784-
* coordinate that is square), otherwise it is 1.
780+
/** Converts a secp256k1_pubkey into a secp256k1_xonly_pubkey.
785781
*
786782
* Returns: 1 if the public key was successfully converted
787783
* 0 otherwise
788784
*
789785
* Args: ctx: pointer to a context object
790786
* Out: xonly_pubkey: pointer to an x-only public key object for placing the
791787
* converted public key (cannot be NULL)
792-
* sign: sign bit of the pubkey. Can be used to reconstruct a
793-
* public key from x-only public key (can be NULL)
788+
* has_square_y: pointer to an integer that will be set to 1 if the pubkey
789+
* encodes a point with a square Y coordinate, and set to 0
790+
* otherwise. (can be NULL)
794791
* In: pubkey: pointer to a public key that is converted (cannot be
795792
* NULL)
796793
*/
797794
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_from_pubkey(
798795
const secp256k1_context* ctx,
799796
secp256k1_xonly_pubkey *xonly_pubkey,
800-
int *is_positive,
797+
int *has_square_y,
801798
const secp256k1_pubkey *pubkey
802799
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4);
803800

@@ -806,10 +803,9 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_from_pubke
806803
* secp256k1_xonly_pubkey_tweak_add called with the same tweak and corresponding
807804
* input public key.
808805
*
809-
* If the public key corresponds to a positive point, tweak32 is added to the
810-
* seckey (modulo the group order). If the public key corresponds to a
811-
* negative point, tweak32 is added to the negation of the seckey (modulo the
812-
* group order).
806+
* If the public key corresponds to a point with square Y, tweak32 is added to
807+
* the seckey (modulo the group order). Otherwise, tweak32 is added to the
808+
* negation of the seckey (modulo the group order).
813809
*
814810
* Returns: 1 if the tweak was successfully added to seckey
815811
* 0 if the tweak was out of range or the resulting private key would be
@@ -836,21 +832,22 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_privkey_tweak_add
836832
* Args: ctx: pointer to a context object initialized for validation
837833
* (cannot be NULL)
838834
* Out: output_pubkey: pointer to a public key object (cannot be NULL)
839-
* is_positive: pointer to an integer that will be set to 1 if the
840-
* output_pubkey is positive, and 0 otherwise (cannot be NULL)
835+
* has_square_y: pointer to an integer that will be set to 1 if the
836+
* output_pubkey has a square Y coordinate, and set to 0
837+
* otherwise (cannot be NULL)
841838
* In: internal_pubkey: pointer to an x-only public key object to apply the
842839
* tweak to (cannot be NULL)
843840
* tweak32: pointer to a 32-byte tweak (cannot be NULL)
844841
*/
845842
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_tweak_add(
846843
const secp256k1_context* ctx,
847844
secp256k1_xonly_pubkey *output_pubkey,
848-
int *is_positive,
845+
int *has_square_y,
849846
const secp256k1_xonly_pubkey *internal_pubkey,
850847
const unsigned char *tweak32
851848
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5);
852849

853-
/** Verifies that output_pubkey and is_positive is the result of calling
850+
/** Verifies that output_pubkey and has_square_y is the result of calling
854851
* secp256k1_xonly_pubkey_tweak_add with internal_pubkey and tweak32.
855852
*
856853
* Returns: 1 if output_pubkey is the result of tweaking the internal_pubkey with
@@ -860,15 +857,15 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_tweak_add(
860857
* Args: ctx: pointer to a context object initialized for validation
861858
* (cannot be NULL)
862859
* In: output_pubkey: pointer to a public key object (cannot be NULL)
863-
* is_positive: 1 if output_pubkey is positive and 0 otherwise
860+
* has_square_y: 1 if output_pubkey has a square Y coordinate and 0 otherwise.
864861
* internal_pubkey: pointer to an x-only public key object to apply the
865862
* tweak to (cannot be NULL)
866863
* tweak32: pointer to a 32-byte tweak (cannot be NULL)
867864
*/
868865
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_tweak_verify(
869866
const secp256k1_context* ctx,
870867
const secp256k1_xonly_pubkey *output_pubkey,
871-
int is_positive,
868+
int has_square_y,
872869
const secp256k1_xonly_pubkey *internal_pubkey,
873870
const unsigned char *tweak32
874871
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5);

src/secp256k1.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -730,19 +730,19 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
730730
return 1;
731731
}
732732

733-
/* Converts the point encoded by a secp256k1_pubkey into its absolute value,
734-
* i.e. keeps it as is if it is positive and otherwise negates it. Sign is set
735-
* to 1 if the input point was negative and set to 0 otherwise. */
736-
static void secp256k1_ec_pubkey_absolute(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, int *sign) {
733+
/* Converts the point encoded by a secp256k1_pubkey into its "absolute" value,
734+
* i.e. keeps it as is if it is has a square Y and otherwise negates it.
735+
* has_square_y is set to 1 in the former case and to 0 in the latter case. */
736+
static void secp256k1_ec_pubkey_absolute(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, int *has_square_y) {
737737
secp256k1_ge ge;
738738
secp256k1_pubkey_load(ctx, &ge, pubkey);
739-
if (sign != NULL) {
740-
*sign = 0;
739+
if (has_square_y != NULL) {
740+
*has_square_y = 1;
741741
}
742742
if (!secp256k1_fe_is_quad_var(&ge.y)) {
743743
secp256k1_ge_neg(&ge, &ge);
744-
if (sign != NULL) {
745-
*sign = 1;
744+
if (has_square_y != NULL) {
745+
*has_square_y = 0;
746746
}
747747
}
748748
secp256k1_pubkey_save(pubkey, &ge);
@@ -792,14 +792,14 @@ int secp256k1_xonly_pubkey_serialize(const secp256k1_context* ctx, unsigned char
792792
return 1;
793793
}
794794

795-
int secp256k1_xonly_pubkey_from_pubkey(const secp256k1_context* ctx, secp256k1_xonly_pubkey *xonly_pubkey, int *sign, const secp256k1_pubkey *pubkey) {
795+
int secp256k1_xonly_pubkey_from_pubkey(const secp256k1_context* ctx, secp256k1_xonly_pubkey *xonly_pubkey, int *has_square_y, const secp256k1_pubkey *pubkey) {
796796
VERIFY_CHECK(ctx != NULL);
797797
ARG_CHECK(xonly_pubkey != NULL);
798798
ARG_CHECK(pubkey != NULL);
799799

800800
*xonly_pubkey = *(const secp256k1_xonly_pubkey *) pubkey;
801801

802-
secp256k1_ec_pubkey_absolute(ctx, (secp256k1_pubkey *) xonly_pubkey, sign);
802+
secp256k1_ec_pubkey_absolute(ctx, (secp256k1_pubkey *) xonly_pubkey, has_square_y);
803803
return 1;
804804
}
805805

@@ -824,35 +824,35 @@ int secp256k1_xonly_privkey_tweak_add(const secp256k1_context* ctx, unsigned cha
824824
return secp256k1_ec_privkey_tweak_add(ctx, seckey32, tweak32);
825825
}
826826

827-
int secp256k1_xonly_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_xonly_pubkey *output_pubkey, int *is_positive, const secp256k1_xonly_pubkey *internal_pubkey, const unsigned char *tweak32) {
827+
int secp256k1_xonly_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_xonly_pubkey *output_pubkey, int *has_square_y, const secp256k1_xonly_pubkey *internal_pubkey, const unsigned char *tweak32) {
828828
secp256k1_pubkey pubkey_tmp;
829829
VERIFY_CHECK(ctx != NULL);
830830
ARG_CHECK(output_pubkey != NULL);
831-
ARG_CHECK(is_positive != NULL);
831+
ARG_CHECK(has_square_y != NULL);
832832
ARG_CHECK(internal_pubkey != NULL);
833833
ARG_CHECK(tweak32 != NULL);
834834

835835
pubkey_tmp = *(secp256k1_pubkey *)internal_pubkey;
836836
if(!secp256k1_ec_pubkey_tweak_add(ctx, &pubkey_tmp, tweak32)) {
837837
return 0;
838838
}
839-
return secp256k1_xonly_pubkey_from_pubkey(ctx, output_pubkey, is_positive, &pubkey_tmp);
839+
return secp256k1_xonly_pubkey_from_pubkey(ctx, output_pubkey, has_square_y, &pubkey_tmp);
840840
}
841841

842-
int secp256k1_xonly_pubkey_tweak_verify(const secp256k1_context* ctx, const secp256k1_xonly_pubkey *output_pubkey, int is_positive, const secp256k1_xonly_pubkey *internal_pubkey, const unsigned char *tweak32) {
842+
int secp256k1_xonly_pubkey_tweak_verify(const secp256k1_context* ctx, const secp256k1_xonly_pubkey *output_pubkey, int has_square_y, const secp256k1_xonly_pubkey *internal_pubkey, const unsigned char *tweak32) {
843843
secp256k1_xonly_pubkey pk_expected;
844-
int is_positive_expected;
844+
int has_square_y_expected;
845845
VERIFY_CHECK(ctx != NULL);
846846
ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx));
847847
ARG_CHECK(internal_pubkey != NULL);
848848
ARG_CHECK(output_pubkey != NULL);
849849
ARG_CHECK(tweak32 != NULL);
850850

851-
if (!secp256k1_xonly_pubkey_tweak_add(ctx, &pk_expected, &is_positive_expected, internal_pubkey, tweak32)) {
851+
if (!secp256k1_xonly_pubkey_tweak_add(ctx, &pk_expected, &has_square_y_expected, internal_pubkey, tweak32)) {
852852
return 0;
853853
}
854854
return memcmp(&pk_expected, output_pubkey, sizeof(pk_expected)) == 0
855-
&& is_positive_expected == is_positive;
855+
&& has_square_y_expected == has_square_y;
856856
}
857857

858858
#ifdef ENABLE_MODULE_ECDH

src/tests.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4278,7 +4278,7 @@ void test_xonly_pubkey(void) {
42784278
secp256k1_ge pk1;
42794279
secp256k1_ge pk2;
42804280
secp256k1_fe y;
4281-
int is_positive;
4281+
int has_square_y;
42824282
unsigned char buf32[32];
42834283

42844284
/* sk = 0 should fail */
@@ -4297,9 +4297,9 @@ void test_xonly_pubkey(void) {
42974297
CHECK(secp256k1_fe_equal(&pk1.y, &y) == 1);
42984298

42994299
/* Test from_pubkey */
4300-
CHECK(secp256k1_xonly_pubkey_from_pubkey(ctx, &xonly_pk_tmp, &is_positive, &xy_pk) == 1);
4300+
CHECK(secp256k1_xonly_pubkey_from_pubkey(ctx, &xonly_pk_tmp, &has_square_y, &xy_pk) == 1);
43014301
CHECK(memcmp(&xonly_pk_tmp, &xonly_pk, sizeof(xonly_pk)) == 0);
4302-
CHECK(is_positive == 1);
4302+
CHECK(has_square_y == 0);
43034303

43044304
/* Serialization and parse roundtrip */
43054305
CHECK(secp256k1_xonly_pubkey_create(ctx, &xonly_pk, sk) == 1);
@@ -4321,7 +4321,7 @@ void test_xonly_pubkey_api(void) {
43214321
unsigned char xy_sk[32];
43224322
unsigned char buf32[32];
43234323
unsigned char tweak[32];
4324-
int pk_is_positive;
4324+
int has_square_y;
43254325

43264326
/** setup **/
43274327
secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
@@ -4379,46 +4379,46 @@ void test_xonly_pubkey_api(void) {
43794379
CHECK(ecount == 4);
43804380

43814381
ecount = 0;
4382-
CHECK(secp256k1_xonly_pubkey_tweak_add(none, &pk, &pk_is_positive, &pk, tweak) == 0);
4382+
CHECK(secp256k1_xonly_pubkey_tweak_add(none, &pk, &has_square_y, &pk, tweak) == 0);
43834383
CHECK(ecount == 1);
4384-
CHECK(secp256k1_xonly_pubkey_tweak_add(sign, &pk, &pk_is_positive, &pk, tweak) == 0);
4384+
CHECK(secp256k1_xonly_pubkey_tweak_add(sign, &pk, &has_square_y, &pk, tweak) == 0);
43854385
CHECK(ecount == 2);
4386-
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &pk_is_positive, &pk, tweak) == 1);
4387-
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, NULL, &pk_is_positive, &pk, tweak) == 0);
4386+
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &has_square_y, &pk, tweak) == 1);
4387+
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, NULL, &has_square_y, &pk, tweak) == 0);
43884388
CHECK(ecount == 3);
43894389
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, NULL, &pk, tweak) == 0);
43904390
CHECK(ecount == 4);
4391-
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &pk_is_positive, NULL, tweak) == 0);
4391+
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &has_square_y, NULL, tweak) == 0);
43924392
CHECK(ecount == 5);
4393-
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &pk_is_positive, &pk, NULL) == 0);
4393+
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk, &has_square_y, &pk, NULL) == 0);
43944394
CHECK(ecount == 6);
43954395

43964396
ecount = 0;
4397-
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk_tweaked, &pk_is_positive, &pk, tweak) == 1);
4398-
CHECK(secp256k1_xonly_pubkey_tweak_verify(none, &pk_tweaked, pk_is_positive, &pk, tweak) == 0);
4397+
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &pk_tweaked, &has_square_y, &pk, tweak) == 1);
4398+
CHECK(secp256k1_xonly_pubkey_tweak_verify(none, &pk_tweaked, has_square_y, &pk, tweak) == 0);
43994399
CHECK(ecount == 1);
4400-
CHECK(secp256k1_xonly_pubkey_tweak_verify(sign, &pk_tweaked, pk_is_positive, &pk, tweak) == 0);
4400+
CHECK(secp256k1_xonly_pubkey_tweak_verify(sign, &pk_tweaked, has_square_y, &pk, tweak) == 0);
44014401
CHECK(ecount == 2);
4402-
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, pk_is_positive, &pk, tweak) == 1);
4403-
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, NULL, pk_is_positive, &pk, tweak) == 0);
4402+
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, has_square_y, &pk, tweak) == 1);
4403+
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, NULL, has_square_y, &pk, tweak) == 0);
44044404
CHECK(ecount == 3);
4405-
/* invalid is_positive value */
4405+
/* invalid has_square_y value */
44064406
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, 2, &pk, tweak) == 0);
44074407
CHECK(ecount == 3);
4408-
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, pk_is_positive, NULL, tweak) == 0);
4408+
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, has_square_y, NULL, tweak) == 0);
44094409
CHECK(ecount == 4);
4410-
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, pk_is_positive, &pk, NULL) == 0);
4410+
CHECK(secp256k1_xonly_pubkey_tweak_verify(vrfy, &pk_tweaked, has_square_y, &pk, NULL) == 0);
44114411
CHECK(ecount == 5);
44124412

44134413

44144414
ecount = 0;
4415-
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, &pk, &pk_is_positive, &xy_pk) == 1);
4416-
CHECK(secp256k1_xonly_pubkey_from_pubkey(sign, &pk, &pk_is_positive, &xy_pk) == 1);
4417-
CHECK(secp256k1_xonly_pubkey_from_pubkey(vrfy, &pk, &pk_is_positive, &xy_pk) == 1);
4418-
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, NULL, &pk_is_positive, &xy_pk) == 0);
4415+
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, &pk, &has_square_y, &xy_pk) == 1);
4416+
CHECK(secp256k1_xonly_pubkey_from_pubkey(sign, &pk, &has_square_y, &xy_pk) == 1);
4417+
CHECK(secp256k1_xonly_pubkey_from_pubkey(vrfy, &pk, &has_square_y, &xy_pk) == 1);
4418+
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, NULL, &has_square_y, &xy_pk) == 0);
44194419
CHECK(ecount == 1);
44204420
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, &pk, NULL, &xy_pk) == 1);
4421-
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, &pk, &pk_is_positive, NULL) == 0);
4421+
CHECK(secp256k1_xonly_pubkey_from_pubkey(none, &pk, &has_square_y, NULL) == 0);
44224422
CHECK(ecount == 2);
44234423

44244424
secp256k1_context_destroy(none);
@@ -4433,7 +4433,7 @@ void test_xonly_pubkey_tweak(void) {
44334433
secp256k1_xonly_pubkey internal_pk;
44344434
secp256k1_xonly_pubkey output_pk;
44354435
secp256k1_pubkey xy_pk;
4436-
int is_positive;
4436+
int has_square_y;
44374437
unsigned char tweak[32];
44384438

44394439
memset(zeros, 0, sizeof(zeros));
@@ -4442,23 +4442,23 @@ void test_xonly_pubkey_tweak(void) {
44424442
CHECK(secp256k1_xonly_pubkey_create(ctx, &internal_pk, sk) == 1);
44434443

44444444
memset(tweak, 1, sizeof(tweak));
4445-
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &output_pk, &is_positive, &internal_pk, tweak) == 1);
4446-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, is_positive, &internal_pk, tweak) == 1);
4445+
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &output_pk, &has_square_y, &internal_pk, tweak) == 1);
4446+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, has_square_y, &internal_pk, tweak) == 1);
44474447
/* Using privkey_tweak_add gives the same result */
44484448
CHECK(secp256k1_xonly_privkey_tweak_add(ctx, sk, tweak) == 1);
44494449
CHECK(secp256k1_ec_pubkey_create(ctx, &xy_pk, sk) == 1);
4450-
CHECK(secp256k1_xonly_pubkey_from_pubkey(ctx, &output_pk, &is_positive, &xy_pk) == 1);
4451-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, is_positive, &internal_pk, tweak) == 1);
4450+
CHECK(secp256k1_xonly_pubkey_from_pubkey(ctx, &output_pk, &has_square_y, &xy_pk) == 1);
4451+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, has_square_y, &internal_pk, tweak) == 1);
44524452

4453-
/* Wrong is_positive */
4454-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, !is_positive, &internal_pk, tweak) == 0);
4453+
/* Wrong has_square_y */
4454+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, !has_square_y, &internal_pk, tweak) == 0);
44554455
/* Wrong public key */
4456-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &internal_pk, is_positive, &internal_pk, tweak) == 0);
4456+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &internal_pk, has_square_y, &internal_pk, tweak) == 0);
44574457

44584458
/* Overflowing tweak not allowed */
4459-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, is_positive, &internal_pk, overflows) == 0);
4459+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &output_pk, has_square_y, &internal_pk, overflows) == 0);
44604460
CHECK(secp256k1_xonly_privkey_tweak_add(ctx, sk, overflows) == 0);
4461-
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &output_pk, &is_positive, &internal_pk, overflows) == 0);
4461+
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &output_pk, &has_square_y, &internal_pk, overflows) == 0);
44624462
}
44634463

44644464
/* Starts with an initial pubkey and recursively creates N_PUBKEYS - 1
@@ -4468,7 +4468,7 @@ void test_xonly_pubkey_tweak(void) {
44684468
void test_xonly_pubkey_tweak_recursive(void) {
44694469
unsigned char sk[32];
44704470
secp256k1_xonly_pubkey pk[N_PUBKEYS];
4471-
int is_positive[N_PUBKEYS];
4471+
int has_square_y[N_PUBKEYS];
44724472
unsigned char tweak[N_PUBKEYS - 1][32];
44734473
int i;
44744474

@@ -4477,12 +4477,12 @@ void test_xonly_pubkey_tweak_recursive(void) {
44774477
/* Add tweaks */
44784478
for (i = 0; i < N_PUBKEYS - 1; i++) {
44794479
memset(tweak[i], i + 1, sizeof(tweak[i]));
4480-
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &pk[i + 1], &is_positive[i + 1], &pk[i], tweak[i]) == 1);
4480+
CHECK(secp256k1_xonly_pubkey_tweak_add(ctx, &pk[i + 1], &has_square_y[i + 1], &pk[i], tweak[i]) == 1);
44814481
}
44824482

44834483
/* Verify tweaks */
44844484
for (i = N_PUBKEYS - 1; i > 0; i--) {
4485-
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &pk[i], is_positive[i], &pk[i - 1], tweak[i - 1]) == 1);
4485+
CHECK(secp256k1_xonly_pubkey_tweak_verify(ctx, &pk[i], has_square_y[i], &pk[i - 1], tweak[i - 1]) == 1);
44864486
}
44874487
}
44884488
#undef N_PUBKEYS

0 commit comments

Comments
 (0)