Git Product home page Git Product logo

ed25519swift's Introduction

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

ed25519swift's People

Contributors

pebble8888 avatar crewshin avatar imaginaris avatar rolandasrazma avatar

Stargazers

adamz avatar Kevin Manase avatar Brandon avatar Happy Coding avatar Maxim avatar Pedro Paulo Amorim avatar Vincent Bellet avatar CMK avatar Eugene Kolpakov avatar  avatar yongjoo avatar Keefer Taylor | Tessellated avatar abigt avatar Mitch Lang avatar Joshua Lin avatar ribencong avatar Jaime Capponi avatar Kyle Schreiber avatar Geoff Rainville avatar Denmark avatar Stone avatar  avatar Yosuke Fukazawa avatar Julien Cayzac avatar Alexander Cyon avatar  avatar sam avatar  avatar daokasweep avatar

Watchers

James Cloos avatar  avatar

ed25519swift's Issues

ge25519_unpackneg_vartime test

    
    func testBytes() {
        let publicKey  = [byte](repeating: 0, count: PublicKeySize)

        print("bytes: \(publicKey)")        
        var gepp : ge = ge()
        let _ = ge.ge25519_unpackneg_vartime(&gepp, publicKey)
        
        var Bv  = [byte](repeating: 0, count: PublicKeySize)

        ge.ge25519_pack(&Bv, gepp)
        print("bytes: \(Bv)")
        XCTAssertEqual(publicKey, Bv)
        // bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
       // bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128]
    }

When I run this test on Go, it's pass, but use swift at iOS the result not equal.

Cocoapods?

I'm interested in using this in my project, can I install it via cocoapods?

Broken backwards compatibility in 1.2.6

In 1.2.6 the minimum required iOS version changed from 11 to 12 and macOS from 10.12 to 10.14.
It's a breaking change so according to semver I'd advise to use 2.0.0 version number instead of 1.2.6.
That way developers using version 1.x.x won't have to pin specific version number in their dependency declaration.

CocoaPod support?

Thank you for this. Are you planning on pushing new versions to cocoapods or just use spm from now on? I would like to use this as a dependency with both but the two aren't in sync. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.