Swiftpack.co -  Package - GigaBitcoin/secp256k1.swift
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: 3
Last commit: 5 days ago

Release Notes

ECDSA
4 weeks ago

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