All Projects → dusk-network → dusk-zerocaf

dusk-network / dusk-zerocaf

Licence: MIT license
Zerocaf: A library built for EC operations in Zero Knowledge.

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to dusk-zerocaf

noble-ed25519
Fastest JS implementation of ed25519, x25519 & ristretto255. Independently audited, high-security, 0-dependency EDDSA signatures and ECDH key agreement
Stars: ✭ 220 (+340%)
Mutual labels:  ristretto, elliptic-curve-cryptography
dryoc
Don't Roll Your Own Crypto: pure-Rust, hard to misuse cryptography library
Stars: ✭ 163 (+226%)
Mutual labels:  cryptography-library
pyecsca
Python Elliptic Curve Side-Channel Analysis toolkit.
Stars: ✭ 23 (-54%)
Mutual labels:  elliptic-curve-cryptography
OpenPGP
A C++ Implementation of RFC 4880
Stars: ✭ 87 (+74%)
Mutual labels:  cryptography-library
pysha2
Pure Python implementation of SHA2 (i.e., SHA224, SHA256, SHA384, and SHA512).
Stars: ✭ 52 (+4%)
Mutual labels:  cryptography-library
Mbedtls
An open source, portable, easy to use, readable and flexible SSL library
Stars: ✭ 3,282 (+6464%)
Mutual labels:  cryptography-library
noble-secp256k1
Fastest JS implementation of secp256k1. Independently audited, high-security, 0-dependency ECDSA & Schnorr signatures.
Stars: ✭ 313 (+526%)
Mutual labels:  elliptic-curve-cryptography
bulletproofs
Bulletproofs and Bulletproofs+ Rust implementation for Aggregated Range Proofs over multiple elliptic curves
Stars: ✭ 62 (+24%)
Mutual labels:  bulletproofs
libgodium
Pure Go implementation of cryptographic APIs found in libsodium
Stars: ✭ 46 (-8%)
Mutual labels:  cryptography-library
python-fastpbkdf2
Python bindings for fastpbkdf2
Stars: ✭ 24 (-52%)
Mutual labels:  cryptography-library
sike-java
SIKE for Java is a software library that implements experimental supersingular isogeny cryptographic schemes that aim to provide protection against attackers running a large-scale quantum computer.
Stars: ✭ 28 (-44%)
Mutual labels:  cryptography-library
Botan
Cryptography Toolkit
Stars: ✭ 1,798 (+3496%)
Mutual labels:  cryptography-library
hermes-core
Security framework for building multi-user end-to-end encrypted data storage and sharing/processing with zero leakage risks from storage and transport infrastructure.
Stars: ✭ 72 (+44%)
Mutual labels:  cryptography-library
klefki
Klefki is a playground for researching elliptic curve group based algorithm, such as MPC, ZKP and HE. All data types & structures are based on mathematical defination of abstract algebra.
Stars: ✭ 12 (-76%)
Mutual labels:  elliptic-curve-cryptography
ripp
Argument systems for inner pairing products
Stars: ✭ 34 (-32%)
Mutual labels:  bulletproofs
nim-blscurve
Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381
Stars: ✭ 19 (-62%)
Mutual labels:  elliptic-curve-cryptography
secretpy
Classical ciphers: Caesar, ADFGX, ROT13 and etc.
Stars: ✭ 40 (-20%)
Mutual labels:  cryptography-library
go
Elliptic Curve Integrated Encryption Scheme for secp256k1 in Golang
Stars: ✭ 56 (+12%)
Mutual labels:  elliptic-curve-cryptography
bulletproofs-r1cs-gadgets
Arithmatic circuits convertible to R1CS based on Bulletproofs
Stars: ✭ 65 (+30%)
Mutual labels:  bulletproofs
python-mbedtls
Cryptographic library with an mbed TLS back end
Stars: ✭ 64 (+28%)
Mutual labels:  cryptography-library

Dusk-Zerocaf Build Status codecov GitHub closed issues Crates.io

WARNING: WIP Repo.

Fast, efficient and bulletproof-friendly cryptographic operations.

This repository contains an implementation of the Sonny curve over the Ristretto Scalar field: a pure Rust implementation designed by Dusk team.

Special thanks to Isis Agora Lovecruft and Henry de Valence for their implementation of Curve25519-dalek library, which has been so useful in order to get some of the basic arithmetic ops and the structure of our library.

Ristretto curve

Ristretto is a technique for constructing prime order elliptic curve groups with non-malleable encodings.

The Ristretto protocol arose as an extension of Mike Hamburg's Decaf approach to cofactor elimination, which is applicable to curves of cofactor 4, whereas the Ristretto is designed for non-prime-order curves of cofactor 8 or 4. Ristretto was designed by the dalek-cryprography team, specifically, Henry de Valence and Isis Agora Lovecruft to whom we greatly appreciate their work and dedication.

Ristretto Scalar Field And Bulletproofs.

Originally designed to abstract non-prime-order curves into prime-order scalar fields, the Ristretto abstraction would have been far too inefficient to implement for Bulletproofs zero-knowledge proof. Therefore the Ristretto scalar field is used to solve all negative impacts of using cofactors equalling 8 on the Ristretto curve.. The strategy is to use a Ristretto embedded curve (also called Sonny Curve), as the initial operations within zerocaf are performed therein. zerocaf opens up new opportunities for the use cases of zero-knowledge proofs inside the Dusk Network protocol as well as making a Bulletproof-integrated ring signature substitute possible, with orders of magnitude performance improvements compared to the fastest ringsig implementation.

