This should hopefully be useful as orientation for users implementing the shared secret derivation part of BIP324. Conceptually the example is not very different to the ECDH one, so a lot of code/comments are just copied (e.g. context creation, secret key generation, shared secret comparison, console output, cleanup with secret key clearing).
Add ellswift usage example #1551
pull theStack wants to merge 2 commits into bitcoin-core:master from theStack:add_ellswift_example changing 9 files +146 −3-
theStack commented at 2:17 PM on June 25, 2024: contributor
-
in CHANGELOG.md:11 in 78fe9f495f outdated
6 | @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 7 | 8 | ## [Unreleased] 9 | 10 | +#### Added 11 | + - Added usage example for a ElligatorSwift key exchange.
real-or-random commented at 2:43 PM on June 25, 2024:- Added usage example for an ElligatorSwift key exchange.in examples/ellswift.c:81 in 78fe9f495f outdated
76 | + /*** Create the shared secret on each side ***/ 77 | + 78 | + /* Perform x-only ECDH with seckey1 and ellswift_pubkey2. Should never fail 79 | + * with a verified seckey and valid pubkey. Note that both parties pass both 80 | + * EllSwift pubkeys in the same order; the pubkey to be actually used for the 81 | + * shared secret derivation is determined by the "party" boolean (sixth parameter). */
real-or-random commented at 2:46 PM on June 25, 2024:* EllSwift pubkeys in the same order; the pubkey of the calling party * is determined by the "party" boolean (sixth parameter). */I think this is a bit cleaner (still need to reformat the paragraph)
in examples/ellswift.c:112 in 78fe9f495f outdated
107 | + /* This will clear everything from the context and free the memory */ 108 | + secp256k1_context_destroy(ctx); 109 | + 110 | + /* It's best practice to try to clear secrets from memory after using them. 111 | + * This is done because some bugs can allow an attacker to leak memory, for 112 | + * example through "out of bounds" array access (see Heartbleed), Or the OS
real-or-random commented at 2:47 PM on June 25, 2024:* example through "out of bounds" array access (see Heartbleed), or the OSis this copied from the other example? Then fix it there too.
real-or-random commented at 2:47 PM on June 25, 2024: contributorConcept ACK
real-or-random added the label user-documentation on Jun 25, 2024examples: fix case typos in secret clearing paragraphs (s/, Or/, or/) fe4fbaa7f331f84595c4Add ellswift usage example
This should hopefully be useful as orientation for users implementing the key exchange part of BIP324. Conceptually the example is not very different to the ECDH one, so a lot of code/comments are just copied (e.g. context creation, secret key generation, shared secret comparison, console output, cleanup with secret key clearing).
theStack force-pushed on Jun 25, 2024theStack commented at 3:24 PM on June 25, 2024: contributor@real-or-random: Thanks for the quick review, force-pushed with all the suggestions taken.
in .gitignore:13 in 31f84595c4
9 | @@ -10,6 +10,7 @@ ctime_tests 10 | ecdh_example 11 | ecdsa_example 12 | schnorr_example 13 | +ellswift_example
hebasto commented at 10:12 PM on June 25, 2024:nit: I understand that this doesn’t adhere to the surrounding code, but, strictly speaking, it should be
/ellswift_example
real-or-random commented at 9:32 AM on June 26, 2024:Yeah, feel free to adjust this for the binaries, but I guess either variant is fine (we also have the pattern
*.exe, which may in rare cases a bit too coarse`...)hebasto commented at 10:12 PM on June 25, 2024: member31f84595c4fa8fcc89021790257b85416aae44f6
I have reviewed both build systems changes and they look OK.
real-or-random approvedreal-or-random commented at 9:30 AM on June 26, 2024: contributorutACK 31f84595c4fa8fcc89021790257b85416aae44f6
jonasnick approvedjonasnick commented at 6:15 PM on July 10, 2024: contributorACK 31f84595c4fa8fcc89021790257b85416aae44f6
jonasnick merged this on Jul 10, 2024jonasnick closed this on Jul 10, 2024theStack deleted the branch on Jul 10, 2024fanquake referenced this in commit 41797f8ab9 on Aug 2, 2024fanquake referenced this in commit d928f4c47f on Aug 6, 2024vmta referenced this in commit f2a8540eae on Sep 3, 2024vmta referenced this in commit 8c2166b973 on Sep 6, 2024real-or-random referenced this in commit e59158b6eb on Oct 15, 2024vmta referenced this in commit 4d1f6d5635 on Oct 29, 2024janus referenced this in commit 1fed89422a on Jan 6, 2025div72 referenced this in commit af627d47c3 on Apr 12, 2025oskarszoon referenced this in commit 0d5c9260f4 on Jul 1, 2025real-or-random referenced this in commit 4ae7cb4f71 on Feb 11, 2026github-actions[bot] referenced this in commit 758d4e90b4 on Mar 1, 2026github-actions[bot] referenced this in commit 68a2178f22 on Mar 1, 2026github-actions[bot] referenced this in commit a8bc1a0b2b on Mar 1, 20260x000000000019d6689c085ae165831e934ff76 referenced this in commit 3b9450150d on Mar 2, 2026csjones referenced this in commit a4d92824ae on Mar 2, 2026ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC