Code Monkey home page Code Monkey logo

python-rubenesque's Introduction

Rubenesque is an implementation of several standard elliptic curve groups
in pure Python 3 used for cryptographic purposes. The classes contained in
this source code should be sufficient to implement your own cryptographic
primitives.

However, please note that, due to the nature of the Python programming
language, this code cannot guarantee either performance or safety from
side-channel attacks. Using this library in situations where such properties
are required is not advised and may actively lead to security compromise.
Although this project will accept patches to improve performance, we will
not consider performance or side-channel avoidance as valid bugs.

Rubenesque does, however, strive to be correct and standards compliant. This
makes it useful in a variety of scenarios; especially use cases such as
offline cryptography or unit tests against servers programmed in lower level
languages.

Rubenesque is licensed under the BSD 2-Clause license.

Rubenesque currently implements the following curves:
 * brainpoolP160r1
 * brainpoolP192r1
 * brainpoolP224r1
 * brainpoolP256r1
 * brainpoolP320r1
 * brainpoolP384r1
 * brainpoolP512r1
 * edwards25519
 * edwards448
 * secp192r1
 * secp224r1
 * secp256r1
 * secp384r1
 * secp521r1

Here is a simple example of doing ECDH with SEC P256 using SEC1 encoding.

Both sides prepare for the exchange by loading the same curve and encoding:
>>> from rubenesque.codecs.sec import encode, decode
>>> import rubenesque.curves
>>> secp256r1 = rubenesque.curves.by_name('secp256r1')

Alice generates her private and public keys:
>>> alice_prv = secp256r1.private_key()
>>> alice_pub = secp256r1.generator() * alice_prv
>>> alice_enc = encode(alice_pub)

Bob does the same:
>>> bob_prv = secp256r1.private_key()
>>> bob_pub = secp256r1.generator() * bob_prv
>>> bob_enc = encode(bob_pub)

After exchanging their encoded keys, Alice computes the session key:
>>> alice_ses = decode(secp256r1, bob_enc) * alice_prv

Bob does the same:
>>> bob_ses = decode(secp256r1, alice_enc) * bob_prv

Notice that Bob and Alice share the same session key:
>>> alice_ses == bob_ses
True

python-rubenesque's People

Contributors

npmccallum avatar

Watchers

 avatar  avatar

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.