Commit Graph

58 Commits

Author SHA1 Message Date
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
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
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
Jack Grigg
27c8f34601
Move Field operations to operator-backed traits
The ff_derive, pairing, zcash_primitives::jubjub, and bellman dummy_engine
changes are minimally implemented on top of the existing *_assign()
functions.
2019-12-12 21:19:46 +00:00
Jack Grigg
7fda177da8
Doc link fixes 2019-11-07 17:33:22 +00:00
NikVolf
7844394364 Remove unneeded extern crate 2019-10-08 16:12:14 +03:00
str4d
2399d9f3e3
Merge pull request #93 from defuse/qed-it-lrz
Bring in QED-it Tests
2019-10-08 13:47:36 +13:00
Jack Grigg
4ad3988e43
Crate docs 2019-09-24 14:23:59 +01:00
Jack Grigg
d9a0b9c83f
CI: Check intra-doc links
Credit: https://twitter.com/tomaka17/status/1176017851410526208
2019-09-24 10:35:12 +01:00
Jack Grigg
39a73c8eda
Add missing cs.is_satisfied() to bellman test 2019-09-17 00:16:33 +01:00
Taylor Hornby
caab37c336
Fix build warnings 2019-09-16 23:06:48 +01:00
Kobi Gurkan
f3533e291f
boolean: adds tests for alloc_conditionally 2019-09-16 22:08:30 +01:00
Kobi Gurkan
2ee7b108af
blake2s: adds test vectors from go-jubjub 2019-09-16 20:34:21 +01:00
Taylor Hornby
cc2a41d86c
Fix blake2s test data length assertion. 2019-09-16 20:24:31 +01:00
Kobi Gurkan
804f4cba67
Add blake2s test vectors for varying sizes from go-jubjub 2019-09-16 20:23:09 +01:00
Kobi Gurkan
43496857c9
pedersen_hash: removes debug prints 2019-09-16 20:20:03 +01:00
Kobi Gurkan
15633ad434
pedersen hashes: example of size limit bug 2019-09-16 20:17:50 +01:00
Jack Grigg
28dcc1c346
bellman: Fix compile errors without multicore feature 2019-09-12 19:38:52 +01:00
Jack Grigg
89dad572ef
Migrate bellman to crossbeam 0.7 2019-09-12 19:38:50 +01:00
Jack Grigg
9016548698
Take self directly in into_* functions 2019-08-24 00:39:55 +01:00
Jack Grigg
fe93f2ff6b
Rename into_ -> to_ where &self is used. 2019-08-24 00:39:54 +01:00
Jack Grigg
d65fe2cda9
Address various clippy warnings/errors in bellman 2019-08-24 00:38:32 +01:00
Eirik Ogilvie-Wigley
76795a9014 cargo fmt 2019-08-20 22:22:03 -06:00
Eirik Ogilvie-Wigley
a5f25c5058 cargo fix --edition-idioms for bellman 2019-08-20 22:07:24 -06:00
Eirik Ogilvie-Wigley
f523ac285d cargo fmt 2019-08-20 17:17:21 -06:00
Eirik Ogilvie-Wigley
4991e53f48 cargo fix --edition for bellman 2019-08-20 16:45:10 -06:00