All Projects → roddhjav → ecurve

roddhjav / ecurve

Licence: other
DiffieHellman, Elgamal, ECDSA & STS with elliptic curve in python

Programming Languages

python
139335 projects - #7 most used programming language
Gnuplot
187 projects
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to ecurve

ECTester
Tests support and behavior of elliptic curve cryptography implementations on JavaCards (TYPE_EC_FP and TYPE_EC_F2M) and in selected software libraries.
Stars: ✭ 51 (+168.42%)
Mutual labels:  elliptic-curves
btclib
btclib: a python3 library for 'bitcoin cryptography'
Stars: ✭ 60 (+215.79%)
Mutual labels:  elliptic-curves
nim-blscurve
Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381
Stars: ✭ 19 (+0%)
Mutual labels:  elliptic-curves
Number-Theory-Python
Python code to implement various number theory, elliptic curve and finite field computations.
Stars: ✭ 85 (+347.37%)
Mutual labels:  elliptic-curves
jwt-compact
Compact JWT implementation in Rust
Stars: ✭ 26 (+36.84%)
Mutual labels:  elliptic-curves
galois
A performant NumPy extension for Galois fields and their applications
Stars: ✭ 106 (+457.89%)
Mutual labels:  elliptic-curves
crypto-in-action
algebra arithmetic, finite fields, elliptic curves, zero-knowledge
Stars: ✭ 65 (+242.11%)
Mutual labels:  elliptic-curves
noble-ed25519
Fastest JS implementation of ed25519, x25519 & ristretto255. Independently audited, high-security, 0-dependency EDDSA signatures and ECDH key agreement
Stars: ✭ 220 (+1057.89%)
Mutual labels:  elliptic-curves
std-curves
Standard curve database.
Stars: ✭ 53 (+178.95%)
Mutual labels:  elliptic-curves
elliptic-curve
A polymorphic interface for elliptic curve operations
Stars: ✭ 37 (+94.74%)
Mutual labels:  elliptic-curves
libgoldilocks
An implementation of Mike Hamburg's Ed448 (Goldilocks) curve - derived from libdecaf. This is a mirror of https://bugs.otr.im/otrv4/libgoldilocks
Stars: ✭ 17 (-10.53%)
Mutual labels:  elliptic-curves
jubjub
Supporting evidence for security of the Jubjub curve to be used in Zcash
Stars: ✭ 13 (-31.58%)
Mutual labels:  elliptic-curves
bls-js
BLS signature implementation
Stars: ✭ 15 (-21.05%)
Mutual labels:  elliptic-curves
keystore-idb
In-browser key management with IndexedDB and the Web Crypto API
Stars: ✭ 37 (+94.74%)
Mutual labels:  elliptic-curves
hacl
Archived. Curve25519 support has been integrated into mirage-crypto-ec (via fiat-crypto). Hacl bindings are available from the hacl-star opam package. OCaml bindings for HACL* elliptic curves
Stars: ✭ 21 (+10.53%)
Mutual labels:  elliptic-curves
cryptotools
No description or website provided.
Stars: ✭ 182 (+857.89%)
Mutual labels:  elliptic-curves
libeddsa
cryptographic library for ed25519 and curve25519
Stars: ✭ 20 (+5.26%)
Mutual labels:  elliptic-curves
cryptos
Pure Python from-scratch zero-dependency implementation of Bitcoin for educational purposes
Stars: ✭ 846 (+4352.63%)
Mutual labels:  elliptic-curves
BulletproofJS
Set of JavaScript based tools and Ethereum Solidity contracts for BulletProof based range proofs and confidential transactions
Stars: ✭ 26 (+36.84%)
Mutual labels:  elliptic-curves
hazmat-math
Hazmat ECC arithmetic for Cryptography.io
Stars: ✭ 28 (+47.37%)
Mutual labels:  elliptic-curves

Elliptic Curves in python

DiffieHellman, Elfgamal, ECDSA & STS with elliptic curve in python

WARNING This was a school project do not use it for actual security purpose.

Description

General

That software provide a python package with elliptic curves and security primitives class :

  • Diffie Hellman : diffiehellman.py
  • ElGamal : elgamal.py
  • ECDSA : ECDSA.py
  • STS : STS.py
  • Elliptic Curves : elliptic.py and point.py
  • Some tools : tools.py, ectools.py, stools.py

In more there is four front-end for an immediate usage :

  • Diffie Hellman : dh
  • ElGamal : elgamal
  • ECDSA : ecdsa
  • STS : sts

Program architecture

