Commit Graph

274 Commits

Author SHA1 Message Date
ebfull 50a2bc3d67
Merge pull request #116 from zkcrypto/release-0.18.0
Release 0.18.0
2020-09-08 15:50:48 -06:00
Jack Grigg 07aba01ef4 pairing 0.18.0 2020-09-08 22:46:11 +01:00
ebfull 51958fd947
Merge pull request #115 from zkcrypto/ci
Actions: Add CI workflow
2020-09-08 15:42:20 -06:00
Jack Grigg 24265c228e Migrate to ff 0.8
MSRV is bumped to 1.44.0, which is required for the ff crate.
2020-09-08 22:40:03 +01:00
Jack Grigg 55eef836f4 no-std support 2020-09-08 18:17:19 +01:00
Jack Grigg 9ed8b27827 Remove obsolete feature flags 2020-09-08 18:05:44 +01:00
Jack Grigg 7717ba5007 Fix dependencies
- Fixes no-std support.
- Removes obsolete dependencies.
2020-09-08 18:03:57 +01:00
Jack Grigg bd0039ff93 Actions: Add CI workflow 2020-09-08 17:57:40 +01:00
ebfull 6d22b98925
Merge pull request #114 from zkcrypto/release-0.17.0
Release 0.17.0
2020-08-25 16:07:20 -06:00
Jack Grigg 7d43d53a96 Remove paths from dependencies
Now that we have extracted the release changes from the
zcash/librustzcash subtree, we are no longer in a workspace with
relative paths to these dependencies.
2020-08-25 23:05:23 +01:00
Jack Grigg c78a299646 pairing 0.17.0 2020-08-25 22:59:57 +01:00
Jack Grigg d7a7034bc6 group 0.7.0 2020-08-25 22:59:57 +01:00
Jack Grigg 67ea8f1177 ff 0.7.0 2020-08-25 22:59:57 +01:00
Jack Grigg e7be89c7a5 pairing: Remove BLS12-381 implementation
It is replaced by the bls12_381 crate.
2020-08-25 22:59:57 +01:00
Jack Grigg bac16ab134 Remove unused import 2020-08-25 22:59:57 +01:00
Jack Grigg 7d603ee323 pairing: Require G1 and G2 to be PrimeCurve
Pairings require that G1, G2, and GT are groups of prime order.
2020-08-25 22:59:57 +01:00
Jack Grigg 6f3a62d32e group: Hard-code a w-NAF window size of 4
We were already ignoring the actual bit length of the scalar, and
selecting the window size based on the maximum bit length, which
effectively hard-coded a window size of 4.
2020-08-25 22:59:57 +01:00
Jack Grigg 3488723dfa group: CofactorGroup::mul_by_cofactor -> CofactorGroup::clear_cofactor
The generic API now only guarantees that the torsion component is
cleared deterministically; group elements may be multiplied by multiples
of the cofactor (not necessarily the actual cofactor), as long as the
choice of multiplier is fixed for a given implementation.
2020-08-25 22:59:56 +01:00
Jack Grigg e608280011 pairing: Bound Engine::Gt on Group instead of Field 2020-08-25 22:59:56 +01:00
Jack Grigg 0a5cee2924 group: Make Wnaf generic over Group
Wnaf was originally generic over CurveProjective; in the prior refactor
commit, we renamed this to CofactorCurve. But w-NAF only requires scalar
multiplication, which is provided by the Group trait, so we relax the
bounds on Wnaf to enable it to be used with any group. We move the
generic w-NAF helper methods from the Curve trait to a new WnafGroup
extension trait, to keep the w-NAF API surface self-contained, and not
expose it to users who aren't using it.
2020-08-25 22:59:56 +01:00
Jack Grigg 0825cfcef9 group: Separate prime and cofactor traits into modules
Instead of having the Group crate hold a Subgroup associated type (and
thus needing to define the subgroup of a prime-order group as itself),
we specify two separate sets of traits for prime-order groups and ones
with a cofactor.

Protocol implementors can either restrict their implementations to only
work with PrimeGroup, or can explicitly choose to support CofactorGroup
and then explicitly handle the subgroup edge cases with e.g.
CofactorGroup::mul_by_cofactor (which would be a no-op for PrimeGroup).

Protocol implementors can also choose to specialise to elliptic curves
if they want to leverage an affine representation and mixed addition in
their protocol for efficiency, or they can ignore those traits and stick
with the simpler group-focused traits.
2020-08-25 22:59:56 +01:00
Jack Grigg d8e80917f5 group: Renaming prior to trait refactor
This will reduce the size of the subsequent refactor diff.
2020-08-25 22:59:56 +01:00
Jack Grigg 225df50d5a group: Remove "compressed" notion from GroupEncoding
A generic group has a single encoding; for elliptic curves, this
happens to be the compressed encoding.
2020-08-25 22:59:56 +01:00
Jack Grigg adc3cce7e7 group: Extract compressed encodings from CurveAffine trait 2020-08-25 22:59:56 +01:00
Jack Grigg bab464901b group: Move uncompressed encodings to an UncompressedEncoding trait
Specifications of deployed elliptic curves fall into one of two
categories:
- They specify both compressed and uncompressed encodings, allowing
  implementations to use either depending on performance vs data size
  considerations.
- They specify a single point encoding format using point compression.

I am unaware of any elliptic curve specification that explicitly forbids
compressed encodings.

