mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-05 20:30:54 +00:00
attempt to clean up some dependency issues
This commit is contained in:
parent
0b748f6365
commit
ea4bc9b079
5 changed files with 27 additions and 13 deletions
|
|
@ -1,2 +1,2 @@
|
|||
[build]
|
||||
target="x86_64-unknown-linux-gnu"
|
||||
#[build]
|
||||
#target="x86_64-unknown-linux-gnu"
|
||||
|
|
|
|||
12
Cargo.toml
12
Cargo.toml
|
|
@ -50,7 +50,6 @@ serde = { version = "1.0", default-features = false, optional = true, features =
|
|||
# https://github.com/rust-lang/packed_simd/issues/303#issuecomment-701361161
|
||||
packed_simd = { version = "0.3.4", package = "packed_simd_2", features = ["into_bits"], optional = true }
|
||||
zeroize = { version = "1", default-features = false }
|
||||
rand = { version = "0.7", default-features = false, features = [] }
|
||||
fiat-crypto = { version = "0.1.6", optional = true}
|
||||
|
||||
# 1. eliminate xous-engine-25519 crate
|
||||
|
|
@ -61,7 +60,9 @@ fiat-crypto = { version = "0.1.6", optional = true}
|
|||
# 6. test that cargo test still works in `std`
|
||||
|
||||
# Betrusted/Precursor dependency set
|
||||
engine-25519 = {version = "0.1.0", optional = true}
|
||||
#[dependencies.engine-25519]
|
||||
#version = "0.1.0"
|
||||
#optional = true
|
||||
[dependencies.engine25519-as]
|
||||
#git="https://github.com/betrusted-io/engine25519-as.git"
|
||||
#rev="0bafc1ff8f58b66189d8c2f9ab7046cbbef77e6e"
|
||||
|
|
@ -70,6 +71,11 @@ default-features = false
|
|||
features = []
|
||||
optional = true
|
||||
|
||||
[dev-dependencies.engine25519-as]
|
||||
#git="https://github.com/betrusted-io/engine25519-as.git"
|
||||
#rev="0bafc1ff8f58b66189d8c2f9ab7046cbbef77e6e"
|
||||
path="../engine25519-as"
|
||||
|
||||
[features]
|
||||
nightly = ["subtle/nightly"]
|
||||
default = ["std", "u32_backend"]
|
||||
|
|
@ -90,6 +96,6 @@ simd_backend = ["nightly", "u64_backend", "packed_simd"]
|
|||
# in some future release.
|
||||
avx2_backend = ["simd_backend"]
|
||||
# the betrusted backend uses the curve25519 hardware accelerator in betrusted-soc
|
||||
betrusted = ["engine-25519", "engine25519-as"]
|
||||
#betrusted = ["engine-25519", "engine25519-as"]
|
||||
|
||||
[workspace]
|
||||
|
|
@ -291,6 +291,9 @@ impl FieldElement {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate rand;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use field::*;
|
||||
|
|
@ -480,7 +483,7 @@ mod test {
|
|||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
use engine25519_as::*;
|
||||
use rand::Rng;
|
||||
use self::rand::Rng;
|
||||
|
||||
fn write_helper(file: &mut File, elem: FieldElement) {
|
||||
let elem_bytes = elem.to_bytes();
|
||||
|
|
@ -1051,7 +1054,9 @@ mod test {
|
|||
write_helper(&mut file, qu);
|
||||
write_helper(&mut file, qw);
|
||||
write_helper(&mut file, pmq);
|
||||
#[allow(non_snake_case)]
|
||||
let mut P: ProjectivePoint = ProjectivePoint{U:pu, W:pw};
|
||||
#[allow(non_snake_case)]
|
||||
let mut Q: ProjectivePoint = ProjectivePoint{U:qu, W:qw};
|
||||
differential_add_and_double(&mut P, &mut Q, &pmq);
|
||||
write_helper(&mut file, &(&P.U + &P.W) + &(&Q.U + &Q.W));
|
||||
|
|
@ -1253,7 +1258,7 @@ mod test {
|
|||
write_helper(&mut file, x1.U);
|
||||
write_helper(&mut file, x1.W);
|
||||
write_helper(&mut file, affine_u);
|
||||
file.write(&scalar.bytes);
|
||||
file.write(&scalar.bytes).unwrap();
|
||||
let number254 = FieldElement::from_bytes(&[
|
||||
254, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ extern crate serde;
|
|||
#[macro_use]
|
||||
pub(crate) mod macros;
|
||||
|
||||
#[cfg(any(feature = "betrusted", test))]
|
||||
#[macro_use]
|
||||
extern crate engine25519_as;
|
||||
extern crate rand;
|
||||
#[cfg(feature = "betrusted")]
|
||||
extern crate engine_25519;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -64,8 +64,6 @@ use subtle::{ConditionallyNegatable, ConditionallySelectable};
|
|||
|
||||
use zeroize::Zeroize;
|
||||
|
||||
#[macro_use]
|
||||
use engine25519_as;
|
||||
|
||||
/// Holds the \\(u\\)-coordinate of a point on the Montgomery form of
|
||||
/// Curve25519 or its twist.
|
||||
|
|
@ -293,6 +291,7 @@ pub fn differential_add_and_double(
|
|||
Q.W = t17; // W_{Q'} = U_D * 4 (W_P U_Q - U_P W_Q)^2
|
||||
}
|
||||
|
||||
#[cfg(betrusted)]
|
||||
fn copy_to_rf(bytes: [u8; 32], register: usize, rf: &mut [u32; engine_25519::RF_SIZE_IN_U32]) {
|
||||
use core::convert::TryInto;
|
||||
for (byte, rf_dst) in bytes.chunks_exact(4).zip(rf[register * 8..(register+1)*8].iter_mut()) {
|
||||
|
|
@ -300,6 +299,7 @@ fn copy_to_rf(bytes: [u8; 32], register: usize, rf: &mut [u32; engine_25519::RF_
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(betrusted)]
|
||||
fn copy_from_rf(register: usize, rf: &[u32; engine_25519::RF_SIZE_IN_U32]) -> [u8; 32] {
|
||||
let mut ret: [u8; 32] = [0; 32];
|
||||
|
||||
|
|
@ -312,6 +312,7 @@ fn copy_from_rf(register: usize, rf: &[u32; engine_25519::RF_SIZE_IN_U32]) -> [u
|
|||
ret
|
||||
}
|
||||
|
||||
#[cfg(betrusted)]
|
||||
pub fn differential_add_and_double_hw(
|
||||
P: &mut ProjectivePoint,
|
||||
Q: &mut ProjectivePoint,
|
||||
|
|
@ -443,11 +444,12 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a MontgomeryPoint {
|
|||
type Output = MontgomeryPoint;
|
||||
|
||||
/// Given `self` \\( = u\_0(P) \\), and a `Scalar` \\(n\\), return \\( u\_0([n]P) \\).
|
||||
#[cfg(betrusted)]
|
||||
fn mul(self, scalar: &'b Scalar) -> MontgomeryPoint {
|
||||
// Algorithm 8 of Costello-Smith 2017
|
||||
let affine_u = FieldElement::from_bytes(&self.0);
|
||||
let mut x0 = ProjectivePoint::identity();
|
||||
let mut x1 = ProjectivePoint {
|
||||
let x1 = ProjectivePoint {
|
||||
U: affine_u,
|
||||
W: FieldElement::one(),
|
||||
};
|
||||
|
|
@ -631,7 +633,7 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a MontgomeryPoint {
|
|||
// curve25519 acceleration!
|
||||
x0.to_affine()
|
||||
}
|
||||
/*
|
||||
#[cfg(not(betrusted))]
|
||||
fn mul(self, scalar: &'b Scalar) -> MontgomeryPoint {
|
||||
// Algorithm 8 of Costello-Smith 2017
|
||||
let affine_u = FieldElement::from_bytes(&self.0);
|
||||
|
|
@ -654,7 +656,7 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a MontgomeryPoint {
|
|||
ProjectivePoint::conditional_swap(&mut x0, &mut x1, Choice::from(bits[0] as u8));
|
||||
|
||||
x0.to_affine()
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b> MulAssign<&'b Scalar> for MontgomeryPoint {
|
||||
|
|
|
|||
Loading…
Reference in a new issue