Skip to content

Commit ce849f9

Browse files
committed
schnorr_adaptor: initialize project
This commit adds the foundational configuration, building scripts, and an initial structure for the project.
1 parent 6152622 commit ce849f9

9 files changed

+125
-0
lines changed

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,18 @@ option(SECP256K1_ENABLE_MODULE_MUSIG "Enable MuSig module." ON)
6969
option(SECP256K1_ENABLE_MODULE_ECDSA_ADAPTOR "Enable ecdsa adaptor signatures module." ON)
7070
option(SECP256K1_ENABLE_MODULE_ECDSA_S2C "Enable ECDSA sign-to-contract module." ON)
7171
option(SECP256K1_ENABLE_MODULE_BPPP "Enable Bulletproofs++ module." ON)
72+
option(SECP256K1_ENABLE_MODULE_SCHNORR_ADAPTOR "Enable schnorr adaptor signatures module." ON)
7273

7374
# Processing must be done in a topological sorting of the dependency graph
7475
# (dependent module first).
76+
if(SECP256K1_ENABLE_MODULE_SCHNORR_ADAPTOR)
77+
if(DEFINED SECP256K1_ENABLE_MODULE_SCHNORRSIG AND NOT SECP256K1_ENABLE_MODULE_SCHNORRSIG)
78+
message(FATAL_ERROR "Module dependency error: You have disabled the schnorrsig module explicitly, but it is required by the schnorr adaptor signatures module.")
79+
endif()
80+
set(SECP256K1_ENABLE_MODULE_SCHNORRSIG ON)
81+
add_compile_definitions(ENABLE_MODULE_SCHNORR_ADAPTOR=1)
82+
endif()
83+
7584
if(SECP256K1_ENABLE_MODULE_BPPP)
7685
if(DEFINED SECP256K1_ENABLE_MODULE_GENERATOR AND NOT SECP256K1_ENABLE_MODULE_GENERATOR)
7786
message(FATAL_ERROR "Module dependency error: You have disabled the generator module explicitly, but it is required by the bppp module.")
@@ -362,6 +371,7 @@ message(" musig ............................... ${SECP256K1_ENABLE_MODULE_MUSIG
362371
message(" ecdsa-s2c ........................... ${SECP256K1_ENABLE_MODULE_ECDSA_S2C}")
363372
message(" ecdsa-adaptor ....................... ${SECP256K1_ENABLE_MODULE_ECDSA_ADAPTOR}")
364373
message(" bppp ................................ ${SECP256K1_ENABLE_MODULE_BPPP}")
374+
message(" schnorr-adaptor ..................... ${SECP256K1_ENABLE_MODULE_SCHNORR_ADAPTOR}")
365375
message("Parameters:")
366376
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
367377
message(" ecmult gen precision bits ........... ${SECP256K1_ECMULT_GEN_PREC_BITS}")

Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,7 @@ endif
320320
if ENABLE_MODULE_ECDSA_ADAPTOR
321321
include src/modules/ecdsa_adaptor/Makefile.am.include
322322
endif
323+
324+
if ENABLE_MODULE_SCHNORR_ADAPTOR
325+
include src/modules/schnorr_adaptor/Makefile.am.include
326+
endif

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Added features:
1212
* Experimental module for Confidential Assets (Pedersen commitments, range proofs, and [surjection proofs](src/modules/surjection/surjection.md)).
1313
* Experimental module for Bulletproofs++ range proofs.
1414
* Experimental module for [address whitelisting](src/modules/whitelist/whitelist.md).
15+
* Experimental module for Schnorr adaptor signatures.
1516

1617
Experimental features are made available for testing and review by the community. The APIs of these features should not be considered stable.
1718

configure.ac

+17
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ AC_ARG_ENABLE(module_schnorrsig_halfagg,
188188
AS_HELP_STRING([--enable-module-schnorrsig-halfagg],[enable schnorrsig half-aggregation module (experimental) [default=no]]), [],
189189
[SECP_SET_DEFAULT([enable_module_schnorrsig_halfagg], [no], [yes])])
190190

191+
AC_ARG_ENABLE(module_schnorr_adaptor,
192+
AS_HELP_STRING([--enable-module-schnorr-adaptor],[enable Schnorr adaptor module [default=no]]), [],
193+
[SECP_SET_DEFAULT([enable_module_schnorr_adaptor], [no], [yes])])
194+
191195
AC_ARG_ENABLE(module_ellswift,
192196
AS_HELP_STRING([--enable-module-ellswift],[enable ElligatorSwift module [default=yes]]), [],
193197
[SECP_SET_DEFAULT([enable_module_ellswift], [yes], [yes])])
@@ -454,6 +458,14 @@ if test x"$enable_module_schnorrsig_halfagg" = x"yes"; then
454458
enable_module_schnorrsig=yes
455459
fi
456460

461+
if test x"$enable_module_schnorr_adaptor" = x"yes"; then
462+
if test x"$enable_module_schnorrsig" = x"no"; then
463+
AC_MSG_ERROR([Module dependency error: You have disabled the schnorrsig module explicitly, but it is required by the schnorr adaptor module.])
464+
fi
465+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SCHNORR_ADAPTOR=1"
466+
enable_module_schnorrsig=yes
467+
fi
468+
457469
if test x"$enable_module_bppp" = x"yes"; then
458470
if test x"$enable_module_generator" = x"no"; then
459471
AC_MSG_ERROR([Module dependency error: You have disabled the generator module explicitly, but it is required by the bppp module.])
@@ -555,6 +567,9 @@ else
555567
if test x"$enable_module_schnorrsig_halfagg" = x"yes"; then
556568
AC_MSG_ERROR([Schnorrsig Half-Aggregation module is experimental. Use --enable-experimental to allow.])
557569
fi
570+
if test x"$enable_module_schnorr_adaptor" = x"yes"; then
571+
AC_MSG_ERROR([Schnorr adaptor signatures module is experimental. Use --enable-experimental to allow.])
572+
fi
558573
if test x"$enable_module_bppp" = x"yes"; then
559574
AC_MSG_ERROR([Bulletproofs++ module is experimental. Use --enable-experimental to allow.])
560575
fi
@@ -611,6 +626,7 @@ AM_CONDITIONAL([ENABLE_MODULE_ECDSA_S2C], [test x"$enable_module_ecdsa_s2c" = x"
611626
AM_CONDITIONAL([ENABLE_MODULE_ECDSA_ADAPTOR], [test x"$enable_module_ecdsa_adaptor" = x"yes"])
612627
AM_CONDITIONAL([ENABLE_MODULE_BPPP], [test x"$enable_module_bppp" = x"yes"])
613628
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG_HALFAGG], [test x"$enable_module_schnorrsig_halfagg" = x"yes"])
629+
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR_ADAPTOR], [test x"$enable_module_schnorr_adaptor" = x"yes"])
614630
AM_CONDITIONAL([USE_REDUCED_SURJECTION_PROOF_SIZE], [test x"$use_reduced_surjection_proof_size" = x"yes"])
615631
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
616632
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm32"])
@@ -651,6 +667,7 @@ echo " module ecdsa-s2c = $enable_module_ecdsa_s2c"
651667
echo " module ecdsa-adaptor = $enable_module_ecdsa_adaptor"
652668
echo " module bppp = $enable_module_bppp"
653669
echo " module schnorrsig-halfagg = $enable_module_schnorrsig_halfagg"
670+
echo " module schnorr-adaptor = $enable_module_schnorr_adaptor"
654671
echo
655672
echo " asm = $set_asm"
656673
echo " ecmult window size = $set_ecmult_window"

