Git Product home page Git Product logo

curve25519-elisabeth's Introduction

curve25519-elisabeth Maven Central Build Status Codecov

A pure-Java implementation of group operations on Curve25519.

Requires Java 7 or higher. Requires JDK 10 or higher to build.

Usage

Gradle

implementation 'cafe.cryptography:curve25519-elisabeth:0.1.0'

Apache Maven

<dependency>
  <groupId>cafe.cryptography</groupId>
  <artifactId>curve25519-elisabeth</artifactId>
  <version>0.1.0</version>
</dependency>

Documentation

To view the public-facing API documentation, first build it:

./gradlew javadoc

Then open build/docs/javadoc/index.html in your browser.

Internal documentation

The unstable internal implementation details are also documented. To build them:

./gradlew internalDocs

Then open build/docs/internal/index.html in your browser.

Safety

The curve25519-elisabeth types are designed to make illegal states unrepresentable. For example, any instance of an EdwardsPoint is guaranteed to hold a point on the Edwards curve, and any instance of a RistrettoElement is guaranteed to hold a valid element in the Ristretto group.

These guarantees only hold if the internal implementation details of the types are opaque. We use several techniques to achieve this in modern Java environments:

  • For all classes that implement java.io.Serializable, the serialization APIs are overridden to use the encoded form of the respective type, instead of directly serializing the internal representation.

  • For Java 9 and above, when this library is in the module path, reflection cannot be used to access non-public classes or fields.

Usage of Java's reflection APIs on types from this library (in legacy environments or configurations where it is possible to do so) is NOT supported.

All operations are implemented using constant-time logic (no secret-dependent branches, no secret-dependent memory accesses), unless specifically marked as being variable-time code. However, while our constant-time logic is lowered to constant-time JVM bytecode, we cannot guarantee that the JVM will not figure out ways to optimise away constant-time logic.

About

curve25519-elisabeth is authored by Jack Grigg.

The field arithmetic was originally extracted from Jack's Java Ed25519 library, which was in turn a port of the reference ref10 implementation.

Test vectors, and the UnpackedScalar arithmetic, were ported from curve25519-dalek, authored by isis agora lovecruft and Henry de Valence. Their library has also influenced the design of this one.

Elisabeth Pepys was the wife of Samuel Pepys. The Third Doctor remembered her as making the best cup of coffee he had ever had. Shortly thereafter, the Fourth Doctor claimed to have met her along with her husband. In his twelfth incarnation, the Doctor still regarded Elisabeth's coffee as the best coffee in the universe.

curve25519-elisabeth contains an experimental implementation of the Ristretto prime-order group.

curve25519-elisabeth's People

Contributors

dependabot[bot] avatar isislovecruft avatar str4d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

curve25519-elisabeth's Issues

Set up as a Java module

An important part of a good cryptographic library is its API. By and large, we only want downstream libraries and applications to use the interface that we have defined, because it helps to ensure that (often security-critical) invariants are enforced (e.g. that an invalid Ristretto group element is unrepresentable, because the only way to instantiate one is through the DECODE or FROM_UNIFORM_BYTES functions).

Currently, the way we enforce the API is by keeping all internal classes inside the same package as the API, so that they can be package-private. Java only provides two levels of visibility for classes - public, and package-private - so this is the only way to keep the implementation accessible to the classes providing the API, without giving the implementation public visibility.

However, this still suffers from reflection: anyone with reflection priviledges can make any class (or its members) visible. Java 7 and 8 provide no way for libraries to override this; reflection can only be disabled at the system level via security permissions.

Java 9 introduced the concept of modules, which enable strong encapsulation by preventing reflection into a package by default. Libraries can use this to export their API without exposing any internals, and reflection for exported APIs is disabled. Only when a package is "opened" can reflection be performed. This can be overridden by the user at the system level (by passing flags to the JVM), but it's a significantly improved barrier, and more effectively encourages use of the intended API.

This issue requires:

  • Creating a module-info.java exporting the intended API.
  • Configuring the build system to compile module-info.java targeting Java 9, while leaving the rest of the codebase targeting Java 7.
  • Testing that the module correctly prevents reflection on Java 9 and above.

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.