ed25519swift

master

ed25199 implementation by pure swift
pebble8888/ed25519swift

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

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

Last updated: Tue Mar 12 2024 02:49:46 GMT-0900 (Hawaii-Aleutian Daylight Time)