include/secp256k1_schnorr_adaptor.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef SECP256K1_SCHNORR_ADAPTOR_H
2+
#define SECP256K1_SCHNORR_ADAPTOR_H
3+
4+
#include "secp256k1.h"
5+
#include "secp256k1_extrakeys.h"
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
/** This module provides an experimental implementation of a Schnorr adaptor
12+
* signature protocol variant.
13+
*
14+
* The test vectors have been generated and cross-verified using a Python
15+
* implementation of this adaptor signature variant available at [0].
16+
*
17+
* The protocol involves two parties, Alice and Bob. The general sequence of
18+
* their interaction is as follows:
19+
* 1. Alice calls the `schnorr_adaptor_presign` function for an adaptor point T
20+
* and sends the pre-signature to Bob.
21+
* 2. Bob extracts the adaptor point T from the pre-signature using
22+
* `schnorr_adaptor_extract`.
23+
* 3. Bob provides the pre-signature and the discrete logarithm of T to
24+
* `schnorr_adaptor_adapt` which outputs a valid BIP 340 Schnorr signature.
25+
* 4. Alice extracts the discrete logarithm of T from the pre-signature and the
26+
* BIP 340 signature using `schnorr_adaptor_extract_sec`.
27+
*
28+
* In contrast to common descriptions of adaptor signature protocols, this
29+
* module does not provide a verification algorithm for pre-signatures.
30+
* Instead, `schnorr_adaptor_extract` returns the adaptor point encoded by a
31+
* pre-signature, reducing communication cost. If a verification function for
32+
* pre-signatures is needed, it can be easily simulated with
33+
* `schnorr_adaptor_extract`.
34+
*
35+
* Assuming that BIP 340 Schnorr signatures satisfy strong unforgeability under
36+
* chosen message attack, the Schnorr adaptor signature scheme fulfills the
37+
* following properties as formalized by [1].
38+
*
39+
* - Witness extractability:
40+
* If Alice
41+
* 1. creates a pre-signature with `schnorr_adaptor_presign` for message m
42+
* and adaptor point T and
43+
* 2. receives a Schnorr signature for message m that she hasn't created
44+
* herself,
45+
* then Alice is able to obtain the discrete logarithm of T with
46+
* `schnorr_adaptor_extract_sec`.
47+
*
48+
* - Pre-signature adaptability:
49+
* If Bob
50+
* 1. receives a pre-signature and extracts an adaptor point T using
51+
* `schnorr_adaptor_extract`, and
52+
* 2. obtains the discrete logarithm of the adaptor point T
53+
* Then then Bob is able to adapt the received pre-signature to a valid BIP
54+
* 340 Schnorr signature using `schnorr_adaptor_adapt`.
55+
*
56+
* - Existential Unforgeability:
57+
* Bob is not able to create a BIP 340 signature from a pre-signature for
58+
* adaptor T without knowing the discrete logarithm of T.
59+
*
60+
* - Pre-signature existiential unforgeability:
61+
* Only Alice can create a pre-signature for her public key.
62+
*
63+
* [0] https://github.com/ZhePang/Python_Specification_for_Schnorr_Adaptor
64+
* [1] https://eprint.iacr.org/2020/476.pdf
65+
*/
66+
67+
#ifdef __cplusplus
68+
}
69+
#endif
70+
71+
#endif /* SECP256K1_SCHNORR_ADAPTOR_H */

