Commit Graph

91 Commits

Author SHA1 Message Date
Jack Grigg 4edff96321 Fix various lints 2020-05-22 18:52:35 +12:00
Jack Grigg 5f1607c9b5 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-05-20 11:32:12 +12:00
Jack Grigg ceecd32ac4 group: Remove EncodedPoint::from_affine
The EncodedPoint trait is replaced by explicit bounds on the
CurveAffine::{Uncompressed, Compressed} associated types.
2020-05-20 11:32:12 +12:00
Jack Grigg b77f8dddda 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-05-20 11:32:12 +12:00
Jack Grigg b0a3713d7e group: Add mixed-addition scalar multiplication bounds to CurveAffine
Replaces the explicit CurveAffine::mul trait method.
2020-05-20 11:32:12 +12:00
Jack Grigg 0941dddc13 group: Return subtle::Choice from CurveAffine::is_identity 2020-05-20 11:32:12 +12:00
Jack Grigg b94d567076 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-05-20 11:32:12 +12:00
Jack Grigg 669f2b43eb group: Return subtle::Choice from Group::is_identity 2020-05-15 10:24:30 +12:00
Jack Grigg ec88778258 group: Add scalar multiplication bounds to Group
The Scalar associated type is moved from CurveProjective to Group.
2020-05-15 10:24:30 +12:00
Jack Grigg 0df950dc0d group: Add Group::Subgroup associated type
For prime-order groups, this may be Self.
2020-05-15 00:20:32 +12:00
Jack Grigg d2aa87f084 group: Move CurveProjective::double to Group 2020-05-15 00:20:32 +12:00
Jack Grigg e3d84280b9 group: Sum + for<'a> Sum<&'a Self> bounds for Group 2020-05-15 00:20:32 +12:00
Jack Grigg 69f53febcf 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-05-15 00:20:32 +12:00
Jack Grigg 7203a7a30a 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-05-15 00:20:32 +12:00
Jack Grigg 8add78a327 Make CurveProjective::double take &self and return Self 2020-05-15 00:20:32 +12:00
Jack Grigg 4f2220fbb1 group: Rename zero and one to identity and generator 2020-05-15 00:20:32 +12:00
Jack Grigg d7d49285d8 Remove explicit std::marker from Sized bound
Sized is always part of the prelude, and binding on std causes
compilation issues for no-std crates.
2020-05-15 00:20:32 +12:00
Jack Grigg c597db59a6 ff: Rename PrimeField::into_repr -> PrimeField::to_repr 2020-05-02 18:55:13 +12:00
Jack Grigg 15e229509a ff: Move pow_vartime back into Field trait
The only places we don't use constant u64 limbs, we use PrimeField::char
instead (except in a single test where we use a field element).
2020-05-02 18:54:02 +12:00
Jack Grigg fb31d09218 ff: Remove Ord bound from PrimeField
ff_derive still implements Ord and PartialOrd for the fields it
implements, because pairing::bls12_381 internally assumes that those are
implemented. Once we delete that implementation, we will remove the Ord
and PartialOrd implementations from ff_derive.
2020-05-02 18:54:02 +12:00
Jack Grigg 38f87c2e73 ff: Add PrimeField::ReprEndianness associated type
This enables generic code to reliably operate on the bits of an encoded
field element, by converting them to and from a known (little)
endianness.

The BitAnd and Shr bounds on PrimeField are now removed, as users can
perform these operations themselves as needed.
2020-05-02 18:54:02 +12:00
Jack Grigg 55568b4d6e ff: Remove frobenius_map from Field trait
It is only used internally in the bls12_381 crate, and field extensions
aren't exposed anywhere in the Zcash stack.
2020-05-02 16:07:48 +12:00
Jack Grigg 1761ebfb35 ff: Remove SqrtField trait
The sqrt() function is now part of the Field trait. ff_derive returns an
error on fields for which it does not support generating a square root
function.

