Swiftpack.co - LanfordCai/Secp256k1Swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by LanfordCai.
LanfordCai/Secp256k1Swift 0.1.2
A well-tested and easy to use secp256k1 wrapper in Swift 5
⭐️ 7
🕓 5 years ago
iOS macOS
.package(url: "https://github.com/LanfordCai/Secp256k1Swift.git", from: "0.1.2")

Secp256k1Swift

A secondary encapsulation of https://github.com/Boilertalk/secp256k1.swift, well-tested and easy to use.

Integration

You can use The Swift Package Manager to install Secp256k1Swift by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/LanfordCai/Secp256k1Swift.git", from: "0.1.2"),
    ]
)

Then run swift build whenever you get prepared.

Basic Usage

Generate Secp256k1 key pairs

let (privkey, pubkey) = try! Secp256k1.keyPair()

Verify a private key

let result = Secp256k1.isValidPrivateKey(privkey)

Sign a message

let sig = try! Secp256k1.sign(msg: msg, with: privkey, nonceFunction: .default)

Verify a signature

let result = Secp256k1.verify(msg: msg, sig: sig, pubkey: pubkey)

Sign compact

let (sig, recID) = try! Secp256k1.signCompact(msg: msg, with: privkey, nonceFunction: .default)

Verify compact

let result = Secp256k1.verifyCompact(msg: msg, sig: sig, pubkey: pubkey)

For more usage examples, please checkout the Tests

Test Vectors

The test vectors are from https://github.com/btccom/secp256k1-go

GitHub

link
Stars: 7
Last commit: 5 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Related Packages

Release Notes

5 years ago

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