Commit Graph

247 Commits

Author SHA1 Message Date
ebfull fa9be45588
Merge pull request #58 from zkcrypto/release-0.8.1
Release v0.8.1
2020-11-10 11:39:04 -07:00
Sean Bowe 2059de8bb3
Release v0.8.1 2020-11-10 11:33:02 -07:00
ebfull a51a6a08f8
Merge pull request #55 from w3f/pub-multiexp
Makes multiexp module public
2020-11-10 07:34:35 -07:00
ebfull a2c22a474e
Merge pull request #57 from zkcrypto/fix-nightly-deref-issue
Fix deref breakage with nightly-2020-10-06
2020-11-02 09:23:04 -07:00
Jack Grigg a5ff6f514b Fix deref breakage with nightly-2020-10-06
Fixes the following error:
  cannot multiply-assign `<E as Engine>::Fr` by `&&<E as Engine>::Fr`

I think this is related to:
  https://github.com/rust-lang/rust/issues/77638
2020-10-30 00:25:57 +00:00
Sergey Vasilyev eec6155ec4 makes multiexp module public 2020-10-25 23:26:35 +03:00
ebfull 0f2244fdb4
Merge pull request #53 from zkcrypto/release-0.8.0
Release 0.8.0
2020-09-08 17:04:14 -06:00
Jack Grigg f0141b6f69 bellman 0.8.0 2020-09-08 23:54:10 +01:00
ebfull e35089357e
Merge pull request #52 from zkcrypto/ff-0.8
Fix performance regression in multiexp
2020-09-08 16:53:05 -06:00
Jack Grigg f3c8d4e634 Add Actions CI workflow 2020-09-08 23:46:57 +01:00
Jack Grigg ec638e4d02 Replace bit-vec crate with bitvec 2020-09-08 23:44:20 +01:00
Jack Grigg e6a404a29e Pass exponent bits into multiexp instead of exponents themselves
This de-duplicates multiple Montgomery reductions.
2020-09-08 23:44:20 +01:00
Jack Grigg f90fa65a32 Migrate to ff 0.8
MSRV is now 1.44.0, matching the ff crate.
2020-09-08 23:44:20 +01:00
ebfull 81f4aac8c7
Merge pull request #50 from zkcrypto/release-0.7.0
Release 0.7.0
2020-08-25 16:34:28 -06:00
Jack Grigg 212f8ae3fe 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:33:43 +01:00
Jack Grigg 227890761a Add missing intra-doc link 2020-08-25 23:32:14 +01:00
Jack Grigg 9738f45d1d s/into_iter/iter to fix warnings 2020-08-25 23:30:20 +01:00
Jack Grigg 18a85dc3bd Remove unnecessary extern crates
Since Rust 2018, these are implied.
2020-08-25 23:29:52 +01:00
Jack Grigg 2030fb488b bellman 0.7.0 2020-08-25 23:11:18 +01:00
Jack Grigg c3cfe43dad bls12_381 0.2.0 2020-08-25 23:11:18 +01:00
Jack Grigg 1f3ffdd5a1 pairing 0.17.0 2020-08-25 23:11:18 +01:00
Jack Grigg 9d85d4eac3 group 0.7.0 2020-08-25 23:11:18 +01:00
Jack Grigg 8521902516 ff 0.7.0 2020-08-25 23:11:18 +01:00
Jack Grigg 459fa4a635 pairing: Remove BLS12-381 implementation
It is replaced by the bls12_381 crate.
2020-08-25 23:11:18 +01:00
Jack Grigg 200901d496 s/{pairing::bls12_381, zcash_primitives::jubjub}/{bls12_381, jubjub}
FINALLY.
2020-08-25 23:11:18 +01:00
Jack Grigg 6c76adca08 bellman: Migrate to bit-vec 0.6 2020-08-25 23:11:18 +01:00
Jack Grigg 10ac7ce51f bellman: Migrate to sha2 0.9 2020-08-25 23:11:18 +01:00
Jack Grigg b6a2e4e485 pairing: Require G1 and G2 to be PrimeCurve
Pairings require that G1, G2, and GT are groups of prime order.
2020-08-25 23:11:18 +01:00
Jack Grigg 74c7d4914d 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 23:11:18 +01:00
Jack Grigg 6875667f1d 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 23:11:18 +01:00
Henry de Valence e534f36ec4 bellman: add VerificationError (#254)
* bellman: add VerificationError

This adds a distinct VerificationError type to the crate and changes
`verify_proof` to return `Result<(), VerificationError>` rather than
`Result<bool, SynthesisError>`.  This is significantly safer, because it avoids
the need to mix pattern-matching logic with boolean logic (the cause of
RUSTSEC-2019-0004).

* Rename VerificationError variants per review comments.

* Add missing Clone impl to VerificationError.
2020-08-25 23:11:18 +01:00
Jack Grigg 701e6cfa1b 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 23:11:18 +01:00
Jack Grigg 0c9e783172 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 23:11:18 +01:00
Jack Grigg a77b2c8623 group: Renaming prior to trait refactor
This will reduce the size of the subsequent refactor diff.
2020-08-25 23:11:18 +01:00
Jack Grigg 8142ece846 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 23:11:18 +01:00
Jack Grigg 9397e78789 group: Extract compressed encodings from CurveAffine trait 2020-08-25 23:11:18 +01:00
Jack Grigg f490cdc674 group: Default implementation of CurveProjective::batch_normalize
For convenience. Implementations will usually override this to take
advantage of implementation-specific batching optimisations.
2020-08-25 23:11:18 +01:00
Jack Grigg 06c2c37b28 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 23:11:18 +01:00
Jack Grigg a1a27128f2 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 23:11:18 +01:00
Jack Grigg 02dc1763a3 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 23:11:18 +01:00
Jack Grigg ee6e00b0e7 pairing: Pass affine references to Engine::pairing 2020-08-25 23:11:17 +01:00
Jack Grigg 5eb58836ce pairing: Move final_exponentiation into a MillerLoopResult trait 2020-08-25 23:11:17 +01:00
Jack Grigg fd53dbc6f2 pairing: Separate associated types for MillerLoopResult and Gt 2020-08-25 23:11:17 +01:00
Jack Grigg f5254a1b8a 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 23:11:17 +01:00
Jack Grigg 2215865538 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 23:11:17 +01:00
Jack Grigg 025746cdc8 ff: Remove ScalarEngine 2020-08-25 23:11:17 +01:00
Jack Grigg 2e540e681c bellman: Replace E: ScalarEngine with Scalar: PrimeField
Instead of imposing the requirement that bellman users explicitly
specify an engine for every proving system, we allow the Rust type
system to figure it out for us. An engine is specifically useful in
places where we require defined relationships between several types;
ff::ScalarEngine only has one type, and thus any usage of it can be
trivially replaced by an explicit Scalar type. This is also more
readable :)
2020-08-25 23:11:05 +01:00
Jack Grigg 027847f543 Fix various lints 2020-08-25 23:09:47 +01:00
Jack Grigg cbe8c5de67 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 23:09:47 +01:00
Jack Grigg 392a107b31 group: Remove EncodedPoint::from_affine
The EncodedPoint trait is replaced by explicit bounds on the
CurveAffine::{Uncompressed, Compressed} associated types.
2020-08-25 23:09:47 +01:00