Package for public key, ECDSA, and Schnorr on Bitcoin. Apple ( iOS macOS tvOS watchOS ) & linux platform compatibility.

What's New



What's Changed

  • Bump Sources/bindings/secp256k1 from fecf436 to 49f608d by @dependabot in #144
  • Bump Sources/bindings/secp256k1 from 49f608d to 61ae37c by @dependabot in #145
  • Bump Sources/bindings/secp256k1 from 61ae37c to 5d0dbef by @dependabot in #146
  • Bump Sources/implementation/swift-crypto from bd5abc2 to 9c53b7a by @dependabot in #147
  • Bump swift from 5.5.1 to 5.5.2 by @dependabot in #149
  • Bump Sources/implementation/swift-crypto from 9c53b7a to 172d71f by @dependabot in #150
  • Updates to Package.swift by @csjones in #156

Full Changelog: 0.3.3...0.3.4

Build Status Build Status

🔐 secp256k1.swift

Swift library plus bindings for ECDSA signatures and secret/public key operations using libsecp256k1.


Long-term goals are:

  • Lightweight ECDSA functionality
  • APIs modeled after Swift Crypto
  • Up-to-date with future versions of Swift and libsecp256k1
  • Consistent across multiple platforms


import secp256k1

let privateKeyBytes = try! "14E4A74438858920D8A35FB2D88677580B6A2EE9BE4E711AE34EC6B396D87B5C".byteArray()
let privatekey = try! secp256k1.Signing.PrivateKey(rawRepresentation: privateKeyBytes)

print(String(byteArray: privatekey.publicKey.rawRepresentation)) //  02734b3511150a60fc8cac329cd5ff804555728740f2f2e98bc4242135ef5d5e4e

let messageData = "Hello World!".data(using: .utf8)!
let signature = try! privateKey.signature(for: messageData)

print(try! signature.derRepresentation().base64EncodedString()) //  MEUCID8JELjY/ua6MSRKh/VtO7q2YAgpPOfqlwi05Lj/gC1jAiEAiJ1r82jIVc9G/2kooLnzIbg04ky/leocdLn9XE1LvwI=

Getting Started

In your Package.swift:

        name: "secp256k1",
        url: "",
        .upToNextMajor(from: "0.3.4")


These APIs should not be considered stable and may change at any time. libsecp256k1 is still experimental and has not been formally released.


  • Swift Tools 5.1.0
View More Packages from this Author


  • None
Last updated: Thu Jan 27 2022 16:59:21 GMT-0500 (GMT-05:00)