Skip to content

Commit 4e6f257

Browse files
committed
port further upstream changes
1 parent 785c869 commit 4e6f257

13 files changed

+46
-46
lines changed

secp256k1/php_secp256k1.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ PHP_FUNCTION(secp256k1_xonly_pubkey_from_pubkey);
8484
PHP_FUNCTION(secp256k1_xonly_pubkey_to_pubkey);
8585
PHP_FUNCTION(secp256k1_xonly_privkey_tweak_add);
8686
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_add);
87-
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify);
87+
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_test);
8888

8989
/* Recovery module */
9090
#ifdef SECP256K1_MODULE_RECOVERY

secp256k1/secp256k1.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_add, I
450450
ZEND_END_ARG_INFO();
451451

452452
#if (PHP_VERSION_ID >= 70000 && PHP_VERSION_ID <= 70200)
453-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_verify, IS_LONG, NULL, 0)
453+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_test, IS_LONG, NULL, 0)
454454
#else
455-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_verify, IS_LONG, 0)
455+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_test, IS_LONG, 0)
456456
#endif
457457
ZEND_ARG_TYPE_INFO(0, context, IS_RESOURCE, 0)
458458
ZEND_ARG_TYPE_INFO(0, outputPubKey, IS_RESOURCE, 0)
@@ -659,7 +659,7 @@ const zend_function_entry secp256k1_functions[] = {
659659
PHP_FE(secp256k1_xonly_pubkey_from_pubkey, arginfo_secp256k1_xonly_pubkey_from_pubkey)
660660
PHP_FE(secp256k1_xonly_privkey_tweak_add, arginfo_secp256k1_xonly_privkey_tweak_add)
661661
PHP_FE(secp256k1_xonly_pubkey_tweak_add, arginfo_secp256k1_xonly_pubkey_tweak_add)
662-
PHP_FE(secp256k1_xonly_pubkey_tweak_verify, arginfo_secp256k1_xonly_pubkey_tweak_verify)
662+
PHP_FE(secp256k1_xonly_pubkey_tweak_test, arginfo_secp256k1_xonly_pubkey_tweak_test)
663663
// secp256k1_recovery.h
664664
#ifdef SECP256K1_MODULE_RECOVERY
665665
PHP_FE(secp256k1_ecdsa_recoverable_signature_parse_compact, arginfo_secp256k1_ecdsa_recoverable_signature_parse_compact)
@@ -2019,9 +2019,9 @@ PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_add)
20192019
}
20202020
/* }}} */
20212021

2022-
/* {{{ proto int secp256k1_xonly_pubkey_tweak_verify(resource context, resource output_pubkey, resource internal_pubkey, string tweak32)
2022+
/* {{{ proto int secp256k1_xonly_pubkey_tweak_test(resource context, resource output_pubkey, bool hasSquareY, resource internal_pubkey, string tweak32)
20232023
* Tweak a public key by adding tweak times the generator to it. */
2024-
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify)
2024+
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_test)
20252025
{
20262026
zval *zCtx, *zOutputPubKey, *zInternalPubKey;
20272027
secp256k1_context *ctx;
@@ -2043,11 +2043,11 @@ PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify)
20432043
}
20442044

20452045
if (zTweak32->len != SECRETKEY_LENGTH) {
2046-
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes");
2046+
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes");
20472047
return;
20482048
}
20492049

2050-
result = secp256k1_xonly_pubkey_tweak_verify(ctx, output_pubkey, (int)has_square_y, internal_pubkey, (unsigned char *)zTweak32->val);
2050+
result = secp256k1_xonly_pubkey_tweak_test(ctx, output_pubkey, (int)has_square_y, internal_pubkey, (unsigned char *)zTweak32->val);
20512051

20522052
RETURN_LONG(result);
20532053
}

secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic1.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ $privKey = str_repeat("\x41", 32);
1414

1515
$pubkey = null;
1616
$xonlyPubKey = null;
17-
$sign = null;
17+
$hasSquareY = null;
1818
$pubkey2 = null;
1919
$result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey);
2020
echo $result . PHP_EOL;
2121
echo get_resource_type($pubkey) . PHP_EOL;
2222

23-
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $pubkey);
23+
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $pubkey);
2424
echo $result . PHP_EOL;
2525

26-
echo "sign: $sign\n";
26+
echo "hasSquareY: $hasSquareY\n";
2727