To support both categories of elliptic curves, we provide the
CurveAffine::Compressed associated type which all curves must define,
and then curves that additionally specify an uncompressed encoding may
implement the UncompressedEncoding trait and its Uncompressed associated
type.

pairing::PairingCurveAffine continues to require that its groups provide
uncompressed encodings, because this is relied upon by bellman::groth16.
We can revisit this restriction when that module is refactored as a
separate crate.
2020-08-25 22:59:56 +01:00
Jack Grigg 938b33fd4e pairing: Move PairingCurveAffine::Prepared to MultiMillerLoop trait
Prepared elements are only used by MultiMillerLoop, and we don't need
the ability to "prepare" G1 elements there.
2020-08-25 22:59:29 +01:00
Jack Grigg 911a16c120 pairing: Extract Engine::miller_loop into a MultiMillerLoop trait
This enables MultiMillerLoop to be conditionally implemented, for
example in libraries where Engine::pairing supports no-std, but
MultiMillerLoop requires an allocator.
2020-08-25 22:58:56 +01:00
Jack Grigg c3b831561d pairing: Pass affine references to Engine::pairing 2020-08-25 22:58:56 +01:00
Jack Grigg b804489a0f pairing: Move final_exponentiation into a MillerLoopResult trait 2020-08-25 22:58:56 +01:00
Jack Grigg d1bd888d97 pairing: Separate associated types for MillerLoopResult and Gt 2020-08-25 22:58:56 +01:00
Jack Grigg bd58777ab6 pairing: Remove Engine::Fq and Engine::Fqe
These are unused now that the Base associated types have been removed
from the group traits.
2020-08-25 22:58:56 +01:00
Jack Grigg 307aa1f29d group: Remove CurveProjective::Base and CurveAffine::Base
These associated types were completly unused. The only place we need
information about the base field of an elliptic curve is inside Jubjub
when operating over its coordinates to implement EC math inside the
circuit, and we can handle that either concretely, or with a future
trait specifically for that use-case.
2020-08-25 22:58:56 +01:00
Jack Grigg 84b8365eea ff: Remove ScalarEngine 2020-08-25 22:58:56 +01:00
Jack Grigg 089f43b508 Fix various lints 2020-08-25 22:58:56 +01:00
Jack Grigg 692b45c803 group: Rename into_*(&self) -> to_*(&self)
Rust naming convention uses the into_ prefix for methods that consume
self, and the to_ prefix for methods that take an immutable reference.
2020-08-25 22:58:56 +01:00
Jack Grigg 60ca2e13b3 group: Remove EncodedPoint::from_affine
The EncodedPoint trait is replaced by explicit bounds on the
CurveAffine::{Uncompressed, Compressed} associated types.
2020-08-25 22:58:56 +01:00
Jack Grigg 70723542d8 group: Remove EncodedPoint::{into_affine, into_affine_unchecked}
Replaced by explicit APIs on the CurveAffine trait.

GroupDecodingError has been moved into pairing::bls12_381::ec, as it is
no longer used by the group traits.
2020-08-25 22:58:56 +01:00
Jack Grigg 5360a59a1d group: Add mixed-addition scalar multiplication bounds to CurveAffine
Replaces the explicit CurveAffine::mul trait method.
2020-08-25 22:58:56 +01:00
Jack Grigg 68b89e6c24 group: Return subtle::Choice from CurveAffine::is_identity 2020-08-25 22:58:56 +01:00
Jack Grigg a58fe58da7 group: Direct-to-affine CurveProjective::batch_normalize
Replaces the mutating CurveProjective::batch_normalization API, and
removes the need for CurveProjective::is_normalized.

The new temporary implementation in pairing::bls12_381::ec is adapted
from bls12_381::g1.
2020-08-25 22:58:56 +01:00
Jack Grigg 7bc9e8f375 group: Return subtle::Choice from Group::is_identity 2020-08-25 22:58:56 +01:00
Jack Grigg 00cf3f7dfa group: Add scalar multiplication bounds to Group
The Scalar associated type is moved from CurveProjective to Group.
2020-08-25 22:58:56 +01:00
Jack Grigg c95fe43b1b group: Add Group::Subgroup associated type
For prime-order groups, this may be Self.
2020-08-25 22:58:56 +01:00
Jack Grigg 9f9d100600 group: Move CurveProjective::double to Group 2020-08-25 22:58:56 +01:00
Jack Grigg cbb613b87c group: Sum + for<'a> Sum<&'a Self> bounds for Group 2020-08-25 22:58:56 +01:00
Jack Grigg 901f7f3213 group: Define group operations on Group trait
The GroupOps trait represents the group operation (addition), and the
combination of the group operation with group inversion (subtraction).
Group inversion (negation) is constrained directly on the Group trait.
2020-08-25 22:58:56 +01:00
Jack Grigg 44d04b28db group: Introduce Group and PrimeGroup traits
Group represents a cryptographic group with a large prime-order subgroup
and a small cofactor. PrimeGroup further constrains the group to have a
cofactor of one.
2020-08-25 22:58:56 +01:00
Jack Grigg cb110f58a4 Remove Engine associated type from CurveAffine and CurveProjective
The type Curve*::Engine::Fr is equivalent to Curve*::Scalar, making
Engine a redundant associated type.
2020-08-25 22:58:56 +01:00
Jack Grigg 9a332c025d Make CurveProjective::double take &self and return Self 2020-08-25 22:58:56 +01:00
Jack Grigg 5b6481160f group: Rename zero and one to identity and generator 2020-08-25 22:58:56 +01:00