Commit graph

895 commits

Author SHA1 Message Date
Isis Lovecruft
1f8a19a753
Fix an attempted overflow on absolute value computation for radix-256 tables.
Found by the fuzzer in 4f5d2d4.
2020-01-07 08:04:46 +00:00
Isis Lovecruft
ca1f730790
Fix debug_assert! range in Scalar::to_radix_2w_size_hint(). 2020-01-03 23:56:30 +00:00
Isis Lovecruft
c01bd780dc
Implement radix-32 precomputed scalar multiplication tables. 2019-12-31 02:26:03 +00:00
Isis Lovecruft
cfbcb6ca61
Implement conversions between basepoint table sizes.
This is useful for programs/protocol which can do some heuristics or
learning-based approach towards optimising the table size based on the number of
uses of e.g. a public key, the second basepoint in a Pedersen commitment, etc.,
i.e. the first time a public key is used to verify a signature, the usual
variable-time basepoint multiscalar multiplication is used, however after 1000
verifications, the table size is upgraded, and again after 10000 verifications,
etc.
2019-12-31 02:26:03 +00:00
Isis Lovecruft
8a9e09ba34
Implement larger sizes of basepoint tables.
This implements a macro for implementing the BasepointTable trait, and
uses the macro to create basepoint table types. The default table
still uses radix-16 representation and is ~30KB in size.  The new
table types, and their memory usage and additions required per
basepoint multiplication are:

 * `EdwardsBasepointTableRadix64`: ~120KB, 43 additions
 * `EdwardsBasepointTableRadix128`: ~240KB, 37 additions
 * `EdwardsBasepointTableRadix256`: ~480KB, 32 additions
2019-12-31 02:26:03 +00:00
Isis Lovecruft
383e65f6bd
Add a trait for implementing a basepoint table. 2019-12-27 12:54:52 +00:00
Isis Lovecruft
4f29935c2c
Create macro for generating different sized LookupTable<T>s. 2019-12-27 12:49:32 +00:00
Henry de Valence
6a44f31702 Revert "Merge pull request #296 from isislovecruft/feature/compressed-try-from"
This reverts commit 46f56f91ee, reversing
changes made to a9b1d50c5a.

These changes are not semver-compatible with the 2.0.0 release.
2019-12-10 14:16:24 -08:00
Isis Lovecruft
7e2aed3943
Fix typo of Pippenger's name. 2019-12-10 20:33:53 +00:00
isis agora lovecruft
d52ab8bb6f
Merge branch 'develop' into feature/compressed-try-from 2019-11-26 21:21:14 +00:00
isis agora lovecruft
77203aa1cb
Merge pull request #306 from isislovecruft/feature/236-merge-rebase
Implement Zeroize for Scalar and MontgomeryPoint
2019-10-28 20:28:34 +00:00
isis agora lovecruft
4d1dfbaf03
Merge pull request #305 from isislovecruft/fix/unused-tmp2-warning
Fix a warning that a temporary value isn't used.
2019-10-28 20:20:06 +00:00
Isis Lovecruft
4423394ed8
Fix warning that a temporary value isn't used. 2019-10-28 19:12:00 +00:00
Isis Lovecruft
57f19e018f
Merge remote-tracking branch 'DebugSteven/zeroize' into feature/236-merge-rebase 2019-10-28 19:09:39 +00:00
Isis Lovecruft
409ebd94c0
Remove dev-dependency on deprecated rand_os crate.
The functionality we were using is now contained in the `rand_core` crate, which
we already depend upon.  As far as testing code goes, only benchmarks still
depend upon `rand`, as they use `thread_rng`.
2019-10-28 18:06:29 +00:00
Isis Lovecruft
9ae2e3b482
Change all from_slice() constructors to return Option<T>s.
We due this in lieu of implementing `TryFrom` to allow for API
consumers to use the `?` operator to convert potential `None`s into
their own `Result<T, CustomError>` types for better error handling
with less boilerplate.

