Swiftpack.co - pebble8888/ed25519swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by pebble8888.
pebble8888/ed25519swift 1.2.8
ed25199 implementation by pure swift
⭐️ 29
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.8")

Ed25519

Ed25519(EdDSA) by pure swift

ed25519

License

Ed25519 can be used, distributed and modified user the zlib license.

Requirements

Ed25519 requires Swift5.

macOS, iOS

Install

CocoaPods

pod 'ed25519swift'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Ed25519 as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.7")
]

Dependency

CryptoSwift for sha512

BigInt for reference implementation that is not included main Ed25519 library.

How to use

Key pair creation

import Ed25519macOS // direct
or
import ed25519swift // pods or Swift Package Manager

static func Ed25519.generateKeyPair() -> (publicKey: [UInt8], secretKey: [UInt8])

Signing

static func Ed25519.sign(message: [UInt8], secretKey: [UInt8]) -> [UInt8]

Validation

static func Ed25519.verify(signature: [UInt8], message: [UInt8], publicKey: [UInt8]) -> Bool

Calc public key from secret key

static func Ed25519.calcPublicKey(secretKey: [UInt8]) -> [UInt8]

Check valid keypair

static func Ed25519.isValidKeyPair(publicKey: [UInt8], secretKey: [UInt8]) -> Bool

Implemantation

It is ported from SUPERCOP

You can check the algorithm in these papers and RFC.
Daniel J. Bernstein, Niels Duif, Tanja Lange, Peter Schwabe, and Bo-Yin Yang, High-speed high-security signatures. 2012

Huseyin Hisl, Kenneth Koon-Ho Wong, Gary Carter, Ed Dawson, Twisted Edwards curves revisited. 2008

RFC8032 Edward-Curve Digital Signature Algorithm (EdDSA)

Performance

macOS

On MacBook Pro 2017 2.3Ghz Intel Core i5

message validation : 10.7 msec per message
keypair creation : 4.8 msec per keypair

iOS

no measurement

GitHub

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

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