Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schnorrsig revised #165

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revised schnorrsig implementation following upstream changes
  • Loading branch information
afk11 committed Jun 16, 2021
commit 13afa387fb42673f763331c4a9daea2994decc5a
17 changes: 16 additions & 1 deletion secp256k1/config.m4
Original file line number Diff line number Diff line change
@@ -29,6 +29,12 @@ PHP_ARG_WITH([module-schnorrsig],
[Include schnorrsig support])],
[no],
[no])
PHP_ARG_WITH([module-extrakeys],
[whether to build secp256k1 with extrakeys support],
[AS_HELP_STRING([--with-module-extrakeys],
[Include extrakeys support])],
[no],
[no])

if test "$PHP_SECP256K1" != "no"; then
dnl Write more examples of tests here...
@@ -91,12 +97,21 @@ if test "$PHP_SECP256K1" != "no"; then
])
fi

if test "$PHP_MODULE_EXTRAKEYS" = "yes"; then
PHP_CHECK_LIBRARY($LIBNAME,secp256k1_xonly_pubkey_parse,
[
AC_DEFINE(SECP256K1_MODULE_EXTRAKEYS, 1, [ ])
],[
AC_MSG_ERROR([missing libraries for secp256k1 extrakeys support])
],[])
fi

if test "$PHP_MODULE_SCHNORRSIG" = "yes"; then
PHP_CHECK_LIBRARY($LIBNAME,secp256k1_schnorrsig_verify,
[
AC_DEFINE(SECP256K1_MODULE_SCHNORRSIG, 1, [ ])
],[
AC_MSG_ERROR([missing libraries for secp256k1 recovery support])
AC_MSG_ERROR([missing libraries for secp256k1 schnorrsig support])
],[])
fi
else
28 changes: 23 additions & 5 deletions secp256k1/php_secp256k1.h
Original file line number Diff line number Diff line change
@@ -24,8 +24,13 @@ extern zend_module_entry secp256k1_module_entry;
#ifdef SECP256K1_MODULE_RECOVERY
#define SECP256K1_RECOVERABLE_SIG_RES_NAME "secp256k1_ecdsa_recoverable_signature"
#endif

#ifdef SECP256K1_MODULE_EXTRAKEYS
#define SECP256K1_XONLY_PUBKEY_RES_NAME "secp256k1_xonly_pubkey"
#define SECP256K1_KEYPAIR_RES_NAME "secp256k1_keypair"
#endif

#ifdef SECP256K1_MODULE_SCHNORRSIG
#define SECP256K1_SCHNORRSIG_RES_NAME "secp256k1_schnorrsig"
#endif

#ifdef ZTS
@@ -35,6 +40,7 @@ extern zend_module_entry secp256k1_module_entry;
#endif

#define MAX_SIGNATURE_LENGTH 72
#define SCHNORRSIG_LENGTH 64
#define COMPACT_SIGNATURE_LENGTH 64
#define PUBKEY_COMPRESSED_LENGTH 33
#define PUBKEY_UNCOMPRESSED_LENGTH 65
@@ -90,14 +96,26 @@ PHP_FUNCTION(secp256k1_ecdsa_recoverable_signature_parse_compact);
PHP_FUNCTION(secp256k1_ecdh);
#endif /* end of ecdh module */


/* extrakeys module */
#ifdef SECP256K1_MODULE_EXTRAKEYS
PHP_FUNCTION(secp256k1_xonly_pubkey_parse);
PHP_FUNCTION(secp256k1_xonly_pubkey_serialize);
PHP_FUNCTION(secp256k1_xonly_pubkey_from_pubkey);
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_add);
PHP_FUNCTION(secp256k1_xonly_pubkey_tweak_add_check);
PHP_FUNCTION(secp256k1_keypair_create);
PHP_FUNCTION(secp256k1_keypair_sec);
PHP_FUNCTION(secp256k1_keypair_pub);
PHP_FUNCTION(secp256k1_keypair_xonly_pub);
PHP_FUNCTION(secp256k1_keypair_xonly_tweak_add);
#endif /* end of schnorrsig module */

/* schnorr module */
#ifdef SECP256K1_MODULE_SCHNORRSIG
PHP_FUNCTION(secp256k1_schnorrsig_serialize);
PHP_FUNCTION(secp256k1_schnorrsig_parse);
PHP_FUNCTION(secp256k1_schnorrsig_sign);
PHP_FUNCTION(secp256k1_schnorrsig_verify);
PHP_FUNCTION(secp256k1_schnorrsig_verify_batch);
PHP_FUNCTION(secp256k1_nonce_function_bipschnorr);
PHP_FUNCTION(secp256k1_nonce_function_bip340);
#endif /* end of schnorrsig module */

#endif /* PHP_SECP256K1_H */
Loading