纯 Swift 实现的 Ed25519 (EdDSA)
Ed25519 使用 zlib 许可证,可以被使用、分发和修改。
Ed25519 需要 Swift 5。
macOS, iOS
pod 'ed25519swift'
Swift Package Manager 是一种用于自动化 Swift 代码分发的工具,并已集成到 swift
编译器中。
一旦你设置好了你的 Swift 包,将 Ed25519 添加为依赖项就像将其添加到你的 Package.swift
文件的 dependencies
值一样简单。
dependencies: [
.package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.2")
]
CryptoSwift 用于 sha512
BigInt 用于参考实现,该实现未包含在主要的 Ed25519 库中。
import Ed25519macOS // direct
or
import ed25519swift // pods or Swift Package Manager
static func generateKeyPair() -> (publicKey: [UInt8], secretKey: [UInt8])
static func sign(message: [UInt8], secretKey: [UInt8]) -> [UInt8]
static func verify(signature: [UInt8], message: [UInt8], publicKey: [UInt8]) -> Bool
static func calcPublicKey(secretKey: [UInt8]) -> [UInt8]
static func isValidKeyPair(publicKey: [UInt8], secretKey: [UInt8]) -> Bool
它移植自 SUPERCOP
你可以在这些论文和 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)
在 MacBook Pro 2017 2.3Ghz Intel Core i5 上
消息验证:每个消息 10.7 毫秒
密钥对创建:每个密钥对 4.8 毫秒
没有测量