Within this library, the implementation of the Ristretto to construct the curve with desired properties is made possible by defining the curve over the scalar field, using only a thin abstraction layer, which in turn allows for systems that use signatures to be safely extended with zero-knowledge protocols. These zero-knowledge protocols are utilised with no additional cryptographic assumptions and minimal changes in the code. The Ristretto scalar field is Bulletproof friendly, which makes it possible to use both cryptographic protocols in tandem with one another, as they are centric to contemporary applications of elliptic curve operations.

Details

Curve parameters:

Variable Value Explanation
Equation Edwards -x²+y²=1-$\frac{126296}{126297}$x²y² -
a -1 -
d $-\frac{126296}{126297}$ -
B $\frac{3}{5}$ Edwards Basepoint Y-coordinate With X > 0

Montgomery y²=x³+505186*x²+x
u(P) 4
A 505186

Weierstrass y²=x³+ax+b
a 7237005577332262213973186563042994240857116359379907606001950828033483786813
b 445582015604702849664
Variable Value Explanation
G 2²⁵² + 115924404605461509904689566245241897752 Curve order
p 2²⁵² + 27742317777372353535851937790883648493 Prime of the field
r 2²⁴⁹ + 15114490550575682688738086195780655237219 Prime of the Sub-Group

Encoding / Decoding tools

In order to work with our points along the curve, or any non trivial computuaions, for example those with tough notations - there has been a set of tools and examples which have been created to make facilitate the Encoding/Decoding processes. These can be found at: tools/src/main.rs

Examples

num_from_bytes_le(&[76, 250, 187, 243, 105, 92, 117, 70, 234, 124, 126, 180, 87, 149, 62, 249, 16, 149, 138, 56, 26, 87, 14, 76, 251, 39, 168, 74, 176, 202, 26, 84]);
// Prints: 38041616210253564751207933125345413214423929536328854382158537130491690875468
    
let res = to_field_elem_51(&"1201935917638644956968126114584555454358623906841733991436515590915937358637");
println!("{:?}", res);
// Gives us: [939392471225133, 1174884015108736, 2226020409917912, 1948943783348399, 46747909865470]

hex_bytes_le("120193591763864495696812611458455545435862390684173399143651559091593735863735685683568356835683");
// Prints: Encoding result -> [63, 41, b7, c, b, 79, 94, 7b, 21, d2, fe, 7b, c8, 89, c9, 7f, 76, c8, 9b, a3, 58, 18, 39, a, f2, d2, 7c, 17, ed, 7f, 6, c4, 9d, 44, f3, 7c, 85, c2, 67, e]
// Put the 0x by yourseleves and if there's any value alone like `c` padd it with a 0 on the left like: `0x0c`

from_radix_to_radix_10("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16u32);
// Prints: 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787

When performing operations with large values, such as: 2²⁵² - 121160309657751286123858757838224683208, it is recomended to compute them through SageMath, as the user interface adheres to these types of functions. From SageMath, they can be converted in a consistent format and easily compiled into Rust.

Roadmap:

Note: the refactoring relations are expressed as indentations

  • Build Scalar Arithmetics and Scalar Struct definition.
    • Find the proper radix value for FieldElement.
    • Add the required constants for computation.
      • Implement Addition.
      • implement Subtraction.
      • Implement Byte-encoding/decoding.
      • Implement From for uint native types.
      • Implement Ord, PartialOrd, Eq & PartialEq.
      • Implement Multiplication on u64-backend with u128 usage.
      • Implement Squaring.
      • Implement Half for even numbers.
      • Implement Modular Negation.
      • Implement Montgomery_reduction.
      • Define Montgomery_reduction algorithm.
  • Create FieldElement Struct and implement the basic operations we need on a u64 backend.
    • Find the proper radix value for FieldElement.
    • Add basic and needed constants.
    • Implement Reduce function to make the FieldElements fit on a 5 u64-bit limbs.
      • Implement Addition.
      • Implement Subtraction.
      • Implement Byte-encoding/decoding.
      • Implement From for uint native types.
      • Implement Ord, PartialOrd, Eq & PartialEq.
      • Implement Multiplication on u64-backend with u128 usage.
      • Implement Squaring.
      • Implement Half for even numbers
      • Implement Modular Negation.
      • Implement Montgomery_reduction.
      • Define Montgomery_reduction algorithm.
      • Implement Modular inversion.
      • Research about addition chains inversion methods.
    • Add proper tests for every function.
  • Implement Edwards Points
    • Implement Twisted Edwards Extended Coordiantes.
      • Implement Point Addition.
      • Implement Point Subtraction.
      • Implement Point Doubling.
      • Implement Scalar Mul.
      • Implement from_bytes conversions.
      • Implement to byte conversions.
      • Implement compressed Edwards point Y-coordinate.
    • Implement Twisted Edwards Projective Coordiates.
      • Implement Point Addition.
      • Implement Point Subtraction.
      • Implement Point Doubling.
      • Implement Scalar Mul.
      • Implement from_bytes conversions.
      • Implement to byte conversions.
      • Implement compressed Edwards point Y-coordinate.
    • Represent Edwards points as Ristretto points using wrapping type or struct.
    • Cargo doc testing and improvement.
    • Decide the best use cases of the various Edwards coordinate types (compressed, standard, extended, projective).
    • Benchmark different implementations and algorithms.
  • Implement Ristretto Mapping.
    • Implement 4coset debugging function.
    • Build and test torsion points.
    • Implement Ecoding & Decoding algorithms.
    • Implement Equalty testing.
    • Implement Elligator-ristretto-flavour.
    • Test all of the algorithms implemented.
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].