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
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
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
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
Isis Lovecruft
c59af2c6b8
Merge branch 'optimzed_scalar_r1' into develop
2017-11-15 22:02:36 +00: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
a7835a1246
UPPERCASE_GLOBALS and add documentation
2017-10-30 17:33:23 -07:00
Henry de Valence
aaa2315703
add failing test case from fuzzer
2017-10-30 22:25:34 +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
Andrew Moon
7e53499a10
optimized scalar implementations for 32/64 bit
2017-09-24 22:24:35 -05: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
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
4bcf8bed9d
Move subtle to its own crate.
2017-05-31 21:20:56 +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
Henry de Valence
69c62a8a17
Serde Scalar support
2017-05-15 22:40:09 -07: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
944e8e1649
Fix and allow some non-snakecased variables in scalar tests.
2017-05-09 00:05:11 +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 & Isis
c6dc9d318d
Add a helper function to construct a Scalar from a u64
2017-05-03 19:32:31 -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
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