Note that Fq6 and Fq12 in pairing::bls12_381 leave the function
unimplemented. They will be dropped once the migration to the bls12_381
crate is complete. The equivalent structs in that crate are not exposed.
2020-05-02 16:07:48 +12:00
Jack Grigg 49f119fb03 ff: Remove PrimeFieldRepr trait
The ff::PrimeField::Repr associated type now has the minimal necessary
bounds, which can be satisfied by a newtype around a byte array.
2020-04-23 18:15:14 +12:00
Jack Grigg 1fe3e3784c ff: Add Ord bound to PrimeField 2020-04-23 17:31:33 +12:00
Jack Grigg 08500ee712 ff: PrimeField: BitAnd<u64, Output = u64> + Shr<u32, Output = Self> 2020-04-23 16:23:24 +12:00
Jack Grigg 1fdca393bb ff: PrimeField::{is_even, is_odd} 2020-04-23 16:23:24 +12:00
Jack Grigg 232f0a50b8 ff: Rework BitIterator to work with both u8 and u64 limb sizes
This enables BitIterator to be used with both the byte encoding and limb
representation of scalars.
2020-04-23 16:23:24 +12:00
Jack Grigg fd79de5408 ff: Add PrimeField: From<u64> constraint 2020-04-23 16:23:24 +12:00
Jack Grigg b6457a905b ff: Move pow_vartime into a trait that is generic over the limb size
The trait is implemented by default for u8 and u64, allowing pow_vartime
to be used with both the byte encoding and limb representation of field
elements.
2020-03-28 00:27:59 +13:00
Jack Grigg 69c60530d4 group: Rewrite wNAF to remove dependency on ff::PrimeFieldRepr
Adapted from Scalar::non_adjacent_form in curve25519-dalek.
2020-03-26 22:32:17 +13:00
Jack Grigg 6e53cf3c4c group: Take scalar by reference in CurveProjective::recommended_wnaf_for_scalar 2020-03-26 19:00:46 +13:00
Jack Grigg 2df2a2b2f2 Merge branch 'develop' 2020-03-14 10:36:58 +13:00
Sean Bowe 100878cd14
Version bump of all crates (except librustzcash) 2020-03-12 15:59:19 -06:00
Sean Bowe f3f8964001
Remove Sized for RngCore
Co-authored-by: Weiliang Li <to.be.impressive@gmail.com>
2020-03-12 15:32:44 -06:00
Sean Bowe b52e4aac3a
Fix Field::random method declarations. 2020-03-03 17:47:29 -07:00
Sean Bowe c49aaceb5d
Merge commit 'f337eb1f5c67d9305b1fb4fb35507bb50817259b' into depends-updates-2 2020-03-03 17:46:59 -07:00
Sean Bowe f337eb1f5c Squashed 'bellman/' changes from 4272cfa..2279da4
2279da4 Merge pull request #38 from debris/docs
2e57190 Remove documentation entry from Cargo.toml
346d540 bellman 0.2.0
8d79665 Merge pull request #93 from defuse/qed-it-lrz
f50079f Crate docs
701cb2b Update READMEs
ccf1ee9 CI: Check intra-doc links
ddd390a Add READMEs to Cargo.toml files
54d3122 Add missing cs.is_satisfied() to bellman test
52bf23c Fix build warnings
581ad35 boolean: adds tests for alloc_conditionally
0403396 blake2s: adds test vectors from go-jubjub
9f24e47 Fix blake2s test data length assertion.
42d5b3b Add blake2s test vectors for varying sizes from go-jubjub
b2597de pedersen_hash: removes debug prints
c903fad pedersen hashes: example of size limit bug
bc697c1 bellman: Fix compile errors without multicore feature
a4e5df9 Upgrade to hex-literal 0.2
c063509 Migrate bellman to crossbeam 0.7
1775843 Take self directly in into_* functions
614d784 Rename into_ -> to_ where &self is used.
08664b1 Address various clippy warnings/errors in bellman
bb11ef2 cargo fmt
cff2e2f cargo fix --edition-idioms for bellman
dc2a280 Add edition = 2018
1a2bc19 cargo fmt
ad37878 cargo fix --edition for bellman
e73d1a2 cargo fmt bellman
dfb86fc Move generic circuit gadgets into bellman
9b3d766 Migrate to rand 0.7
055280f Migrate ff, group, pairing, and bellman to rand 0.6
533d586 Migrate bellman to rand 0.5
bfa9aaf Merge pull request #61 from rex4539/fix-typos
3dd8490 Place bellman multicore operations behind a (default) feature flag
955e679 Merge pull request #46 from str4d/ff-traits
d4ddaa9 Fix typos
12f93f2 Add ff and group crates to Cargo workspace
2e35a32 Update sapling-crypto crate to use ff crate
2019e63 Update workspace after pulling in external crates

git-subtree-dir: bellman
git-subtree-split: 2279da422c
2020-03-03 17:46:04 -07:00
François Garillot 865275e2a2
Correcting some trivial Rust option/iterator warts 2020-01-29 13:53:05 -08:00
Jack Grigg 9c485cc97e Move from CurveProjective::add_assign_mixed to traits 2020-01-13 21:20:46 -05:00
Jack Grigg 1a8ec21c03 Move from Curve*::negate to Neg operator 2020-01-13 21:19:33 -05:00
Jack Grigg 8193324986 Move additive CurveProjective operators to traits 2020-01-13 21:19:33 -05:00
Jack Grigg ec2c304efd
no_std support for ff crate 2019-12-14 12:55:34 +00:00
Jack Grigg 1c9f5742fa
Improve Field::pow API and impl
Renamed to Field::pow_vartime to indicate it is still variable time with
respect to the exponent.
2019-12-14 12:27:48 +00:00
Jack Grigg 3d2acf48ce
Constant-time field square root
WARNING: THIS IS NOT FULLY CONSTANT TIME YET!

This will be fixed once we migrate to the jubjub and bls12_381 crates.
2019-12-13 20:13:30 +00:00
Jack Grigg 40749da9a7
Constant-time field inversion
WARNING: THIS IS NOT ACTUALLY CONSTANT TIME YET!

The jubjub and bls12_381 crates will replace our constant-time usages,
but we NEED to fix ff_derive because other users will expect it to
implement the Field trait correctly.
2019-12-13 19:46:04 +00:00
Jack Grigg 662be3551f
impl ConditionallySelectable for Field 2019-12-12 23:15:48 +00:00
Jack Grigg cded08b0c5
Make Field::square take &self and return Self 2019-12-12 23:09:28 +00:00
Jack Grigg 9dac748224
Make Field::double take &self and return Self 2019-12-12 22:59:18 +00:00
Jack Grigg 91c32f1c7c
Move from Field::negate to Neg operator 2019-12-12 22:52:17 +00:00