All Projects → hyugit → EllipticCurve

hyugit / EllipticCurve

Licence: MIT License
An elliptic curve library written in Swift 4

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to EllipticCurve

hazmat-math
Hazmat ECC arithmetic for Cryptography.io
Stars: ✭ 28 (+55.56%)
Mutual labels:  ecc, elliptic-curves, secp256k1, elliptic-curve-arithmetic
noble-secp256k1
Fastest JS implementation of secp256k1. Independently audited, high-security, 0-dependency ECDSA & Schnorr signatures.
Stars: ✭ 313 (+1638.89%)
Mutual labels:  ecc, ecdsa, secp256k1
Number-Theory-Python
Python code to implement various number theory, elliptic curve and finite field computations.
Stars: ✭ 85 (+372.22%)
Mutual labels:  ecdsa, finite-fields, elliptic-curves
secp256k1.cr
a native library implementing secp256k1 purely for the crystal language.
Stars: ✭ 34 (+88.89%)
Mutual labels:  ecdsa, secp256k1
galois
A performant NumPy extension for Galois fields and their applications
Stars: ✭ 106 (+488.89%)
Mutual labels:  finite-fields, elliptic-curves
elliptic-curve
A polymorphic interface for elliptic curve operations
Stars: ✭ 37 (+105.56%)
Mutual labels:  ecc, elliptic-curves
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (+94.44%)
Mutual labels:  carthage, swift-package-manager
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (+50%)
Mutual labels:  carthage, swift-package-manager
nim-blscurve
Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381
Stars: ✭ 19 (+5.56%)
Mutual labels:  elliptic-curves, elliptic-curve-arithmetic
VisualDebugger
The most elegant and easiest way to visual you data in playground
Stars: ✭ 22 (+22.22%)
Mutual labels:  carthage, swift-package-manager
interesting-keys
Interesting collected (leaked) encryption/decryption keys
Stars: ✭ 33 (+83.33%)
Mutual labels:  ecc, ecdsa
pairing
Optimised bilinear pairings over elliptic curves
Stars: ✭ 44 (+144.44%)
Mutual labels:  ecc, elliptic-curves
secp256k1-ml
Elliptic curve library secp256k1 wrapper for Ocaml
Stars: ✭ 18 (+0%)
Mutual labels:  elliptic-curves, secp256k1
SwiftFCXRefresh
Pull to refresh in Swift.
Stars: ✭ 29 (+61.11%)
Mutual labels:  carthage, swift-package-manager
Sqlable
Swift library for making storing data in a SQLite database simple and magic-free
Stars: ✭ 83 (+361.11%)
Mutual labels:  carthage, swift-package-manager
noble-ed25519
Fastest JS implementation of ed25519, x25519 & ristretto255. Independently audited, high-security, 0-dependency EDDSA signatures and ECDH key agreement
Stars: ✭ 220 (+1122.22%)
Mutual labels:  ecc, elliptic-curves
ECDSA secp256k1 JordonMatrix nodejs
javascript ecdsa generator, specifically secp256k1 properties, using jordon form matrices
Stars: ✭ 15 (-16.67%)
Mutual labels:  ecdsa, secp256k1
AirPlay
Small framework that lets users track iOS AirPlay availability and extra features.
Stars: ✭ 46 (+155.56%)
Mutual labels:  carthage, swift-package-manager
btclib
btclib: a python3 library for 'bitcoin cryptography'
Stars: ✭ 60 (+233.33%)
Mutual labels:  ecdsa, elliptic-curves
SwiftGradients
Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Stars: ✭ 15 (-16.67%)
Mutual labels:  carthage, swift-package-manager

EllipticCurve

Build Status Language Platform Carthage Compatible

An elliptic curve library written in Swift 4

Warning: this library started as a learning process. It is not meant for production use. Please use libsecp256k1 instead.

Features

  • ECDSA
  • secp256k1
  • provide your own hashing functions
  • FiniteFieldInteger protocol to create your own finite field integers
  • EllipticCurve protocol to create your own elliptic curves
  • generic signing and signature verifying
  • secp192k1, secp192r1, secp224k1, secp224r1, secp256k1, secp256r1

