Skip to content

Commit ff061fd

Browse files
committed
Squashed 'src/secp256k1/' changes from 705ce7e..c545fdc
c545fdc Merge bitcoin-core/secp256k1#1298: Remove randomness tests b40e2d3 Merge bitcoin-core/secp256k1#1378: ellswift: fix probabilistic test failure when swapping sides c424e2f ellswift: fix probabilistic test failure when swapping sides 907a672 Merge bitcoin-core/secp256k1#1313: ci: Test on development snapshots of GCC and Clang 0f7657d Merge bitcoin-core/secp256k1#1366: field: Use `restrict` consistently in fe_sqrt cc55757 Merge bitcoin-core/secp256k1#1340: clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3) 600c5ad clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3) 981e5be ci: Fix typo in comment e9e9648 ci: Reduce number of macOS tasks from 28 to 8 609093b ci: Add x86_64 Linux tasks for gcc and clang snapshots 1deecaa ci: Install development snapshots of gcc and clang b79ba8a field: Use `restrict` consistently in fe_sqrt c9ebca9 Merge bitcoin-core/secp256k1#1363: doc: minor ellswift.md updates afd7eb4 Merge bitcoin-core/secp256k1#1371: Add exhaustive tests for ellswift (with create+decode roundtrip) 2792119 Add exhaustive test for ellswift (create+decode roundtrip) c7d900f doc: minor ellswift.md updates 332af31 Merge bitcoin-core/secp256k1#1344: group: save normalize_weak calls in `secp256k1_ge_is_valid_var`/`secp256k1_gej_eq_x_var` 9e6d1b0 Merge bitcoin-core/secp256k1#1367: build: Improvements to symbol visibility logic on Windows (attempt 3) 0aacf64 Merge bitcoin-core/secp256k1#1370: Corrected some typos b6b9834 small fixes 07c0e8b group: remove unneeded normalize_weak in `secp256k1_gej_eq_x_var` 3fc1de5 Merge bitcoin-core/secp256k1#1364: Avoid `-Wmaybe-uninitialized` when compiling with `gcc -O1` fb758fe Merge bitcoin-core/secp256k1#1323: tweak_add: fix API doc for tweak=0 c6cd2b1 ci: Add task for static library on Windows + CMake 020bf69 build: Add extensive docs on visibility issues 0196e8a build: Introduce `SECP256k1_DLL_EXPORT` macro 9f1b190 refactor: Replace `SECP256K1_API_VAR` with `SECP256K1_API` ae9db95 build: Introduce `SECP256K1_STATIC` macro for Windows users 7966aee Merge bitcoin-core/secp256k1#1369: ci: Print commit in Windows container a7bec34 ci: Print commit in Windows container 249c81e Merge bitcoin-core/secp256k1#1368: ci: Drop manual checkout of merge commit 98579e2 ci: Drop manual checkout of merge commit 5b9f37f ci: Add `CFLAGS: -O1` to task matrix a6ca76c Avoid `-Wmaybe-uninitialized` when compiling with `gcc -O1` 0fa84f8 Merge bitcoin-core/secp256k1#1358: tests: introduce helper for non-zero `random_fe_test()` results 5a95a26 tests: introduce helper for non-zero `random_fe_test` results 304421d tests: refactor: remove duplicate function `random_field_element_test` 3aef6ab Merge bitcoin-core/secp256k1#1345: field: Static-assert that int args affecting magnitude are constant 4494a36 Merge bitcoin-core/secp256k1#1357: tests: refactor: take use of `secp256k1_ge_x_on_curve_var` 799f4ee Merge bitcoin-core/secp256k1#1356: ci: Adjust Docker image to Debian 12 "bookworm" c862a9f ci: Adjust Docker image to Debian 12 "bookworm" a178209 ci: Force DWARF v4 for Clang when Valgrind tests are expected 7d8d5c8 tests: refactor: take use of `secp256k1_ge_x_on_curve_var` 8a72734 Help the compiler prove that a loop is entered fd491ea Merge bitcoin-core/secp256k1#1355: Fix a typo in the error message ac43613 Merge bitcoin-core/secp256k1#1354: Add ellswift to CHANGELOG 67887ae Fix a typo in the error message 926dd3e Merge bitcoin-core/secp256k1#1295: abi: Use dllexport for mingw builds 1083683 Merge bitcoin-core/secp256k1#1336: Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC 7c7467a Refer to ellswift.md in API docs c32ffd8 Add ellswift to CHANGELOG 3c1a0fd Merge bitcoin-core/secp256k1#1347: field: Document return value of fe_sqrt() 5779137 field: Document return value of fe_sqrt() be8ff3a field: Static-assert that int args affecting magnitude are constant efa76c4 group: remove unneeded normalize_weak in `secp256k1_ge_is_valid_var` 5b7bf2e Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC 05873bb tweak_add: fix API doc for tweak=0 6ec3731 Simplify test PRNG implementation fb5bfa4 Add static test vector for Xoshiro256++ 723e8ca Remove randomness tests bc7c8db abi: Use dllexport for mingw builds git-subtree-dir: src/secp256k1 git-subtree-split: c545fdc
1 parent 901336e commit ff061fd

