Commit graph

42 commits

Author SHA1 Message Date
DebugSteven
39145da396 implement default for MontgomeryPoint using zero byte array 2018-11-14 23:16:50 -05:00
DebugSteven
2adc985f63 default & identity trait for MontgomeryPoint 2018-11-14 14:43:11 -05:00
Henry de Valence
a116fd9679 test subtle 2.0 2018-11-05 12:06:23 -08:00
Henry de Valence
53fcd1060d Change internal API to use ConditionallySelectable 2018-11-02 14:17:43 -07:00
Tony Arcieri
10e8abf926 Unify alloc and std cargo features
This change provides a common convention for using allocator-dependent
features with:

    #![cfg(feature = "alloc")]

When available, `Vec` is imported consistently as `prelude::Vec`, which
means modules that need access to `Vec` can simply do:

    use prelude::*;

and if an allocator is available, `Vec` will be in the crate prelude.

This allows all `alloc` vs `std` gating to be handled in `lib.rs`,
`build.rs`, and `prelude.rs` so the rest of the codebase doesn't have to
do any gating whatsoever.
2018-07-23 10:50:21 -07:00
Isis Lovecruft
38aa0ee2b7
Implement Default for remaining point types.
* FIXES https://github.com/dalek-cryptography/curve25519-dalek/issues/154
2018-07-20 00:47:36 +00:00
Isis Lovecruft
f43f4f9770
Update year in copyright notices to 2018. 2018-07-05 00:30:27 +00:00
Henry de Valence
bbb64312f7 Use rand 0.5
Requires `0.5.0-pre.2`, which adds `impl CryptoRng for OsRng`.
2018-05-15 12:30:28 -07:00
Henry de Valence
9b6c932635 Rename 'precomputed_tables' to the more accurate 'stage2_build' 2018-05-14 15:41:45 -07:00
Isis Lovecruft
3281708965
Define mul variants for MontgomeryPoints.
This results in less changes to the x25519-dalek code to upgrade to
the latest version.
2018-04-02 21:09:41 +00: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
e73b635fe0 Remove unused constants 2018-03-22 12:17:23 -07:00
Henry de Valence
792ac0775e Change to the updated subtle API. 2018-03-22 11:13:26 -07:00
Henry de Valence
6748dddb96 Simplify and optimize Montgomery code.
The `MontgomeryPoint` struct is now a point on the Kummer line of the Montgomery curve.

The `ProjectivePoint` struct is made private, since its only purpose is
internal to the Montgomery ladder.

The Montgomery ladder takes affine input, making it faster, and produces affine output.

The Edwards-Montgomery correspondence is simplified.
2018-02-05 10:40:25 -08:00
Isis Lovecruft
cd112afff5
Whitespace EOL fixes. 2018-01-31 02:19:53 +00:00
Henry de Valence
1d480a8a71 Rename X25519 basepoint to X25519_BASEPOINT_MONTGOMERY 2018-01-29 14:36:45 -08:00
Henry de Valence
ae46ecd445 Rename BASE_CMPRSSD to ED25519_BASEPOINT_COMPRESSED. 2018-01-29 12:38:58 -08:00
Isis Lovecruft
4f37785f0e
Rename ExtendedPoint to EdwardsPoint. 2018-01-25 02:56:38 +00:00
Henry de Valence
a0c93cb730 fix inconsistency in variable naming 2018-01-10 06:04:03 -08:00
Henry de Valence
841c026c13 Remove dead code 2018-01-10 05:49:47 -08:00
Isis Lovecruft
28f114f127
Combine differential_add and differential_double in Montgomery ladder. 2017-12-24 00:17:15 +00:00
Henry de Valence
da8b12a62d Align montgomery summary to match the edwards summary 2017-11-29 13:01:31 -08:00
Henry de Valence
d32fe9772b Ensure that all Scalars are bounded by 2^255.
This commit defines a Scalar to hold an integer representing an element of
Z/lZ.  Applications like X/Ed25519 that care about the bit-patterns of the
scalars they use can set a specific bit-pattern using the `from_bits`
constructor.  Applications that want to treat scalars as integers mod l can use
the `from_bytes_mod_order` constructor.  Either way, the constructor ensures
that the integer representing each Scalar is bounded by 2^255 so that the high
bit is set.  This means that any Scalar object is always safe to use for scalar
multiplication, while maintaining compatibility with both the Ristretto
use-case and the X/Ed25519 usecase.
2017-11-23 12:29:46 -08:00
Henry de Valence
8d0808a077 Split internal curve models into a private submodule 2017-11-16 17:34:28 -08:00
Henry de Valence
83e20b5387 cfg-gate all tests using precomputed tables 2017-11-16 12:13:13 -08:00
Henry de Valence
a7835a1246 UPPERCASE_GLOBALS and add documentation 2017-10-30 17:33:23 -07:00
Henry de Valence
f4135da5c9 Remove is_negative_decaf since ristretto uses the low bit 2017-10-30 16:34:36 -07: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
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
c08591a7d8
Improve documentation for Mongomery code. 2017-10-04 07:31:11 +00: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
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
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