src/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ if(SECP256K1_INSTALL)
120120
"${PROJECT_SOURCE_DIR}/include/secp256k1.h"
121121
"${PROJECT_SOURCE_DIR}/include/secp256k1_preallocated.h"
122122
)
123+
if(SECP256K1_ENABLE_MODULE_SCHNORR_ADAPTOR)
124+
list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_schnorr_adaptor.h")
125+
endif()
123126
if(SECP256K1_ENABLE_MODULE_BPPP)
124127
list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_bppp.h")
125128
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include_HEADERS += include/secp256k1_schnorr_adaptor.h
2+
noinst_HEADERS += src/modules/schnorr_adaptor/main_impl.h
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**********************************************************************
2+
* Copyright (c) 2023-2024 Zhe Pang and Sivaram Dhakshinamoorthy *
3+
* Distributed under the MIT software license, see the accompanying *
4+
* file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5+
**********************************************************************/
6+
7+
#ifndef SECP256K1_MODULE_SCHNORR_ADAPTOR_MAIN_H
8+
#define SECP256K1_MODULE_SCHNORR_ADAPTOR_MAIN_H
9+
10+
#include "../../../include/secp256k1.h"
11+
#include "../../../include/secp256k1_schnorr_adaptor.h"
12+
13+
#endif

src/secp256k1.c

+4
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,10 @@ static int secp256k1_ge_parse_ext(secp256k1_ge* ge, const unsigned char *in33) {
877877
# include "modules/schnorrsig_halfagg/main_impl.h"
878878
#endif
879879

880+
#ifdef ENABLE_MODULE_SCHNORR_ADAPTOR
881+
# include "modules/schnorr_adaptor/main_impl.h"
882+
#endif
883+
880884
#ifdef ENABLE_MODULE_ELLSWIFT
881885
# include "modules/ellswift/main_impl.h"
882886
#endif

0 commit comments

Comments
 (0)