Merge pull request #1970 from triska/crrl
switch to using crrl for scalar multiplication on Curve25519
This commit is contained in:
57
Cargo.lock
generated
57
Cargo.lock
generated
@@ -310,13 +310,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crrl"
|
||||
version = "0.2.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2db40892a506901e4e8281f00e42687df82d1d3448cb0289ae9183a60cb42ec1"
|
||||
checksum = "b083214486dae00f49a2f21f32fc8bbc333d6048601bc89203a8ab92bfa691f0"
|
||||
dependencies = [
|
||||
"blake2 0.10.6",
|
||||
"rand_core",
|
||||
"sha2",
|
||||
"sha3 0.10.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -499,15 +500,6 @@ version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7"
|
||||
dependencies = [
|
||||
"signature",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
@@ -1142,18 +1134,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsodium-sys"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b779387cd56adfbc02ea4a668e704f729be8d6a6abd2c27ca5ee537849a92fd"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.3.8"
|
||||
@@ -1991,9 +1971,8 @@ dependencies = [
|
||||
"ryu",
|
||||
"select",
|
||||
"serial_test",
|
||||
"sha3",
|
||||
"sha3 0.8.2",
|
||||
"smallvec",
|
||||
"sodiumoxide",
|
||||
"static_assertions",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
@@ -2116,6 +2095,16 @@ dependencies = [
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
|
||||
dependencies = [
|
||||
"digest 0.10.7",
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.15"
|
||||
@@ -2146,12 +2135,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "1.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c"
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.10"
|
||||
@@ -2183,18 +2166,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sodiumoxide"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e26be3acb6c2d9a7aac28482586a7856436af4cfe7100031d219de2d2ecb0028"
|
||||
dependencies = [
|
||||
"ed25519",
|
||||
"libc",
|
||||
"libsodium-sys",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
|
||||
@@ -49,14 +49,13 @@ ring = "0.16.13"
|
||||
ripemd160 = "0.8.0"
|
||||
sha3 = "0.8.2"
|
||||
blake2 = "0.8.1"
|
||||
crrl = "0.2.0"
|
||||
crrl = "0.6.0"
|
||||
native-tls = "0.2.4"
|
||||
chrono = "0.4.11"
|
||||
select = "0.6.0"
|
||||
roxmltree = "0.11.0"
|
||||
base64 = "0.12.3"
|
||||
smallvec = "1.8.0"
|
||||
sodiumoxide = "0.2.6"
|
||||
static_assertions = "1.1.0"
|
||||
ryu = "1.0.9"
|
||||
hyper = { version = "1.0.0-rc.3", features = ["full"] }
|
||||
|
||||
@@ -711,6 +711,8 @@ curve25519_scalar_mult(Scalar, Point, Result) :-
|
||||
must_be_bytes(ScalarBytes, curve25519_scalar_mult/3),
|
||||
length(ScalarBytes, 32)
|
||||
),
|
||||
must_be(chars, Point),
|
||||
length(Point, 32),
|
||||
maplist(char_code, Point, PointBytes),
|
||||
'$curve25519_scalar_mult'(ScalarBytes, PointBytes, Result).
|
||||
|
||||
|
||||
@@ -72,9 +72,7 @@ use ring::{
|
||||
use ripemd160::{Digest, Ripemd160};
|
||||
use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512};
|
||||
|
||||
use crrl::secp256k1;
|
||||
|
||||
use sodiumoxide::crypto::scalarmult::curve25519::*;
|
||||
use crrl::{secp256k1, x25519};
|
||||
|
||||
use native_tls::{TlsConnector,TlsAcceptor,Identity};
|
||||
|
||||
@@ -7298,13 +7296,11 @@ impl Machine {
|
||||
pub(crate) fn curve25519_scalar_mult(&mut self) {
|
||||
let stub1_gen = || functor_stub(atom!("curve25519_scalar_mult"), 3);
|
||||
let scalar_bytes = self.machine_st.integers_to_bytevec(self.machine_st.registers[1], stub1_gen);
|
||||
let scalar = Scalar(<[u8; 32]>::try_from(&scalar_bytes[..]).unwrap());
|
||||
|
||||
let stub2_gen = || functor_stub(atom!("curve25519_scalar_mult"), 3);
|
||||
let point_bytes = self.machine_st.integers_to_bytevec(self.machine_st.registers[2], stub2_gen);
|
||||
let point = GroupElement(<[u8; 32]>::try_from(&point_bytes[..]).unwrap());
|
||||
|
||||
let result = scalarmult(&scalar, &point).unwrap();
|
||||
let result = x25519::x25519(&<[u8; 32]>::try_from(&point_bytes[..]).unwrap(),
|
||||
&<[u8; 32]>::try_from(&scalar_bytes[..]).unwrap());
|
||||
|
||||
let string = self.u8s_to_string(&result[..]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user