Seamlessly integrate, test, and utilize the elliptic curve cryptography for development of Bitcoin applications.
Get Startedimport P256K
// Create ECDSA keypair
let priv = try! P256K.Signing.PrivateKey()
let pub = priv.publicKey
// Sign message with private key
let msg = "Hello Bitcoin".data(using: .utf8)!
let sig = try! priv.signature(for: msg)
// Verify signature with public key
let valid = pub.isValidSignature(sig, for: msg)
import P256K
// Create Schnorr keypair
let priv = try! P256K.Schnorr.PrivateKey()
let pub = priv.publicKey
// Sign message with private key
let msg = "Bitcoin Script".data(using: .utf8)!
let sig = try! priv.signature(for: msg)
// Verify signature with public key
let valid = pub.isValidSignature(sig, for: msg)
Integration
Streamline your development: utilize the efficiency of libsecp256k1 for Swift
We've wrapped libsecp256k1 into a package and made it super simple to include into your Xcode project. And it works with Swift Packages too!
Easy Integration
Unlock simplicity and efficiency with just a few lines from P256K1 APIs. Leave the heavy lifting of project mutations to libsecp256k1 while you focus on what truly matters.
Swift Packages Support
Most of the time you don't need to compile sources of your Swift Package dependencies. Therefore we wrapped libsecp256k1 for others to integrate.
Flexibility
Schnorr and ECDSA Signatures functionality with ease. Exposed C bindings to take full control of the implementation.
Installation
Get Started
Add P256K using your preferred package manager.
https://github.com/21-DOT-DEV/swift-secp256k1
In Xcode, go to File → Add Package Dependencies, paste the URL above, select version 0.21.1, and add to your target.
.package(url: "https://github.com/21-DOT-DEV/swift-secp256k1", exact: "0.21.1")
Add this line to your Package.swift dependencies array, then run `swift build` to integrate P256K into your project.
pod 'swift-secp256k1', '0.21.1'
Add this line to your Podfile, then run `pod install` to integrate P256K into your Xcode workspace.
Documentation
Explore the APIs
Comprehensive API documentation for P256K cryptography.
ECDSA Signatures
Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital Signature Algorithm (DSA) which uses elliptic-curve cryptography.
Learn more
Schnorr Signatures
Schnorr signatures provide enhanced privacy and efficiency with mathematical properties that enable advanced Bitcoin scripting capabilities.
Learn more
Key Management
Secure key generation, derivation, and management utilities for Bitcoin development with industry-standard practices.
Learn more
FAQ
Frequently Asked Questions
Common questions about using P256K for Swift integration.
P256K is built specifically for Swift developers with modern language features, comprehensive test coverage, and seamless integration with Swift Package Manager. It provides type-safe APIs and follows Swift conventions.
p256k supports Swift 5.9+ and is tested on macOS, iOS, watchOS, tvOS, and Linux. It requires no external packages and works with both UIKit and SwiftUI applications.
Equipping developers with the tools they need today to build the Bitcoin apps of tomorrow.
© 2025 21.dev. All rights reserved.