CREATE YOUR OWN ELLIPTIC CURVES! 😃

This Library provides the necessary scaffoldings for you to easily create elliptic curves.

The library includes several SEC-2 curves, among which is the secp256k1, the most popular curve at the moment. On top of the curves, a generic ECDSA struct is included for signing and verifying.

Protocol oriented architecture

All the protocols are generic, which means none of them is tied to a certain curve or a specific UInt family member. It is very straight forward to create a specific finite field with a specific prime number as its order, or to create a specific elliptic curve of Double precision or Float80 precision. Please see to the playground for demonstrations.

The top level protocol for creating elliptic curve cryptography is EllipticCurveOverFiniteField. It is constructed from two basic protocols: FiniteFieldInteger and EllipticCurve, the former of which is based on FiniteField. The diagram of protocol inheritance is as follows:

                                                                    
 +--------------------------+                                       
 |                          |                                       
 |        FiniteField       |-----+                                 
 |                          |     |                                 
 +-------------|------------+     |Conformance                      
               |                  |                                 
               |Conformance       |                                 
               |                  |                                 
 +-------------v------------+     |    +---------------------------+
 |                          |     |    |                           |
 |    FiniteFieldInteger    |     |    |        EllipticCurve      |
 |                          |     |    |                           |
 +-------------|------------+     |    +-------------|-------------+
               |                  |                  |              
               |                  |                  |              
 As Coordinates|  +------------------------------+   |Conformance   
               |  |                              |   |              
               +--- EllipticCurveOverFiniteField <---+              
                  |                              |                  
                  +---------------|--------------+                  
                                  |                                 
                                  |As T                             
                                  |                                 
                  +---------------|--------------+                  
                  |                              |                  
                  |           ECDSA<T>           |                  
                  |                              |                  
                  +------------------------------+                                              

FiniteField

FiniteField is the base protocol. It defines several basic properties like Zero, One, Characteristic, and etc. It is not meant to be used directly, but you can use it to create finite fields.

FiniteFieldInteger

FiniteFieldInteger defines the basic scaffolding and provides most of the default implementations for any finite field integer. Example:

let p: UInt8 = 223

struct MyFFInt: FiniteFieldInteger {
    static var Characteristic = p

    var value: UInt8

    init() {
        value = 0
    }
}

let a: MyFFInt = 1
let b: MyFFInt = 500
print(a + b)

This will create a finite field integer of F_223, and then you can use the basic +, -, *, / on it.

EllipticCurve

EllipticCurve is also generic. You can create an elliptic curve on real domain like this:

struct MyECPoint: EllipticCurve {
    static var a: Double = -1
    static var b: Double = 1

    var x: Double
    var y: Double?

    init() {
        x = 0
    }
}

let p: MyECPoint = MyECPoint(x: 1, y: 1)
print(p.description)

EllipticCurveOverFiniteField

This is the top level protocol to use, if you want to create an ECC of your own:

let P: UInt8 = 223

struct FFInt223: FiniteFieldInteger {
    static var Characteristic: UInt8 = P
    var value: UInt8

    init() {
        value = 0
    }
}

struct MyECFF: EllipticCurveOverFiniteField {

    static var Order: UInt8 = 212

    static var a: FFInt223 = 2
    static var b: FFInt223 = 7

    var x: FFInt223
    var y: FFInt223?

    static var Generator: MyECFF = MyECFF(x: 16, y: 11)

    init() {
        x = 0
    }
}

Requirements

  • iOS 8.0+ / macOS 10.10+
  • Xcode 9.2+
  • Swift 4

Installation

Carthage

Currently, only carthage package installation is tested.

  • install Carthage: brew install carthage
  • add this line to your Cartfile: github "hyugit/EllipticCurve"
  • run carthage update under your project directory

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/hyugit/EllipticCurve.git", from: "0.3.0")
]

Communication

If you have a bug report or a feature request, please open an issue here on GitHub. Any contribution is welcome. 😃

License

EllipticCurve is released under MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].