Commit graph

87 commits

Author SHA1 Message Date
Sean Bowe
02af12b81a
Replace batch inversion for FieldElement with sequential variant of Montgomery's trick. 2018-07-01 15:07:04 -06:00
Henry de Valence
34c43c20a9 Rework backend selection code.
Each backend can now be selected by an individual feature:

- `u32_backend` for `backend::u32`;
- `u64_backend` for `backend::u64`;
- `avx2_backend` for `backend::avx2`;

The `u64_backend` is selected by default, since most people use X64 and we have
no way to select based on target (see discussion in #126).  However, these
changes mean that it is possible to select the backend explicitly, and if we
had the ability to select target-default features, we could do so easily.
2018-05-14 17:43:54 -07:00
Henry de Valence
d6b8389428 Use criterion.rs instead of libtest for benchmarks.
Since Criterion can only benchmark public API, these changes just drop
all internal benchmarks (e.g., benchmarks for field operations). But
those are usually microbenchmarks whose meaning is kind of questionable
anyways, so I don't think this is a big loss.

The `bench` feature disappears, since Criterion works on stable Rust.
2018-03-25 17:14:37 -07:00
Henry de Valence
792ac0775e Change to the updated subtle API. 2018-03-22 11:13:26 -07:00
Henry de Valence
d8d235fb48 Move pow2k into the backends and use it to implement square() 2018-01-19 17:50:48 -08:00
Henry de Valence
1f821d34a5 Feature-gate batch inversion and compression on alloc 2018-01-19 17:22:28 -08:00
Henry de Valence
de377290ee Implement batch inversion using a product tree. 2018-01-19 17:22:28 -08:00
Henry de Valence
c0633ae2d7 KaTeXify some backend documentation 2017-12-01 11:46:36 -08:00
Henry de Valence
e196f8347c Move 32/64-bit code into submodules in a backend module.
See the doc comment in `backend/mod.rs` for motivation on naming.
2017-11-16 16:07:55 -08:00
Henry de Valence
207af566b9 Replace signed constants with unsigned constants 2017-11-16 12:13:13 -08:00
Henry de Valence
b6bfc79cd1 Fix up Elligator tests to match ristretto.sage 2017-10-30 16:34:36 -07:00
Henry de Valence
f4135da5c9 Remove is_negative_decaf since ristretto uses the low bit 2017-10-30 16:34:36 -07:00
Henry de Valence
fafdae7a60 Prototype of Ristretto encoding 2017-10-30 16:34:36 -07:00
Isis Lovecruft
acd3826fe2 Implement Montgomery arithmetic and laddering.
* ADDs part of https://github.com/isislovecruft/curve25519-dalek/issues/47
2017-09-14 02:09:14 +00:00
Isis Lovecruft
17290db44c
Update copyright/license headers in source files. 2017-08-15 05:09:20 +00:00
Isis Lovecruft
f2883028dc
Use subtle version 0.2.0.
* CLOSES PR#66 https://github.com/isislovecruft/curve25519-dalek/pull/66
2017-08-01 02:22:43 +00:00
Henry de Valence
f72de04003 Remove unneeded imports to suppress warnings 2017-07-30 16:29:37 -07:00
Henry de Valence
77103986a3 Split field arithmetic into per-implementation files
Split the field arithmetic implementations into `FieldElement`,
`FieldElement32`, and `FieldElement64`.  `FieldElement` is a type alias for one
of `FieldElement32` or `FieldElement64`, depending on feature selection.
`field.rs` contains tests and code which is generic with respect to the
implementation (e.g., inversions), while `field_32bit.rs` and `field_64bit.rs`
contain the implementation-specific code.

The implementation is not completely hidden, since `FieldElement32` and
`FieldElement64` are tuple structs whose elements are public; `pub(crate)`
doesn't seem to work for tuple structs.

Similarly, the constants file is split over multiple files, depending on the
implementation.
2017-07-30 16:25:42 -07:00
Henry de Valence
513ce26942 avoid 128-bit multiplications 2017-07-20 21:33:15 -07:00
Isis Lovecruft
4bcf8bed9d
Move subtle to its own crate. 2017-05-31 21:20:56 +00:00
Isis Lovecruft
16904432be
Remove an unnecessary explicit return in FieldElement.to_bytes(). 2017-05-28 22:45:13 +00:00
Isis Lovecruft
674a00df5b
Some rustfmt fixes. I disagreed with all the other ones. 2017-05-28 22:42:09 +00:00
Isis Lovecruft
0c38718346
Rename subtle::arrays_equal_ct() to subtle::arrays_equal().
It's already obvious that it's constant-time because it's in the subtle
module.
2017-05-26 22:35:45 +00:00
Isis Lovecruft
9a9959061d
Merge remote-tracking branch 'hdevalence/feature/clippy-fixes' into develop 2017-05-06 00:16:09 +00:00
Henry de Valence
cb656bafa7 Delete bytes_equal_less_than
This function is unused and untested.  It's also incorrect, since the loop
32..0 iterates over an empty range.  Remove it for now; if we need it later, it
still lives in the history.
2017-04-25 15:08:59 -07:00
Henry de Valence
57c96616b9 Remove unused import 2017-04-25 14:50:59 -07:00
Henry de Valence
e00cd114d7 Have radix 25.5 reduce() consume its argument 2017-04-02 23:46:01 +02:00
Henry de Valence
162dfc8331 Remove clones on Copy types 2017-04-02 23:45:34 +02:00
Henry de Valence
3705346afa Remove unnecessary returns 2017-04-02 23:39:45 +02:00
Henry de Valence
7f4b96150d Remove explicit lifetimes 2017-04-02 23:36:05 +02:00
Henry de Valence
c8e7e22ddf Remove unnecessary returns 2017-04-02 23:28:01 +02:00
Henry de Valence
73e172484c Add tick marks around code items in docs 2017-04-02 23:12:18 +02:00
Isis Lovecruft
d549fdc8f9
Whitespace fixes. 2017-03-17 21:42:40 +00:00
Henry de Valence
2f5b9e198c Remove warnings from load3/load4 and load8 functions 2017-03-14 01:05:31 -07:00
Isis Lovecruft
6991b4264b
Merge remote-tracking branch 'hdevalence/feature/64bit-multiplication_r3' into develop 2017-03-14 04:23:11 +00:00
Isis Lovecruft
f6930997d2
Make #[feature(test)] depend on #[cfg(all(test, feature = "bench"))].
* FIXES Issue #38:
   https://github.com/isislovecruft/curve25519-dalek/pull/38
2017-03-14 01:59:08 +00:00
Isis Lovecruft
cb3b3144be
Remove prefix from field tests. 2017-03-14 01:11:54 +00:00
Isis Lovecruft
904911e2b8
Move field module benchmarks to separate module. 2017-03-14 01:11:03 +00:00
Henry de Valence
cf9f9aa402 Enable radix_51 on nightly 2017-03-13 17:04:37 -07:00
Henry de Valence
45cc82d258 Move multiply() into the Mul impl 2017-03-13 16:38:05 -07:00
Henry de Valence
f11c97e75c Remove obsolete test code 2017-03-13 16:38:05 -07:00
Henry de Valence
d2a51197d7 Add a carry-reduction during subtraction. 2017-03-13 16:38:05 -07:00
Henry de Valence
e1d3281c2d Add debug asserts for multiplication preconditions. 2017-03-13 16:38:05 -07:00
Henry de Valence
9524c079ee Reduce mod p in radix51 to_bytes 2017-03-13 16:38:05 -07:00
Henry de Valence
0fa8d8f4a7 Reduce to narrower range before to_bytes 2017-03-13 16:38:05 -07:00
Henry de Valence
24f11427a1 Add 2p to avoid underflows 2017-03-13 16:38:05 -07:00
Henry de Valence
a9cbca668b Implement squaring for radix51 2017-03-13 16:38:05 -07:00
Henry de Valence
df080411e0 Implement multiply() for radix51 2017-03-13 16:38:05 -07:00
Henry de Valence
d6465ccd5e Fix remaining compile errors for radix_51 2017-03-13 16:38:05 -07:00
Henry de Valence
147b9d90b8 Revert "Add radix51 impl of reduce"
This reverts commit 488e886d1e1b11400dedc6c41e7108e34c6747cc.
2017-03-13 16:38:05 -07:00