From 2ed4936977ea877a38d4864ece3526ae96d66c77 Mon Sep 17 00:00:00 2001 From: Thomas Kerin Date: Thu, 21 Nov 2019 18:49:18 +0000 Subject: [PATCH] port further upstream changes --- secp256k1/php_secp256k1.h | 2 +- secp256k1/secp256k1.c | 14 +++++++------- ...ecp256k1_xonly_pubkey_from_pubkey_basic1.phpt | 8 ++++---- ...ecp256k1_xonly_pubkey_from_pubkey_basic2.phpt | 8 ++++---- ...ecp256k1_xonly_pubkey_from_pubkey_error2.phpt | 4 ++-- ...ecp256k1_xonly_pubkey_from_pubkey_error3.phpt | 2 +- .../secp256k1_xonly_pubkey_tweak_verify.phpt | 6 +++--- ...cp256k1_xonly_pubkey_tweak_verify_error1.phpt | 6 +++--- ...cp256k1_xonly_pubkey_tweak_verify_error2.phpt | 6 +++--- ...cp256k1_xonly_pubkey_tweak_verify_error3.phpt | 6 +++--- ...cp256k1_xonly_pubkey_tweak_verify_error4.phpt | 6 +++--- ...cp256k1_xonly_pubkey_tweak_verify_error5.phpt | 16 ++++++++-------- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/secp256k1/php_secp256k1.h b/secp256k1/php_secp256k1.h index e5974212..578d5b09 100755 --- a/secp256k1/php_secp256k1.h +++ b/secp256k1/php_secp256k1.h @@ -84,7 +84,7 @@ PHP_FUNCTION(secp256k1_xonly_pubkey_from_pubkey); PHP_FUNCTION(secp256k1_xonly_pubkey_to_pubkey); PHP_FUNCTION(secp256k1_xonly_privkey_tweak_add); PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_add); -PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify); +PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_test); /* Recovery module */ #ifdef SECP256K1_MODULE_RECOVERY diff --git a/secp256k1/secp256k1.c b/secp256k1/secp256k1.c index 2cf1ff04..bc2c6e8a 100755 --- a/secp256k1/secp256k1.c +++ b/secp256k1/secp256k1.c @@ -450,9 +450,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_add, I ZEND_END_ARG_INFO(); #if (PHP_VERSION_ID >= 70000 && PHP_VERSION_ID <= 70200) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_verify, IS_LONG, NULL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_test, IS_LONG, NULL, 0) #else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_verify, IS_LONG, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_xonly_pubkey_tweak_test, IS_LONG, 0) #endif ZEND_ARG_TYPE_INFO(0, context, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, outputPubKey, IS_RESOURCE, 0) @@ -659,7 +659,7 @@ const zend_function_entry secp256k1_functions[] = { PHP_FE(secp256k1_xonly_pubkey_from_pubkey, arginfo_secp256k1_xonly_pubkey_from_pubkey) PHP_FE(secp256k1_xonly_privkey_tweak_add, arginfo_secp256k1_xonly_privkey_tweak_add) PHP_FE(secp256k1_xonly_pubkey_tweak_add, arginfo_secp256k1_xonly_pubkey_tweak_add) - PHP_FE(secp256k1_xonly_pubkey_tweak_verify, arginfo_secp256k1_xonly_pubkey_tweak_verify) + PHP_FE(secp256k1_xonly_pubkey_tweak_test, arginfo_secp256k1_xonly_pubkey_tweak_test) // secp256k1_recovery.h #ifdef SECP256K1_MODULE_RECOVERY 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) } /* }}} */ -/* {{{ proto int secp256k1_xonly_pubkey_tweak_verify(resource context, resource output_pubkey, resource internal_pubkey, string tweak32) +/* {{{ proto int secp256k1_xonly_pubkey_tweak_test(resource context, resource output_pubkey, bool hasSquareY, resource internal_pubkey, string tweak32) * Tweak a public key by adding tweak times the generator to it. */ -PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify) +PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_test) { zval *zCtx, *zOutputPubKey, *zInternalPubKey; secp256k1_context *ctx; @@ -2043,11 +2043,11 @@ PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_verify) } if (zTweak32->len != SECRETKEY_LENGTH) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes"); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes"); return; } - result = secp256k1_xonly_pubkey_tweak_verify(ctx, output_pubkey, (int)has_square_y, internal_pubkey, (unsigned char *)zTweak32->val); + result = secp256k1_xonly_pubkey_tweak_test(ctx, output_pubkey, (int)has_square_y, internal_pubkey, (unsigned char *)zTweak32->val); RETURN_LONG(result); } diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic1.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic1.phpt index 60416da5..dc8485e0 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic1.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic1.phpt @@ -14,16 +14,16 @@ $privKey = str_repeat("\x41", 32); $pubkey = null; $xonlyPubKey = null; -$sign = null; +$hasSquareY = null; $pubkey2 = null; $result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey); echo $result . PHP_EOL; echo get_resource_type($pubkey) . PHP_EOL; -$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $pubkey); +$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $pubkey); echo $result . PHP_EOL; -echo "sign: $sign\n"; +echo "hasSquareY: $hasSquareY\n"; $serialized = null; $result = secp256k1_xonly_pubkey_serialize($ctx, $serialized, $xonlyPubKey); @@ -36,6 +36,6 @@ echo bin2hex($serialized) . PHP_EOL; 1 secp256k1_pubkey 1 -sign: 1 +hasSquareY: 0 1 eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619 \ No newline at end of file diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic2.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic2.phpt index aeb71dc5..b1dab5e1 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic2.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_basic2.phpt @@ -14,16 +14,16 @@ $privKey = str_repeat("\x42", 32); $pubkey = null; $xonlyPubKey = null; -$sign = null; +$hasSquareY = null; $pubkey2 = null; $result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey); echo $result . PHP_EOL; echo get_resource_type($pubkey) . PHP_EOL; -$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $pubkey); +$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $pubkey); echo $result . PHP_EOL; -echo "sign: $sign\n"; +echo "hasSquareY: $hasSquareY\n"; $serialized = null; $result = secp256k1_xonly_pubkey_serialize($ctx, $serialized, $xonlyPubKey); @@ -36,6 +36,6 @@ echo bin2hex($serialized) . PHP_EOL; 1 secp256k1_pubkey 1 -sign: 0 +hasSquareY: 1 1 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c \ No newline at end of file diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error2.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error2.phpt index 22f48121..6bcd5781 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error2.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error2.phpt @@ -14,7 +14,7 @@ $privKey = str_repeat("\x41", 32); $pubkey = null; $xonlyPubKey = null; -$sign = null; +$hasSquareY = null; $pubkey2 = null; $result = secp256k1_ec_pubkey_create($ctx, $pubkey, $privKey); echo $result . PHP_EOL; @@ -22,7 +22,7 @@ echo get_resource_type($pubkey) . PHP_EOL; $badCtx = tmpfile(); set_error_handler(function($code, $str) { echo $str . PHP_EOL; }); -$result = secp256k1_xonly_pubkey_from_pubkey($badCtx, $xonlyPubKey, $sign, $pubkey); +$result = secp256k1_xonly_pubkey_from_pubkey($badCtx, $xonlyPubKey, $hasSquareY, $pubkey); echo $result . PHP_EOL; ?> diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error3.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error3.phpt index 3be243af..e86defb2 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error3.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_from_pubkey_error3.phpt @@ -14,7 +14,7 @@ $privKey = str_repeat("\x42", 32); $badPubKey = tmpfile(); set_error_handler(function($code, $str) { echo $str . PHP_EOL; }); -$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $sign, $badPubKey); +$result = secp256k1_xonly_pubkey_from_pubkey($ctx, $xonlyPubKey, $hasSquareY, $badPubKey); echo $result . PHP_EOL; ?> diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify.phpt index 41044018..e65d996a 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify works +secp256k1_xonly_pubkey_tweak_test works --SKIPIF-- diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error1.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error1.phpt index a2dfd846..a3096669 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error1.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error1.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify errors if parameter parsing fails +secp256k1_xonly_pubkey_tweak_test errors if parameter parsing fails --SKIPIF-- --EXPECT-- -secp256k1_xonly_pubkey_tweak_verify() expects exactly 5 parameters, 0 given +secp256k1_xonly_pubkey_tweak_test() expects exactly 5 parameters, 0 given 0 \ No newline at end of file diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error2.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error2.phpt index c51ff7e5..66ff30b3 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error2.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error2.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify errors if context is wrong resource type +secp256k1_xonly_pubkey_tweak_test errors if context is wrong resource type --SKIPIF-- @@ -35,5 +35,5 @@ echo $result.PHP_EOL; 1 secp256k1_xonly_pubkey 1 -secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_context resource +secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_context resource 0 diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error3.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error3.phpt index 680672f8..723adecf 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error3.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error3.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify errors if output_pubkey is wrong type +secp256k1_xonly_pubkey_tweak_test errors if output_pubkey is wrong type --SKIPIF-- @@ -34,5 +34,5 @@ echo $result.PHP_EOL; 1 secp256k1_xonly_pubkey 1 -secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_xonly_pubkey resource +secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_xonly_pubkey resource 0 diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error4.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error4.phpt index c6643113..98fba984 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error4.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error4.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify errors if internal pubkey is wrong type +secp256k1_xonly_pubkey_tweak_test errors if internal pubkey is wrong type --SKIPIF-- @@ -34,5 +34,5 @@ echo $result.PHP_EOL; 1 secp256k1_xonly_pubkey 1 -secp256k1_xonly_pubkey_tweak_verify(): supplied resource is not a valid secp256k1_xonly_pubkey resource +secp256k1_xonly_pubkey_tweak_test(): supplied resource is not a valid secp256k1_xonly_pubkey resource 0 diff --git a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error5.phpt b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error5.phpt index 1d82348c..b2d6aad2 100644 --- a/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error5.phpt +++ b/secp256k1/tests/secp256k1_xonly_pubkey_tweak_verify_error5.phpt @@ -1,5 +1,5 @@ --TEST-- -secp256k1_xonly_pubkey_tweak_verify throws if tweak is not 32 bytes +secp256k1_xonly_pubkey_tweak_test throws if tweak is not 32 bytes --SKIPIF-- getMessage() !== $expecting) { echo "ERROR\n"; @@ -37,7 +37,7 @@ try { } try { - secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak31); + secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak31); } catch (\Exception $e) { if ($e->getMessage() !== $expecting) { echo "ERROR\n"; @@ -46,7 +46,7 @@ try { } try { - secp256k1_xonly_pubkey_tweak_verify($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak33); + secp256k1_xonly_pubkey_tweak_test($ctx, $tweakedPub, $hasSquareY, $pubkey1, $tweak33); } catch (\Exception $e) { if ($e->getMessage() !== $expecting) { echo "ERROR\n"; @@ -58,6 +58,6 @@ try { 1 secp256k1_xonly_pubkey 1 -secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes -secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes -secp256k1_xonly_pubkey_tweak_verify(): Parameter 4 should be 32 bytes \ No newline at end of file +secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes +secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes +secp256k1_xonly_pubkey_tweak_test(): Parameter 5 should be 32 bytes \ No newline at end of file