🔏

P256K

Efficient SECP256K1 for Swift

Seamlessly integrate, test, and utilize the elliptic curve cryptography for development of Bitcoin applications.

Supported by

Get Started

import 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.

Ecosystem

Used by Organizations

Several applications use our package for their SECP256K1 needs.

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.

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.

Visit our comprehensive documentation site for tutorials, API reference, and real-world examples. You can also explore the example projects repository on GitHub.

Need help? Let us help you get started

Contact us →

21.dev

Equipping developers with the tools they need today to build the Bitcoin apps of tomorrow.

Resources

Documentation Blog P256K

Contact

[email protected]

Licensed under MIT

Follow Us

© 2025 21.dev. All rights reserved.