├── .codecov.yml ├── LICENCE ├── README.md ├── composer.json ├── secp256k1 ├── .gitignore ├── config.m4 ├── config.w32 ├── lax_der.h ├── php_secp256k1.h ├── secp256k1.c └── tests │ ├── bug1.phpt │ ├── bug2.phpt │ ├── ecdsa_signature_parse_der_lax_basic.phpt │ ├── ecdsa_signature_parse_der_lax_error1.phpt │ ├── ecdsa_signature_parse_der_lax_error2.phpt │ ├── ecdsa_signature_parse_der_lax_error3.phpt │ ├── php_minfo_function_basic.phpt │ ├── secp256k1_context_clone_basic.phpt │ ├── secp256k1_context_clone_error1.phpt │ ├── secp256k1_context_clone_error2.phpt │ ├── secp256k1_context_create_basic.phpt │ ├── secp256k1_context_create_error1.phpt │ ├── secp256k1_context_create_error2.phpt │ ├── secp256k1_context_destroy_basic.phpt │ ├── secp256k1_context_destroy_error1.phpt │ ├── secp256k1_context_destroy_error2.phpt │ ├── secp256k1_context_randomize_basic.phpt │ ├── secp256k1_context_randomize_error1.phpt │ ├── secp256k1_context_randomize_error2.phpt │ ├── secp256k1_context_randomize_error3.phpt │ ├── secp256k1_context_randomize_error4.phpt │ ├── secp256k1_ec_privkey_negate_basic.phpt │ ├── secp256k1_ec_privkey_negate_error1.phpt │ ├── secp256k1_ec_privkey_negate_error2.phpt │ ├── secp256k1_ec_privkey_negate_error3.phpt │ ├── secp256k1_ec_privkey_negate_error4.phpt │ ├── secp256k1_ec_privkey_negate_error5.phpt │ ├── secp256k1_ec_privkey_tweak_add_basic.phpt │ ├── secp256k1_ec_privkey_tweak_add_error1.phpt │ ├── secp256k1_ec_privkey_tweak_add_error2.phpt │ ├── secp256k1_ec_privkey_tweak_add_error3.phpt │ ├── secp256k1_ec_privkey_tweak_add_error4.phpt │ ├── secp256k1_ec_privkey_tweak_mul_basic.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error1.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error2.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error3.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error4.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error5.phpt │ ├── secp256k1_ec_privkey_tweak_mul_error6.phpt │ ├── secp256k1_ec_pubkey_combine_basic.phpt │ ├── secp256k1_ec_pubkey_combine_error1.phpt │ ├── secp256k1_ec_pubkey_combine_error2.phpt │ ├── secp256k1_ec_pubkey_combine_error3.phpt │ ├── secp256k1_ec_pubkey_combine_error4.phpt │ ├── secp256k1_ec_pubkey_create_basic.phpt │ ├── secp256k1_ec_pubkey_create_error1.phpt │ ├── secp256k1_ec_pubkey_create_error2.phpt │ ├── secp256k1_ec_pubkey_create_error3.phpt │ ├── secp256k1_ec_pubkey_create_error4.phpt │ ├── secp256k1_ec_pubkey_encoding_basic.phpt │ ├── secp256k1_ec_pubkey_negate_basic.phpt │ ├── secp256k1_ec_pubkey_negate_error1.phpt │ ├── secp256k1_ec_pubkey_negate_error2.phpt │ ├── secp256k1_ec_pubkey_negate_error3.phpt │ ├── secp256k1_ec_pubkey_parse_error1.phpt │ ├── secp256k1_ec_pubkey_parse_error2.phpt │ ├── secp256k1_ec_pubkey_parse_error3.phpt │ ├── secp256k1_ec_pubkey_serialize_error1.phpt │ ├── secp256k1_ec_pubkey_serialize_error2.phpt │ ├── secp256k1_ec_pubkey_serialize_error3.phpt │ ├── secp256k1_ec_pubkey_tweak_add_basic.phpt │ ├── secp256k1_ec_pubkey_tweak_add_error1.phpt │ ├── secp256k1_ec_pubkey_tweak_add_error2.phpt │ ├── secp256k1_ec_pubkey_tweak_add_error3.phpt │ ├── secp256k1_ec_pubkey_tweak_add_error4.phpt │ ├── secp256k1_ec_pubkey_tweak_mul_basic.phpt │ ├── secp256k1_ec_pubkey_tweak_mul_error1.phpt │ ├── secp256k1_ec_pubkey_tweak_mul_error2.phpt │ ├── secp256k1_ec_pubkey_tweak_mul_error3.phpt │ ├── secp256k1_ec_pubkey_tweak_mul_error4.phpt │ ├── secp256k1_ec_seckey_verify_basic.phpt │ ├── secp256k1_ec_seckey_verify_error1.phpt │ ├── secp256k1_ec_seckey_verify_error2.phpt │ ├── secp256k1_ec_seckey_verify_error3.phpt │ ├── secp256k1_ecdh_basic.phpt │ ├── secp256k1_ecdh_customhash_can_fail.phpt │ ├── secp256k1_ecdh_customhash_equivalent_sha256.phpt │ ├── secp256k1_ecdh_customhash_equivalent_sha256_returntrue.phpt │ ├── secp256k1_ecdh_customhash_example.phpt │ ├── secp256k1_ecdh_customhash_fxn_can_typehint_with_data_int.phpt │ ├── secp256k1_ecdh_customhash_fxn_can_typehint_with_data_object.phpt │ ├── secp256k1_ecdh_customhash_fxn_can_typehint_with_data_string.phpt │ ├── secp256k1_ecdh_customhash_fxn_can_use_vars.phpt │ ├── secp256k1_ecdh_customhash_fxn_must_write_correct_len.phpt │ ├── secp256k1_ecdh_customhash_receives_x_y_and_data.phpt │ ├── secp256k1_ecdh_error1.phpt │ ├── secp256k1_ecdh_error2.phpt │ ├── secp256k1_ecdh_error3.phpt │ ├── secp256k1_ecdh_error4.phpt │ ├── secp256k1_ecdh_error5.phpt │ ├── secp256k1_ecdsa_recover_basic1.phpt │ ├── secp256k1_ecdsa_recover_error1.phpt │ ├── secp256k1_ecdsa_recover_error2.phpt │ ├── secp256k1_ecdsa_recover_error3.phpt │ ├── secp256k1_ecdsa_recover_error4.phpt │ ├── secp256k1_ecdsa_recoverable_signature_convert_basic.phpt │ ├── secp256k1_ecdsa_recoverable_signature_convert_error1.phpt │ ├── secp256k1_ecdsa_recoverable_signature_convert_error2.phpt │ ├── secp256k1_ecdsa_recoverable_signature_convert_error3.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_basic.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_error1.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_error2.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_error3.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_error4.phpt │ ├── secp256k1_ecdsa_recoverable_signature_parse_compact_error5.phpt │ ├── secp256k1_ecdsa_recoverable_signature_serialize_compact_basic.phpt │ ├── secp256k1_ecdsa_recoverable_signature_serialize_compact_error1.phpt │ ├── secp256k1_ecdsa_recoverable_signature_serialize_compact_error2.phpt │ ├── secp256k1_ecdsa_recoverable_signature_serialize_compact_error3.phpt │ ├── secp256k1_ecdsa_sign_custom_nonce_can_return0.phpt │ ├── secp256k1_ecdsa_sign_custom_nonce_can_return_false.phpt │ ├── secp256k1_ecdsa_sign_custom_nonce_can_return_true.phpt │ ├── secp256k1_ecdsa_sign_custom_nonce_error_wrong_size.phpt │ ├── secp256k1_ecdsa_sign_error1.phpt │ ├── secp256k1_ecdsa_sign_error2.phpt │ ├── secp256k1_ecdsa_sign_error3.phpt │ ├── secp256k1_ecdsa_sign_error4.phpt │ ├── secp256k1_ecdsa_sign_error5.phpt │ ├── secp256k1_ecdsa_sign_noncefp_and_data_equal.phpt │ ├── secp256k1_ecdsa_sign_noncefp_equal.phpt │ ├── secp256k1_ecdsa_sign_recoverable_error1.phpt │ ├── secp256k1_ecdsa_sign_recoverable_error2.phpt │ ├── secp256k1_ecdsa_sign_recoverable_error3.phpt │ ├── secp256k1_ecdsa_sign_recoverable_error4.phpt │ ├── secp256k1_ecdsa_sign_verify_basic.phpt │ ├── secp256k1_ecdsa_sign_verify_custom_nonce.phpt │ ├── secp256k1_ecdsa_sign_verify_custom_nonce_and_data.phpt │ ├── secp256k1_ecdsa_sign_verify_recoverable_basic.phpt │ ├── secp256k1_ecdsa_sign_with_noncefp_default.phpt │ ├── secp256k1_ecdsa_sign_with_noncefp_rfc6979.phpt │ ├── secp256k1_ecdsa_signature_encoding_basic.phpt │ ├── secp256k1_ecdsa_signature_lax_encoding_basic.phpt │ ├── secp256k1_ecdsa_signature_normalize_basic.phpt │ ├── secp256k1_ecdsa_signature_normalize_error1.phpt │ ├── secp256k1_ecdsa_signature_normalize_error2.phpt │ ├── secp256k1_ecdsa_signature_normalize_error3.phpt │ ├── secp256k1_ecdsa_signature_parse_compact_basic.phpt │ ├── secp256k1_ecdsa_signature_parse_compact_error1.phpt │ ├── secp256k1_ecdsa_signature_parse_compact_error2.phpt │ ├── secp256k1_ecdsa_signature_parse_compact_error3.phpt │ ├── secp256k1_ecdsa_signature_parse_compact_error4.phpt │ ├── secp256k1_ecdsa_signature_parse_der_error1.phpt │ ├── secp256k1_ecdsa_signature_parse_der_error2.phpt │ ├── secp256k1_ecdsa_signature_parse_der_error3.phpt │ ├── secp256k1_ecdsa_signature_recoverable_error4.phpt │ ├── secp256k1_ecdsa_signature_serialize_compact_basic.phpt │ ├── secp256k1_ecdsa_signature_serialize_compact_error1.phpt │ ├── secp256k1_ecdsa_signature_serialize_compact_error2.phpt │ ├── secp256k1_ecdsa_signature_serialize_compact_error3.phpt │ ├── secp256k1_ecdsa_signature_serialize_compact_error4.phpt │ ├── secp256k1_ecdsa_signature_serialize_der_error1.phpt │ ├── secp256k1_ecdsa_signature_serialize_der_error2.phpt │ ├── secp256k1_ecdsa_signature_serialize_der_error3.phpt │ ├── secp256k1_ecdsa_signature_serialize_der_error4.phpt │ ├── secp256k1_ecdsa_signture_serialize_compact_basic.phpt │ ├── secp256k1_ecdsa_verify_error1.phpt │ ├── secp256k1_ecdsa_verify_error2.phpt │ ├── secp256k1_ecdsa_verify_error3.phpt │ ├── secp256k1_ecdsa_verify_error4.phpt │ ├── secp256k1_ecdsa_verify_error5.phpt │ ├── secp256k1_nonce_function_bipschnorr_error1.phpt │ ├── secp256k1_nonce_function_bipschnorr_error_algo16_wrong_size.phpt │ ├── secp256k1_nonce_function_bipschnorr_error_data_wrong_size.phpt │ ├── secp256k1_nonce_function_bipschnorr_error_data_wrong_type.phpt │ ├── secp256k1_nonce_function_bipschnorr_test.phpt │ ├── secp256k1_nonce_function_default_error1.phpt │ ├── secp256k1_nonce_function_default_error_algo16_wrong_size.phpt │ ├── secp256k1_nonce_function_default_error_data_wrong_size.phpt │ ├── secp256k1_nonce_function_default_error_data_wrong_type.phpt │ ├── secp256k1_nonce_function_default_test.phpt │ ├── secp256k1_nonce_function_rfc6979_error1.phpt │ ├── secp256k1_schnorrsig_parse_basic.phpt │ ├── secp256k1_schnorrsig_parse_error1.phpt │ ├── secp256k1_schnorrsig_parse_error2.phpt │ ├── secp256k1_schnorrsig_parse_error3.phpt │ ├── secp256k1_schnorrsig_serialize_basic.phpt │ ├── secp256k1_schnorrsig_serialize_error1.phpt │ ├── secp256k1_schnorrsig_serialize_error2.phpt │ ├── secp256k1_schnorrsig_serialize_error3.phpt │ ├── secp256k1_schnorrsig_sign_basic.phpt │ ├── secp256k1_schnorrsig_sign_basic2.phpt │ ├── secp256k1_schnorrsig_sign_custom_nonce_and_int_data.phpt │ ├── secp256k1_schnorrsig_sign_custom_nonce_and_stdclass_data.phpt │ ├── secp256k1_schnorrsig_sign_custom_nonce_and_string_data.phpt │ ├── secp256k1_schnorrsig_sign_custom_noncefp.phpt │ ├── secp256k1_schnorrsig_sign_custom_noncefp_and_data_uses_use.phpt │ ├── secp256k1_schnorrsig_sign_error1.phpt │ ├── secp256k1_schnorrsig_sign_error2.phpt │ ├── secp256k1_schnorrsig_sign_error3.phpt │ ├── secp256k1_schnorrsig_sign_error4.phpt │ ├── secp256k1_schnorrsig_sign_error5.phpt │ ├── secp256k1_schnorrsig_sign_with_noncefp_bipschnorr.phpt │ ├── secp256k1_schnorrsig_verify_basic.phpt │ ├── secp256k1_schnorrsig_verify_batch.phpt │ ├── secp256k1_schnorrsig_verify_batch_error1.phpt │ ├── secp256k1_schnorrsig_verify_batch_error2.phpt │ ├── secp256k1_schnorrsig_verify_batch_error3.phpt │ ├── secp256k1_schnorrsig_verify_batch_error4.phpt │ ├── secp256k1_schnorrsig_verify_batch_error5.phpt │ ├── secp256k1_schnorrsig_verify_batch_error6.phpt │ ├── secp256k1_schnorrsig_verify_batch_error7.phpt │ ├── secp256k1_schnorrsig_verify_batch_error8.phpt │ ├── secp256k1_schnorrsig_verify_error1.phpt │ ├── secp256k1_schnorrsig_verify_error2.phpt │ ├── secp256k1_schnorrsig_verify_error3.phpt │ ├── secp256k1_schnorrsig_verify_error4.phpt │ ├── secp256k1_schnorrsig_verify_error5.phpt │ ├── secp256k1_schnorrsig_verify_error6.phpt │ ├── secp256k1_scratch_space_create_basic.phpt │ ├── secp256k1_scratch_space_create_error1.phpt │ ├── secp256k1_scratch_space_create_error2.phpt │ ├── secp256k1_scratch_space_destroy_basic.phpt │ ├── secp256k1_scratch_space_destroy_error1.phpt │ ├── secp256k1_scratch_space_destroy_error2.phpt │ └── secp256k1_scratch_space_destroy_error3.phpt ├── stubs ├── const.php └── functions.php └── travis ├── docker-load-cache.sh ├── docker-save-cache.sh ├── generate_stubs.sh ├── phpqa ├── .gitignore ├── Dockerfile ├── README.md ├── build_container.sh ├── container_command.sh └── scripts │ ├── coverage.sh │ ├── docker-php-ext-configure │ ├── docker-php-ext-enable │ ├── docker-php-ext-install │ ├── docker-php-source │ └── valgrind.sh ├── run_coverage_test.sh ├── run_valgrind_test.sh ├── stubs ├── .gitignore └── config.json ├── validate_examples.sh └── verify_stubs.sh /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - secp256k1/lax_der.h 3 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bitwasp/secp256k1-php", 3 | "description": "PHP Extension with bindings for bitcoin/secp256k1.", 4 | "keywords": ["bitwasp", "bitcoin", "php", "secp256k1", "ecc", "ecdsa", "cryptocurrency", "extension"], 5 | "authors": [ 6 | { 7 | "name": "Ruben de Vries", 8 | "email": "ruben@rubensayshi.com" 9 | }, 10 | { 11 | "name": "Thomas Kerin", 12 | "email": "afk11@users.noreply.github.com" 13 | } 14 | ], 15 | "require": { 16 | "php": "^7.0" 17 | }, 18 | "license": "Unlicense" 19 | } 20 | -------------------------------------------------------------------------------- /secp256k1/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | CMakeLists.txt 3 | *.lo 4 | *.la 5 | .libs 6 | acinclude.m4 7 | aclocal.m4 8 | autom4te.cache 9 | build 10 | config.guess 11 | config.h 12 | config.h.in 13 | config.log 14 | config.nice 15 | config.status 16 | config.sub 17 | configure 18 | configure.in 19 | include 20 | install-sh 21 | libtool 22 | ltmain.sh 23 | Makefile 24 | Makefile.fragments 25 | Makefile.global 26 | Makefile.objects 27 | missing 28 | mkinstalldirs 29 | modules 30 | run-tests.php 31 | tests/*/*.diff 32 | tests/*/*.out 33 | tests/*/*.php 34 | tests/*/*.exp 35 | tests/*/*.log 36 | tests/*/*.sh 37 | -------------------------------------------------------------------------------- /secp256k1/config.w32: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | // vim:ft=javascript 3 | 4 | // If your extension references something external, use ARG_WITH 5 | // ARG_WITH("secp256k1", "for secp256k1 support", "no"); 6 | 7 | // Otherwise, use ARG_ENABLE 8 | // ARG_ENABLE("secp256k1", "enable secp256k1 support", "no"); 9 | 10 | if (PHP_SECP256K1 != "no") { 11 | EXTENSION("secp256k1", "secp256k1.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /secp256k1/tests/bug1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Case where referenced zvals are being modified. Only the provided copy should be modified. 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | key = $key; 18 | } 19 | public function getKey() { 20 | return $this->key; 21 | } 22 | } 23 | 24 | echo $mainKey . PHP_EOL; 25 | $something = new Something($mainKey); 26 | $copyKey = $something->getKey(); 27 | 28 | $result = secp256k1_ec_privkey_tweak_add($context, $copyKey, $secKeyOne); 29 | echo $result . PHP_EOL; 30 | echo $copyKey . PHP_EOL; 31 | echo $mainKey . PHP_EOL; 32 | 33 | ?> 34 | --EXPECT-- 35 | 0123abcd0123abcd0123abcd0123abcd 36 | 1 37 | 0123abcd0123abcd0123abcd0123abce 38 | 0123abcd0123abcd0123abcd0123abcd -------------------------------------------------------------------------------- /secp256k1/tests/bug2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul case where referenced zvals are being modified. Only the provided copy should be modified. 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | key = $key; 19 | } 20 | public function getKey() { 21 | return $this->key; 22 | } 23 | } 24 | 25 | echo unpack("H*", $mainKey)[1] . PHP_EOL; 26 | $something = new Something($mainKey); 27 | $copyKey = $something->getKey(); 28 | 29 | $result = secp256k1_ec_privkey_tweak_mul($context, $copyKey, $secKey8); 30 | echo $result . PHP_EOL; 31 | echo unpack("H*", $copyKey)[1] . PHP_EOL; 32 | echo unpack("H*", $mainKey)[1] . PHP_EOL; 33 | 34 | ?> 35 | --EXPECT-- 36 | 0000000000000000000000000000000000000000000000000000000000000008 37 | 1 38 | 0000000000000000000000000000000000000000000000000000000000000010 39 | 0000000000000000000000000000000000000000000000000000000000000008 -------------------------------------------------------------------------------- /secp256k1/tests/ecdsa_signature_parse_der_lax_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ecdsa_signature_parse_der_lax works like secp256k1_ecdsa_signature_parse_der 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | 1 22 | -------------------------------------------------------------------------------- /secp256k1/tests/ecdsa_signature_parse_der_lax_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ecdsa_signature_parse_der_lax returns null if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 24 | --EXPECT-- 25 | ecdsa_signature_parse_der_lax(): supplied resource is not a valid secp256k1_context resource 26 | 0 27 | -------------------------------------------------------------------------------- /secp256k1/tests/ecdsa_signature_parse_der_lax_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ecdsa_signature_parse_der_lax errors signature is garbage 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/ecdsa_signature_parse_der_lax_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ecdsa_signature_parse_der_lax returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | ecdsa_signature_parse_der_lax() expects exactly 3 parameters, 0 given 18 | 0 19 | -------------------------------------------------------------------------------- /secp256k1/tests/php_minfo_function_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Code coverage for PHP_MINFO_FUNCTION(secp256k1) 3 | --SKIPIF-- 4 | if (!extension_loaded("secp256k1")) print "skip extension not loaded"; 5 | --FILE-- 6 | 15 | --EXPECTF-- 16 | Done -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_clone_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_clone works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_context 17 | secp256k1_context 18 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_clone_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_clone returns false if provided the wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_context_clone(): supplied resource is not a valid secp256k1_context resource 19 | NULL -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_clone_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_clone returns false if missing flags argument 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_context_clone() expects exactly 1 parameter, 0 given 18 | NULL 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_create_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_create works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_context 19 | secp256k1_context 20 | secp256k1_context 21 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_create_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_create returns false if provided invalid flags 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | >1)); 11 | echo gettype($ctx1) . PHP_EOL; 12 | 13 | ?> 14 | --EXPECT-- 15 | NULL 16 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_create_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_create returns false if missing flags argument 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_context_create() expects exactly 1 parameter, 0 given 18 | NULL 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_destroy_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_destroy works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_context 17 | Unknown 18 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_destroy_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_destroy returns false if provided the wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | secp256k1_context_destroy(): supplied resource is not a valid secp256k1_context resource 20 | boolean 21 | false -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_destroy_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_destroy returns false if missing flags argument 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_context_destroy() expects exactly 1 parameter, 0 given 19 | boolean 20 | false 21 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_randomize_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_randomize works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | secp256k1_context 27 | 1 28 | 1 29 | 1 30 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_randomize_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_randomize returns false if provided the wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_context_randomize(): supplied resource is not a valid secp256k1_context resource 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_randomize_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_randomize returns false if missing flags argument 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_context_randomize() expects at least 1 parameter, 0 given 18 | 0 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_randomize_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_randomize throws an exception if not byte32/null 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 17 | } 18 | 19 | ?> 20 | --EXPECT-- 21 | secp256k1_context 22 | secp256k1_context_randomize(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_context_randomize_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_context_randomize throws an exception if not string not 32 bytes 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 17 | } 18 | 19 | ?> 20 | --EXPECT-- 21 | secp256k1_context 22 | secp256k1_context_randomize(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 21 | --EXPECT-- 22 | 1 23 | fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140 24 | 1 25 | 0000000000000000000000000000000000000000000000000000000000000001 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate returns false if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_ec_privkey_negate(): supplied resource is not a valid secp256k1_context resource 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_privkey_negate() expects exactly 2 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate throws exception if privKey is not a string 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 16 | } 17 | 18 | ?> 19 | --EXPECT-- 20 | secp256k1_ec_privkey_negate(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate throws exception if privKey is not 32 bytes 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 16 | } 17 | 18 | ?> 19 | --EXPECT-- 20 | secp256k1_ec_privkey_negate(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_negate_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_negate throws \TypeError if privKey is not a string and strict_types=1 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage()) { 18 | $message = str_replace("int given", "integer given", $e->getMessage()); 19 | } else { 20 | $message = $e->getMessage(); 21 | } 22 | echo $message . PHP_EOL; 23 | } 24 | 25 | ?> 26 | --EXPECT-- 27 | Argument 2 passed to secp256k1_ec_privkey_negate() must be of the type string, integer given -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_add_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_add errors if invalid values are incorrect size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 21 | } 22 | 23 | try { 24 | $result = secp256k1_ec_privkey_tweak_add($context, $chars32, $chars31); 25 | } catch (\Exception $e) { 26 | echo $e->getMessage() . PHP_EOL; 27 | } 28 | 29 | try { 30 | $result = secp256k1_ec_privkey_tweak_add($context, $chars32, $chars32); 31 | echo $result . PHP_EOL; 32 | } catch (\Exception $e) { 33 | echo $e->getMessage() . PHP_EOL; 34 | } 35 | 36 | try { 37 | $result = secp256k1_ec_privkey_tweak_add($context, $chars33, $chars32); 38 | } catch (\Exception $e) { 39 | echo $e->getMessage() . PHP_EOL; 40 | } 41 | 42 | try { 43 | $result = secp256k1_ec_privkey_tweak_add($context, $chars0, $chars32); 44 | } catch (\Exception $e) { 45 | echo $e->getMessage() . PHP_EOL; 46 | } 47 | 48 | ?> 49 | --EXPECT-- 50 | secp256k1_ec_privkey_tweak_add(): Parameter 3 should be 32 bytes 51 | secp256k1_ec_privkey_tweak_add(): Parameter 3 should be 32 bytes 52 | 1 53 | secp256k1_ec_privkey_tweak_add(): Parameter 2 should be 32 bytes 54 | secp256k1_ec_privkey_tweak_add(): Parameter 2 should be 32 bytes 55 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_add_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_add errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_ec_privkey_tweak_add(): supplied resource is not a valid secp256k1_context resource 22 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_add_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_add returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_privkey_tweak_add() expects exactly 3 parameters, 0 given 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_add_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_add returns false if modified parameter is not a string 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 21 | } 22 | 23 | ?> 24 | --EXPECT-- 25 | secp256k1_ec_privkey_tweak_add(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 34 | --EXPECT-- 35 | 1 36 | 0000000000000000000000000000000000000000000000000000000000000004 37 | 1 38 | 0000000000000000000000000000000000000000000000000000000000000008 39 | 1 40 | 0000000000000000000000000000000000000000000000000000000000000010 41 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul errors if invalid values are incorrect size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 21 | } 22 | 23 | try { 24 | $result = secp256k1_ec_privkey_tweak_mul($context, $chars32, $chars31); 25 | } catch (\Exception $e) { 26 | echo $e->getMessage() . PHP_EOL; 27 | } 28 | 29 | try { 30 | $result = secp256k1_ec_privkey_tweak_mul($context, $chars32, $chars32); 31 | echo $result . PHP_EOL; 32 | } catch (\Exception $e) { 33 | echo $e->getMessage() . PHP_EOL; 34 | } 35 | 36 | try { 37 | $result = secp256k1_ec_privkey_tweak_mul($context, $chars33, $chars32); 38 | } catch (\Exception $e) { 39 | echo $e->getMessage() . PHP_EOL; 40 | } 41 | 42 | try { 43 | $result = secp256k1_ec_privkey_tweak_mul($context, $chars0, $chars32); 44 | } catch (\Exception $e) { 45 | echo $e->getMessage() . PHP_EOL; 46 | } 47 | 48 | ?> 49 | --EXPECT-- 50 | secp256k1_ec_privkey_tweak_mul(): Parameter 3 should be 32 bytes 51 | secp256k1_ec_privkey_tweak_mul(): Parameter 3 should be 32 bytes 52 | 1 53 | secp256k1_ec_privkey_tweak_mul(): Parameter 2 should be 32 bytes 54 | secp256k1_ec_privkey_tweak_mul(): Parameter 2 should be 32 bytes 55 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_privkey_tweak_mul(): supplied resource is not a valid secp256k1_context resource 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_privkey_tweak_mul() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul type hints coerce to string if possible, size check 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 19 | } 20 | 21 | ?> 22 | --EXPECT-- 23 | secp256k1_ec_privkey_tweak_mul(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul type error using strict_types and wrong type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage(); 21 | // php7.3 changes integer -> int. convert to int always, test against that 22 | if ($error === "Argument 2 passed to secp256k1_ec_privkey_tweak_mul() must be of the type string, integer given") { 23 | $error = "Argument 2 passed to secp256k1_ec_privkey_tweak_mul() must be of the type string, int given"; 24 | } 25 | echo $error . PHP_EOL; 26 | } 27 | 28 | ?> 29 | --EXPECT-- 30 | TypeError 31 | Argument 2 passed to secp256k1_ec_privkey_tweak_mul() must be of the type string, int given -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_privkey_tweak_mul_error6.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_privkey_tweak_mul no coercion of classes, causes error 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 19 | } 20 | 21 | ?> 22 | --EXPECT-- 23 | TypeError 24 | Argument 2 passed to secp256k1_ec_privkey_tweak_mul() must be of the type string, object given -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_combine_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_combine works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 32 | --EXPECT-- 33 | 1 34 | 03e9a06e539d6bf5cf1ca5c41b59121fa3df07a338322405a312c67b6349a707e9 35 | 1 36 | 03e9a06e539d6bf5cf1ca5c41b59121fa3df07a338322405a312c67b6349a707e9 37 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_combine_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_combine returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_combine() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_combine_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_combine returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | secp256k1_ec_pubkey_combine(): supplied resource is not a valid secp256k1_context resource 20 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_combine_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_combine returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 21 | --EXPECT-- 22 | secp256k1_ec_pubkey_combine(): supplied resource is not a valid secp256k1_pubkey resource 23 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_combine_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_combine returns false if combination operation fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 29 | --EXPECT-- 30 | 1 31 | 1 32 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_create_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_create works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 26 | --EXPECT-- 27 | 1 28 | 1 29 | 03e9a06e539d6bf5cf1ca5c41b59121fa3df07a338322405a312c67b6349a707e9 30 | 1 31 | 04e9a06e539d6bf5cf1ca5c41b59121fa3df07a338322405a312c67b6349a707e94c181c5fe89306493dd5677143a329065606740ee58b873e01642228a09ecf9d 32 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_create_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_create throws an exception if seckey is incorrect size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 22 | } 23 | 24 | try { 25 | $result = secp256k1_ec_pubkey_create($context, $pub, $chars33); 26 | } catch (\Exception $e) { 27 | echo $e->getMessage() . PHP_EOL; 28 | } 29 | 30 | try { 31 | $result = secp256k1_ec_pubkey_create($context, $pub, $chars0); 32 | } catch (\Exception $e) { 33 | echo $e->getMessage() . PHP_EOL; 34 | } 35 | 36 | ?> 37 | --EXPECT-- 38 | secp256k1_ec_pubkey_create(): Parameter 2 should be 32 bytes 39 | secp256k1_ec_pubkey_create(): Parameter 2 should be 32 bytes 40 | secp256k1_ec_pubkey_create(): Parameter 2 should be 32 bytes 41 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_create_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_create returns -1 if seckey isn't valid 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | 0 21 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_create_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_create errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_pubkey_create(): supplied resource is not a valid secp256k1_context resource 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_create_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_create returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_create() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_encoding_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse are consistent 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 23 | 24 | --EXPECT-- 25 | 1 26 | secp256k1_pubkey 27 | 1 28 | 02227cedfab55d1b7642d47a5ac92638ed8822a23c3ddadf88defea45a37f5935e 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_negate_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_negate works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 36 | --EXPECT-- 37 | 02227cedfab55d1b7642d47a5ac92638ed8822a23c3ddadf88defea45a37f5935e 38 | 1 39 | 1 40 | 03227cedfab55d1b7642d47a5ac92638ed8822a23c3ddadf88defea45a37f5935e 41 | 1 42 | 1 43 | 02227cedfab55d1b7642d47a5ac92638ed8822a23c3ddadf88defea45a37f5935e 44 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_negate_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_negate returns 0 if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | 1 27 | secp256k1_ec_pubkey_negate(): supplied resource is not a valid secp256k1_context resource 28 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_negate_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_negate returns 0 if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_pubkey_negate(): supplied resource is not a valid secp256k1_pubkey resource 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_negate_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_negate returns 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_negate() expects exactly 2 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_parse_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_parse errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_pubkey_parse(): supplied resource is not a valid secp256k1_context resource 21 | 0 22 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_parse_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_parse errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_ec_pubkey_parse() expects exactly 3 parameters, 0 given 17 | 0 18 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_parse_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_parse fails if public key is garbage 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | 17 | --EXPECT-- 18 | 0 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_serialize_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_serialize returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_serialize() expects exactly 4 parameters, 0 given 18 | false 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_serialize_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_serialize returns false if provided incorrect context type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | 26 | --EXPECT-- 27 | secp256k1_ec_pubkey_serialize(): supplied resource is not a valid secp256k1_context resource 28 | integer 29 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_serialize_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_serialize returns false if pubkey is incorrect resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | 21 | --EXPECT-- 22 | secp256k1_ec_pubkey_serialize(): supplied resource is not a valid secp256k1_pubkey resource 23 | integer 24 | 0 25 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_add_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_add works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 46 | --EXPECT-- 47 | 1 48 | 1 49 | 1 50 | 1 51 | 1 52 | 02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 53 | 1 54 | 1 55 | 02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 56 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_add_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_add returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_tweak_add() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_add_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_add returns false if pubkey wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 21 | --EXPECT-- 22 | secp256k1_ec_pubkey_tweak_add(): supplied resource is not a valid secp256k1_pubkey resource 23 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_add_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_add returns false if context wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | 1 30 | secp256k1_ec_pubkey_tweak_add(): supplied resource is not a valid secp256k1_context resource 31 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_add_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_add returns false if context wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 26 | } 27 | 28 | ?> 29 | --EXPECT-- 30 | 1 31 | secp256k1_ec_pubkey_tweak_add(): Parameter 3 should be 32 bytes 32 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_mul_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_mul returns false if context wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | 1 30 | secp256k1_ec_pubkey_tweak_mul(): supplied resource is not a valid secp256k1_context resource 31 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_mul_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_mul returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_pubkey_tweak_mul() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_mul_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_mul returns false if pubkey wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 21 | --EXPECT-- 22 | secp256k1_ec_pubkey_tweak_mul(): supplied resource is not a valid secp256k1_pubkey resource 23 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_pubkey_tweak_mul_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_pubkey_tweak_mul errors if tweak is incorrect size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 26 | } 27 | 28 | try { 29 | $result = secp256k1_ec_pubkey_tweak_mul($context, $pubKey, $chars31); 30 | } catch (\Exception $e) { 31 | echo $e->getMessage() . PHP_EOL; 32 | } 33 | 34 | ?> 35 | --EXPECT-- 36 | 1 37 | secp256k1_ec_pubkey_tweak_mul(): Parameter 3 should be 32 bytes 38 | secp256k1_ec_pubkey_tweak_mul(): Parameter 3 should be 32 bytes 39 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_seckey_verify_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_seckey_verify works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 26 | --EXPECT-- 27 | 1 28 | 1 29 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_seckey_verify_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_seckey_verify errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ec_seckey_verify(): supplied resource is not a valid secp256k1_context resource 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_seckey_verify_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_seckey_verify errors if key is wrong size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 17 | } 18 | 19 | ?> 20 | --EXPECT-- 21 | secp256k1_ec_seckey_verify(): Parameter 1 should be 32 bytes 22 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ec_seckey_verify_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ec_seckey_verify errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ec_seckey_verify() expects exactly 2 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 27 | --EXPECT-- 28 | 1 29 | 1 30 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 31 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_can_fail.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - a custom hash function can cause operation to fail 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 44 | --EXPECT-- 45 | 1 46 | return 0 47 | 0 48 | return false 49 | 0 50 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_equivalent_sha256.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - can write equivalent hash fxn to default 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 41 | --EXPECT-- 42 | 1 43 | 1 44 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 45 | 1 46 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 47 | 48 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_equivalent_sha256_returntrue.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - can write equivalent hash fxn to default. callback returns true, not 1. 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 41 | --EXPECT-- 42 | 1 43 | 1 44 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 45 | 1 46 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 47 | 48 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_example.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash functions can be used (not 32 bytes) 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | 1 39 | 1 40 | 774b629c86a6dbbcaa384bbb8a5fd34ca4c96431151a8da482865377dacc86d7638edb0f4761d0abca7853d156c4a46a 41 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_fxn_can_typehint_with_data_int.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function can typehint X / Y as string, and data can be int 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 40 | --EXPECT-- 41 | 1 42 | secret x: 17d1ee664632a741f87da19c82d4fc8352368305062370769cf78779ad6ad250 43 | secret y: 70d091c815ec945c61c282e60be6da41423b00b415d76e44ae58a343d670797b 44 | extra: int(128) 45 | 1 46 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 47 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_fxn_can_typehint_with_data_object.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function can typehint X / Y as string, and data can be stdClass 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 41 | --EXPECT-- 42 | 1 43 | secret x: 17d1ee664632a741f87da19c82d4fc8352368305062370769cf78779ad6ad250 44 | secret y: 70d091c815ec945c61c282e60be6da41423b00b415d76e44ae58a343d670797b 45 | extra: object(stdClass)#2 (0) { 46 | } 47 | 1 48 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 49 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_fxn_can_typehint_with_data_string.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function can typehint X / Y as string, and data can be string 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 40 | --EXPECT-- 41 | 1 42 | secret x: 17d1ee664632a741f87da19c82d4fc8352368305062370769cf78779ad6ad250 43 | secret y: 70d091c815ec945c61c282e60be6da41423b00b415d76e44ae58a343d670797b 44 | extra: string(4) "AAAA" 45 | 1 46 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 47 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_fxn_can_use_vars.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function can use the use keyword 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 39 | --EXPECT-- 40 | 1 41 | 1 42 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 43 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_fxn_must_write_correct_len.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function must write correct number of bytes 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | 1 39 | 0 40 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_customhash_receives_x_y_and_data.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh - custom hash function receives X Y and DATA values 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 40 | --EXPECT-- 41 | 1 42 | secret x: 17d1ee664632a741f87da19c82d4fc8352368305062370769cf78779ad6ad250 43 | secret y: 70d091c815ec945c61c282e60be6da41423b00b415d76e44ae58a343d670797b 44 | extra: string(4) "AAAA" 45 | 1 46 | 238c14f420887f8e9bfa78bc9bdded1975f0bb6384e33b4ebbf7a8c776844aec 47 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_ecdh() expects at least 4 parameters, 0 given 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh errors with 0 key 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | 26 | --EXPECT-- 27 | 1 28 | 0 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh returns false if context is the wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 28 | --EXPECT-- 29 | 1 30 | secp256k1_ecdh(): supplied resource is not a valid secp256k1_context resource 31 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh returns false if public key is the wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 24 | --EXPECT-- 25 | secp256k1_ecdh(): supplied resource is not a valid secp256k1_pubkey resource 26 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdh_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdh errors with overflow key 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | 1 27 | 0 28 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recover_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recover returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_recover() expects exactly 4 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recover_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recover returns false if parameter parsing (context) fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 32 | --EXPECT-- 33 | 1 34 | secp256k1_ecdsa_recover(): supplied resource is not a valid secp256k1_context resource 35 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recover_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recover returns false if parameter parsing (signature) fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 28 | --EXPECT-- 29 | secp256k1_ecdsa_recover(): supplied resource is not a valid secp256k1_ecdsa_recoverable_signature resource 30 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recover_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recover returns false signatures as garbage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 31 | --EXPECT-- 32 | 1 33 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_convert_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_convert works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | secp256k1_ecdsa_signature 24 | /** @var resource $convertedSig */ 25 | $convertedSig = null; 26 | $result = secp256k1_ecdsa_recoverable_signature_convert($context, $convertedSig, $recoverableSignature); 27 | echo $result . PHP_EOL; 28 | 29 | // Create public key from private to verify 30 | /** @var resource $publicKey */ 31 | $publicKey = null; 32 | $result = secp256k1_ec_pubkey_create($context, $publicKey, $privKey); 33 | echo $result . PHP_EOL; 34 | 35 | // Verify the converted signature, should work! 36 | $result = secp256k1_ecdsa_verify($context, $convertedSig, $msg32, $publicKey); 37 | echo $result . PHP_EOL; 38 | 39 | ?> 40 | --EXPECT-- 41 | 1 42 | secp256k1_ecdsa_recoverable_signature 43 | 1 44 | 1 45 | 1 46 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_convert_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_convert returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_ecdsa_recoverable_signature_convert() expects exactly 3 parameters, 0 given 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_convert_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_convert returns false when context is wrong type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | secp256k1_ecdsa_signature 28 | /** @var resource $convertedSig */ 29 | $convertedSig = null; 30 | $result = secp256k1_ecdsa_recoverable_signature_convert($badCtx, $convertedSig, $signature); 31 | echo $result . PHP_EOL; 32 | 33 | ?> 34 | --EXPECT-- 35 | 1 36 | secp256k1_ecdsa_recoverable_signature_convert(): supplied resource is not a valid secp256k1_context resource 37 | 0 38 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_convert_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_convert returns false when context is wrong type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | secp256k1_ecdsa_signature 22 | /** @var resource $convertedSig */ 23 | $convertedSig = null; 24 | $result = secp256k1_ecdsa_recoverable_signature_convert($context, $convertedSig, $signature); 25 | echo $result . PHP_EOL; 26 | ?> 27 | --EXPECT-- 28 | secp256k1_ecdsa_recoverable_signature_convert(): supplied resource is not a valid secp256k1_ecdsa_recoverable_signature resource 29 | 0 30 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 23 | --EXPECT-- 24 | 1 25 | secp256k1_ecdsa_recoverable_signature 26 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact errors if context is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 22 | --EXPECT-- 23 | secp256k1_ecdsa_recoverable_signature_parse_compact(): supplied resource is not a valid secp256k1_context resource 24 | integer 25 | 0 26 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 18 | --EXPECT-- 19 | secp256k1_ecdsa_recoverable_signature_parse_compact() expects exactly 4 parameters, 0 given 20 | integer 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact returns false on bad sig 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 21 | } 22 | ?> 23 | --EXPECT-- 24 | secp256k1_ecdsa_recoverable_signature_parse_compact(): Parameter 3 should be 64 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact returns false on bad recid 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 21 | } 22 | ?> 23 | --EXPECT-- 24 | secp256k1_ecdsa_recoverable_signature_parse_compact(): recid should be between 0-3 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_parse_compact_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_parse_compact returns false on bad sig 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 23 | --EXPECT-- 24 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_serialize_compact_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_serialize_compact works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 27 | --EXPECT-- 28 | 1 29 | 1 30 | fe5fe404f3d8c21e1204a08c38ff3912d43c5a22541d2f1cdc4977cbcad240015a3b6e9040f62cacf016df4fef9412091592e4908e5e3a7bd2a42a4d1be01951 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_serialize_compact_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_serialize_compact returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_recoverable_signature_serialize_compact() expects exactly 4 parameters, 0 given 18 | false -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_serialize_compact_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_serialize_compact returns false when signature is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | secp256k1_ecdsa_recoverable_signature_serialize_compact(): supplied resource is not a valid secp256k1_ecdsa_recoverable_signature resource 27 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_recoverable_signature_serialize_compact_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_recoverable_signature_serialize_compact returns false when context is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | secp256k1_ecdsa_recoverable_signature_serialize_compact(): supplied resource is not a valid secp256k1_context resource 32 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_custom_nonce_can_return0.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign errors if noncefp returns false 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | triggered callback 30 | 0 31 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_custom_nonce_can_return_false.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign errors if noncefp returns false 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | triggered callback 30 | 0 31 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_custom_nonce_can_return_true.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign can return true 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 42 | --EXPECT-- 43 | triggered callback 44 | 1 45 | secp256k1_ecdsa_signature 46 | 1 47 | 3044022024653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c02203f3b6adf058b6954343437c9ad4d3b0b4970ecc5bf93472aa4b0aebe886ecae4 48 | 1 49 | 1 50 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_custom_nonce_error_wrong_size.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign will error if nonce function writes incorrect size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | triggered callback 30 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign errors if provided an invalid resource as a context 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 24 | --EXPECT-- 25 | secp256k1_ecdsa_sign(): supplied resource is not a valid secp256k1_context resource 26 | 0 27 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign errors if msg parameter is not 32 bytes 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 24 | } 25 | 26 | ?> 27 | --EXPECT-- 28 | secp256k1_ecdsa_sign(): Parameter 3 should be 32 bytes 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign errors if key parameter is not 32 bytes 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 24 | } 25 | 26 | ?> 27 | --EXPECT-- 28 | secp256k1_ecdsa_sign(): Parameter 4 should be 32 bytes 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign returns int 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_sign() expects at least 4 parameters, 0 given 18 | 0 19 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign fails when seckey is invalid 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 22 | --EXPECT-- 23 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_noncefp_equal.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign without additional data produces same signatures for secp256k1_nonce_function_default and secp256k1_nonce_function_rfc6979 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 42 | --EXPECT-- 43 | 1 44 | secp256k1_ecdsa_signature 45 | 1 46 | 1 47 | secp256k1_ecdsa_signature 48 | 1 49 | Signatures are equal: 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_recoverable_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign_recoverable errors if provided an invalid resource as a context 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 24 | --EXPECT-- 25 | secp256k1_ecdsa_sign_recoverable(): supplied resource is not a valid secp256k1_context resource 26 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_recoverable_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign_recoverable returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_ecdsa_sign_recoverable() expects exactly 4 parameters, 0 given 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_recoverable_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign_recoverable throws exception is hash is wrong size 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 24 | } 25 | ?> 26 | --EXPECT-- 27 | secp256k1_ecdsa_sign_recoverable(): Parameter 2 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_recoverable_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign_recoverable fails with 0 private key 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 24 | --EXPECT-- 25 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_verify_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign and secp256k1_ecdsa_verify are consistent 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 35 | --EXPECT-- 36 | 1 37 | secp256k1_ecdsa_signature 38 | 1 39 | 30440220132382ca59240c2e14ee7ff61d90fc63276325f4cbe8169fc53ade4a407c2fc802204d86fbe3bde6975dd5a91fdc95ad6544dcdf0dab206f02224ce7e2b151bd82ab 40 | 1 41 | 1 42 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_with_noncefp_default.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign with secp256k1_nonce_function_default matches default 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 40 | --EXPECT-- 41 | 1 42 | secp256k1_ecdsa_signature 43 | 1 44 | 1 45 | secp256k1_ecdsa_signature 46 | 1 47 | Signatures are equal: 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_sign_with_noncefp_rfc6979.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign with secp256k1_nonce_function_rfc6979 matches default 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 40 | --EXPECT-- 41 | 1 42 | secp256k1_ecdsa_signature 43 | 1 44 | 1 45 | secp256k1_ecdsa_signature 46 | 1 47 | Signatures are equal: 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_encoding_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_der and secp256k1_ecdsa_signature_serialize_der are consistent 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 21 | --EXPECT-- 22 | 1 23 | secp256k1_ecdsa_signature 24 | 1 25 | 304402207a8e3bdc7c64f31b119a849e8bb39ddbdc0a64abd4cadcc5cfc15d3ec06354ed02204719389aedb16b2dd13552eed546b24350d6e636ac454ea72afc1ffd0cf421b7 26 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_lax_encoding_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ecdsa_signature_parse_der_lax and secp256k1_ecdsa_signature_serialize_der cooperate 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 26 | --EXPECT-- 27 | 1 28 | secp256k1_ecdsa_signature 29 | 1 30 | 304402207a8e3bdc7c64f31b119a849e8bb39ddbdc0a64abd4cadcc5cfc15d3ec06354ed02204719389aedb16b2dd13552eed546b24350d6e636ac454ea72afc1ffd0cf421b7 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_normalize_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_normalize returns false if missing context argument 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_signature_normalize() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_normalize_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_normalize returns false if provided the wrong type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 27 | --EXPECT-- 28 | 1 29 | secp256k1_ecdsa_signature 30 | secp256k1_ecdsa_signature_normalize(): supplied resource is not a valid secp256k1_context resource 31 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_normalize_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_normalize works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_ecdsa_signature_normalize(): supplied resource is not a valid secp256k1_ecdsa_signature resource 22 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_compact_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_compact works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | 1 20 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_compact_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_compact returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_ecdsa_signature_parse_compact() expects exactly 3 parameters, 0 given 17 | 0 18 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_compact_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_compact returns false if invalid resource type given 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_ecdsa_signature_parse_compact(): supplied resource is not a valid secp256k1_context resource 21 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_compact_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_compact returns false if garbage signature given 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_compact_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_compact returns false if signature is wrong size 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 18 | } 19 | 20 | ?> 21 | --EXPECT-- 22 | secp256k1_ecdsa_signature_parse_compact(): Parameter 3 should be 64 bytes 23 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_der_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_der errors if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_ecdsa_signature_parse_der(): supplied resource is not a valid secp256k1_context resource 22 | 0 23 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_der_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_der returns false if missing required parameters 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_signature_parse_der() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_parse_der_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_parse_der errors signature is garbage 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_recoverable_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_sign_recoverable throws exception is privkey is wrong size 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | getMessage() . PHP_EOL; 25 | } 26 | ?> 27 | --EXPECT-- 28 | secp256k1_ecdsa_sign_recoverable(): Parameter 3 should be 32 bytes 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_compact_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 22 | --EXPECT-- 23 | 1 24 | 1 25 | 7a8e3bdc7c64f31b119a849e8bb39ddbdc0a64abd4cadcc5cfc15d3ec06354ed4719389aedb16b2dd13552eed546b24350d6e636ac454ea72afc1ffd0cf421b7 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_compact_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact returns false if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_signature_serialize_compact() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_compact_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact returns false if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | 1 27 | secp256k1_ecdsa_signature_serialize_compact(): supplied resource is not a valid secp256k1_context resource 28 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_compact_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact returns false if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | 1 27 | secp256k1_ecdsa_signature_serialize_compact(): supplied resource is not a valid secp256k1_context resource 28 | 0 29 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_compact_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact returns false if context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 24 | --EXPECT-- 25 | 1 26 | secp256k1_ecdsa_signature_serialize_compact(): supplied resource is not a valid secp256k1_ecdsa_signature resource 27 | 0 28 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_der_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_der returns false if missing required parameters 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 16 | --EXPECT-- 17 | secp256k1_ecdsa_signature_serialize_der() expects exactly 3 parameters, 0 given 18 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_der_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_der returns false if signature is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | 1 27 | secp256k1_ecdsa_signature 28 | secp256k1_ecdsa_signature_serialize_der(): supplied resource is not a valid secp256k1_context resource 29 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_der_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_der returns false if signature is not a resource 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getMessage() . PHP_EOL; 20 | } 21 | 22 | ?> 23 | --EXPECT-- 24 | Argument 3 passed to secp256k1_ecdsa_signature_serialize_der() must be of the type resource, string given 25 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signature_serialize_der_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_der returns false if signature is not a resource 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_ecdsa_signature_serialize_der(): supplied resource is not a valid secp256k1_ecdsa_signature resource 22 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_signture_serialize_compact_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_signature_serialize_compact works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 23 | --EXPECT-- 24 | 1 25 | 1 26 | 7a8e3bdc7c64f31b119a849e8bb39ddbdc0a64abd4cadcc5cfc15d3ec06354ed4719389aedb16b2dd13552eed546b24350d6e636ac454ea72afc1ffd0cf421b7 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_verify_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_verify errors when context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 31 | --EXPECT-- 32 | 1 33 | 1 34 | secp256k1_ecdsa_verify(): supplied resource is not a valid secp256k1_context resource 35 | 0 36 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_verify_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_verify errors when signature is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 25 | --EXPECT-- 26 | 1 27 | secp256k1_ecdsa_verify(): supplied resource is not a valid secp256k1_ecdsa_signature resource 28 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_verify_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_verify errors when public key is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 28 | --EXPECT-- 29 | 1 30 | secp256k1_ecdsa_verify(): supplied resource is not a valid secp256k1_pubkey resource 31 | 0 32 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_verify_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_verify returns false when parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_ecdsa_verify() expects exactly 4 parameters, 0 given 17 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_ecdsa_verify_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_ecdsa_verify fails when the signature requires normalization 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 31 | --EXPECT-- 32 | 1 33 | secp256k1_ecdsa_signature 34 | 1 35 | 0 36 | 37 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_bipschnorr_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_bipschnorr returns 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 21 | --EXPECT-- 22 | secp256k1_nonce_function_bipschnorr() expects exactly 6 parameters, 0 given 23 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_bipschnorr_error_algo16_wrong_size.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_bipschnorr returns 0 if algo16 is neither NULL, or a 16 byte string 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 23 | --EXPECT-- 24 | 0 25 | 0 26 | 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_bipschnorr_error_data_wrong_size.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_bipschnorr returns 0 if data string length is not 32 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | 0 27 | 0 28 | 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_bipschnorr_error_data_wrong_type.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_bipschnorr returns 0 if data is neither NULL, or a 32 byte string 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | 0 27 | 0 28 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_bipschnorr_test.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_bipschnorr returns a result 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | a9be39328bdf208e8b9e3cfafe7909c9816314193139c93f2d092efa8de68703 32 | 1 33 | c437c1fda591773cba3c9aa3a0676de698bc8abbde9b19ae6ae5163d3815e447 34 | 1 35 | 03da74950c67f923871c0052de77dd137b26943e1d4eacb573590aa82820b0a4 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_default_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_default returns 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_nonce_function_default() expects exactly 6 parameters, 0 given 22 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_default_error_algo16_wrong_size.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_default returns 0 if algo16 is neither NULL, or a 16 byte string 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 22 | --EXPECT-- 23 | 0 24 | 0 25 | 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_default_error_data_wrong_size.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_default returns 0 if data string length is not 32 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 24 | --EXPECT-- 25 | 0 26 | 0 27 | 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_default_error_data_wrong_type.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_default returns 0 if data is neither NULL, or a 32 byte string 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 24 | --EXPECT-- 25 | 0 26 | 0 27 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_default_test.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_default returns a result 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 32 | --EXPECT-- 33 | 1 34 | 16e98a1b0eac623f8f2b8106288510f47aa499f4061788ee67808096b77ad7be 35 | 1 36 | 7b3c36437a157ef1ebb16f33259c8920b4b23c448115f013211669d8b13c6e64 37 | 1 38 | e85cb42a7c3e55985672168de30e534d1ce4e9634378e36299722c78ab893f73 39 | 1 40 | e40f838b9929bd8f4b99102221aa93f56b02ddee9e54709c7dab13e8f3d7ee8c -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_nonce_function_rfc6979_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_nonce_function_rfc6979 returns 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | secp256k1_nonce_function_rfc6979() expects exactly 6 parameters, 0 given 22 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_parse_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_parse works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 20 | --EXPECT-- 21 | 1 22 | secp256k1_schnorrsig 23 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_parse_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_parse errors when context is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 20 | --EXPECT-- 21 | secp256k1_schnorrsig_parse(): supplied resource is not a valid secp256k1_context resource 22 | int(0) -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_parse_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_parse errors when signature is invalid 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage(); 21 | } 22 | ?> 23 | --EXPECT-- 24 | secp256k1_schnorrsig_parse(): Parameter 3 should be 64 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_parse_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_parse errors if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_schnorrsig_parse() expects exactly 3 parameters, 0 given 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_serialize_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_serialize works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | 1 27 | 1 28 | 7a8e3bdc7c64f31b119a849e8bb39ddbdc0a64abd4cadcc5cfc15d3ec06354ed4719389aedb16b2dd13552eed546b24350d6e636ac454ea72afc1ffd0cf421b7 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_serialize_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_serialize errors if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_schnorrsig_serialize() expects exactly 3 parameters, 0 given 19 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_serialize_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_serialize errors if context is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | secp256k1_schnorrsig_serialize(): supplied resource is not a valid secp256k1_context resource 32 | 0 33 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_serialize_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_serialize errors if secp256k1_schnorrsig is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 25 | --EXPECT-- 26 | secp256k1_schnorrsig_serialize(): supplied resource is not a valid secp256k1_schnorrsig resource 27 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | 1 32 | b8edb50a96431b8a15c71f128f1f9bc9dd2e01c75894f757d0ee4aa6a1ca60fc9753f61ce15907f7a1adcac85e3f93cb256c01d040b575b0bf74e8b9661a75fa -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_basic2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works with a different key 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | 1 32 | b2579a4e31562773bf4b3717527013f9e996f0a712b4606321f16e705b9a5e179b6cd094edfcfcb1cd82c1ac46e496423fc51a9a8f4fbcde4f8b9bc8207f6c87 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_custom_nonce_and_int_data.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works a user provided nonce function, with additional integer data 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | triggered callback 39 | int(42) 40 | 1 41 | 1 42 | 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c76badaec2bc699660d7a17f3457c5e4aeef226a5890676675cc25b7ee7a25de2 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_custom_nonce_and_stdclass_data.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works a user provided nonce function, with additional data (stdClass) 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | triggered callback 39 | object(stdClass)#2 (0) { 40 | } 41 | 1 42 | 1 43 | 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c76badaec2bc699660d7a17f3457c5e4aeef226a5890676675cc25b7ee7a25de2 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_custom_nonce_and_string_data.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works a user provided nonce function, with additional string data 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 36 | --EXPECT-- 37 | triggered callback 38 | string(4) "ABCD" 39 | 1 40 | 1 41 | 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c76badaec2bc699660d7a17f3457c5e4aeef226a5890676675cc25b7ee7a25de2 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_custom_noncefp.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works a user provided nonce function, no additional data 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 35 | --EXPECT-- 36 | triggered callback 37 | 1 38 | 1 39 | 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c76badaec2bc699660d7a17f3457c5e4aeef226a5890676675cc25b7ee7a25de2 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_custom_noncefp_and_data_uses_use.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign works a user provided nonce function, with additional string data, and can use 'use' 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | triggered callback 39 | string(4) "ABCD" 40 | string(14) "THIS IS EXTRA!" 41 | 1 42 | 1 43 | 24653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c76badaec2bc699660d7a17f3457c5e4aeef226a5890676675cc25b7ee7a25de2 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign errors if provided an invalid resource as a context 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 31 | --EXPECT-- 32 | 1 33 | secp256k1_schnorrsig_sign(): supplied resource is not a valid secp256k1_context resource 34 | 0 35 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign errors if msg parameter is not 32 bytes 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 25 | } 26 | 27 | ?> 28 | --EXPECT-- 29 | secp256k1_schnorrsig_sign(): Parameter 3 should be 32 bytes 30 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign errors if key parameter is not 32 bytes 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 25 | } 26 | 27 | ?> 28 | --EXPECT-- 29 | secp256k1_schnorrsig_sign(): Parameter 4 should be 32 bytes 30 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_error4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign returns int 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_schnorrsig_sign() expects at least 4 parameters, 0 given 19 | 0 20 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign fails when seckey is invalid 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 23 | --EXPECT-- 24 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_sign_with_noncefp_bipschnorr.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_sign with secp256k1_nonce_function_bipschnorr matches default 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 41 | --EXPECT-- 42 | 1 43 | secp256k1_schnorrsig 44 | 1 45 | 1 46 | secp256k1_schnorrsig 47 | 1 48 | Signatures are equal: 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify works 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | 1 32 | 1 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_batch_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify_batch errors when parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 13 | --EXPECT-- 14 | secp256k1_schnorrsig_verify_batch() expects exactly 6 parameters, 0 given 15 | int(0) -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_batch_error6.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify_batch errors when the signature array has the wrong type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 46 | --EXPECT-- 47 | setup: 48 | 1 49 | 1 50 | 1 51 | 1 52 | tests: 53 | secp256k1_schnorrsig_verify_batch(): supplied resource is not a valid secp256k1_schnorrsig resource 54 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify errors if provided an invalid resource as a context 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 33 | --EXPECT-- 34 | 1 35 | 1 36 | secp256k1_schnorrsig_verify(): supplied resource is not a valid secp256k1_context resource 37 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify errors when msg32 is wrong size 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage() . PHP_EOL; 29 | } 30 | 31 | 32 | ?> 33 | --EXPECT-- 34 | 1 35 | 1 36 | secp256k1_schnorrsig_verify(): Parameter 3 should be 32 bytes -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify returns int 0 if parameter parsing fails 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 17 | --EXPECT-- 18 | secp256k1_schnorrsig_verify() expects exactly 4 parameters, 0 given 19 | 0 20 | -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_error5.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify errors when signature is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 29 | --EXPECT-- 30 | 1 31 | secp256k1_schnorrsig_verify(): supplied resource is not a valid secp256k1_schnorrsig resource 32 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_schnorrsig_verify_error6.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_schnorrsig_verify errors when pubkey is wrong resource type 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 27 | --EXPECT-- 28 | 1 29 | secp256k1_schnorrsig_verify(): supplied resource is not a valid secp256k1_pubkey resource 30 | 0 -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_create_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_create works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_scratch_space -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_create_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_create errors if secp256k1 context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 15 | --EXPECT-- 16 | secp256k1_scratch_space_create(): supplied resource is not a valid secp256k1_context resource 17 | NULL -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_create_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_create errors if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 14 | --EXPECT-- 15 | secp256k1_scratch_space_create() expects exactly 2 parameters, 0 given 16 | NULL -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_destroy_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_destroy works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | secp256k1_scratch_space 20 | bool(true) -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_destroy_error1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_destroy errors if parameter parsing fails 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 14 | --EXPECT-- 15 | secp256k1_scratch_space_destroy() expects exactly 2 parameters, 0 given 16 | bool(false) -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_destroy_error2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_destroy errors if secp256k1 context is wrong resource type 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECT-- 20 | secp256k1_scratch_space_destroy(): supplied resource is not a valid secp256k1_context resource 21 | bool(false) -------------------------------------------------------------------------------- /secp256k1/tests/secp256k1_scratch_space_destroy_error3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | secp256k1_scratch_space_destroy works 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | secp256k1_scratch_space_destroy(): supplied resource is not a valid secp256k1_scratch_space resource 19 | bool(false) -------------------------------------------------------------------------------- /stubs/const.php: -------------------------------------------------------------------------------- 1 | ' 10 | 11 | NEW=$(docker history -q ${PROJECTNAME}:latest | grep -v '' | sha256sum | awk '{print $1}') 12 | OLD=$(cat ${DOCKER_CACHE_DIR}/${PROJECTNAME}.checksum) 13 | 14 | echo "new=${NEW} old=${OLD}" 15 | 16 | if [ "$NEW" != "$OLD" ]; then 17 | echo "saving" 18 | docker save $(docker history -q ${PROJECTNAME}:latest | grep -v '') | gzip > ${DOCKER_CACHE_DIR}/${PROJECTNAME}.gz 19 | echo "$NEW" > ${DOCKER_CACHE_DIR}/${PROJECTNAME}.checksum 20 | else 21 | echo "no change" 22 | fi 23 | 24 | -------------------------------------------------------------------------------- /travis/generate_stubs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _LIVE=$1 4 | [ "${_LIVE}" = "live" ] || _LIVE=false 5 | 6 | cd $(git rev-parse --show-toplevel)/travis/stubs 7 | 8 | if [ ! -d php-extension-stub-generator ]; then 9 | git clone -b mods-secp256k1-stubs https://github.com/afk11/php-extension-stub-generator 10 | fi 11 | 12 | if [ ! -d php-extension-stub-generator/vendor ]; then 13 | cd php-extension-stub-generator 14 | composer install 15 | cd ../ 16 | fi 17 | 18 | if [ "${_LIVE}" = "live" ]; then 19 | _STUBSOUT=$(git rev-parse --show-toplevel)/stubs 20 | else 21 | _STUBSOUT=$(git rev-parse --show-toplevel)/travis/stubs/output 22 | [ -d "${_STUBSOUT}" ] || mkdir output 23 | fi 24 | 25 | php -dextension=secp256k1.so php-extension-stub-generator/bin/docblock-stub-generator dump-files --docBlock=config.json secp256k1 ${_STUBSOUT} <<< $'y' 26 | 27 | -------------------------------------------------------------------------------- /travis/phpqa/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | -------------------------------------------------------------------------------- /travis/phpqa/README.md: -------------------------------------------------------------------------------- 1 | phpqa container 2 | =============== 3 | 4 | This Dockerfile was inspired by the [docker-phpqa](https://github.com/herdphp/docker-phpqa) project, 5 | borrowing their original file so we can make some customizations. Once the project stabilizes we will 6 | review for being able to just pull upstream and work with their images. 7 | 8 | ## Starting a container 9 | 10 | docker build -it secp256k1build . 11 | docker run -it -v /path/to/output:/usr/src/php/lcov_html -v /path/to/secp256k1-php/secp256k1:/usr/src/php/ext/secp256k1 --name s1 secp256k1build 12 | 13 | ## supported versions 14 | 15 | default: secp256k1-v7.1.7 16 | 17 | supported: 18 | * secp256k1-v7.1.7 19 | * secp256k1-v7.2.20 20 | 21 | ## scripts! 22 | 23 | #### ./build_container.sh 24 | 25 | this command builds the container for us 26 | 27 | versions can be chosen using PHPQA_PHP_VERSION in the environment 28 | 29 | support for other php versions is added by updating the build_container.sh with 30 | - php version 31 | - gpg keys 32 | - sha256sum 33 | 34 | #### ./container_command.sh $command 35 | 36 | run $command in the container. 37 | versions can be chosen using PHPQA_PHP_VERSION in the environment -------------------------------------------------------------------------------- /travis/phpqa/build_container.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _PHP=${PHPQA_PHP_VERSION} 4 | 5 | _php="7.1.7" 6 | _sha256="0d42089729be7b2bb0308cbe189c2782f9cb4b07078c8a235495be5874fff729" 7 | _gpg="A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0 528995BFEDFBA7191D46839EF9BA0ADA31CBD89E" 8 | 9 | if [ ${_PHP} = "7.0.33" ]; then 10 | _php=${_PHP} 11 | _sha256="ab8c5be6e32b1f8d032909dedaaaa4bbb1a209e519abb01a52ce3914f9a13d96" 12 | _gpg="1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3" 13 | elif [ ${_PHP} = "7.1.7" ]; then 14 | _php=${_PHP} 15 | _sha256="0d42089729be7b2bb0308cbe189c2782f9cb4b07078c8a235495be5874fff729" 16 | _gpg="A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0 528995BFEDFBA7191D46839EF9BA0ADA31CBD89E" 17 | elif [ ${_PHP} = "7.2.20" ]; then 18 | _php=${_PHP} 19 | _sha256="eff09da83e235c2ba25c85deea1d4f663bd71d50fd51ad11e1acebe26d733494" 20 | _gpg="1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F CBAF69F173A0FEA4B537F470D66C9593118BCCB6" 21 | elif [ ${_PHP} = "7.3.7" ]; then 22 | _php=${_PHP} 23 | _sha256="ba067200ba649956b3a92ec8b71a6ed8ce8a099921212443c1bcf3260a29274c" 24 | _gpg="CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D" 25 | fi 26 | 27 | echo "build php ${_php} ${_sha256}" 28 | docker build --build-arg BUILD_PHP_VERSION=${_php} --build-arg BUILD_PHP_SHA256=${_sha256} --build-arg BUILD_GPG_KEYS="${_gpg}" . -t secp256k1-${_php} -------------------------------------------------------------------------------- /travis/phpqa/container_command.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | _PHPQA_DIR=$(git rev-parse --show-toplevel)/travis/phpqa 3 | _GCOV_DIR=${_PHPQA_DIR}/output 4 | _EXT_DIR=$(git rev-parse --show-toplevel)/secp256k1 5 | _CMD=$1 6 | 7 | sudo rm -rf ${_GCOV_DIR} 8 | 9 | _PHP=${PHPQA_PHP_VERSION} 10 | 11 | _php="7.1.7" 12 | if [ ${_PHP} = "7.1.7" ]; then 13 | _php=${_PHP} 14 | elif [ ${_PHP} = "7.2.20" ]; then 15 | _php=${_PHP} 16 | elif [ ${_PHP} = "7.3.7" ]; then 17 | _php=${_PHP} 18 | elif [ ${_PHP} = "7.0.33" ]; then 19 | _php=${_PHP} 20 | fi 21 | 22 | docker run -it \ 23 | -v ${_GCOV_DIR}:/usr/src/php/lcov_html \ 24 | -v ${_EXT_DIR}:/usr/src/php/ext/secp256k1 \ 25 | --name s1 secp256k1-${_php} ${_CMD} 26 | -------------------------------------------------------------------------------- /travis/phpqa/scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | target=$1 3 | set -x 4 | 5 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" 6 | debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" 7 | 8 | rm configure && ./buildconf --force 9 | 10 | ./configure \ 11 | --build="$gnuArch" \ 12 | --with-config-file-path="$PHP_INI_DIR" \ 13 | --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ 14 | --enable-gcov \ 15 | --with-curl \ 16 | --with-openssl \ 17 | --with-secp256k1 \ 18 | --with-secp256k1-config \ 19 | --with-module-ecdh \ 20 | --with-module-recovery \ 21 | --with-module-schnorrsig \ 22 | --with-libdir="lib/$debMultiarch" \ 23 | $PHP_EXTRA_CONFIGURE_ARGS \ 24 | && make -j "$(nproc)" \ 25 | && make install \ 26 | && php -m \ 27 | && ls -lsh ext/secp256k1 \ 28 | && make lcov TESTS=ext/secp256k1/tests \ 29 | && gcov lcov_data/ext/secp256k1/secp256k1.c -f > coverage.output 30 | 31 | cp -v coverage.output ext/secp256k1/ 32 | cp -v secp256k1.c.gcov ext/secp256k1/ 33 | -------------------------------------------------------------------------------- /travis/phpqa/scripts/docker-php-ext-configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # prefer user supplied CFLAGS, but default to our PHP_CFLAGS 5 | : ${CFLAGS:=$PHP_CFLAGS} 6 | : ${CPPFLAGS:=$PHP_CPPFLAGS} 7 | : ${LDFLAGS:=$PHP_LDFLAGS} 8 | export CFLAGS CPPFLAGS LDFLAGS 9 | 10 | srcExists= 11 | if [ -d /usr/src/php ]; then 12 | srcExists=1 13 | fi 14 | docker-php-source extract 15 | if [ -z "$srcExists" ]; then 16 | touch /usr/src/php/.docker-delete-me 17 | fi 18 | 19 | cd /usr/src/php/ext 20 | 21 | ext="$1" 22 | if [ -z "$ext" ] || [ ! -d "$ext" ]; then 23 | echo >&2 "usage: $0 ext-name [configure flags]" 24 | echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" 25 | echo >&2 26 | echo >&2 'Possible values for ext-name:' 27 | find /usr/src/php/ext \ 28 | -mindepth 2 \ 29 | -maxdepth 2 \ 30 | -type f \ 31 | -name 'config.m4' \ 32 | | xargs -n1 dirname \ 33 | | xargs -n1 basename \ 34 | | sort \ 35 | | xargs 36 | exit 1 37 | fi 38 | shift 39 | 40 | pm='unknown' 41 | if [ -e /lib/apk/db/installed ]; then 42 | pm='apk' 43 | fi 44 | 45 | if [ "$pm" = 'apk' ]; then 46 | if \ 47 | [ -n "$PHPIZE_DEPS" ] \ 48 | && ! apk info --installed .phpize-deps > /dev/null \ 49 | && ! apk info --installed .phpize-deps-configure > /dev/null \ 50 | ; then 51 | apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS 52 | fi 53 | fi 54 | 55 | if command -v dpkg-architecture > /dev/null; then 56 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" 57 | set -- --build="$gnuArch" "$@" 58 | fi 59 | 60 | set -x 61 | cd "$ext" 62 | phpize 63 | ./configure "$@" 64 | -------------------------------------------------------------------------------- /travis/phpqa/scripts/docker-php-source: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | dir=/usr/src/php 5 | 6 | usage() { 7 | echo "usage: $0 COMMAND" 8 | echo 9 | echo "Manage php source tarball lifecycle." 10 | echo 11 | echo "Commands:" 12 | echo " extract extract php source tarball into directory $dir if not already done." 13 | echo " delete delete extracted php source located into $dir if not already done." 14 | echo 15 | } 16 | 17 | case "$1" in 18 | extract) 19 | mkdir -p "$dir" 20 | if [ -f "/usr/src/php-src-master.zip" ]; then 21 | unzip /usr/src/php-src-master.zip -d "/tmp" && mv /tmp/php-src-master/* "$dir" 22 | elif [ -f "/usr/src/php.tar.xz" ]; then 23 | tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1 24 | fi 25 | ;; 26 | 27 | delete) 28 | rm -rf "$dir" 29 | ;; 30 | 31 | *) 32 | usage 33 | exit 1 34 | ;; 35 | esac 36 | -------------------------------------------------------------------------------- /travis/phpqa/scripts/valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | target=$1 3 | set -x 4 | 5 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" 6 | debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" 7 | 8 | rm configure && ./buildconf --force 9 | 10 | ./configure \ 11 | --build="$gnuArch" \ 12 | --with-config-file-path="$PHP_INI_DIR" \ 13 | --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ 14 | --with-curl \ 15 | --with-openssl \ 16 | --with-secp256k1 \ 17 | --with-secp256k1-config \ 18 | --with-module-ecdh \ 19 | --with-module-recovery \ 20 | --with-module-schnorrsig \ 21 | --with-libdir="lib/$debMultiarch" \ 22 | $PHP_EXTRA_CONFIGURE_ARGS \ 23 | && make -j "$(nproc)" \ 24 | && make install \ 25 | && php -m \ 26 | && make test TESTS="ext/secp256k1/tests -m" 27 | -------------------------------------------------------------------------------- /travis/run_coverage_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exitHard=false 4 | if [ "${COVERAGE}" = "true" ]; then 5 | cd $(git rev-parse --show-toplevel)/secp256k1 6 | sudo make clean 7 | cd $(git rev-parse --show-toplevel)/travis/phpqa 8 | ./build_container.sh 9 | ./container_command.sh coverage.sh 10 | if [ "$?" != "0" ]; then 11 | exitHard=true 12 | fi 13 | docker stop s1 > /dev/null; 14 | docker rm s1 > /dev/null; 15 | echo "completed coverage command"; 16 | fi 17 | 18 | if [ "${exitHard}" = "true" ]; then 19 | echo "received error from coverage.sh" 20 | exit 1; 21 | fi 22 | 23 | exit 0; 24 | -------------------------------------------------------------------------------- /travis/run_valgrind_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exitHard=false 4 | if [ "${VALGRIND}" = "true" ]; then 5 | cd $(git rev-parse --show-toplevel)/secp256k1 6 | sudo make clean 7 | cd $(git rev-parse --show-toplevel)/travis/phpqa 8 | ./build_container.sh 9 | ./container_command.sh valgrind.sh 10 | if [ "$?" != "0" ]; then 11 | exitHard=true 12 | fi 13 | docker stop s1 > /dev/null; 14 | docker rm s1 > /dev/null; 15 | echo "completed valgrind command"; 16 | fi 17 | 18 | if [ "${exitHard}" = "true" ]; then 19 | echo "received error from valgrind.sh" 20 | exit 1; 21 | fi 22 | 23 | exit 0; 24 | -------------------------------------------------------------------------------- /travis/stubs/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | php-extension-stub-generator/ -------------------------------------------------------------------------------- /travis/validate_examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "${COVERAGE}" = "true" ]; then 3 | for i in $(git rev-parse --show-toplevel)/examples/*.php; do 4 | php -dextension=secp256k1.so $i > /dev/null 5 | if [ $? -ne 0 ]; then 6 | echo "Error running example code: $i"; 7 | exit -1 8 | fi; 9 | done 10 | echo "examples OK" 11 | fi -------------------------------------------------------------------------------- /travis/verify_stubs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd $(git rev-parse --show-toplevel) 4 | 5 | if [ "${COVERAGE}" = "true" ]; then 6 | travis/generate_stubs.sh 7 | 8 | cmp --silent stubs/const.php travis/stubs/output/const.php 9 | 10 | if [ $? -eq 0 ] 11 | then 12 | echo "const file ok" 13 | else 14 | echo "const file not up to date" 15 | exit -1 16 | fi 17 | 18 | cmp --silent stubs/functions.php travis/stubs/output/functions.php 19 | 20 | if [ $? -eq 0 ] 21 | then 22 | echo "functions file ok" 23 | else 24 | echo "functions file not up to date" 25 | diff stubs/functions.php travis/stubs/output/functions.php 26 | exit -1 27 | fi 28 | fi 29 | --------------------------------------------------------------------------------