Skip to content

About

Cryptographic Primitives for Blockchain Systems (solidity, cairo, C and rust)

Topics

Resources

Stars

165 stars

Watchers

7 watching

Forks

Repository files navigation

Fresh Crypto Lib (FCL)

The Fresh Crypto Lib is a set of functions for blockchain systems such as Wallet, SmartContracts.

*** 15/05/24 : Deprecated

*** This library is an experimental prequel of SCL. SCL proposes more generic implementation with RIP7696 for lesser cost (beating record set by FCL) and is currently under audit. https://github.com/get-smooth/crypto-lib.

*** new (27/05/24): SCL now supports both Ed25519 and P256 using RIP7696.

*** new (06/08/24): SCL first audit completed, second VERIDISE audit being reviewed (FCL has no audit).

*** new (17/11/26): FCL_elliptic.sol is about 26 % cheaper for P256 verification with the same API, and BabyJubJub (circomlib) EdDSA verification is added. See solidity/src/README.md.

*** We warmly thanks all contributors of FCL, they will be added as contributor to SCL.

Content

The implemented content is:

  • sec256r1 optimizations for EVM chains and Starknet
  • BabyJubJub (circomlib) EdDSA verification for EVM chains
  • an ecdaa implementation using blockchain primitives
  • a Starknet dedicated musig2 implementation

Directory solidity:

  • FCL_ecdsa.sol: an EVM optimized implementation of ecdsa over sec256r1(P256), using language hacks and specificities, as described in paper https://eprint.iacr.org/2023/939.pdf.
  • FCL_elliptic.sol: the XYZZ engine behind FCL_ecdsa.sol, uG+vQ with a joint 2-bit window and a batch normalized table.
  • FCL_eddsa.sol : an EVM optimized implementation of ed25519, using same paper tricks.
  • FCL_babyjubjub.sol: circomlib EdDSA verification over BabyJubJub, through the isomorphism to a short Weierstrass curve with a=-3 (same idea as Wei25519 in SCL), reusing the FCL_elliptic.sol engine.
  • FCL_babyjubjub_edwards.sol: the same verification on the a=-1 twisted Edwards model, with complete formulas.
  • FCL_sha512.sol : implementation of the SHA512 primitive (single bloc implementation)
  • FLC_Webauthn.sol: implementation of the WebAuthn2/FIDO2 authentication over ECDSA with P256
PR # Create2 Mainnets Testnets
46 0xE9399D1183a5cf9E14B120875A616b6E2bcB840a Polygon Optimism, Sepolia, Linea

(code is verified except for linea, one could check that bytecode is identical).

Directory cairo0.9:

  • FCL_ec_mulmuladd.cairo: an implementation of the operation aP+bQ (addition of the results of two distincts point multiplication by scalar a and b). It uses the Shamir's trick with the windowing method. signature_opt.cairo : optimisation of ECDSA verification using ec_mulmuladd_W function

Note : The language is now deprecated since its transition from python-like to rust-like language.

Directory sage:

  • FCL_ecdsa_precompute.sage : precompute bytecode contract to speed up ecdsa verification for a given key.
  • FCL_ecdaa : sage reference for a blockchain implementation of ECDAA
  • FCL_pairings : sage implementation of curve and pairing computation over BN254 (aka altbn128) and BLS12381 using INRIA sources.

Acknowledments:

Building Blocks

The following repos are used as building blocks in the FCL:

Benchmark

The following repos have been used in benchmarks:

Testing

FCL in the wild

Do not hesitate to reach us to be listed.

License

License: This software is licensed under MIT License (see LICENSE FILE at root directory of project).

About

Cryptographic Primitives for Blockchain Systems (solidity, cairo, C and rust)

Topics

Resources

Stars

165 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages