Swiftpack.co -  GigaBitcoin/secp256k1.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GigaBitcoin/secp256k1.swift
Swift library plus bindings for ECDSA signatures and secret/public key operations using libsecp256k1.
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", from: "0.3.0")

Build Status

🔐 secp256k1.swift

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

Objectives

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

Usage

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:

dependencies: [
    .package(
        name: "secp256k1",
        url: "https://github.com/GigaBitcoin/secp256k1.swift.git",
        from: "0.3.0"
    ),
]

Danger

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

GitHub

link
Stars: 6
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Related Packages

Release Notes

ECDSA
19 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API