mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-10 21:21:13 +00:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
9422804e13
14 changed files with 46 additions and 126 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "curve25519-dalek"
|
||||
version = "0.13.2"
|
||||
version = "0.14.0"
|
||||
authors = ["Isis Lovecruft <isis@patternsinthevoid.net>",
|
||||
"Henry de Valence <hdevalence@hdevalence.ca>"]
|
||||
readme = "README.md"
|
||||
|
|
@ -12,6 +12,7 @@ categories = ["cryptography", "no-std"]
|
|||
keywords = ["cryptography", "curve25519", "elliptic", "curve", "ECC"]
|
||||
description = "A low-level cryptographic library for point, group, field, and scalar operations on a curve isomorphic to the twisted Edwards curve defined by -x²+y² = 1 - 121665/121666 x²y² over GF(2²⁵⁵ - 19)."
|
||||
exclude = [
|
||||
"**/.gitignore",
|
||||
".gitignore",
|
||||
".travis.yml",
|
||||
]
|
||||
|
|
|
|||
20
README.md
20
README.md
|
|
@ -44,22 +44,34 @@ Extensive documentation is available [here](https://docs.rs/curve25519-dalek).
|
|||
To install, add the following to the dependencies section of your project's
|
||||
`Cargo.toml`:
|
||||
|
||||
curve25519-dalek = "^0.13"
|
||||
```toml
|
||||
curve25519-dalek = "^0.14"
|
||||
```
|
||||
|
||||
Then, in your library or executable source, add:
|
||||
|
||||
extern crate curve25519_dalek
|
||||
extern crate curve25519_dalek;
|
||||
|
||||
## Features
|
||||
|
||||
On nightly Rust, using the `nightly` feature enables a radix-51 field
|
||||
arithmetic implementation using `u128`s, which is approximately twice as
|
||||
fast.
|
||||
fast. It will also enable additional developer documentation when
|
||||
compiling via `make doc-internal`.
|
||||
|
||||
By default, the benchmarks are not compiled without the `bench`
|
||||
feature. To run the benchmarks, do:
|
||||
|
||||
```sh
|
||||
cargo bench --features="bench"
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
We intend to stabilise the following before curve25519-dalek-1.0.0:
|
||||
|
||||
* Implement hashing to a point on the curve (Elligator).
|
||||
* Finish Ristretto (Decaf for curve25519) implementation.
|
||||
* Finish Ristretto documentation.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
4
fuzz/.gitignore
vendored
4
fuzz/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
target
|
||||
corpus
|
||||
artifacts
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
|
||||
[package]
|
||||
name = "curve25519-dalek-fuzz"
|
||||
version = "0.0.1"
|
||||
authors = ["Automatically generated"]
|
||||
publish = false
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies.curve25519-dalek]
|
||||
path = ".."
|
||||
|
||||
[features]
|
||||
yolocrypto = ["curve25519-dalek/yolocrypto"]
|
||||
nightly = ["curve25519-dalek/nightly"]
|
||||
radix_51 = ["curve25519-dalek/radix_51"]
|
||||
|
||||
[dependencies.libfuzzer-sys]
|
||||
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "decaf"
|
||||
path = "fuzz_targets/decaf.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "scalar_constructor_accepts_256bit_values"
|
||||
path = "fuzz_targets/scalar_constructor_accepts_256bit_values.rs"
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#![no_main]
|
||||
#[macro_use] extern crate libfuzzer_sys;
|
||||
extern crate curve25519_dalek;
|
||||
|
||||
use curve25519_dalek::curve::ValidityCheck;
|
||||
use curve25519_dalek::decaf::DecafPoint;
|
||||
use curve25519_dalek::field::FieldElement;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if data.len() != 32 {
|
||||
return;
|
||||
}
|
||||
let mut field_bytes = [0u8; 32];
|
||||
for (by, data) in field_bytes.iter_mut().zip(data.iter()) {
|
||||
*by = *data;
|
||||
}
|
||||
let fe = FieldElement::from_bytes(&field_bytes);
|
||||
let p = DecafPoint::elligator_decaf_flavour(&fe);
|
||||
assert!(p.0.is_valid());
|
||||
p.compress();
|
||||
});
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#![no_main]
|
||||
#[macro_use] extern crate libfuzzer_sys;
|
||||
extern crate curve25519_dalek;
|
||||
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
|
||||
/// Check that the Scalar constructor accepts 256-bit input values and
|
||||
/// behaves correctly on them.
|
||||
///
|
||||
/// Specifically, we take 256-bit values `a` and `b` from the fuzzer
|
||||
/// input data and check that `(a mod l) * (b mod l) == (a * b) mod l`.
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if data.len() != 64 {
|
||||
return;
|
||||
}
|
||||
let mut a_bytes = [0u8; 32];
|
||||
let mut b_bytes = [0u8; 32];
|
||||
|
||||
// Set a, b to be random 256-bit integers
|
||||
a_bytes.copy_from_slice(&data[ 0..32]);
|
||||
b_bytes.copy_from_slice(&data[32..64]);
|
||||
|
||||
// Compute c = a*b (mod l)
|
||||
let c1 = &Scalar(a_bytes) * &Scalar(b_bytes);
|
||||
|
||||
// Compute c = (a mod l) * (b mod l)
|
||||
let mut tmp = [0u8; 64];
|
||||
tmp[0..32].copy_from_slice(&a_bytes[..]);
|
||||
let a_mod_l = Scalar::reduce(&tmp);
|
||||
tmp[0..32].copy_from_slice(&b_bytes[..]);
|
||||
let b_mod_l = Scalar::reduce(&tmp);
|
||||
|
||||
let c2 = &a_mod_l * &b_mod_l;
|
||||
|
||||
assert_eq!(c1, c2);
|
||||
});
|
||||
Loading…
Reference in a new issue