Note that this is a breaking API change.
2019-10-28 17:29:15 +00:00
Henry de Valence
4cc0afdcfc
Merge pull request #302 from isislovecruft/fix/228-remove-ristretto-random-test
Remove test for validity of randomly generated RistrettoPoints.
2019-10-28 10:29:11 -07:00
Isis Lovecruft
c21224170a
Remove optional failure dependency and impl std::error::Error. 2019-10-28 17:29:04 +00:00
Isis Lovecruft
1d8b3995c9
Add custom error types, currently only used in TryFrom impls. 2019-10-28 17:28:40 +00:00
Isis Lovecruft
1fa0048262
Implement TryFrom<&[u8]> and ValidityCheck for MontgomeryPoint. 2019-10-28 17:26:23 +00:00
Isis Lovecruft
db3d26f4b9
Fix typo in TryFrom docstring. 2019-10-28 17:26:23 +00:00
Isis Lovecruft
a7f317a2b8
Impl TryFrom<&[u8]> for all compressed point types.
This reduces copy-pasta in downstream users to check the length of the
slice beforehand.
2019-10-28 17:26:23 +00:00
Trangar
ae4bf40e28 Added constants to reduce recalculations in elligator_risteretto_flavor 2019-10-28 11:48:33 +01:00
Isis Lovecruft
0709a27e46
Remove test for validity of randomly generated RistrettoPoints.
This test is no longer necessary as it originally had a possibility of
failure due to the original implementation of the invsqrt() function
in the decompression algorithm.  The failure with the current API is
nonexistent.