2828
$serialized = null;
2929
$result = secp256k1_xonly_pubkey_serialize($ctx, $serialized, $xonlyPubKey);
@@ -36,6 +36,6 @@ echo bin2hex($serialized) . PHP_EOL;
3636
1
3737
secp256k1_pubkey
3838
1
39-
sign: 1
39+
hasSquareY: 0
4040
1
4141
eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619

secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic2.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ $privKey = str_repeat("\x42", 32);
1414

1515
$pubkey = null;
1616
$xonlyPubKey = null;
17-
$sign = null;
17+
$hasSquareY = null;
1818
$pubkey2 = null;
1919
$result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey);
2020
echo $result . PHP_EOL;
2121
echo get_resource_type($pubkey) . PHP_EOL;
2222

23-
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $pubkey);
23+
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $pubkey);
2424
echo $result . PHP_EOL;
2525

26-
echo "sign: $sign\n";
26+
echo "hasSquareY: $hasSquareY\n";
2727

2828
$serialized = null;
2929
$result = secp256k1_xonly_pubkey_serialize($ctx, $serialized, $xonlyPubKey);
@@ -36,6 +36,6 @@ echo bin2hex($serialized) . PHP_EOL;
3636
1
3737
secp256k1_pubkey
3838
1
39-
sign: 0
39+
hasSquareY: 1
4040
1
4141
24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c

secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error2.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ $privKey = str_repeat("\x41", 32);
1414

1515
$pubkey = null;
1616
$xonlyPubKey = null;
17-
$sign = null;
17+
$hasSquareY = null;
1818
$pubkey2 = null;
1919
$result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey);
2020
echo $result . PHP_EOL;
2121
echo get_resource_type($pubkey) . PHP_EOL;
2222

2323
$badCtx = tmpfile();
2424
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
25-
$result = secp256k1_xonly_pubkey_from_pubkey($badCtx, $xonlyPubKey, $sign, $pubkey);
25+
$result = secp256k1_xonly_pubkey_from_pubkey($badCtx, $xonlyPubKey, $hasSquareY, $pubkey);
2626
echo $result . PHP_EOL;
2727

2828
?>

secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error3.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $privKey = str_repeat("\x42", 32);
1414

1515
$badPubKey = tmpfile();
1616
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
17-
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $badPubKey);
17+
$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $badPubKey);
1818
echo $result . PHP_EOL;
1919

2020
?>

secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify works
2+
secp256k1_xonly_pubkey_tweak_test works
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -25,10 +25,10 @@ $hasSquareY = null;
2525
$result = secp256k1_xonly_pubkey_tweak_add($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
2626
echo $result . PHP_EOL;
2727

28-
$result = secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweakInvalid);
28+
$result = secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweakInvalid);
2929
echo $result.PHP_EOL;
3030

31-
$result = secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
31+
$result = secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
3232
echo $result.PHP_EOL;
3333

3434
?>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify errors if parameter parsing fails
2+
secp256k1_xonly_pubkey_tweak_test errors if parameter parsing fails
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -9,10 +9,10 @@ if (!extension_loaded("secp256k1")) print "skip extension not loaded";
99

1010
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
1111

12-
$result = secp256k1_xonly_pubkey_tweak_verify();
12+
$result = secp256k1_xonly_pubkey_tweak_test();
1313
echo $result . PHP_EOL;
1414

1515
?>
1616
--EXPECT--
17-
secp256k1_xonly_pubkey_tweak_verify() expects exactly 5 parameters, 0 given
17+
secp256k1_xonly_pubkey_tweak_test() expects exactly 5 parameters, 0 given
1818
0

secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error2.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify errors if context is wrong resource type
2+
secp256k1_xonly_pubkey_tweak_test errors if context is wrong resource type
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -27,13 +27,13 @@ echo $result . PHP_EOL;
2727
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
2828

