Henry de Valence
ae46ecd445
Rename BASE_CMPRSSD to ED25519_BASEPOINT_COMPRESSED.
2018-01-29 12:38:58 -08:00
Henry de Valence
06994e8139
Tidy docs for public constants in backends
2018-01-29 12:38:58 -08:00
Henry de Valence
739755cb1c
Fix up constants docstrings
2018-01-29 12:38:58 -08:00
Henry de Valence
d3a8ee0d7b
Remove BASEPOINT_ORDER_MINUS_* constants
...
These were originally added in 32da4c7d50
to implement Scalar negation in terms of multiply-add.
But we have a full implementation of scalar arithmetic now, so it's not
necessary to keep the constants around.
2018-01-29 12:38:58 -08:00
Henry de Valence
3b5a8f84a8
Add an is_torsion_free function and document cofactor-related functions.
2018-01-26 16:07:52 -08:00
Henry de Valence
3d2cf74261
Add docs on Edwards points
2018-01-26 15:36:06 -08:00
Henry de Valence
d4d9d86d72
Fix up coffee/ristretto reference
2018-01-26 15:35:51 -08:00
Henry de Valence
12e658401c
Reword Ristretto intro
2018-01-26 14:53:31 -08:00
Henry de Valence
52904b5c3e
Use math for multiscalar docs
2018-01-26 13:39:11 -08:00
Henry de Valence
4b47087b40
Refactor Ristretto notes into doc and doc-internal sections.
2018-01-26 13:35:30 -08:00
Henry de Valence
576e27982f
Tweak module header names
2018-01-26 10:44:48 -08:00
Henry de Valence
fbd84af767
Ristretto API docs fixups
2018-01-25 17:34:57 -08:00
Henry de Valence
d04d3719a5
Add logo to sidebar
2018-01-25 17:34:20 -08:00
Henry de Valence
99921de6f3
Use README.md for the crate docs, and rewrite it.
2018-01-25 16:26:05 -08:00
Henry de Valence
ce45cfec8e
This isn't true after renaming the struct
2018-01-25 12:16:11 -08:00
Henry de Valence
3f7923b628
Keep the AVX2 point type named as ExtendedPoint.
2018-01-25 12:00:40 -08:00
Isis Lovecruft
4f37785f0e
Rename ExtendedPoint to EdwardsPoint.
2018-01-25 02:56:38 +00:00
Isis Lovecruft
9cb915126e
Merge remote-tracking branch 'dalek/feature/borrow-operators' into develop
2018-01-25 02:00:52 +00:00
Henry de Valence
86fd06db00
s/eps/epsilon/ for clarity
2018-01-24 12:42:57 -08:00
Henry de Valence
52d600db95
Implement public-facing ops traits on all combos of &T/T
...
The public-facing types with arithmetic operations are:
- `Scalar`s
- `ExtendedPoint`s
- `RistrettoPoint`s
For these types we define operators with all combinations of borrowed and
non-borrowed inputs, to avoid forcing API consumers to write extra ampersands.
Since all of the operations involved with these types are expensive relative to
the cost of an unnecessary copy, this isn't a big deal.
The `MontgomeryPoint` struct isn't included in the above because it's only
useful for scalar multiplication.
This commit is based on work by @UnlawfulMonad.
2018-01-24 11:05:06 -08:00
Henry de Valence
0e9b8e0a6e
Refactor multiply implementation to eliminate reduce() call
2018-01-19 18:23:41 -08:00
Henry de Valence
ec50ec96f7
Use parallel carry-ins and carry-outs in FieldElement64::reduce()
2018-01-19 17:50:48 -08: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
b20ccbd685
Implement batched encoding for RistrettoPoints
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
Isis Lovecruft
0012e1f12f
Merge remote-tracking branch 'hdevalence/feature/avx2_r7' into develop
2018-01-19 23:46:30 +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
Henry de Valence
f816083575
Use >> instead of srl intrinsic
2018-01-03 14:04:27 -08:00
Henry de Valence
4cbff3983d
Remove fixme notes
2018-01-03 14:01:48 -08:00
Henry de Valence
628af18a1d
Suppress some warnings
2018-01-03 13:57:50 -08:00
Henry de Valence
3686562b2f
Clear memory from avx2 multiscalar mult
2018-01-03 13:37:12 -08:00
Henry de Valence
d41dbb1fe4
Replace some binary constants with named constants
2018-01-03 12:34:25 -08:00
Henry de Valence
dd80421094
Move field constants to constants module
2018-01-03 12:13:52 -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
ce68b8d72b
Document bounds yoga in doubling
2017-12-18 14:48:44 -08:00
Henry de Valence
af3c2b2821
Document readdition
2017-12-18 13:58:37 -08:00
Henry de Valence
c0f64009a7
Implement readdition using a CachedPoint type
2017-12-18 11:42:53 -08:00
Henry de Valence
80813e81b1
make diff_sum maskable
2017-12-15 15:24:13 -08:00
Henry de Valence
0f6171b788
Try to make stdsimd an optional dependency
2017-12-15 13:57:01 -08:00
Henry de Valence
caf296a546
Try to make target_feature work on stable
2017-12-15 13:57:01 -08:00
Henry de Valence
70f710eafe
Use the LookupTable struct in AVX2 code
2017-12-15 13:57:01 -08:00
Henry de Valence
34f44dcf5d
Merge branch 'develop' into feature/avx2_r8
2017-12-15 11:37:10 -08:00
Henry de Valence
640888198e
Eliminate a carry pass through tighter bounds checks
2017-12-14 14:17:34 -08:00
Henry de Valence
a3f53c9134
Refactor select_precomputed_point into a LookupTable struct.
...
Originally this was for hygiene, so that we could erase points from
heap-allocated memory in multiscalar_mult, but it ends up providing a cleaner
API for scalar multiplication.
It's kept inside curve_models for now, but it could go somewhere else if that's a better place.
2017-12-07 12:46:57 -08:00
Henry de Valence
98a78d7a58
Clear scalar digits from memory in multiscalar_mult
2017-12-07 12:34:40 -08:00
Henry de Valence
d62fc7caf1
Rearrange signs to avoid a subtraction
2017-12-07 10:55:33 -08:00
Henry de Valence
1d39d2ec6e
Implement Default for internal point types
2017-12-06 17:30:19 -08:00
Henry de Valence
7d2d87441b
Connect double_scalar_mult_basepoint to AVX2 backend
2017-12-04 11:05:24 -08:00
Henry de Valence
2c29d9a2ad
tweak docs
2017-12-04 10:37:37 -08:00
Henry de Valence
3814beeafe
Fix typo and add note on AVX512VL
2017-12-04 10:37:37 -08:00
Henry de Valence
bf5e3581d2
Update AVX2 docs
2017-12-04 10:37:37 -08:00
Henry de Valence
1103c5c43a
Implement Sub by pre-negating the point
2017-12-04 10:37:37 -08:00
Henry de Valence
e3579995c0
Add double-base scalar vartime for AVX2
2017-12-04 10:37:37 -08:00
Henry de Valence
9213dc0bbb
Implement point subtraction
2017-12-04 10:37:37 -08:00
Henry de Valence
3094866442
Fix up after Scalar API changes
2017-12-04 10:37:37 -08:00
Henry de Valence
ba071f12aa
Write up notes on the AVX2 backend
2017-12-04 10:37:37 -08:00
Henry de Valence
3d435a1f4f
Fix up tests to use new Scalar API
2017-12-04 10:37:37 -08:00
Henry de Valence
b5305b4e30
Connect multiscalar_mult to the AVX2 backend
2017-12-04 10:37:37 -08:00
Henry de Valence
912fc5d412
Never build avx2 without avx2
2017-12-04 10:37:37 -08:00
Henry de Valence
97fe2f0bf4
Try to connect the AVX2 backend to the ExtendedPoint frontend
2017-12-04 10:37:37 -08:00
Henry de Valence
77766b3422
Add benchmark for conversion to avx2 format
2017-12-04 10:37:37 -08:00
Henry de Valence
208180dc72
Simplify mul, square implementations
2017-12-04 10:37:37 -08:00
Henry de Valence
f28635ab4e
Add a new 'avx2_backend' yolocrypto feature
2017-12-04 10:37:37 -08:00
Henry de Valence
841e0d5b64
Fix wrong feature for benchmarks
2017-12-04 10:37:37 -08:00
Henry de Valence
81ecef89ee
Connect AVX2 and u64 backends
2017-12-04 10:37:37 -08:00
Henry de Valence
ed24d1c5fa
Move AVX2 code into a backend
2017-12-04 10:37:37 -08:00
Henry de Valence
2b37a65d66
Remove debugging code
2017-12-04 10:37:37 -08:00
Henry de Valence
1ba7cb1e2c
Add stub implementations of multiscalar mult
2017-12-04 10:37:37 -08:00
Henry de Valence
7354b569bb
Add 32bit reduction code
2017-12-04 10:37:37 -08:00
Henry de Valence
e7ec5b3dd1
Add basepoint table code
2017-12-04 10:37:37 -08:00
Henry de Valence
34ae1b15e0
Add a squaring implementation
2017-12-04 10:37:37 -08:00
Henry de Valence
2f32f6355c
Add doubling skeleton and scalar mult
2017-12-04 10:37:37 -08:00
Henry de Valence
9e383ffccb
Add doubling test harness
2017-12-04 10:37:37 -08:00
Henry de Valence
e2a2b3a3b5
Add comment to mul draft
2017-12-04 10:37:37 -08:00
Henry de Valence
4f6788c72d
First working version
2017-12-04 10:37:37 -08:00
Henry de Valence
15b88be2d2
Add serial implementation of the algorithm and a test
2017-12-04 10:37:37 -08:00
Henry de Valence
51f04d7cce
first avx2 code
2017-12-04 10:37:37 -08:00
Isis Lovecruft
c71d41ddcc
Whitespace fixes.
2017-12-04 01:17:17 +00:00
Isis Lovecruft
9824894eb1
Merge remote-tracking branch 'hdevalence/feature/texify-formulas' into develop
2017-12-04 01:10:54 +00:00
Henry de Valence
c0633ae2d7
KaTeXify some backend documentation
2017-12-01 11:46:36 -08:00
Henry de Valence
2d6d79dc21
KaTeXify more of edwards.rs
2017-11-30 17:36:56 -08:00
Henry de Valence
10bba1207b
KaTeXify and document basepoint tables
2017-11-30 17:11:25 -08:00
Henry de Valence
786e4b65a8
Add reference to from_bytes_mod_order_wide ctor
2017-11-30 16:48:29 -08:00
Henry de Valence
bb9c171487
fix typo in internal Scalar docs
2017-11-30 16:46:46 -08:00
Henry de Valence
1caed9a4fc
Remove Scalar::multiply_add
2017-11-30 16:44:51 -08:00
Henry de Valence
9e892dd5f3
Rename reduce_wide to from_bytes_mod_order_wide and keep it with the other constructors
2017-11-30 16:44:10 -08:00
Henry de Valence
a6b4467d23
KaTeXify Scalar docs
2017-11-30 16:43:21 -08:00
Isis Lovecruft
d21b74ea36
Line wrap an inline comment.
2017-11-30 22:41:06 +00:00
Henry de Valence
beda5df2f1
Remove "scalar multiplication" since that's more of a scalar*point thing than just a scalar thing
2017-11-29 13:04:04 -08:00
Henry de Valence
2e9a3cba35
Remove reference to field elts since they're private
2017-11-29 13:03:01 -08:00
Henry de Valence
da8b12a62d
Align montgomery summary to match the edwards summary
2017-11-29 13:01:31 -08:00
Henry de Valence
c209b49264
Tweak description and fix formatting
2017-11-29 13:00:50 -08:00
Henry de Valence
442eba57c9
Comment out #[doc(hidden)] to allow impls to appear in internal docs.
...
This is related to https://github.com/rust-lang/rust/issues/46380 upstream.
2017-11-29 12:40:42 -08:00
Henry de Valence
d862912511
KaTeXify struct docs for internal point types
2017-11-29 12:30:51 -08:00
Henry de Valence
b2a85da09d
Edit curve model description to use KaTeX
2017-11-29 12:07:55 -08:00
Isis Lovecruft
88200f9fc9
Fix Scalar.to_bytes() after merging PR#88.
2017-11-26 04:16:12 +00:00
Isis Lovecruft
220c6c1d13
Merge remote-tracking branch 'hdevalence/feature/refactor-scalar-api' into develop
2017-11-26 04:15:04 +00:00
Isis Lovecruft
227acc117b
Whitespace fix.
2017-11-26 03:26:47 +00:00
Isis Lovecruft
7a0c0e9d0d
Change Debug for Scalar output to be valid Rust code.
2017-11-26 03:26:29 +00:00
Isis Lovecruft
87f93a5df2
Add to_bytes() convenience method for Scalar.
2017-11-26 03:23:31 +00:00
Isis Lovecruft
9a49263752
Add to_bytes() convenience method for CompressedRistretto points.
2017-11-26 03:22:28 +00:00
Henry de Valence
f165b63ee9
Encode scalars canonically using Serde.
2017-11-23 12:29:46 -08:00
Henry de Valence
c1f6302879
Add a Scalar::from_bytes_canonical method
2017-11-23 12:29:46 -08:00
Henry de Valence
9855260bfd
Add a method to test if a Scalar is canonical
2017-11-23 12:29:46 -08:00
Henry de Valence
34639725d4
clean up reduction test
2017-11-23 12:29:46 -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
d88f92276a
Add Scalar::reduce method
2017-11-21 11:28:25 -08:00
Henry de Valence
df182b79d0
Rename Scalar::reduce to Scalar::reduce_wide
...
This opens the `Scalar::reduce` name for reduction mod l.
2017-11-21 11:06:54 -08:00
Henry de Valence
033a90890c
Remove Scalar::{add, sub, mul} methods
2017-11-21 10:43:49 -08:00
Henry de Valence
e94c6f0a96
Make more Scalar methods pub(crate)
2017-11-20 16:45:30 -08:00
Henry de Valence
2d69a8a7dc
Eliminate array_ref dependency
2017-11-20 14:53:08 -08:00
Henry de Valence
504a557b33
Hide UnpackedScalars
2017-11-17 15:51:29 -08:00
Henry de Valence
0cb70ae032
Hide the underlying ExtendedPoint from a Ristretto point
2017-11-17 15:50:58 -08:00
Henry de Valence
a9f8789524
hide unimplemented fns from docs
2017-11-17 15:50:04 -08:00
Henry de Valence
9fda4739d0
Hide fns using private types
2017-11-17 15:42:37 -08:00
Henry de Valence
78d9e70071
Move ExtendedPoint->MontgomeryPoint conversion to edwards.rs
...
Need to find a solution to the internal/external docs problem
2017-11-17 15:13:45 -08:00
Henry de Valence
2b0a4979b1
Fix indentation
2017-11-17 14:09:48 -08:00
Henry de Valence
8337a895d4
Only compress ExtendedPoints
2017-11-17 13:32:22 -08:00
Henry de Valence
7f52745770
Remove unused import
2017-11-16 20:11:18 -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
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
6ce7a4ee2d
Remove catchall 'utils' module
2017-11-16 12:13:13 -08:00
Henry de Valence
e4f5f23b8d
fixup! Merge branch 'optimzed_scalar_r1' into develop
2017-11-16 12:13:13 -08:00
Henry de Valence
207af566b9
Replace signed constants with unsigned constants
2017-11-16 12:13:13 -08:00
Henry de Valence
83e20b5387
cfg-gate all tests using precomputed tables
2017-11-16 12:13:13 -08:00
Henry de Valence
8952c7f476
initial work on rewriting 32bit arithmetic
2017-11-16 12:13:13 -08:00
Henry de Valence
399a9db478
Generate AFFINE_ODD_MULTIPLES_OF_BASEPOINT at compile time
2017-11-16 12:13:13 -08:00
Henry de Valence
e7387650f6
Remove warnings from build.rs
2017-11-16 12:13:13 -08:00
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