Jack Grigg
c597db59a6
ff: Rename PrimeField::into_repr -> PrimeField::to_repr
2020-05-02 18:55:13 +12:00
Jack Grigg
9114c367f4
ff_derive: Generate modulus representation with correct endianness
...
Now that PrimeField::ReprEndianness exists, users can obtain a
known-endianness representation from the output of PrimeField::char
(which is a PrimeField::Repr, and should return a representation with
the same endianness as PrimeField::into_repr).
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
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
fd79de5408
ff: Add PrimeField: From<u64> constraint
2020-04-23 16:23:24 +12:00
Jack Grigg
2942e9a7e6
Generate addition chains inside Field::invert and SqrtField::sqrt
2020-03-14 10:54:22 +13:00
Jack Grigg
232fb4b7a3
Procedural macro for fixed-exponent variable-base modular exponentiation
...
Uses the addchain crate to obtain an addition chain for the exponent,
and then generates the corresponding constant-time square-and-multiply
algorithm.
2020-03-14 10:54:22 +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
31d887c943
Merge commit 'd7f78db121ee6f720e97401ded0c9c597d1a4857' into depends-updates-2
2020-03-03 17:44:28 -07:00
Jack Grigg
620213a0f0
ff_derive: Fix a clippy issue in generated code
...
This shows up as a clippy warning in the pairing crate.
2020-01-14 22:00:50 -05:00
Jack Grigg
8887414c49
ff_derive: Fix various clippy issues
2020-01-14 21:59:45 -05:00
Jack Grigg
56999d0f73
Constant-time field inversion in ff_derive using Field::pow_vartime
...
This is around 2.5-3x slower than the non-constant-time inversion. We
can regain some of this speed later by dynamically generating addition
chains.
2019-12-19 12:25:39 -06:00
Jack Grigg
26ef9c9842
Pass modulus to prime_field_constants_and_sqrt by reference
2019-12-19 12:18:09 -06: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
str4d
40d22ea2cc
Merge pull request #135 from NikVolf/extern-purge
...
Remove unneeded "extern crate"
2019-10-31 17:12:26 +00:00
NikVolf
7844394364
Remove unneeded extern crate
2019-10-08 16:12:14 +03:00
Jack Grigg
216f0f62a0
ff 0.5.0
2019-10-08 17:43:33 +13:00
Jack Grigg
bef3e7e336
Migrate ff_derive to proc-macro2 1.0
2019-09-06 19:03:12 -04:00
Eirik Ogilvie-Wigley
09882c6d08
Add edition = 2018
2019-08-20 18:31:20 -06:00
Eirik Ogilvie-Wigley
b35a819a09
Replace try! macro
2019-08-20 18:24:47 -06:00
Eirik Ogilvie-Wigley
a7c5993597
cargo fmt
2019-08-15 10:41:48 -06:00
str4d
0255dca16e
Clarify masking of bits in Field::random impls
...
Co-Authored-By: Daira Hopwood <daira@jacaranda.org>
2019-07-26 19:43:42 +01:00
Jack Grigg
7a6642b221
Migrate ff to rand_core 0.3 (used by rand 0.5)
2019-07-19 00:35:06 +02:00
Jack Grigg
af9f9c17ee
Add 'ff/' from commit '661558e0c8a5e02e08dac6530d39b2e38919aa04'
...
git-subtree-dir: ff
git-subtree-mainline: 07955092f3
git-subtree-split: 661558e0c8
2019-01-06 09:37:22 +00:00