Skip to content

penumbra-zone/decaf377

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b75c815 · Nov 19, 2024
Jan 31, 2024
Jan 31, 2024
Feb 8, 2024
Jan 30, 2024
Jul 1, 2024
Nov 19, 2024
Jan 23, 2024
Apr 27, 2021
Jul 1, 2024
Jul 1, 2024
Nov 19, 2024
Nov 15, 2022
Aug 4, 2022

Repository files navigation

decaf377

Crates.io

Many zero-knowledge protocols require a cryptographic group that can be used inside of an arithmetic circuit. This is accomplished by defining an “embedded” elliptic curve whose base field is the scalar field of the proving curve used by the proof system.

The Zexe paper, which defined BLS12-377, also defined (but did not name) a cofactor-4 Edwards curve defined over the BLS12-377 scalar field for exactly this purpose. However, non-prime-order groups are a leaky abstraction, forcing all downstream constructions to pay attention to correct handling of the cofactor. Although it is usually possible to do so safely, it requires additional care, and as discussed below, the optimal technique for handling the cofactor is different inside and outside of a circuit.

Instead, applying the Decaf construction to this curve gives decaf377, a clean abstraction that provides a prime-order group, complete with hash-to-group functionality, and works the same way inside and outside of a circuit.

More details are available on the Penumbra website.

Features

  • std: default, for use in std environments,
  • alloc: default, for use in alloc environments,
  • arkworks: default, uses Arkworks crates for elliptic curve operations,
  • u32_backend: uses 32-bit finite field arithmetic (default is 64-bit),
  • r1cs: enables rank-1 constraint system gadgets,
  • parallel: enables the use of parallelism.

Benchmarks

Run criterion benchmarks using:

cargo bench

This will generate a report at target/criterion/report/index.html.

Generate Test Vectors

There is a test utility that will generate the proving and verifying keys for the R1CS tests. These keys are pre-generated to guard against breaking changes to the circuits (e.g. when upgrading Arkworks dependencies).

cargo test generate_test_vectors -- --ignored