Commit graph

857 commits

Author SHA1 Message Date
Henry de Valence
108a690941 First attempt at generating basepoint tables at compile time 2017-11-16 12:13:13 -08:00
Henry de Valence
b966f942a8 Impl Debug for EdwardsBasepointTable 2017-11-16 11:09:45 -08:00
Henry de Valence
6f5f0c51fd Tweak Debug impls to produce Rust source 2017-11-16 11:09:32 -08:00
Isis Lovecruft
cc8528f41f
Change implementation-specific scalar constants to be pub(crate). 2017-11-16 00:39:27 +00:00
Isis Lovecruft
c59af2c6b8
Merge branch 'optimzed_scalar_r1' into develop 2017-11-15 22:02:36 +00:00
Isis Lovecruft
2345a3f2fa
Fix typo in Scalar64::from_bytes_wide().
* FIXES issue #82:
   https://github.com/isislovecruft/curve25519-dalek/issues/82
2017-11-15 03:19:39 +00:00
Henry de Valence
f3a7108c55 Remove sha2 crate, which is only used in doctests 2017-10-31 14:12:29 -07:00
Henry de Valence
8f68b7a3ed Remove MSQRT_M1 constant 2017-10-31 14:10:33 -07:00
Isis Lovecruft
583a45ddc2
Add test that scalar Montgomery reduction matches reduction. 2017-10-31 01:18:52 +00:00
Isis Lovecruft
e2cbec81fc
Add test that UnpackedScalar::{to,from}_bytes() roundtrips. 2017-10-31 01:02:20 +00:00
Henry de Valence
bbbe4bf665 Make most numeric constants pub(crate) 2017-10-30 17:33:23 -07:00
Henry de Valence
a7835a1246 UPPERCASE_GLOBALS and add documentation 2017-10-30 17:33:23 -07:00
Isis Lovecruft
f0102806a2
Remove unnecessary mask operation in Scalar32::from_bytes_wide().
The significant bits here can only be
2017-10-31 00:00:14 +00:00
Henry de Valence
089efbbbbe Prune constants that are no longer used anywhere 2017-10-30 16:53:39 -07:00
Henry de Valence
d08c3d252b fix std/alloc dep for multiscalar_mult for RistrettoPoints 2017-10-30 16:34:36 -07:00
Henry de Valence
8c3ae7f010 Remove 'yolocrypto' from Ristretto 2017-10-30 16:34:36 -07: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
21101a7d71 Add test vectors from ristretto.sage 2017-10-30 16:34:36 -07:00
Henry de Valence
8e21c0b4f0 Start writing down some notes on the compression procedure 2017-10-30 16:34:36 -07:00
Henry de Valence
98c34adf6d Change to Ristretto test vectors. 2017-10-30 16:34:36 -07:00
Henry de Valence
7097d8f98e Add Ristretto equality 2017-10-30 16:34:36 -07:00
Henry de Valence
fafdae7a60 Prototype of Ristretto encoding 2017-10-30 16:34:36 -07:00
Henry de Valence
58a55117be Rename Decaf to Ristretto 2017-10-30 16:34:36 -07:00
Isis Lovecruft
6ed006abc1
Fix two oversized buffer allocations in scalar code. 2017-10-30 23:17:46 +00:00
Henry de Valence
aaa2315703
add failing test case from fuzzer 2017-10-30 22:25:34 +00:00
Henry de Valence
3c085d264c
Change Scalar32 and Scalar64 to not mask the high 3 bits of a Scalar.
This should not cause overflow, since this just lets the high limb have the
same bounds as the other limbs, but we should check this carefully.
2017-10-30 22:25:33 +00:00
Isis Lovecruft
6079b0269f
Revert "Revert "Merge remote-tracking branch 'floodyberry/optimized_scalar' into develop""
This reverts commit 90b69c13ee.

Signed-off-by: Isis Lovecruft <isis@torproject.org>
2017-10-30 19:27:44 +00:00
Isis Lovecruft
90b69c13ee
Revert "Merge remote-tracking branch 'floodyberry/optimized_scalar' into develop"
This reverts commit 804dab8924, reversing
changes made to 5d15ca77ff.

This is due to a (previously undocumented) contract on the behaviours of
(potentially unreduced mod \ell) "packed" scalars w.r.t. to the manner in which
their bytes are interpreted.