2929
$badCtx = tmpfile();
30-
$result = secp256k1_xonly_pubkey_tweak_verify($badCtx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
30+
$result = secp256k1_xonly_pubkey_tweak_test($badCtx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
3131
echo $result.PHP_EOL;
3232

3333
?>
3434
--EXPECT--
3535
1
3636
secp256k1_xonly_pubkey
3737
1
38-
secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_context resource
38+
secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_context resource
3939
0

secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error3.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify errors if output_pubkey is wrong type
2+
secp256k1_xonly_pubkey_tweak_test errors if output_pubkey is wrong type
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -26,13 +26,13 @@ echo $result . PHP_EOL;
2626

2727
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
2828
$badTweakedPub = tmpfile();
29-
$result = secp256k1_xonly_pubkey_tweak_verify($ctx, $badTweakedPub, $hasSquareY, $pubkey1, $tweak);
29+
$result = secp256k1_xonly_pubkey_tweak_test($ctx, $badTweakedPub, $hasSquareY, $pubkey1, $tweak);
3030
echo $result.PHP_EOL;
3131

3232
?>
3333
--EXPECT--
3434
1
3535
secp256k1_xonly_pubkey
3636
1
37-
secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_xonly_pubkey resource
37+
secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_xonly_pubkey resource
3838
0

secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error4.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify errors if internal pubkey is wrong type
2+
secp256k1_xonly_pubkey_tweak_test errors if internal pubkey is wrong type
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -26,13 +26,13 @@ echo $result . PHP_EOL;
2626

2727
$badInternal = tmpfile();
2828
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
29-
$result = secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $badInternal, $tweak);
29+
$result = secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $badInternal, $tweak);
3030
echo $result.PHP_EOL;
3131

3232
?>
3333
--EXPECT--
3434
1
3535
secp256k1_xonly_pubkey
3636
1
37-
secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_xonly_pubkey resource
37+
secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_xonly_pubkey resource
3838
0

secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error5.phpt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
secp256k1_xonly_pubkey_tweak_verify throws if tweak is not 32 bytes
2+
secp256k1_xonly_pubkey_tweak_test throws if tweak is not 32 bytes
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
@@ -25,10 +25,10 @@ echo get_resource_type($pubkey1) . PHP_EOL;
2525
$hasSquareY = null;
2626
$result = secp256k1_xonly_pubkey_tweak_add($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak);
2727
echo $result . PHP_EOL;
28-
$expecting = "secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes";
28+
$expecting = "secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes";
2929

3030
try {
31-
secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweakEmpty);
31+
secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweakEmpty);
3232
} catch (\Exception $e) {
3333
if ($e->getMessage() !== $expecting) {
3434
echo "ERROR\n";
@@ -37,7 +37,7 @@ try {
3737
}
3838

3939
try {
40-
secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak31);
40+
secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak31);
4141
} catch (\Exception $e) {
4242
if ($e->getMessage() !== $expecting) {
4343
echo "ERROR\n";
@@ -46,7 +46,7 @@ try {
4646
}
4747

4848
try {
49-
secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak33);
49+
secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak33);
5050
} catch (\Exception $e) {
5151
if ($e->getMessage() !== $expecting) {
5252
echo "ERROR\n";
@@ -58,6 +58,6 @@ try {
5858
1
5959
secp256k1_xonly_pubkey
6060
1
61-
secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes
62-
secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes
63-
secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes
61+
secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes
62+
secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes
63+
secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes

stubs/functions.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,21 +342,21 @@ function secp256k1_xonly_privkey_tweak_add($context, string &$seckey, string $tw
342342
/**
343343
* @param resource $context
344344
* @param resource|null $outputPubKey
345-
* @param int|null $isPositive
345+
* @param int|null $hasSquareY
346346
* @param resource $internalPubKey
347347
* @param string $tweak32
348348
* @return int
349349
*/
350-
function secp256k1_xonly_pubkey_tweak_add($context, &$outputPubKey, ?int &$isPositive, $internalPubKey, string $tweak32): int {}
350+
function secp256k1_xonly_pubkey_tweak_add($context, &$outputPubKey, ?int &$hasSquareY, $internalPubKey, string $tweak32): int {}
351351
/**
352352
* @param resource $context
353353
* @param resource $outputPubKey
354-
* @param int $isPositive
354+
* @param int $hasSquareY
355355
* @param resource $internalPubKey
356356
* @param string $tweak32
357357
* @return int
358358
*/
359-
function secp256k1_xonly_pubkey_tweak_verify($context, $outputPubKey, int $isPositive, $internalPubKey, string $tweak32): int {}
359+
function secp256k1_xonly_pubkey_tweak_test($context, $outputPubKey, int $hasSquareY, $internalPubKey, string $tweak32): int {}
360360
/**
361361
* Parse a compact ECDSA signature (64 bytes + recovery id).
362362
*

0 commit comments

Comments
 (0)