Tools used by primitives Class and front-end :

  • EllipticCurve : The elliptic curve class
  • Point ; The point class
  • ectools.py : Mathematic function for elliptic curve
  • tools.py :
    • tools : Read curve, I/O files
    • key : I/O functions for the keys
    • message Easy to use socket functions
  • stools : STS and DH tools for secret exchange using socket

File system :

  • curves/ :
    • There are 17 256bits curves and 18 512bits curves. All front-end and class manage the two sizes of curve
    • The curve are taken from http://galg.acrypta.com/. Therefore these are not the usual curves recommended by the NIST
    • We use Weierstrass curves
    • See curves/README.md for more information
  • keys/
    • As the curve are not the classic NSA's curves, the key format contains the curve itself.
    • See keys/README.md for more information about keys format
  • sample/
    • Default directory for plain text, signed and encrypted files
    • See sample/README.md for more information

Requirements

That software run with Python 2.x and 3.x.

For AES function and the secure random generator you need the python library Crypto avaible here

If you want to install the pakage ecurve : sudo python setup install

Usages

All the following command are showed with all their options. But some options are not mandatory as described

Diffie Hellman (DH) : dh

Create connection with a computer and start DH protocol :

dh --curve <curve.gp> --output <sharedsecret> --port <port> --host <hostname>

The first computer connected have to create the server with --server

dh --curve <curve.gp> --output <sharedsecret> --port <port> --server

Get the help :

dh --help

Default options :

  • <curve.gp> : curves/w256-001.gp
  • <sharedsecret> : keys/dh.shared
  • <port> : 12800
  • <localhost> : 12800

Elgamal : elgamal

This front-end provide an easy to use command for encrypt a file with elgamal. The front-end reads the file as a binary file but writes the cipher as a text file. As an asymetric security primitives, Elgamal is used for encryption of short message like keys. Do not use it for encrypt big file.

Generate an elgamal key pair : <key> as private and <key.pub> as public key

elgamal --keygen --curve <curves.gp> --output <key>

Encrypt a file :

elgamal --crypt --key <key.pub> --input <file> --output <file.elgamal>

Decrypt a file :

elgamal --decrypt -key <key> --input <file.elgamal> --output <file.decoded>

Get the help :

elgamal --help

Default options :

  • <curve.gp> : curves/w256-001.gp
  • <key.pub> : keys/elgamal.pub Public key
  • <key> : keys/elgamal Private key
  • <file> : sample/text Plain text file
  • <file.elgamal> : sample/text.elgamal Encrypted file
  • <file.decoded> : sample/text.decoded File decrypted

ECDSA : ecdsa

ecdsa reads your file as a binary file with a buffer. Therefore, you can sign any file you want.

Generate an ECDSA key pair : <key> as private and <key.pub> as public key

ecdsa --keygen --curve <curves.gp> --output <key>

Sign a file :

ecdsa --sign --key <key> --input <file> --output <file.signed>

Verify the signature : the signed have to be named <file.signed>

ecdsa --verif --key <key.pub> --input <file> 

Get the help :

ecdsa --help

Default options :

  • <curve.gp> : curves/w256-001.gp
  • <key.pub> : keys/ecdsa.pub Public key
  • <key> : keys/ecdsa Private key
  • <file> : sample/text Plain text file
  • <file.signed> : sample/text.signed The signed of the file (You still need the file itsel)

Sation To Station (STS) : sts

Requirements :

  • You need to generate first an ECDSA key pair with the same curve you will use for STS
  • <key> is your ECDSA private key
  • <key.pub> is your ECDSA public key

Create connection with a computer and start STS protocol :

sts --curve <curve.gp> --key <key> --output <sharedsecret> --port <port> --host <hostname>

The first computer connected have to create the server with --server

sts --curve <curve.gp> --key <key> --output <sharedsecret> --port <port> --server

Get the help :

sts --help

Default options :

  • <curve.gp> : curves/w256-001.gp
  • <key> : keys/ecdsa and keys/ecdsa.pub We need the both private and public key
  • <sharedsecret> : keys/sts.shared
  • <port> : 12800
  • <localhost> : 12800

Security purpose

We provide elliptic curve for level 7 and 8.

Level Protection Sym Asym EC Hash
1 Attacks in "real-time" by individuals 32
2 Very short-term protection 64 816 128 128
3 Short-term protection against medium organizations 72 1008 144 144
4 80 1248 160 160
5 Legacy standard level 96 1776 192 192
6 Medium-term protection 112 2432 224 224
7 Long-term protection (minimum level recommended) 128 3248 256 256
8 ”Foreseeable future”, Good protection against government agencies 256 15424 512 512

Authors

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].