Commit graph

738 commits

Author SHA1 Message Date
Henry de Valence
e17c98a391 Ensure NAF works on manually-constructed extremal values.
The NAF computation can generate a 1 in the last digit (only) when s = 2^255-1,
so someone who manually constructed the value s = 2^255-1 and fed it into a NAF-using
computation could generate an incorrect result.  Some version of this bug has
been present from the beginning of the library, but it has no security content,
because the NAF computations are not applied to secret data, and the error
occurs only on one value which is not constructed by any client caller.
2019-06-05 23:18:43 -07:00
Henry de Valence
389d2bc9e2 Ensure Pippenger works on manually-constructed extremal values.
When using Scalar::from_bits to manually create unreduced Scalars (e.g.,
X/Ed25519 keys with specified bit patterns), it's possible to construct Scalar
values that range up to 2^255-1.  These shouldn't ever end up in a vartime
multiscalar mul call anyways, because it doesn't handle secret data, but it is
technically allowed by the type system and should be handled.  When w=8, these
can generate terminal carries that can't be folded into the last digit, but
this can be handled by folding them into an extra digit instead.
2019-06-05 23:03:07 -07:00
Henry de Valence
5f1d73bca0 Fix a negate-with-overflow edgecase by widening before computation.
This fixes a bug in the Pippenger implementation reported by Fernando Krell and
diagnosed by Oleg Andreev.  The problem is that at the largest problem sizes
(using w=8), the signed digits fill the value range of an i8, and so doing
computation on them to calculate the bucket index can hit an overflow.

This was not caught in CI because the test suite didn't check all problem
sizes; tests for these sizes which expose this bug were added in the previous
commit.
2019-06-05 20:59:07 -07:00
Henry de Valence
6fe93564cd Add a more comprehensive random multiscalar test.
This exercises the constant- and variable- time code at large sizes, to hit
every path of Straus/Pippenger.
2019-06-05 20:54:00 -07:00
Henry de Valence
c084def3a3
Merge pull request #249 from oleganza/oleg/pippenger2
Pippenger multiscalar multiplication algorithm
2019-06-04 15:13:41 -07:00
Henry de Valence
19dcd62053 Add reference to 2012/549 2019-06-04 13:41:43 -07:00
Henry de Valence
5921d6d2ac Replace std::iter with core::iter 2019-06-04 13:36:07 -07:00
Henry de Valence
baaeed23fc
Merge pull request #251 from fabric-and-ink/quench-warning
Quench snake case warning
2019-05-26 20:35:27 -07:00
Fabian Drinck
29dca772a9 Quench snake case warning 2019-05-26 13:03:40 +02:00
Oleg Andreev
eb82a9d8b6
Update src/backend/serial/scalar_mul/pippenger.rs
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2019-05-24 18:00:34 -05:00
Oleg Andreev
9836d6622c cleaner name per Henry’s suggestion 2019-05-24 12:18:10 -07:00
Oleg Andreev
ca2926ac89 use one buffer instead of two 2019-05-22 11:48:30 -07:00
Henry de Valence
dfcac0d8e2 rustfmt and copyright fixes 2019-05-22 11:38:52 -07:00
Oleg Andreev
7fba2a1bcc avoid unnecessary allocation 2019-05-22 11:14:26 -07:00
Oleg Andreev
df745e98a2 oops - forgot to switch on pippenger 2019-05-21 14:10:56 -07:00
Oleg Andreev
33b41ac10d fix type conversions 2019-05-21 13:48:29 -07:00
Oleg Andreev
42648aa460 cgs 2019-05-21 13:32:50 -07:00
Oleg Andreev
b52c2053c1 new pippenger radix 6/7/8 implementation 2019-05-21 12:35:58 -07:00
Henry de Valence
e726147af8
Merge pull request #245 from dalek-cryptography/optimize-variable-base
Save 2.5% on variable-base scmul by squeezing some multiplications.
2019-05-21 08:52:53 -07:00
Henry de Valence
23ca520ac2
Merge pull request #226 from ebfull/faster-equality
Check the equality of `EdwardsPoint`s in the projective coordinates
2019-05-21 08:50:32 -07:00
Henry de Valence
6503378fef Save 2.5% on variable-base scmul by squeezing some multiplications.
This saves 4 point doublings by unwrapping the first loop iteration,
as well as 63 field multiplications (one per iteration) by managing
curve model choice explicitly.
2019-05-08 21:04:13 -07:00
Henry de Valence
b52c7ddafe Suppress a generated <br> which breaks KaTeX. 2019-05-06 15:18:16 -07:00
Mark Blunk
50f46c7685 fix typo in torsion documentation 2019-04-02 14:33:27 -06:00
Dawid Ciężarkiewicz
f612dd9dfa
Remove unnecessary trait bound 2019-03-20 20:30:58 -07:00
Henry de Valence
9a623868c5 Revert #219.
See discussion at https://github.com/dalek-cryptography/curve25519-dalek/issues/232 , copied below:

`1.1` changed the trait bounds for `RistrettoPoint::random` and `Scalar::random`, see #222 and #219.

These changes have two benefits:
* they unlink us from the `rand` crate and make us depend only on `rand_core`;
* they allow passing both owned and borrowed RNGs.

The change was not supposed to be a breaking change, since the new bounds are strictly more general than the old ones (as every `RngCore` is an `Rng` and every `&mut RngCore` is an `RngCore`), so the new bound is satisfied in every situation where the old bound applied.

The `1.1.0-pre.0` version didn't cause problems on the crates I tested it on, but there was an unexpected problem: ce71c93a9a/spacesuit/src/value.rs (L160-L161) broke, since it took a borrow as input and used it twice. So there was slight breakage.

One option is to revert the changes (probably just the ones from #219) and release 1.1.3; another would be to fix up `slingshot` and leave the new bound.
2019-02-15 13:30:05 -08:00
Henry de Valence
b8c62ec4b4 Attempt to fix cfg(rustdoc) on docs.rs
Building the docs currently doesn't work, because rustdoc enables parts of the
code (to document them) which then don't check (because there are missing
exports or dependencies).  This **should** fix the issue, but there's no way to
test without publishing a new version.
2019-02-15 11:18:25 -08:00
Henry de Valence
66b38ce5fc Merge branch 'rng_ref' of git://github.com/burdges/curve25519-dalek into burdges-rng_ref 2019-02-14 14:38:14 -08:00
Henry de Valence
cf7a1a4a0f Merge branch 'rand_core' of git://github.com/newpavlov/curve25519-dalek into newpavlov-rand_core 2019-02-14 14:29:58 -08:00
Henry de Valence
a1123e7cd3
Merge pull request #230 from hdevalence/updated-precomputation
Multiscalar multiplication with precomputation.
2019-02-14 12:18:29 -08:00
Henry de Valence
092ff52cb0 Remove constant-time multiscalar precomputation.
This doesn't (yet) give any speedup over the non-precomputed multiscalar
multiplication, and it's not clear that it's a good idea to commit to
supporting it in the future.  Removing it means that it's not committed-to as
part of the public API, but the source is still there in the tree if we want to
revisit it later.
2019-02-13 12:26:31 -08:00
Henry de Valence
96df60895f Fix comment on Montgomery conversion.
Closes #213.
2019-02-12 19:30:18 -08:00
Henry de Valence
27daa5215e Add Ristretto precomputation facade. 2019-02-12 12:52:02 -08:00
Henry de Valence
8adcfb7fa3 Simplify length checking. 2019-02-12 12:52:02 -08:00
Henry de Valence
727ba86292 Rework the vartime precomputation trait to be Option-al 2019-02-12 12:52:02 -08:00
Henry de Valence
e693d7f020 fixup AVX2 ascii blocks so they don't run as doctests 2019-02-12 12:52:02 -08:00
Henry de Valence
8b0ad2b03d Add vector implementation of precomputation. 2019-02-12 12:52:02 -08:00
Henry de Valence
c6acdfd5e2 Add serial implementation of precomputation. 2019-02-12 12:52:02 -08:00
Henry de Valence
5daff66079 Move cfgs into outer module. 2019-02-12 12:52:02 -08:00
Henry de Valence
98e713ef91 Add a trait for multiscalar multiplication with precomputation. 2019-02-12 12:52:02 -08:00
Sean Bowe
d71b6650d6
Check the equality of EdwardsPoints in the projective coordinates to avoid expensive compressions. 2019-02-06 17:45:25 -07:00
Henry de Valence
ff0dc4a3db Merge branch 'master' into develop 2019-01-27 23:19:44 -08:00
Henry de Valence
5ddc30061c Implement ConstantTimeEq on compressed points. 2019-01-27 23:13:58 -08:00
Henry de Valence
6d7d94372e
Merge pull request #227 from isislovecruft/fix/weird-pub
I found a weird pub, not the kind you get cidre in.
2019-01-24 14:12:10 -08:00
Isis Lovecruft
0d23260a75
I found a weird pub, not the kind you get cidre in. 2019-01-24 21:36:00 +00:00
Isis Lovecruft
4270d4ff5f
Fix two typos in FieldElement::invsqrt documentation. 2019-01-22 01:01:08 +00:00
Henry de Valence
e3ca8961fc Fix rustdoc feature flags to compile on stable. 2019-01-18 14:19:39 -08:00
Henry de Valence
9ddbf1ba83 Add notes on the IFMA implementation. 2019-01-18 14:19:39 -08:00
Henry de Valence
dc8431429f Refactor documentation to use doc_cfg. 2019-01-18 14:19:39 -08:00
Henry de Valence
5700add507 Clean up warnings. 2019-01-18 14:19:30 -08:00
Henry de Valence
fa42708257 Change naming scheme for multiplication accumulators. 2019-01-18 14:19:30 -08:00