Files
buzz/mobile/ios/BuzzPushKit/Sources/CSecp256k1
Tom Brow 73962435b6 Use upstream C secp256k1 for native Nostr signatures (#8398)
Replace the Swift secp256k1 wrapper with a small native adapter over
Bitcoin Core libsecp256k1. This is an alternative to the wrapper upgrade
in [#8381](https://github.com/block/buzz/pull/8381), not an additional
change to merge alongside it.

The adapter covers the three Nostr operations Buzz needs: x-only
public-key derivation, BIP-340 signing, and signature verification. It
compiles pinned, unmodified upstream C source through SwiftPM. There is
no build plugin, plugin approval script, or underscored Swift import.
The app and notification extension use an explicit C module map and
header search path.

This trades the third-party Swift wrapper for a Buzz-owned adapter and
responsibility for updating the vendored C source. Upstream v0.8.0
source, its license, and update provenance are included. The release
Xcode pin remains separate in
[buzz-releases#110](https://github.com/squareup/buzz-releases/pull/110).

### Validation

- Native package tests passed on Xcode 27.0 and 26.5: 96 XCTest tests
and 65 Swift Testing tests per toolchain.
- Added tests cover the official BIP-340 vectors for 32-byte Nostr
messages, invalid secret keys, and malformed input lengths.
- Full unsigned Release app and notification extension build passed on
exact Xcode 27.0.
- Vendored files were compared byte-for-byte with upstream v0.8.0.
- Full local `just ci` passed.
- [Hosted full unsigned iOS Release
build](https://github.com/block/buzz/actions/runs/38924020583/job/117051237094)
passed. [Hosted Native Swift
validation](https://github.com/block/buzz/actions/runs/38924020583/job/117051237153)
passed, including the complete simulator build and native controls/push
navigation tests.
- Codex code review and security review completed with no findings.

### Before merge

- [x] Tom selected the direct-C approach with vendored upstream source;
[the wrapper alternative](https://github.com/block/buzz/pull/8381) is
closed.

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-10-16 09:26:55 -07:00
..

Native secp256k1

vendor/src, vendor/include, and vendor/COPYING are unmodified files from Bitcoin Core libsecp256k1 v0.8.0, commit 6e2c8bc4ecdc6e71dbe7a368f360d8d453ce435d: 6e2c8bc4ec

The upstream MIT license is retained in vendor/COPYING. SwiftPM compiles the three translation units listed in Package.swift, with the extrakeys and schnorrsig modules enabled. Upstream precomputed tables are checked in; no build plugin, downloaded binary, or generated source is needed.

To update, replace these three vendor paths from a reviewed upstream release. Do not edit upstream sources locally. Run the NostrSchnorr BIP-340 vector tests, all BuzzPushKit tests, and complete app and notification extension builds on supported Xcode versions before accepting an update.

The BIP-340 test fixture comes from bitcoin/bips commit 927b6de9915c9262615a6399de51b200f81e5aa4, bip-0340/test-vectors.csv.