Upon documentation fixes and corresponding fixes being made on top of the
floodyberry/optimized_scalar branch, this revert will again be reverted and then
the additional changes merged (à la
file:///usr/share/doc/git/html/howto/revert-a-faulty-merge.html).

Signed-off-by: Isis Lovecruft <isis@patternsinthevoid.net>
2017-10-16 21:41:52 +00:00
Isis Lovecruft
804dab8924
Merge remote-tracking branch 'floodyberry/optimized_scalar' into develop 2017-10-05 02:57:55 +00:00
Isis Lovecruft
5d15ca77ff
Merge branch 'feature/montgomery-arithmetic_r1' into develop 2017-10-05 02:37:27 +00:00
Isis Lovecruft
d39e47ff11
Remove comment on non-canonical encodings in CompressedMontgomeryU.decompress(). 2017-10-05 02:27:27 +00:00
Isis Lovecruft
4965238b5a
Removed now unused subtle import from montgomery module. 2017-10-05 02:23:55 +00:00
Isis Lovecruft
29f9090411
Fix two typos in docstrings for constants. 2017-10-05 02:23:34 +00:00
Isis Lovecruft
9da24d8afa
Add test for Montgomery ladder with a scalar with high bit set. 2017-10-05 02:15:28 +00:00
Isis Lovecruft
ca5b58c2b7
Clarify doc note on degenerate cases for differential addition. 2017-10-05 01:54:26 +00:00
Isis Lovecruft
7b378ada6b
Rephrase doc note on exceptional projective Montgomery points. 2017-10-05 01:46:42 +00:00
Isis Lovecruft
5e6e6c3fa8
Eliminate extra inversions in MontgomeryPoint.ct_eq(). 2017-10-05 01:32:44 +00:00
Isis Lovecruft
7e4fd5677c
Add tests and benchmark for MontgomeryPoint.ct_eq(). 2017-10-05 01:26:15 +00:00
Isis Lovecruft
d39cb275c5
Remove DecafPoint.to_edwards() method. 2017-10-05 00:56:40 +00:00
Isis Lovecruft
c08591a7d8
Improve documentation for Mongomery code. 2017-10-04 07:31:11 +00:00
Isis Lovecruft
ecef4d836e
Make FieldElement limbs private to the curve25519-dalek crate.
Limbs are no longer accessible outside of the curve25519-dalek crate.
If you were relying on this behaviour, first you probably shouldn't be
doing that, second please contact us so we can determine the best way
forward for your use case.
2017-10-01 23:36:57 +00:00
Andrew Moon
7e53499a10 optimized scalar implementations for 32/64 bit 2017-09-24 22:24:35 -05:00
Isis Lovecruft
6be10341e2
Add benchmarks for Mongomery point (de)compression and laddering. 2017-09-14 04:55:11 +00:00
Isis Lovecruft
2939d26b5c
Remove direct compression methods between points in curve models.
compress_edwards() is now named compress() and works only on points
which are in Edwards form.  Similarly, compress_montgomery() is now
also called compress(), and it only works on point already in
Mongomery form.

To switch between forms, use to_montgomery().

Conversion from Montgomery directly to Edwards is not yet implemented.

 * CHANGE the API requested in
   https://github.com/isislovecruft/curve25519-dalek/issues/47,
   hopefully for the better.
2017-09-14 04:55:11 +00: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
Brian Smith
7ed9eb8617 Replace one multiplication with a squaring in scalar inversion.
This brings the code up to date with the 2017-09-04 version of
the source article.
2017-09-04 09:45:13 -10:00
Brian Smith
028140bb33 Reformat addition chain window building code to better show pattern.
Make the 2 digit, `_10`, the first argument to more closely match the
Haskell code in the source article. Align the code into columns to
further clarify the patterns.
2017-09-04 09:23:27 -10:00
Brian Smith
91a7c641c2 Use more efficient addition chain for scalar inversion.
Use the addition chain from
https://briansmith.org/ecc-inversion-addition-chains-01#curve25519_scalar_inversion.

In my benchmarking, this consistently runs at least 20% faster.
2017-09-03 17:00:42 -10:00
khyperia
6747133519 Optimize scalar inversion by implementing square()
This shows an 11% speedup for invert()
2017-08-21 21:35:26 -07:00
Isis Lovecruft
17290db44c
Update copyright/license headers in source files. 2017-08-15 05:09:20 +00:00
Henry de Valence
c29103d109 Rename _BASEPOINT to _BASEPOINT_POINT.
Having _BASEPOINT_TABLE and _BASEPOINT_POINT means that it's not possible to
use the slow, generic scalar mult in place of the fast, precomputed scalar
mults.
2017-08-14 00:20:18 -07:00
Henry de Valence
afecd4f438 Fixup types and publication 2017-08-13 23:57:57 -07:00
Henry de Valence
ea845b4163 Fix missing import in tests 2017-08-02 23:08:46 -07:00
Henry de Valence
3dddecb4a8 Move Montgomery code to a montgomery.rs module 2017-08-02 22:58:15 -07:00
Henry de Valence
8ad02e2f57 Move curve.rs to edwards.rs 2017-08-02 22:35:12 -07:00
Isis Lovecruft
2d15619c6c
Add DecafPoint.to_bytes(). 2017-08-01 19:30:51 +00:00
Isis Lovecruft
4d8c18fff3
Add documentation warnings on FieldElement32 and FieldElement64. 2017-08-01 02:46:14 +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
Isis Lovecruft
7202ab8e63
Merge remote-tracking branch 'hdevalence/feature/constant-time-k-fold-scalar-mult' into develop 2017-08-01 01:51:58 +00:00
Henry de Valence
ddaf602a09 Add multiscalar_mult to Decaf. 2017-07-31 18:40:53 -07:00
Henry de Valence
d2ce1ce5dc Revert "Add size checking to multiscalar multiplication."
This reverts commit 720da348c0.

Unfortunately, iter::chain on two ExactSizeIterators does not produce an ExactSizeIterator, for reasons described here: https://github.com/rust-lang/rust/issues/34433 .
2017-07-31 18:23:26 -07:00
Henry de Valence
720da348c0 Add size checking to multiscalar multiplication. 2017-07-30 23:54:13 -07:00
Henry de Valence
2d01aa1bf7 Add fixme note on cache awareness 2017-07-30 22:26:18 -07:00
Henry de Valence
63ee9d21ae tweak code arrangement to keep comments together 2017-07-30 22:24:58 -07:00
Henry de Valence
aaefb90ed3 Rename k_fold_scalar_mult to multiscalar_mult 2017-07-30 22:16:22 -07:00
Henry de Valence
9c4046c3d9 Add constant-time k-fold scalar multiplication 2017-07-30 21:13:56 -07: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
4e63cbfe4c
Merge remote-tracking branch 'chain/no_std-fix' into develop 2017-06-26 20:14:38 +00:00
Tony Arcieri
d9742c2367 Switch from libcollections to liballoc (gated on an "alloc" feature)
libcollections was recently merged into liballoc:

https://github.com/rust-lang/rust/pull/42648

I went ahead and also added an "alloc" feature which no_std users can use to opt
into liballoc features (i.e. any code using Vec). This should have no effect on
anything but no_std usage. It does make it possible for people without
allocators to use curve25519-dalek if they want though. Might be nice for
"bare metal" development.

All that said, from what I can gather liballoc, while not "stable", should
likely stick around for the forseeable future.

Some backstory on the liballoc/libcollections merge here:

https://github.com/rust-lang/rust/pull/42565
2017-06-19 16:59:45 -07:00
Isis Lovecruft
4bcf8bed9d
Move subtle to its own crate. 2017-05-31 21:20:56 +00:00
Isis Lovecruft
161c0cd96d
Add a doctest for subtle::bytes_equal(). 2017-05-31 01:31:40 +00:00
Isis Lovecruft
43481a9ff6
Change the whitespace because Boats made fun of it on twitter. 2017-05-31 01:31:37 +00:00
Isis Lovecruft
4ecf6ab326
Implement constant-time selection between two things. 2017-05-31 01:29:59 +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
648f95887a
Rename subtle::bytes_equal_ct() to bytes_equal(). 2017-05-27 18:35:34 +00:00
Isis Lovecruft
1c4f283be4
Change debug_assert to assert in arrays_equal(). 2017-05-27 18:28:37 +00:00
Isis Lovecruft
60692ce891
Put math/code in a docstring in ticks. 2017-05-27 18:24:08 +00:00
Isis Lovecruft
2485472023
Remove explicit lifetime, caught by clippy. 2017-05-27 18:23:31 +00:00
Isis Lovecruft
044128dc58
Remove excessive clone() on Copy, caught by clippy. 2017-05-27 18:21:37 +00:00
Isis Lovecruft
3a664a054a
Whitespace fix in decaf module. 2017-05-27 01:20:14 +00:00
Isis Lovecruft
3decdbed0d
Make arrays_equal() work for any size &[u8], as long as sizes are equal. 2017-05-26 22:39:20 +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
e74be0024d
Better documentation for arrays_equal_ct. 2017-05-26 21:22:31 +00:00
Isis Lovecruft
a12c2979fb
Fix the doctest for byte_is_nonzero. 2017-05-26 20:53:18 +00:00
Isis Lovecruft
c6057cb2d0
Merge remote-tracking branch 'hdevalence/feature/fast-decaf' into develop 2017-05-25 21:51:57 +00:00
Isis Lovecruft
8772e863e7
Merge remote-tracking branch 'manishearth/fuzz' into develop 2017-05-25 21:50:48 +00:00
Isis Lovecruft
00f3a20329
Merge branch 'feature/add-sub-assign' into develop 2017-05-21 23:04:06 +00:00
Henry de Valence
58982cbc2b Lower the trial number in decaf_random
The radix_51 implementation has many more debug checks, so this takes quite
long to run, and it's rude to run a fuzzer on the CI server.
2017-05-20 21:39:58 -07:00
Henry de Valence
27dbfa9536 Use Mike Hamburg's trick for Decaf compression. 2017-05-20 21:39:58 -07:00
Henry de Valence
52e51bdb16 Add constants for 1/sqrt(a-d) and 1/(a-d) 2017-05-20 21:39:58 -07:00
Henry de Valence
e4913dfc2b Batch inversions in Decaf decompression. 2017-05-20 21:39:58 -07:00
Henry de Valence
273db53cfd Benchmark Edwards decompression and compression 2017-05-20 21:39:58 -07:00
Henry de Valence
f741e50eb5 Add a test against current encodings of small multiples of the ed25519 basepoint 2017-05-20 21:39:58 -07:00
Manish Goregaokar
e076079772 Add cargo-fuzz 2017-05-19 16:44:05 -07:00
Henry de Valence
714bf3dd07 Set the number of trials back to 10,000 2017-05-19 14:23:51 -07:00
Henry de Valence
fbd8d0a605 Rewrite decaf elligator code to avoid two consecutive additions 2017-05-19 14:23:51 -07:00
Henry de Valence
b6cb7a7983 Increase number of trials for decaf elligator 2017-05-19 14:23:51 -07:00
Isis Lovecruft
e374451249
Implement {AddAssign, SubAssign} for DecafPoint. 2017-05-18 23:02:39 +00:00
Isis Lovecruft
27e4ea5181
Add a divider to separate Neg code from Add/Sub. 2017-05-18 23:01:31 +00:00
Isis Lovecruft
ed315ffcae
Implement {AddAssign, SubAssign} for ExtendedPoint. 2017-05-18 23:00:55 +00:00
Isis Lovecruft
b97868beb8
Remove unused import of ExtendedPoint in decaf::test module. 2017-05-18 03:44:42 +00:00
Isis Lovecruft
cc86091224
Remove unused import of DecafPoint in curve module. 2017-05-18 03:43:42 +00:00
Isis Lovecruft
767c99adf5
Remove unused assignment in a decaf test. 2017-05-18 03:43:15 +00:00
Isis Lovecruft
891cf76aab
Remove unused imports in curve::bench module. 2017-05-18 03:42:31 +00:00
Isis Lovecruft
0b70ab3638
Move DecafPoint * Scalar definition to decaf module. 2017-05-18 02:57:10 +00:00
Isis Lovecruft
e3adf3eea3
Merge remote-tracking branch 'hdevalence/feature/decaf_elligator_hash_to_point' into develop 2017-05-18 02:50:28 +00:00
Henry de Valence
aea15e8612 remove debugging println!s 2017-05-15 22:40:09 -07:00
Henry de Valence
69c62a8a17 Serde Scalar support 2017-05-15 22:40:09 -07:00
Henry de Valence
d3515e8cbf Add test that decompressing an invalid point with serde fails 2017-05-15 22:40:09 -07:00
Henry de Valence
69fd268aa4 Make serde an optional feature 2017-05-15 22:40:09 -07:00
Henry de Valence
7c32271346 Initial work on Serde support 2017-05-15 22:37:50 -07:00
Henry de Valence
608634a7bd Implement DecafPoint::{random, hash_from_bytes, from_hash} using Decaf-flavoured elligator 2017-05-15 21:06:26 -07:00
Isis Lovecruft
fe58e81bbc
Add missing conditional import for collection::Vec. 2017-05-14 11:16:07 +00:00
Isis Lovecruft
4a646806b8
Merge branch 'feature/scalarmult-lhs' into develop 2017-05-14 09:35:15 +00:00
Isis Lovecruft
61d07693ec
Merge remote-tracking branch 'hdevalence/feature/operator_scalar_mult_r2' into develop 2017-05-14 09:34:45 +00:00
Isis Lovecruft
ae11d4bc76
Merge remote-tracking branch 'hdevalence/feature/vartime-module' into develop 2017-05-14 09:34:14 +00:00
Isis Lovecruft
1b7b57c351
Make basepoint multiplication for precomputed tables go both ways. 2017-05-14 03:10:26 +00:00
Isis Lovecruft
7478814dfc
Implement CTAssignable for DecafPoint. 2017-05-14 02:59:54 +00:00
Isis Lovecruft
b6faf7c05e
Implement CTAssignable for ExtendedPoint. 2017-05-14 02:31:36 +00:00
Isis Lovecruft
738049619b
Also make scalar multiplication with DecafPoints go both ways. 2017-05-09 02:04:22 +00:00
Isis Lovecruft
944e8e1649
Fix and allow some non-snakecased variables in scalar tests. 2017-05-09 00:05:11 +00:00
Isis Lovecruft
4da1d795a1
Make scalar multiplication go both ways.
Being able to do `P * s`, but not `s * P`, is slightly annoying, particularly
with longer equations when it is desired to be able to glance at the maths and
see that the code is the same.

Now either syntax is allowed.
2017-05-09 00:01:48 +00:00
Isis Lovecruft
9a9959061d
Merge remote-tracking branch 'hdevalence/feature/clippy-fixes' into develop 2017-05-06 00:16:09 +00:00
Isis Lovecruft
8f4114a211
Merge remote-tracking branch 'hdevalence/feature/streamable-hash-to-scalar' into develop 2017-05-05 23:52:59 +00:00
Henry de Valence
c18627f7c2 Generalize k_fold_scalar_mult 2017-05-04 00:02:29 -07:00
Henry & Isis
c6dc9d318d Add a helper function to construct a Scalar from a u64 2017-05-03 19:32:31 -07:00
Henry de Valence
0ae0d2b72a Add function to get the basepoint from a basepoint table 2017-05-03 19:32:30 -07:00
Henry de Valence
127169c151 Remove boxes 2017-05-03 19:32:30 -07:00
Henry de Valence
0678e619cc Implement Mul for basepoint tables 2017-05-03 19:32:30 -07:00
Henry de Valence
59453d755d Implement Mul for scalar multiplication 2017-05-03 19:32:30 -07:00
Henry & Isis
7cbb8dd94e Merge branch 'feature/streamable-hash-to-scalar' into develop 2017-05-03 19:32:09 -07:00
Henry de Valence
a479b627a8 Add Decaf wrapper for k-fold vartime 2017-05-03 17:39:06 -07:00
Henry de Valence
5100ba4a07 Move variable time code into a module 2017-05-03 17:31:16 -07:00
Henry de Valence
68f74d9b22 Merge branch 'feature/vartime_k_fold_scalarmult' into feature/vartime-module 2017-05-03 16:27:43 -07:00
Henry de Valence
b05c897123 Implement operators for Scalars using multiply_add 2017-05-02 22:29:18 -07:00
Henry de Valence
91e11b6318 Change docstring to match the trait bound 2017-05-02 21:22:04 -07:00
Henry de Valence
6ea1d4dad2 Add an implementation of Scalar inversion 2017-04-28 22:59:56 -07:00
Henry de Valence
653f134bc7 Implement Mul, MulAssign, zero(), one() for UnpackedScalar 2017-04-28 22:57:17 -07:00
Henry de Valence
b5ccb42759 Rename lminus1 to l_minus_1 2017-04-28 22:54:00 -07:00
Henry de Valence
057c84abd5 Add a bits() function for scalars 2017-04-28 22:51:32 -07:00
Henry de Valence
60ad000609 Remove redundant & 2017-04-25 15:56:36 -07: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
b3041f2adc Remove unnecessary if statements 2017-04-02 23:27:38 +02:00
Henry de Valence
e74bf8e789 Remove unnecessary if statement 2017-04-02 23:15:26 +02:00
Henry de Valence
73e172484c Add tick marks around code items in docs 2017-04-02 23:12:18 +02:00
Henry de Valence
eca28fd3e8 Refactor Scalar::hash_from_bytes to allow streaming input to the hash. 2017-03-27 04:49:00 -07:00
Isis Lovecruft
5ebbd5dd86
Remove an XXX comment about using something better than array_ref!().
It turns out array_ref!() is probably the best way, or, at least, we're
already using it everywhere.
2017-03-17 21:42:58 +00: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
Henry de Valence
abb1b6fef9 Add a variable-time k-fold scalar mult function. 2017-03-13 21:45:41 -07:00
Henry de Valence
57ebc9d7f9 Add an OddMultiples helper struct 2017-03-13 21:45:41 -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
3cfaf0cf6d
Merge branch 'feature/generic-basepoint_r3' into develop 2017-03-14 03:26:51 +00:00
Henry de Valence
b8b5af24b6 fixup! Enable radix_51 on nightly 2017-03-13 20:24:59 -07:00
Isis Lovecruft
26a77cd7f3
Feature-gate box syntax on both std and basepoint_table_creation. 2017-03-14 03:21:32 +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
3882a41d27
Remove test_ prefix from tests in scalar module. 2017-03-14 01:58:39 +00:00
Isis Lovecruft
4afe4ae37f
Move scalar module benchmarks to separate module. 2017-03-14 01:52:42 +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
Isis Lovecruft
ba9d3be011
Merge remote-tracking branch 'isislovecruft/develop' into develop 2017-03-13 23:49:13 +00:00
Henry de Valence
f80754a954 Further rename fixups in benchmark test names 2017-03-13 16:38:05 -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
b75a88458a Add monte carlo test for FieldElements 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
Henry de Valence
75baefabeb Stub remaining radix_51 functions with unimplemented!() 2017-03-13 16:38:05 -07:00
Henry de Valence
b515e43dfd Move to_bytes_64 to to_bytes for radix51 2017-03-13 16:38:05 -07:00
Henry de Valence
7591c74018 Add radix51 impl of reduce 2017-03-13 16:38:05 -07:00
Henry de Valence
08ac5a9068 Add radix51 impl of from_bytes 2017-03-13 16:38:05 -07:00
Henry de Valence
7f8b3fe594 Rename combine_coeffs to reduce 2017-03-13 16:38:05 -07:00
Henry de Valence
f16f5d1e73 Add minus_one for radix51 2017-03-13 16:38:05 -07:00
Henry de Valence
3eab4acbd8 Add p constant for subtraction 2017-03-13 16:38:05 -07:00
Henry de Valence
08ef9e5d1e Add constants in radix_51 form 2017-03-13 16:38:05 -07:00
Henry de Valence
4ef22b679c Implement sub_assign for radix_51 2017-03-13 16:38:05 -07:00
Henry de Valence
87001f9d6e Add utility for extracting constants in the new repr 2017-03-13 16:38:05 -07:00
Henry de Valence
4db735ca44 Add subtraction stub 2017-03-13 16:38:05 -07:00
Henry de Valence
eb66088cb9 Add to/from bytes for radix 51 2017-03-13 16:38:05 -07:00
Henry de Valence
afd42a4628 More feature-gating 2017-03-13 16:38:05 -07:00
Henry de Valence
a884260341 Add radix_51 and radix_25_5 features and start feature-gating 2017-03-13 16:38:05 -07:00
Henry de Valence
3a55a2f410 Add a test for radix-51 multiplication 2017-03-13 16:36:32 -07:00
Henry de Valence
92bf47f990 Clean up field tests 2017-03-13 16:36:32 -07:00
Henry de Valence
97b60d61ab draft of 64-bit multiplication 2017-03-13 16:36:32 -07:00
Isis Lovecruft
10fa989883
Print "CompressedEdwardsY" in Debug impl, not "CompressedPoint". 2017-03-13 23:29:13 +00:00
Henry de Valence
2610ab872a Feature-gate basepoint table creation on a nightly feature 2017-03-13 16:28:52 -07:00
Henry & Isis
049556147f Add wrapper for basepoint precomputations for decaf 2017-03-13 15:50:44 -07:00
Henry & Isis
c873f725a5 Rename BasepointTable as EdwardsBasepointTable. 2017-03-13 15:50:43 -07:00
Henry & Isis
f312160d2c Fixup errors introduced from not running yolocrypto tests by default 2017-03-13 15:50:43 -07:00
Henry de Valence
e757959bb8 Add benchmark for basepoint table creation 2017-03-13 15:50:43 -07:00
Henry de Valence
a4ed8e2b81 Use box syntax instead of an unsafe block 2017-03-13 15:50:43 -07:00
Henry de Valence
640f40287f Wrap the existing basepoint table as a BasepointTable 2017-03-13 15:50:43 -07:00
Henry de Valence
05fa1318b9 First work on dynamic basepoint table generation 2017-03-13 15:50:41 -07:00
Henry & Isis
7a2ea44ce6 Test multiplication by basepoint order 2017-03-13 15:49:18 -07:00
Henry de Valence
80d4566853 Merge remote-tracking branch 'tarcieri/nostd-cleanups' into develop 2017-03-13 15:00:20 -07:00
Isis Lovecruft
65136a202a
Merge remote-tracking branch 'isislovecruft/develop' into develop 2017-03-13 21:52:20 +00:00
Isis Lovecruft
f9c237bd6a
Typo fix in utils module docstring. 2017-03-10 02:36:15 +00:00
Isis Lovecruft
1f871ea0a0
Obsessive whitespace fix. 2017-03-10 02:36:01 +00:00
Isis Lovecruft
2039a66cb3
Fix two decaf unittests to use compress_edwards(). 2017-03-10 02:35:38 +00:00
Tony Arcieri
384cf1df31 no_std import cleanups
- Gate no_std on the "std" feature
- Import core when std is present
- Import collections when std is absent
- Add a placeholder gated "use" directive for Box in curve.rs
2017-03-08 00:19:08 -08:00
Henry de Valence
ab6d32efe1 Make functions pub to suppress dead code warnings 2017-03-07 23:03:48 -08:00
Henry de Valence
0e9dc1d38d Remove warnings about unused variables
These bindings are shadowed by the later let statements, so they're considered unused.
2017-03-07 23:01:49 -08:00
Henry de Valence
3f208359b3 Merge branch 'feature/test-reorg' into develop 2017-03-07 22:20:22 -08:00
Henry de Valence
b61ed818b8 Remove all remaining warnings 2017-03-07 01:37:31 -08:00
Henry de Valence
913e699145 Rename Decaf tests 2017-03-07 01:28:38 -08:00
Henry de Valence
e446bc8a1f The identity point is already in EIGHT_TORSION 2017-03-07 00:58:32 -08:00
Henry de Valence
cf24cb8900 Also test points that are not the identity 2017-03-07 00:58:32 -08:00
Henry de Valence
47143e9114 Rewrite conditional assignment test for AffineNielsPoints 2017-03-07 00:58:32 -08:00
Henry de Valence
9414a2f4db Remove old tests that aren't so useful any more 2017-03-07 00:49:21 -08:00
Henry de Valence
78fe9c490d Eliminate BASE_CMPRSSD or rename it to constants::BASE_CMPRSSD and do misc cleanup 2017-03-07 00:48:36 -08:00
Henry de Valence
94416eb1cb Clean decompression_sign_handling 2017-03-07 00:11:47 -08:00
Henry de Valence
b5b0ac7628 Add doc comments to test vectors 2017-03-07 00:11:16 -08:00
Henry de Valence
0585af6c68 Move sqrt(-(A+2)) test to constants.rs 2017-03-07 00:03:59 -08:00
Henry de Valence
3a9ee16a30 Remove test_ prefix from test functions in curve.rs 2017-03-06 23:59:49 -08:00
Henry de Valence
31c350b6f2 Split benchmarks into their own module 2017-03-06 23:53:38 -08:00
Isis Lovecruft
9f0c6c86f3
Change another unittest compress() to compress_edwards(). 2017-03-07 01:33:38 +00:00
Henry & Isis
e5f5dea444 Rename to_{cached,precomputed} to to_{projective,affine}_niels 2017-03-05 15:27:26 -08:00
Isis Lovecruft
9171a03894
Merge branch 'feature/rename-compress' into develop 2017-03-04 05:52:57 +00:00
Isis Lovecruft
b81f84bee8
Merge branch 'feature/montgomery-x-format_r1' into develop 2017-03-04 05:48:12 +00:00
Isis Lovecruft
2c83d48cfa
Demote a docstring note to inline code comment to avoid confusing users. 2017-03-04 05:29:19 +00:00
Isis Lovecruft
20ace8da48
Rename compress() to compress_edwards(). 2017-03-04 03:41:47 +00:00
Isis Lovecruft
cfd0e8ad6e
Add method for recovery of Edwards x-coordinate given Montgomery (u, v).
This function is necessary for matching Signal's hash_to_point() behaviour.
2017-03-04 03:39:58 +00:00
Isis Lovecruft
b9de92aeaf
Add benchmarks for Edwards-Y and Mongomery-U decompression. 2017-03-04 03:39:57 +00:00
Isis Lovecruft
915f41c643
Fixup CompressedMontgomeryU::decompress() and ensure no divide-by-zeroes.
Also, match Signal behaviour, and split off recovery of other
coordinates into separate functions.
2017-03-04 03:39:56 +00:00
Isis Lovecruft
5edd8d6d26
Merge remote-tracking branch 'hdevalence/feature/montgomery-x-format_r1' into develop 2017-03-04 02:40:17 +00:00
Isis Lovecruft
1c9637490c
Obsessive whitespace fix. 2017-03-04 02:00:59 +00:00
Henry de Valence
5d3d114628 fixup! Properly handle exceptional points. 2017-02-27 23:15:39 -08:00
Isis Lovecruft
f48947fb57
Merge remote-tracking branch 'hdevalence/feature/some-cleanup-tweaks' into develop 2017-02-28 05:50:22 +00:00
Henry de Valence
db53b58e89 Properly handle exceptional points. 2017-02-27 21:13:24 -08:00
Henry de Valence
19d452c2dc Test decompressing an invalid montgomery point 2017-02-27 13:42:13 -08:00
Henry de Valence
45fbcb45f6 First notes and code on Montgomery conversion 2017-02-27 13:41:50 -08:00
Henry de Valence
fe15bc1d0b Add note on fn main() in doctest 2017-02-27 11:22:07 -08:00
Henry de Valence
a93798d209 Add a function to hash a byte slice to a scalar. 2017-02-27 11:19:06 -08:00
Henry de Valence
e5c0d789fd Add a Scalar::as_bytes() method. 2017-02-26 15:25:05 -08:00
Henry de Valence
950519b97b Implement Debug for Scalar 2017-02-26 15:25:05 -08:00
Henry de Valence
1dac2f53bb Implement Identity for CompressedEdwardsY 2017-02-26 15:25:05 -08:00
Henry de Valence
f39566cf16 Change CompressedDecaf::to_bytes to ::as_bytes 2017-02-26 15:25:05 -08:00
Henry de Valence
2cef5fcecd Add CompressedEdwardsY::as_bytes 2017-02-26 15:25:05 -08:00
Isis Lovecruft
e6b7192d5e
Merge branch 'feature/rename-niels-point' into develop 2017-02-25 01:26:33 +00:00
Isis Lovecruft
a649ea38ee
Rename {PreComputed,Cached}Point → {Affine,Projective}NielsPoint.
* FIXES Issue #28: https://github.com/isislovecruft/curve25519-dalek/issues/28
2017-02-25 00:47:06 +00:00
Henry de Valence
d450659b7f Rewrite CompressedEdwardsY::decompress() to use FieldElement::sqrt_ratio 2017-02-22 20:59:51 -08:00
Henry de Valence
1febf3f753 Add an invsqrt_ratio function. 2017-02-22 20:59:50 -08:00
Henry de Valence
a202f36916 Rewrite invsqrt to avoid using an Option type. 2017-02-22 16:24:11 -08:00
Isis Lovecruft
74feb0db75
Merge remote-tracking branch 'hdevalence/feature/decaf_r15' into develop 2017-02-22 05:30:18 +00:00
Isis Lovecruft
ff28cacd13
Enable std and std macros during test builds. 2017-02-22 03:07:57 +00:00
Henry de Valence
f93dd4ccf5 Use is_identity() in the torsion subgroup tests.
ht @dconnolly for pointing this out
2017-02-21 15:13:18 -08:00
Henry de Valence
9473299d04 Add benchmarks for Decaf [de]compression 2017-02-21 14:59:25 -08:00
Henry de Valence
dd8f17dfb3 Add note on feature-gating 2017-02-21 13:43:10 -08:00
Henry de Valence
95bf09a335 Check xy is nonnegative, y nonzero in decoding. 2017-02-21 13:43:09 -08:00
Henry de Valence
5daa217b18 Fix sign error 2017-02-21 13:43:09 -08:00
Henry de Valence
6b3dbf6870 Add another test and some notes 2017-02-21 13:43:09 -08:00
Henry de Valence
93be83c6df Check that s = |s| in decompression. 2017-02-21 13:43:09 -08:00
Henry de Valence
9cb48c44ba Use conditional_negate in Decaf 2017-02-21 13:43:03 -08:00
Henry & Isis
c2bee88c0f Add a feature gate for unfinished implementations. 2017-02-21 13:39:01 -08:00
Henry & Isis
ea5efcdc29 Add impl of Identity for DecafPoint and CompressedDecaf 2017-02-21 13:39:00 -08:00
Henry & Isis
f06afbc493 Add a coset4 function for debugging 2017-02-21 13:39:00 -08:00
Henry & Isis
375d326e75 Change some tests to use new API 2017-02-21 13:39:00 -08:00
Henry & Isis
db17dc4b78 Add Eq implementation for DecafPoint 2017-02-21 13:39:00 -08:00
Henry & Isis
bf19df64f0 Add ScalarMult and BasepointMult impls for DecafPoint 2017-02-21 13:39:00 -08:00
Henry & Isis
084c29c4ed Implement addition and subtraction for DecafPoint. 2017-02-21 13:39:00 -08:00
Henry & Isis
f52e2ee37e Create BasepointMult and ScalarMult traits. 2017-02-21 13:38:59 -08:00
Henry de Valence
66e598a47c Minor doc tweaks 2017-02-21 13:38:59 -08:00
Henry de Valence
0992237233 XY is a misleading variable name, use T instead 2017-02-21 13:38:59 -08:00
Henry de Valence
ec82e7a4f4 Create a DecafPoint struct, wrapping an ExtendedPoint 2017-02-21 13:38:59 -08:00
Henry de Valence
08fc10f356 Rename DecafPoint -> CompressedDecaf 2017-02-21 13:38:59 -08:00
Henry de Valence
eec7747be7 Move Decaf code to decaf.rs 2017-02-21 13:38:59 -08:00
Henry de Valence
f18ebe9430 First draft of decaf decompression 2017-02-21 13:38:58 -08:00
Henry de Valence
a415caa9fb Add a seperate invsqrt function.
This code isn't constant-time, but maybe should be.  However that would
prevent a bunch of nice things (e.g., Option types).  Probably good to
think about this.
2017-02-21 13:38:58 -08:00
Henry de Valence
ee5958c407 Add is_[non]negative_decaf functions.
Computes whether a point is nonnegative in the same way as Mike Hamburg's code.
2017-02-21 13:37:50 -08:00
Henry de Valence
3fc5f75300 Rename is_negative to is_negative_ed25519 2017-02-21 13:23:57 -08:00
Henry de Valence
5720e249ab Add constants for points of the eight-torsion subgroup. 2017-02-21 13:23:57 -08:00
Henry de Valence
ee5ea0a013 Make double functions public 2017-02-21 13:23:11 -08:00
Henry de Valence
dd23a48ade Make ExtendedPoint attrs pub as we need them in constants.rs 2017-02-21 13:23:11 -08:00
Henry de Valence
82041c2c67 Add constant for bytes of (p-1)/2. 2017-02-21 13:23:11 -08:00
Henry de Valence
363ea405d4 Add constant for a-d = -1-d 2017-02-21 13:23:11 -08:00
Henry de Valence
6fd3028956 Add constant for 4*d 2017-02-21 13:23:10 -08:00
Henry de Valence
fb0c431184 Add constant for MSQRT_M1, equal to -SQRT_M1 2017-02-21 13:23:10 -08:00
Henry de Valence
e1feb653be Add constant value of 1/2 (mod p) 2017-02-21 13:23:10 -08:00
Henry de Valence
79afc6bd0f Add debugging checks to test if points are on the curve 2017-02-21 13:23:10 -08:00
Henry de Valence
cb4ff3097c Add FieldElement::is_zero() 2017-02-21 13:23:10 -08:00
Isis Lovecruft
44e7d500db
Remove unused import of PartialEq and Eq in curve module. 2017-02-21 21:01:58 +00:00
Isis Lovecruft
e4d041836e
Move load3 and load4 to new utils module and remove #[allow(dead_code)]. 2017-02-21 06:15:08 +00:00
Isis Lovecruft
4b738c7e19
Remove #[allow(dead_code)] from arrays_equal_ct(). 2017-02-21 06:06:16 +00:00
Isis Lovecruft
6f67a7d716
Rename util module to subtle.
* CHANGE subtle module documentation slightly to clarify the module's purpose.
 * FIXES issue #25.
2017-02-21 06:01:22 +00:00
Isis Lovecruft
3eb5dcaae7
Implement CTEq for ExtendedPoint. 2017-02-21 05:45:37 +00:00
Isis Lovecruft
b1afdf5204
Implement CTEq for FieldElement. 2017-02-21 05:44:35 +00:00
Isis Lovecruft
5308fef210
Add CTEq trait and implement it for Scalar. 2017-02-21 05:44:35 +00:00
Isis Lovecruft
1381e07ffb
Implement a method for determining if an element is the identity.
This corresponds to ge_isneutral() in Open Whispersystems' ed25519 library.
2017-02-21 05:43:20 +00:00
Isis Lovecruft
03589dff43
Add method for determining if an ExtendedPoint is of small order. 2017-02-21 05:41:16 +00:00
Isis Lovecruft
7b57be69fd
Implement constant time equality check for scalars. 2017-02-21 05:41:14 +00:00
Isis Lovecruft
32da4c7d50
Implement Neg for Scalar. 2017-02-21 05:41:14 +00:00
Isis Lovecruft
51f59565f5
Typo fix; Negateable → Negatable.
* Fixup on #22.
2017-02-21 04:15:15 +00:00
Isis Lovecruft
9154e59ec1
Merge remote-tracking branch 'hdevalence/feature/conditional-negation' into develop 2017-02-21 04:13:29 +00:00
Isis Lovecruft
8c432ef78a
Another obsessive compulsive whitespace fix. 2017-02-21 01:46:01 +00:00
Henry de Valence
dc5621f527 Use conditional_negate in select_precomputed_point 2017-02-20 15:30:59 -08:00
Henry de Valence
8a1c13ef49 Make a CTNegateable trait with a generic impl for better ergonomics 2017-02-20 15:30:59 -08:00
Henry de Valence
5f4de0074d Add a conditional negation function. 2017-02-20 15:30:59 -08:00
Isis Lovecruft
57884ecefa
Merge remote-tracking branch 'hdevalence/feature/derive-eq-partialeq-compressededwardsy' into develop 2017-02-20 02:14:37 +00:00
Isis Lovecruft
5f70ab55f8
Obsessive compulsive whitespace fix. 2017-02-20 01:58:56 +00:00
Henry de Valence
eaa5d3e595 Derive Eq, PartialEq for CompressedEdwardsY 2017-02-19 17:39:48 -05:00
Isis Lovecruft
1e7199dcc4
Remove now unused core::clone::Clone from scalar. 2017-01-27 02:16:30 +00:00
Isis Lovecruft
366e9029bf
Rename a CompressedPoint from #17 to CompressedEdwardsY (from #6). 2017-01-27 02:15:31 +00:00
Isis Lovecruft
d88b6c01c4
Merge remote-tracking branch 'tarcieri/no-std' into develop 2017-01-27 02:13:04 +00:00
Isis Lovecruft
d4cccbc4d8
Whitespace cleanup in constants module. 2017-01-27 01:38:56 +00:00
Isis Lovecruft
0c14f58797
Merge remote-tracking branch 'burdges/patch-1' into develop 2017-01-27 00:40:32 +00:00
Isis Lovecruft
8c986fb3da
Allow non-snakecase in constants.
We follow the standard mathematical naming convention of lowercase to
denote affine coordinates and uppercase to for projective.
2017-01-27 00:34:38 +00:00
Isis Lovecruft
3f900e60bd
Change CompressedPoint in constants module to CompressedEdwardsY. 2017-01-27 00:33:59 +00:00
Isis Lovecruft
1d964fa4b7
Merge remote-tracking branch 'hdevalence/feature/seperate-constants-file' into develop 2017-01-27 00:15:31 +00:00
Jeff Burdges
b96281ab12 Link needs http://www. 2017-01-23 00:29:02 -05:00
Isis Lovecruft
39f417f75e
Merge remote-tracking branch 'hdevalence/feature/move-ct-traits' into develop 2017-01-20 21:51:19 +00:00
Isis Lovecruft
6d2ab84d38
Merge remote-tracking branch 'hdevalence/feature/add-mult-cofactor-fn' into develop 2017-01-19 23:37:50 +00:00
Isis Lovecruft
761ef304d4
Merge remote-tracking branch 'hdevalence/feature/rename-compressed-point' into develop 2017-01-19 23:33:58 +00:00
Tony Arcieri
d08bc7395e Add #![no_std] (fixes #16)
Use ::core in lieu of ::std, allowing this crate to be usable in #![no_std]
environments.

Gates features that presently depend on ::std (presently just rand) behind a
"std" cargo feature, which is enabled by default.
2017-01-18 15:16:01 -08:00
Henry de Valence
46bf69b80e Test basepoint multiple generation 2017-01-09 16:15:23 -05:00
Henry de Valence
187d4d3c09 Make some conversions public 2017-01-09 16:15:23 -05:00
Henry de Valence
6559e1de37 Derive Eq for PreComputedPoints 2017-01-09 16:15:22 -05:00
Henry de Valence
d94edc6a36 Move compressed basepoint into constants
Would be good to have the basepoint itself, but this doesn't seem possible: the
fields of an ExtendedPoint are not public, so we can't construct them outside
of curve.rs (by design, to prevent constructing invalid points).  Maybe const
fn support could change this.
2017-01-09 16:15:22 -05:00
Henry de Valence
ff9e78572c Add a way to construct precomputed points 2017-01-09 16:15:22 -05:00
Henry de Valence
16b4be6663 Add fixme on SQRT_MINUS_A 2017-01-08 15:11:16 -05:00
Henry de Valence
7ee568780b Shorten docstring on monty A value 2017-01-08 15:11:16 -05:00
Henry de Valence
8a5332b220 Remove unused, incorrect a value
This was presumably added for use with formulas that use two multiplications by
small constants (i.e., 121665 and 121666) instead of one multiplication by a
large constant (i.e., -121665/121666), but we don't use those formulas.
2017-01-08 15:11:16 -05:00
Henry de Valence
8fb9e44dd2 Test that d = -121665/121666 2017-01-08 15:11:16 -05:00
Henry de Valence
3f7d06138a Test that SQRT_M1 is a square root of -1 2017-01-08 15:11:15 -05:00
Henry de Valence
a9e3c330a6 Move constants into its own module 2017-01-08 14:39:25 -05:00
Henry de Valence
63e7e9f8de Implement CTAssignable for Scalar 2017-01-06 12:56:53 -05:00
Henry de Valence
74049e039e Make FieldElement's conditional_assign a trait impl 2017-01-06 12:34:57 -05:00
Henry de Valence
c92ebdd0ac Remove unused conditional_choose function 2017-01-06 12:29:24 -05:00
Henry de Valence
098ff2ffca Move CTAssignable trait to util.rs from curve.rs 2017-01-06 12:26:43 -05:00
Henry de Valence
4a5d7052a9 Add convenience wrapper around mult_by_pow_2 to clear cofactor 2017-01-06 10:47:05 -05:00
Henry de Valence
d1599410ee Rename CompressedPoint -> CompressedEdwardsY
This allows other compression formats (e.g., CompressedMontgomeryX).
2016-12-23 17:50:24 -08:00
Henry de Valence
ef2987349f Add bench for unpacked multiply_add 2016-12-23 13:01:16 -08:00
Henry de Valence
85d4b7e98c Split the Scalar type into Scalar and UnpackedScalar
The Scalar type is stored in memory as an array of bytes.  This allows easy
access to the bits of a scalar for Scalar x Point operations, at the cost of
forcing a pack/unpack for Scalar x Scalar.  This commit splits the Scalar type
into Scalar (packed) and UnpackedScalar (limbs).
2016-12-23 12:49:00 -08:00
Henry de Valence
e2dfa17879 Add fixme on load3/4 as utilities 2016-12-23 10:03:30 -08:00
Isis Lovecruft
c9b0e45afb
Specify the RNG for Scalar::random. 2016-12-14 05:54:22 +00:00
Henry de Valence
c6b1b497b0 Add benchmark for Scalar::random() 2016-12-09 17:45:54 -08:00
Henry de Valence
d8476fe6cf Add a Scalar::random() constructor
This adds a dependency on the `rand` crate, used to construct an
OS-backed CSPRNG.  The implementation in this commit is somewhat
inefficient as it constructs a new OsRng object every time; it might be
better to construct it once.  (Seems like a lot of overhead for a few
getrandom(2) calls...)
2016-12-09 17:38:51 -08:00
Henry de Valence
71bf0d5e53 Remove port of Montgomery conversion from Adam's code
This should be brought back later as part of reworking the compressed
point formats / serialization code.  Right now there's just
"CompressedPoint" which is in the ed25519 format.  Ideally, users should
be able to serialize points to formats used for X25519, for decaf, etc.
and not have to worry too much about the internal model.
2016-12-09 14:49:27 -08:00
Isis Lovecruft
f7972041ab
Fix a typo in lib.rs module documention. 2016-12-08 21:59:52 +00:00
Isis Lovecruft
387a56fe2c
Initial commit. 2016-12-08 05:12:00 +00:00