Swiftpack.co - GigaBitcoin/secp256k1.swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by GigaBitcoin.
GigaBitcoin/secp256k1.swift 0.3.4
Package for public key, ECDSA, and Schnorr on Bitcoin. Apple ( iOS macOS tvOS watchOS ) & linux platform compatibility.
⭐️ 10
🕓 4 weeks ago
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", from: "0.3.4")

Build Status 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:

    .package(
        name: "secp256k1",
        url: "https://github.com/GigaBitcoin/secp256k1.swift.git",
        .upToNextMajor(from: "0.3.4")
    )

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: 11
Last commit: 2 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.3.4
4 weeks ago

What's Changed

Full Changelog: https://github.com/GigaBitcoin/secp256k1.swift/compare/0.3.3...0.3.4

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