* FIXES #288.
2019-10-26 04:27:30 +00:00
Henry de Valence
d0ea313e99 Remove broken impl Zeroize for FieldElement2625x4.
This implementation is broken because the packed_simd types don't implement `Zeroize`.
2019-10-25 15:38:50 -07:00
Henry de Valence
a79459a1c8
Merge pull request #289 from tarcieri/zeroize
Switch from `clear_on_drop` to `zeroize` (fixes #281)
2019-10-23 20:17:14 -07:00
Tony Arcieri
9480844b8d Switch from clear_on_drop to zeroize (fixes #281)
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
2019-10-23 16:39:21 -07:00
Henry de Valence
70e46c9826 Fill in missing Serde impl for MontgomeryPoint. 2019-10-23 15:55:03 -07:00
Henry de Valence
0fc534d989 Use "tuples" instead of "bytes" in the Serde datamodel.
This is a breaking change to the serialization format.  It fixes it so that the
Serde encoding can match the conventional encoding of each type of object, and
so that Serde can be used with no overhead -- when using serde-bincode, the
Serde encoding now matches the manual encoding.
2019-10-23 15:40:50 -07:00
Henry de Valence
29ce0d4fe9 Add length checks to serde-bincode tests.
This ensures that the serde Serialize and Deserialize implementations use
fixed-length Serde tuples, rather than variable-length byte arrays.  This flaw
in data modeling was pointed out by Trevor Perrin.
2019-10-23 15:28:48 -07:00
Henry de Valence
620d17ef40
Merge pull request #293 from dalek-cryptography/remove-build-rs
Remove build.rs constants generation.
2019-10-23 14:44:46 -07:00
Henry de Valence
574217694e Remove build.rs.
This was more useful at the time when we were determining, e.g., optimal lookup
table sizes and could regenerate them more easily, but it came at a massive
complexity cost.  It also meant that we were unable to implement backend
autoselection.  This commit removes the `build.rs` entirely.  In the future, a
different `build.rs` could be added that auto-selects a backend, but it seems
like the current default-u64 setup has been working fine.
2019-10-23 14:20:38 -07:00
Isis Lovecruft
019b81aa20
Clarify docs for the choice of sign for MontgomeryPoint.to_edwards(). 2019-10-23 19:49:06 +00:00
Isis Lovecruft
7c5ba69491
Update copyright year. 2019-10-23 19:43:56 +00:00
Isis Lovecruft
028c0b9d4d
Fix typo in 64-bit scalar implementation code comment. 2019-10-23 19:35:57 +00:00
François Garillot
9785f56c0f
Rust fixes for some clippy warnings
Clippy lints with instances in the project but NOT applied here, since they seem consistently at odds with the projects' style:
- [unreadable literal](https://rust-lang.github.io/rust-clippy/master/#unreadable_literal)
- [cast lossless](https://rust-lang.github.io/rust-clippy/master/#cast_lossless)
- [assign op pattern](https://rust-lang.github.io/rust-clippy/master/#assign_op_pattern)
2019-10-05 12:02:08 -07:00
François Garillot
023fdf2a2c
Rust added support for the ? operator on Option in 1.22
This converts a few instances of an early-returning unwrap to it.
2019-10-05 11:44:36 -07:00
root
2d0c5323cb errata and basepoint_odd_lookup_table test for better understanding 2019-09-04 13:15:09 +08:00
root
8da05f7e90 errata and basepoint_odd_lookup_table test for better understanding 2019-09-04 12:38:02 +08:00
root
f6015c66c2 errata for comment 2019-09-03 10:38:23 +08:00
Henry de Valence
b01888a929
Merge pull request #260 from fabric-and-ink/ed-decompress-simplify
Remove unneeded check for negativity in edwards point decompression
2019-08-07 12:57:24 -07:00
Fabian Drinck
26ae185bc9
Apply suggestion by @hdevalence
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2019-08-07 19:43:10 +02:00
Henry de Valence
cfa09d859f Use upstream IFMA intrinsics now that they exist. 2019-08-06 17:14:31 -07:00
Henry de Valence
4bbcc28cdc
Merge pull request #275 from Pratyush/fix-docs-link-on-avx2
Fix link to AVX2 docs
2019-08-06 17:08:30 -07:00
Pratyush Mishra
912fe4794f Fix link to AVX2 and IFMA docs 2019-08-06 16:53:54 -07:00
Henry de Valence
4bc2ec0082
Merge pull request #276 from dalek-cryptography/quarkslab
Fix issues found in Quarkslab audit
2019-08-06 16:08:23 -07:00
Henry de Valence
68b71578af
Merge pull request #274 from 3for/comment-fix
`curve_models` Comment fix
2019-08-06 16:07:13 -07:00
Henry de Valence
a480844992 Tighten a too-permissive debug_assert in NafLookupTable8.
This issue was found by Laurent Grémy & Nicolas Surbayrole of Quarkslab.
2019-08-06 15:21:06 -07:00
Henry de Valence
90baabe50b Ensure Scalar Add and Sub produce canonical results.
Closes #238.

This issue was discovered independently by both Jack "str4d" Grigg
(issue #238), who noted that reduction was not performed on addition, and
Laurent Grémy & Nicolas Surbayrole of Quarkslab, who noted that it was possible
to cause an overflow and compute incorrect results.
2019-08-06 15:20:19 -07:00
Jack Grigg
a3246d82e5 Tests showing that scalar addition and subtraction don't reduce mod l 2019-08-06 15:18:46 -07:00
root
ccaf86ea86 curve_models link in comment mismatch 2019-08-06 16:40:47 +08:00
Henry de Valence
01d9e904e1 Add a missing wrapping_sub in NAF computation.
Found by @3for; this only affected width-7 NAF computations, which were never
used in the source tree (only width 5, optimal for dynamic cases, and 8, better
for static cases).

Closes #272
2019-08-05 15:56:56 -07:00
root
2a46cd3b20 add non-zero assert in field batch_invert 2019-08-01 15:02:15 +08:00
Henry de Valence
5c18bfb6a7 Update doc(include) paths.
Since https://github.com/rust-lang/rust/pull/60938 the path root changed and
these new paths are required to compile on nightly.

Closes #268.
2019-07-31 14:54:24 -07:00
Daan Sprenkels
e4c086ab59
Fix a typo in AVX2
Last two (least significant) limbs should be `z8`, `z9`. Were probably
copy-paste typos.
2019-07-22 14:17:23 +02:00
Fabian Drinck
53da2aaaf4 Remove unneeded check for negativity in edwards point decompression
The function `FieldElement::sqrt_ratio_i` always returns a positive root
by definition. Therefore the test for negativity in the edwards point
decompression function always returns false and we only need to flip its
sign if `compressed_sign_bit` is set.
2019-06-07 21:04:12 +02:00
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
DebugSteven
ba389040de implement Zeroize for Scalar and MontgomeryPoint 2019-03-03 17:09:34 -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
Henry de Valence
a84f9eafe4 Allow non_snake_case in the IFMA field and edwards modules. 2019-01-18 14:19:30 -08:00
Henry de Valence
06766bfdea Delay shuffles that cross the "Great Wall of Intel". 2019-01-18 14:19:30 -08:00
Henry de Valence
33aa544cf4 Add IFMA constants file. 2019-01-18 14:19:30 -08:00
Henry de Valence
f825426ff4 Add impl Default, Identity for ExtendedPoint, CachedPoint. 2019-01-18 14:19:30 -08:00
Henry de Valence
da62569355 Add lookup table support. 2019-01-18 14:19:30 -08:00
Henry de Valence
6cec313f16 Add impl of Sub and Neg for Edwards points. 2019-01-18 14:19:30 -08:00
Henry de Valence
6faaef21df Add mul_by_pow_2 for IFMA 2019-01-18 14:19:30 -08:00
Henry de Valence
8e38ff2859 Add Edwards doubling implementation. 2019-01-18 14:19:30 -08:00
Henry de Valence
c4617b28a9 Add squaring implementation. 2019-01-18 14:19:30 -08:00
Henry de Valence
a62571b003 Reduce field elements during conversion to vector form.
The IFMA types have tighter bounds than the u64 types.
2019-01-18 14:19:30 -08:00
Henry de Valence
3f21bb3b58 Add skeleton of parallel Edwards formulas. 2019-01-18 14:19:30 -08:00
Henry de Valence
5880fced2b Add skeleton of shuffle and blend functions. 2019-01-18 14:19:30 -08:00
Henry de Valence
d90bb779ca Delay all computations using x[0], y[0]
Since computation of the 0 term in reduction requires a multiplication with a
4-cycle latency, this ensures that the rest of the computation can start before
the 0 term is finished
2019-01-18 14:19:30 -08:00
Henry de Valence
c925c76342 Change the strategy for reducing the high half of the product. 2019-01-18 14:19:30 -08:00
Henry de Valence
607b839032 Change size of limbs in the reduction test. 2019-01-18 14:19:30 -08:00
Henry de Valence
14163131f9 Lift the reduction state of the field elements into the type system.
This splits the `FieldElement51x4` type into two types:

- `F51x4Reduced` (with reduced limbs)
- `F51x4Unreduced` (with unreduced limbs)

The reduction is implemented as a `From` impl to convert one type to the other.

The output of a multiplication is now a `F51x4Unreduced`.  The reason is that
the inputs to IFMA operations must be at most 52 bits, so it's not possible to
perform an addition of (51+epsilon)-bit values and still be small enough to be
used as an input to multiplication.  So, it doesn't make sense to perform a
reduction at the end of a multiplication, because the reduced values will be
fed into an addition or subtraction, which then needs to be re-reduced.
2019-01-18 14:19:30 -08:00
Henry de Valence
ff49673214 Add impl Mul<(u32, u32, u32, u32)> for FieldElement51x4. 2019-01-18 14:19:30 -08:00
Henry de Valence
70199d6094 Add impl Mul<FieldElement51x4> for FieldElement51x4. 2019-01-18 14:19:30 -08:00
Henry de Valence
aa73d7b1bc Add a FieldElement51x4 type. 2019-01-18 14:19:30 -08:00
Henry de Valence
3233e2eac6 Fix: cfg_target_feature is stable since 1.27. 2019-01-18 14:19:20 -08:00
Henry de Valence
be77af1cd8 Remove unnecessary feature gate.
The vector backend doesn't generate constants in build.rs, so this isn't necessary.
2019-01-18 14:18:55 -08:00
Henry de Valence
47a164da4d Replace avx2_backend with simd_backend (autoselects AVX2/IFMA) 2019-01-18 01:52:17 -08:00
Henry de Valence
9ed2128a10 Add stub code for IFMA intrinsics in Rust. 2019-01-18 01:52:17 -08:00
Henry de Valence
0a97f5fe8c Don't compile the serial scalar_mul when using the vector one. 2019-01-18 01:52:07 -08:00
Henry de Valence
f1d2b5182b Restructure source tree into serial and vector backends.
This begins to attempt to restructure the source tree so that the common parts
are common and the different parts are different.

The backend is now split into two parts:
- serial (containing the implementation using serial formulas and mixed-model arithmetic).
- vector (containing the implementation using parallel formulas and single-model arithmetic).

The serial scalar_mul tree is now under backend::serial::scalar_mul.
The avx2 scalar_mul tree is now under backend::avx2::scalar_mul.
2019-01-18 01:49:40 -08:00
Henry de Valence
94cb3e7842 Rename field types based on radix.
`FieldElement32` -> `FieldElement2625`
`FieldElement64` -> `FieldElement51`
`Scalar32` -> `Scalar29`
`Scalar64` -> `Scalar52`

This naming is more accurate and would let us add an ADX backend later.
2019-01-17 22:21:55 -08:00
Henry de Valence
e6f27ca996 Fix Ristretto variable naming in decoding function
The code swaps u_1 and u_2 relative to the formulas (probably when doing the change for a=-1)
2019-01-13 18:01:00 -08:00
Артём Павлов [Artyom Pavlov]
d6ca36fa0b replace rand with rand_core+rand_os 2019-01-05 14:27:24 +03:00
Jeff Burdges
20fd561482 Support passing both borrowed and owned Rngs 2018-12-26 17:09:20 +01:00
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
isis agora lovecruft
5d0bdf2f21
Merge pull request #205 from dalek-cryptography/fix-subtle-traits
Change to subtle::ConditionallySelectable
2018-11-05 23:50:35 +00:00
isis agora lovecruft
0a1dc053d1
Merge pull request #203 from dalek-cryptography/sqrt_i
Refactor square root computations and Elligator
2018-11-05 23:16:59 +00: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
Henry de Valence
b0a190bd63 Change externally-exposed API to implement ConditionallySelectable 2018-11-02 14:16:51 -07:00
Henry de Valence
8f605dce6d Tweak ristretto elligator to match ristretto.group description 2018-11-01 17:41:56 -07:00
Henry de Valence
4e2fc53e5b Refactor sqrt_ratio to return either sqrt(u/v) or sqrt(iu/v)
Also removes the chi function since Ristretto elligator merges it with the square root.
2018-11-01 17:37:18 -07:00
Tony Arcieri
31e8626133 Update to digest 0.8 and sha2 0.8
Vicariously updates to `generic-array` 0.12, however this change also
removes `generic-array` as a direct dependency, as it can be sourced
from the `digest` crate.
2018-10-19 10:44:42 -07:00
Henry de Valence
e6c9243e46 Merge branch 'develop' into serde-compressed 2018-09-26 15:54:06 -07:00
Henry de Valence
18391bfc5f Add Serde support for compressed points; use bincode for tests. 2018-09-26 15:46:37 -07:00
Isis Lovecruft
b8fa5ec3e0
Add constructors for compressed points from slices. 2018-09-26 02:07:15 +00:00
Isis Lovecruft
819a85ef18
Fix a typo in the curve model docs. 2018-09-13 22:44:41 +00:00