From fe6b2c3cfd35a05d2256566b77106a4c4ad08dbf Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 24 Jan 2022 23:07:43 +1100 Subject: [PATCH] Update readme with build details, license clarifications, reorder macros --- README.md | 29 ++++++++++++++++++++--------- bt_secp256k1_i128.h | 7 ++++++- bt_secp256k1_i128_x86_64_asm.h | 7 ++++++- bt_secp256k1_i64.h | 7 ++++++- bt_secp256k1_metaprogram.cpp | 7 ++++++- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5741d88..c6c60bb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# Blockchain Tools - secp256k1 (bt\_secp256k1) +# bt\_secp256k1 (Blockchain Tools - secp256k1) -A code-generated single file header for bitcoin-core/secp256k1, an optimized -C library for ECDSA signatures and secret/public key operations on curve -secp256k1. +A code-generated single file header for +[bitcoin-core/secp256k1](https://github.com/bitcoin-core/secp256k1), an +optimized C library for ECDSA signatures and secret/public key operations on +curve secp256k1. ## Using bt\_secp256k1 @@ -24,8 +25,6 @@ definitive explanations). ```cpp #define BT_SECP256K1_IMPLEMENTATION -// NOTE: The 2 following defines are optional! We provide a default value if -// these are not defined before the implementation #define ECMULT_GEN_PREC_BITS 4 #define ECMULT_WINDOW_SIZE 15 #include "bt_secp256k1_i64.h" @@ -40,17 +39,29 @@ combined into a single header file, generating the output files. The code generated header files vendored in the repository correspond to the current commit hash checked out from the secp256k1 submodule. -The single file header code-generator metaprogram is provided under the -Unlicense license. - An example program `bt_secp256k1_example.c` is provided that implements a basic secp256k1 keypair generator for reference and testing the single header file compilation. +## Build + +The build is currently tested on Windows Visual Studio 2019's `cl` via +`build.bat` which will build the metaprogram and generate the single header +files. + +Examples are built using `build_examples.bat` and optionally invoke `clang-cl` +if it's available on the path. + ## License +The single file header code-generator metaprogram is provided under the +Unlicense license. + This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +bitcoin-core/secp256k1 is provided under its original license and is embedded in +the single-file-header. diff --git a/bt_secp256k1_i128.h b/bt_secp256k1_i128.h index a7c8fc7..b5d4931 100644 --- a/bt_secp256k1_i128.h +++ b/bt_secp256k1_i128.h @@ -59,11 +59,16 @@ THE SOFTWARE. // NOTE: Example // ----------------------------------------------------------------------------- #if 0 -#define BT_SECP256K1_IMPLEMENTATION // NOTE: The 2 following defines are optional! We provide a default value if // these are not defined before the implementation #define ECMULT_GEN_PREC_BITS 4 #define ECMULT_WINDOW_SIZE 15 +// NOTE: The module defines are optional! They expose optional secp256k1 modules API +#define ENABLE_MODULE_ECDH +#define ENABLE_MODULE_RECOVERY +#define ENABLE_MODULE_EXTRAKEYS +#define ENABLE_MODULE_SCHNORRSIG +#define BT_SECP256K1_IMPLEMENTATION #include "bt_secp256k1_i128.h" #include diff --git a/bt_secp256k1_i128_x86_64_asm.h b/bt_secp256k1_i128_x86_64_asm.h index 1911830..27cd69e 100644 --- a/bt_secp256k1_i128_x86_64_asm.h +++ b/bt_secp256k1_i128_x86_64_asm.h @@ -59,11 +59,16 @@ THE SOFTWARE. // NOTE: Example // ----------------------------------------------------------------------------- #if 0 -#define BT_SECP256K1_IMPLEMENTATION // NOTE: The 2 following defines are optional! We provide a default value if // these are not defined before the implementation #define ECMULT_GEN_PREC_BITS 4 #define ECMULT_WINDOW_SIZE 15 +// NOTE: The module defines are optional! They expose optional secp256k1 modules API +#define ENABLE_MODULE_ECDH +#define ENABLE_MODULE_RECOVERY +#define ENABLE_MODULE_EXTRAKEYS +#define ENABLE_MODULE_SCHNORRSIG +#define BT_SECP256K1_IMPLEMENTATION #include "bt_secp256k1_i128_x86_64_asm.h" #include diff --git a/bt_secp256k1_i64.h b/bt_secp256k1_i64.h index 8e72cf7..febef84 100644 --- a/bt_secp256k1_i64.h +++ b/bt_secp256k1_i64.h @@ -59,11 +59,16 @@ THE SOFTWARE. // NOTE: Example // ----------------------------------------------------------------------------- #if 0 -#define BT_SECP256K1_IMPLEMENTATION // NOTE: The 2 following defines are optional! We provide a default value if // these are not defined before the implementation #define ECMULT_GEN_PREC_BITS 4 #define ECMULT_WINDOW_SIZE 15 +// NOTE: The module defines are optional! They expose optional secp256k1 modules API +#define ENABLE_MODULE_ECDH +#define ENABLE_MODULE_RECOVERY +#define ENABLE_MODULE_EXTRAKEYS +#define ENABLE_MODULE_SCHNORRSIG +#define BT_SECP256K1_IMPLEMENTATION #include "bt_secp256k1_i64.h" #include diff --git a/bt_secp256k1_metaprogram.cpp b/bt_secp256k1_metaprogram.cpp index f8fd59c..37979f6 100644 --- a/bt_secp256k1_metaprogram.cpp +++ b/bt_secp256k1_metaprogram.cpp @@ -465,11 +465,16 @@ int main(int argc, char *argv[]) "// NOTE: Example\n" "// -----------------------------------------------------------------------------\n" "#if 0\n" - "#define BT_SECP256K1_IMPLEMENTATION\n" "// NOTE: The 2 following defines are optional! We provide a default value if\n" "// these are not defined before the implementation\n" "#define ECMULT_GEN_PREC_BITS 4\n" "#define ECMULT_WINDOW_SIZE 15\n" + "// NOTE: The module defines are optional! They expose optional secp256k1 modules API\n" + "#define ENABLE_MODULE_ECDH\n" + "#define ENABLE_MODULE_RECOVERY\n" + "#define ENABLE_MODULE_EXTRAKEYS\n" + "#define ENABLE_MODULE_SCHNORRSIG\n" + "#define BT_SECP256K1_IMPLEMENTATION\n" "#include \"" ));