36 files changed

+373
-331
lines changed

.cirrus.yml

+25-29
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ cat_logs_snippet: &CAT_LOGS
5454
cat_ci_env_script:
5555
- env
5656

57-
merge_base_script_snippet: &MERGE_BASE
58-
merge_base_script:
59-
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
60-
- git fetch --depth=1 $CIRRUS_REPO_CLONE_URL "pull/${CIRRUS_PR}/merge"
61-
- git checkout FETCH_HEAD # Use merged changes to detect silent merge conflicts
62-
6357
linux_container_snippet: &LINUX_CONTAINER
6458
container:
6559
dockerfile: ci/linux-debian.Dockerfile
@@ -68,12 +62,12 @@ linux_container_snippet: &LINUX_CONTAINER
6862
# Gives us more CPUs for free if they're available.
6963
greedy: true
7064
# More than enough for our scripts.
71-
memory: 1G
65+
memory: 2G
7266

7367
task:
7468
name: "x86_64: Linux (Debian stable)"
7569
<< : *LINUX_CONTAINER
76-
matrix: &ENV_MATRIX
70+
matrix:
7771
- env: {WIDEMUL: int64, RECOVERY: yes}
7872
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7973
- env: {WIDEMUL: int128}
@@ -86,14 +80,18 @@ task:
8680
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETESTS: no, BENCH: no}
8781
- env: {CPPFLAGS: -DDETERMINISTIC}
8882
- env: {CFLAGS: -O0, CTIMETESTS: no}
83+
- env: {CFLAGS: -O1, RECOVERY: yes, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
8984
- env: { ECMULTGENPRECISION: 2, ECMULTWINDOW: 2 }
9085
- env: { ECMULTGENPRECISION: 8, ECMULTWINDOW: 4 }
9186
matrix:
9287
- env:
9388
CC: gcc
9489
- env:
9590
CC: clang
96-
<< : *MERGE_BASE
91+
- env:
92+
CC: gcc-snapshot
93+
- env:
94+
CC: clang-snapshot
9795
test_script:
9896
- ./ci/cirrus.sh
9997
<< : *CAT_LOGS
@@ -111,7 +109,6 @@ task:
111109
CC: i686-linux-gnu-gcc
112110
- env:
113111
CC: clang --target=i686-pc-linux-gnu -isystem /usr/i686-linux-gnu/include
114-
<< : *MERGE_BASE
115112
test_script:
116113
- ./ci/cirrus.sh
117114
<< : *CAT_LOGS
@@ -125,20 +122,22 @@ task:
125122
HOMEBREW_NO_INSTALL_CLEANUP: 1
126123
# Cirrus gives us a fixed number of 4 virtual CPUs. Not that we even have that many jobs at the moment...
127124
MAKEFLAGS: -j5
128-
matrix:
129-
<< : *ENV_MATRIX
130125
env:
131126
ASM: no
132127
WITH_VALGRIND: no
133128
CTIMETESTS: no
129+
CC: clang
134130
matrix:
135-
- env:
136-
CC: gcc
137-
- env:
138-
CC: clang
131+
- env: {WIDEMUL: int64, RECOVERY: yes, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
132+
- env: {WIDEMUL: int64, RECOVERY: yes, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes, CC: gcc}
133+
- env: {WIDEMUL: int128_struct, ECMULTGENPRECISION: 2, ECMULTWINDOW: 4}
134+
- env: {WIDEMUL: int128, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
135+
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes}
136+
- env: {WIDEMUL: int128, RECOVERY: yes, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes, CC: gcc}
137+
- env: {WIDEMUL: int128, RECOVERY: yes, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes, CPPFLAGS: -DVERIFY}
138+
- env: {BUILD: distcheck}
139139
brew_script:
140140
- brew install automake libtool gcc
141-
<< : *MERGE_BASE
142141
test_script:
143142
- ./ci/cirrus.sh
144143
<< : *CAT_LOGS
@@ -157,7 +156,6 @@ task:
157156
SCHNORRSIG: yes
158157
ELLSWIFT: yes
159158
CTIMETESTS: no
160-
<< : *MERGE_BASE
161159
test_script:
162160
# https://sourceware.org/bugzilla/show_bug.cgi?id=27008
163161
- rm /etc/ld.so.cache
@@ -180,7 +178,6 @@ task:
180178
matrix:
181179
- env: {}
182180
- env: {EXPERIMENTAL: yes, ASM: arm32}
183-
<< : *MERGE_BASE
184181
test_script:
185182
- ./ci/cirrus.sh
186183
<< : *CAT_LOGS
@@ -198,7 +195,6 @@ task:
198195
SCHNORRSIG: yes
199196
ELLSWIFT: yes
200197
CTIMETESTS: no
201-
<< : *MERGE_BASE
202198
test_script:
203199
- ./ci/cirrus.sh
204200
<< : *CAT_LOGS
@@ -216,7 +212,6 @@ task:
216212
SCHNORRSIG: yes
217213
ELLSWIFT: yes
218214
CTIMETESTS: no
219-
<< : *MERGE_BASE
220215
test_script:
221216
- ./ci/cirrus.sh
222217
<< : *CAT_LOGS
@@ -237,7 +232,6 @@ task:
237232
- name: "i686 (mingw32-w64): Windows (Debian stable, Wine)"
238233
env:
239234
HOST: i686-w64-mingw32
240-
<< : *MERGE_BASE
241235
test_script:
242236
- ./ci/cirrus.sh
243237
<< : *CAT_LOGS
@@ -280,7 +274,6 @@ task:
280274
CC: /opt/msvc/bin/x86/cl
281275
AR: /opt/msvc/bin/x86/lib
282276
NM: /opt/msvc/bin/x86/dumpbin -symbols -headers
283-
<< : *MERGE_BASE
284277
test_script:
285278
- ./ci/cirrus.sh
286279
<< : *CAT_LOGS
@@ -325,7 +318,6 @@ task:
325318
- env:
326319
HOST: i686-linux-gnu
327320
CC: i686-linux-gnu-gcc
328-
<< : *MERGE_BASE
329321
test_script:
330322
- ./ci/cirrus.sh
331323
<< : *CAT_LOGS
@@ -352,7 +344,6 @@ task:
352344
ECMULTGENPRECISION: 2
353345
ECMULTWINDOW: 2
354346
CFLAGS: "-fsanitize=memory -g -O3"
355-
<< : *MERGE_BASE
356347
test_script:
357348
- ./ci/cirrus.sh
358349
<< : *CAT_LOGS
@@ -369,7 +360,6 @@ task:
369360
RECOVERY: yes
370361
SCHNORRSIG: yes
371362
ELLSWIFT: yes
372-
<< : *MERGE_BASE
373363
test_script:
374364
- ./ci/cirrus.sh
375365
<< : *CAT_LOGS
@@ -401,11 +391,17 @@ task:
401391
# Ignore MSBuild warning MSB8029.
402392
# See: https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb8029?view=vs-2022
403393
IgnoreWarnIntDirInTempDetected: 'true'
404-
merge_script:
405-
- PowerShell -NoLogo -Command if ($env:CIRRUS_PR -ne $null) { git fetch $env:CIRRUS_REPO_CLONE_URL pull/$env:CIRRUS_PR/merge; git reset --hard FETCH_HEAD; }
394+
matrix:
395+
- env:
396+
BUILD_SHARED_LIBS: ON
397+
- env:
398+
BUILD_SHARED_LIBS: OFF
399+
git_show_script:
400+
# Print commit to allow reproducing the job outside of CI.
401+
- git show --no-patch
406402
configure_script:
407403
- '%x64_NATIVE_TOOLS%'
408-
- cmake -E env CFLAGS="/WX" cmake -G "Visual Studio 17 2022" -A x64 -S . -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_BUILD_EXAMPLES=ON
404+
- cmake -E env CFLAGS="/WX" cmake -A x64 -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_BUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
409405
build_script:
410406
- '%x64_NATIVE_TOOLS%'
411407
- cmake --build build --config RelWithDebInfo -- -property:UseMultiToolTask=true;CL_MPcount=5

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
#### Added
11+
- New module `ellswift` implements ElligatorSwift encoding for public keys and x-only Diffie-Hellman key exchange for them.
12+
ElligatorSwift permits representing secp256k1 public keys as 64-byte arrays which cannot be distinguished from uniformly random. See:
13+
- Header file `include/secp256k1_ellswift.h` which defines the new API.
14+
- Document `doc/ellswift.md` which explains the mathematical background of the scheme.
15+
- The [paper](https://eprint.iacr.org/2022/759) on which the scheme is based.
16+
17+
#### Changed
18+
- When consuming libsecp256k1 as a static library on Windows, the user must now define the `SECP256K1_STATIC` macro before including `secp256k1.h`.
19+
1020
## [0.3.2] - 2023-05-13
1121
We strongly recommend updating to 0.3.2 if you use or plan to use GCC >=13 to compile libsecp256k1. When in doubt, check the GCC version using `gcc -v`.
1222

Makefile.am

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ endif
153153
if USE_EXAMPLES
154154
noinst_PROGRAMS += ecdsa_example
155155
ecdsa_example_SOURCES = examples/ecdsa.c
156-
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
156+
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
157157
ecdsa_example_LDADD = libsecp256k1.la
158158
ecdsa_example_LDFLAGS = -static
159159
if BUILD_WINDOWS
@@ -163,7 +163,7 @@ TESTS += ecdsa_example
163163
if ENABLE_MODULE_ECDH
164164
noinst_PROGRAMS += ecdh_example
165165
ecdh_example_SOURCES = examples/ecdh.c
166-
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
166+
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
167167
ecdh_example_LDADD = libsecp256k1.la
168168
ecdh_example_LDFLAGS = -static
169169
if BUILD_WINDOWS
@@ -174,7 +174,7 @@ endif
174174
if ENABLE_MODULE_SCHNORRSIG
175175
noinst_PROGRAMS += schnorr_example
176176
schnorr_example_SOURCES = examples/schnorr.c
177-
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
177+
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
178178
schnorr_example_LDADD = libsecp256k1.la
179179
schnorr_example_LDFLAGS = -static
180180
if BUILD_WINDOWS

ci/cirrus.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ set -eux
44

55
export LC_ALL=C
66

7-
# Print relevant CI environment to allow reproducing the job outside of CI.
7+
# Print commit and relevant CI environment to allow reproducing the job outside of CI.
8+
git show --no-patch
89
print_environment() {
910
# Turn off -x because it messes up the output
1011
set +x
@@ -53,6 +54,22 @@ if [ -n "$WRAPPER_CMD" ]; then
5354
$WRAPPER_CMD --version
5455
fi
5556

57+
# Workaround for https://bugs.kde.org/show_bug.cgi?id=452758 (fixed in valgrind 3.20.0).
58+
case "${CC:-undefined}" in
59+
clang*)
60+
if [ "$CTIMETESTS" = "yes" ] && [ "$WITH_VALGRIND" = "yes" ]
61+
then
62+
export CFLAGS="${CFLAGS:+$CFLAGS }-gdwarf-4"
63+
else
64+
case "$WRAPPER_CMD" in
65+
valgrind*)
66+
export CFLAGS="${CFLAGS:+$CFLAGS }-gdwarf-4"
67+
;;
68+
esac
69+
fi
70+
;;
71+
esac
72+
5673
./autogen.sh
5774

5875
./configure \

ci/linux-debian.Dockerfile

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM debian:stable
22

3+
SHELL ["/bin/bash", "-c"]
4+
35
RUN dpkg --add-architecture i386 && \
46
dpkg --add-architecture s390x && \
57
dpkg --add-architecture armhf && \
@@ -9,11 +11,11 @@ RUN dpkg --add-architecture i386 && \
911
# dkpg-dev: to make pkg-config work in cross-builds
1012
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
1113
RUN apt-get update && apt-get install --no-install-recommends -y \
12-
git ca-certificates \
14+
git ca-certificates wget \
1315
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
14-
gcc clang llvm libc6-dbg \
16+
gcc clang llvm libclang-rt-dev libc6-dbg \
1517
g++ \
16-
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan6:i386 \
18+
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan8:i386 \
1719
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \
1820
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
1921
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 \
@@ -23,9 +25,44 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
2325
sagemath
2426

2527
WORKDIR /root
26-
# The "wine" package provides a convience wrapper that we need
28+
29+
# Build and install gcc snapshot
30+
ARG GCC_SNAPSHOT_MAJOR=14
31+
RUN wget --progress=dot:giga --https-only --recursive --accept '*.tar.xz' --level 1 --no-directories "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}" && \
32+
wget "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}/sha512.sum" && \
33+
sha512sum --check --ignore-missing sha512.sum && \
34+
# We should have downloaded exactly one tar.xz file
35+
ls && \
36+
[[ $(ls *.tar.xz | wc -l) -eq "1" ]] && \
37+
tar xf *.tar.xz && \
38+
mkdir gcc-build && cd gcc-build && \
39+
apt-get update && apt-get install --no-install-recommends -y libgmp-dev libmpfr-dev libmpc-dev flex && \
40+
../*/configure --prefix=/opt/gcc-snapshot --enable-languages=c --disable-bootstrap --disable-multilib --without-isl && \
41+
make -j $(nproc) && \
42+
make install && \
43+
ln -s /opt/gcc-snapshot/bin/gcc /usr/bin/gcc-snapshot
44+
45+
# Install clang snapshot
46+
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
47+
# Add repository for this Debian release
48+
. /etc/os-release && echo "deb http://apt.llvm.org/${VERSION_CODENAME} llvm-toolchain-${VERSION_CODENAME} main" >> /etc/apt/sources.list && \
49+
# Install clang snapshot
50+
apt-get update && apt-get install --no-install-recommends -y clang && \
51+
# Remove just the "clang" symlink again
52+
apt-get remove -y clang && \
53+
# We should have exactly two clang versions now
54+
ls /usr/bin/clang* && \
55+
[[ $(ls /usr/bin/clang-?? | sort | wc -l) -eq "2" ]] && \
56+
# Create symlinks for them
57+
ln -s $(ls /usr/bin/clang-?? | sort | tail -1) /usr/bin/clang-snapshot && \
58+
ln -s $(ls /usr/bin/clang-?? | sort | head -1) /usr/bin/clang
59+
60+
# The "wine" package provides a convenience wrapper that we need
2761
RUN apt-get update && apt-get install --no-install-recommends -y \
2862
git ca-certificates wine64 wine python3-simplejson python3-six msitools winbind procps && \
63+
# Workaround for `wine` package failure to employ the Debian alternatives system properly.
64+
ln -s /usr/lib/wine/wine64 /usr/bin/wine64 && \
65+
# Set of tools for using MSVC on Linux.
2966
git clone https://github.com/mstorsjo/msvc-wine && \
3067
mkdir /opt/msvc && \
3168
python3 msvc-wine/vsdownload.py --accept-license --dest /opt/msvc Microsoft.VisualStudio.Workload.VCTools && \

configure.ac

-6
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
127127
SECP_TRY_APPEND_CFLAGS([-wd4267], $1) # Disable warning C4267 "'var' : conversion from 'size_t' to 'type', possible loss of data".
128128
# Eliminate deprecation warnings for the older, less secure functions.
129129
CPPFLAGS="-D_CRT_SECURE_NO_WARNINGS $CPPFLAGS"
130-
# We pass -ignore:4217 to the MSVC linker to suppress warning 4217 when
131-
# importing variables from a statically linked secp256k1.
132-
# (See the libtool manual, section "Windows DLLs" for background.)
133-
# Unfortunately, libtool tries to be too clever and strips "-Xlinker arg"
134-
# into "arg", so this will be " -Xlinker -ignore:4217" after stripping.
135-
LDFLAGS="-Xlinker -Xlinker -Xlinker -ignore:4217 $LDFLAGS"
136130
fi
137131
])
138132
SECP_TRY_APPEND_DEFAULT_CFLAGS(SECP_CFLAGS)

doc/ellswift.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $$
8888
\begin{array}{lcl}
8989
X(u, t) & = & \left\\{\begin{array}{ll}
9090
\dfrac{g(u) - t^2}{2t} & a = 0 \\
91-
\dfrac{g(u) + h(u)(Y_0(u) + X_0(u)t)^2}{X_0(u)(1 + h(u)t^2)} & a \neq 0
91+
\dfrac{g(u) + h(u)(Y_0(u) - X_0(u)t)^2}{X_0(u)(1 + h(u)t^2)} & a \neq 0
9292
\end{array}\right. \\
9393
Y(u, t) & = & \left\\{\begin{array}{ll}
9494
\dfrac{X(u, t) + t}{u \sqrt{-3}} = \dfrac{g(u) + t^2}{2tu\sqrt{-3}} & a = 0 \\
@@ -329,7 +329,7 @@ $t$ value for multiple $c$ inputs (thereby biasing that encoding):
329329
it requires $g(u)=0$ which is already outlawed on even-ordered curves and impossible on others; in the second it would trigger division by zero.
330330
* Curve-specific special cases also exist that need to be rejected, because they result in $(u,t)$ which is invalid to the decoder, or because of division by zero in the encoder:
331331
* For $a=0$ curves, when $u=0$ or when $t=0$. The latter can only be reached by the encoder when $g(u)=0$, which requires an even-ordered curve.
332-
* For $a \neq 0$ curves, when $X_0(u)=0$, when $h(u)t^2 = -1$, or when $2w(u + 2v) = 2X_0(u)$ while also either $w \neq 2Y_0(u)$ or $h(u)=0$.
332+
* For $a \neq 0$ curves, when $X_0(u)=0$, when $h(u)t^2 = -1$, or when $w(u + 2v) = 2X_0(u)$ while also either $w \neq 2Y_0(u)$ or $h(u)=0$.
333333

334334
**Define** a version of $G_{c,u}(x)$ which deals with all these cases:
335335
* If $a=0$ and $u=0$, return $\bot.$

examples/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ target_link_libraries(example INTERFACE
66
secp256k1
77
$<$<PLATFORM_ID:Windows>:bcrypt>
88
)
9-
if(NOT BUILD_SHARED_LIBS AND MSVC)
10-
target_link_options(example INTERFACE /IGNORE:4217)
11-
endif()
129

1310
add_executable(ecdsa_example ecdsa.c)
1411
target_link_libraries(ecdsa_example example)

examples/examples_util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void secure_erase(void *ptr, size_t len) {
9595
* As best as we can tell, this is sufficient to break any optimisations that
9696
* might try to eliminate "superfluous" memsets.
9797
* This method used in memzero_explicit() the Linux kernel, too. Its advantage is that it is
98-
* pretty efficient, because the compiler can still implement the memset() efficently,
98+
* pretty efficient, because the compiler can still implement the memset() efficiently,
9999
* just not remove it entirely. See "Dead Store Elimination (Still) Considered Harmful" by
100100
* Yang et al. (USENIX Security 2017) for more background.
101101
*/

0 commit comments

Comments
 (0)