Skip to content

Commit

Permalink
Bump voprf to v0.5.0-pre.2
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Feb 3, 2023
1 parent 8901b74 commit 5dc221f
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 89 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- --features serde
toolchain:
- stable
- 1.57.0
- 1.60.0
name: test
steps:
- name: Checkout sources
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
matrix:
toolchain:
- stable
- 1.57.0
- 1.60.0
name: test simple_login command-line example
steps:
- name: install expect
Expand All @@ -101,7 +101,7 @@ jobs:
matrix:
toolchain:
- stable
- 1.57.0
- 1.60.0
name: test digital_locker command-line example
steps:
- name: install expect
Expand Down
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ license = "Apache-2.0 OR MIT"
name = "opaque-ke"
readme = "README.md"
repository = "https://github.com/novifinancial/opaque-ke"
rust-version = "1.57"
rust-version = "1.60"
version = "2.0.0"

[features]
curve25519 = ["curve25519-dalek"]
curve25519 = ["curve25519-dalek/precomputed-tables"]
default = ["ristretto255-voprf", "serde"]
ristretto255 = ["curve25519-dalek", "voprf/ristretto255"]
ristretto255-voprf = ["ristretto255", "voprf/ristretto255-ciphersuite"]
Expand All @@ -23,8 +23,9 @@ std = ["getrandom"]
argon2 = { version = "0.4", default-features = false, features = [
"alloc",
], optional = true }
curve25519-dalek = { version = "=4.0.0-pre.5", default-features = false, features = [
curve25519-dalek = { version = "=4.0.0-rc.1", default-features = false, features = [
"rand_core",
"zeroize",
], optional = true }
derive-where = { version = "1", features = ["zeroize-on-drop"] }
digest = "0.10"
Expand All @@ -38,7 +39,7 @@ serde_ = { version = "1", package = "serde", default-features = false, features
"derive",
], optional = true }
subtle = { version = "2.3", default-features = false }
voprf = { version = "=0.5.0-pre.1", default-features = false, features = [
voprf = { version = "=0.5.0-pre.2", default-features = false, features = [
"danger",
] }
zeroize = { version = "1.5", features = ["zeroize_derive"] }
Expand All @@ -52,14 +53,15 @@ chacha20poly1305 = "0.10"
criterion = "0.4"
hex = "0.4"
json = "0.12"
p256 = { version = "0.11", default-features = false, features = [
p256 = { version = "0.12", default-features = false, features = [
"hash2curve",
"voprf",
] }
proptest = "1"
rand = "0.8"
regex = "1"
rustyline = "10"
# MSRV
rustyline = "10.1.1"
scrypt = "0.10"
serde_json = "1"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ opaque-ke = "2"

### Minimum Supported Rust Version

Rust **1.57** or higher.
Rust **1.60** or higher.

Audit
-----
Expand Down
106 changes: 47 additions & 59 deletions benches/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl CipherSuite for Default {
fn server_setup(c: &mut Criterion) {
let mut rng = OsRng;

c.bench_function(&format!("server setup ({})", SUFFIX), move |b| {
c.bench_function(&format!("server setup ({SUFFIX})"), move |b| {
b.iter(|| {
ServerSetup::<Default>::new(&mut rng);
})
Expand All @@ -49,14 +49,11 @@ fn client_registration_start(c: &mut Criterion) {
let mut rng = OsRng;
let password = b"password";

c.bench_function(
&format!("client registration start ({})", SUFFIX),
move |b| {
b.iter(|| {
ClientRegistration::<Default>::start(&mut rng, password).unwrap();
})
},
);
c.bench_function(&format!("client registration start ({SUFFIX})"), move |b| {
b.iter(|| {
ClientRegistration::<Default>::start(&mut rng, password).unwrap();
})
});
}

fn server_registration_start(c: &mut Criterion) {
Expand All @@ -67,19 +64,16 @@ fn server_registration_start(c: &mut Criterion) {
let client_registration_start_result =
ClientRegistration::<Default>::start(&mut rng, password).unwrap();

c.bench_function(
&format!("server registration start ({})", SUFFIX),
move |b| {
b.iter(|| {
ServerRegistration::<Default>::start(
&server_setup,
client_registration_start_result.message.clone(),
username,
)
.unwrap();
})
},
);
c.bench_function(&format!("server registration start ({SUFFIX})"), move |b| {
b.iter(|| {
ServerRegistration::<Default>::start(
&server_setup,
client_registration_start_result.message.clone(),
username,
)
.unwrap();
})
});
}

fn client_registration_finish(c: &mut Criterion) {
Expand All @@ -97,7 +91,7 @@ fn client_registration_finish(c: &mut Criterion) {
.unwrap();

c.bench_function(
&format!("client registration finish ({})", SUFFIX),
&format!("client registration finish ({SUFFIX})"),
move |b| {
b.iter(|| {
client_registration_start_result
Expand Down Expand Up @@ -139,7 +133,7 @@ fn server_registration_finish(c: &mut Criterion) {
.unwrap();

c.bench_function(
&format!("server registration finish ({})", SUFFIX),
&format!("server registration finish ({SUFFIX})"),
move |b| {
b.iter(|| {
ServerRegistration::finish(client_registration_finish_result.clone().message);
Expand All @@ -152,7 +146,7 @@ fn client_login_start(c: &mut Criterion) {
let mut rng = OsRng;
let password = b"password";

c.bench_function(&format!("client login start ({})", SUFFIX), move |b| {
c.bench_function(&format!("client login start ({SUFFIX})"), move |b| {
b.iter(|| {
ClientLogin::<Default>::start(&mut rng, password).unwrap();
})
Expand Down Expand Up @@ -184,22 +178,19 @@ fn server_login_start_real(c: &mut Criterion) {
let password_file = ServerRegistration::finish(client_registration_finish_result.message);
let client_login_start_result = ClientLogin::<Default>::start(&mut rng, password).unwrap();

c.bench_function(
&format!("server login start (real) ({})", SUFFIX),
move |b| {
b.iter(|| {
ServerLogin::start(
&mut rng,
&server_setup,
Some(password_file.clone()),
client_login_start_result.clone().message,
username,
ServerLoginStartParameters::default(),
)
.unwrap();
})
},
);
c.bench_function(&format!("server login start (real) ({SUFFIX})"), move |b| {
b.iter(|| {
ServerLogin::start(
&mut rng,
&server_setup,
Some(password_file.clone()),
client_login_start_result.clone().message,
username,
ServerLoginStartParameters::default(),
)
.unwrap();
})
});
}

fn server_login_start_fake(c: &mut Criterion) {
Expand All @@ -209,22 +200,19 @@ fn server_login_start_fake(c: &mut Criterion) {
let server_setup = ServerSetup::<Default>::new(&mut rng);
let client_login_start_result = ClientLogin::<Default>::start(&mut rng, password).unwrap();

c.bench_function(
&format!("server login start (fake) ({})", SUFFIX),
move |b| {
b.iter(|| {
ServerLogin::start(
&mut rng,
&server_setup,
None,
client_login_start_result.clone().message,
username,
ServerLoginStartParameters::default(),
)
.unwrap();
})
},
);
c.bench_function(&format!("server login start (fake) ({SUFFIX})"), move |b| {
b.iter(|| {
ServerLogin::start(
&mut rng,
&server_setup,
None,
client_login_start_result.clone().message,
username,
ServerLoginStartParameters::default(),
)
.unwrap();
})
});
}

fn client_login_finish(c: &mut Criterion) {
Expand Down Expand Up @@ -261,7 +249,7 @@ fn client_login_finish(c: &mut Criterion) {
)
.unwrap();

c.bench_function(&format!("client login finish ({})", SUFFIX), move |b| {
c.bench_function(&format!("client login finish ({SUFFIX})"), move |b| {
b.iter(|| {
client_login_start_result
.clone()
Expand Down Expand Up @@ -318,7 +306,7 @@ fn server_login_finish(c: &mut Criterion) {
)
.unwrap();

c.bench_function(&format!("server login finish ({})", SUFFIX), move |b| {
c.bench_function(&format!("server login finish ({SUFFIX})"), move |b| {
b.iter(|| {
server_login_start_result
.clone()
Expand Down
16 changes: 5 additions & 11 deletions examples/digital_locker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,10 @@ fn main() {
&registered_lockers[locker_index],
) {
Ok(contents) => {
println!("\n\nSuccess! Contents: {}\n\n", contents);
println!("\n\nSuccess! Contents: {contents}\n\n");
}
Err(err) => {
println!(
"\n\nError encountered, could not open locker: {}\n\n",
err
);
println!("\n\nError encountered, could not open locker: {err}\n\n");
}
}
}
Expand All @@ -304,10 +301,7 @@ fn display_lockers(lockers: &[Locker]) {
locker_numbers.push(i);
}

println!(
"\nCurrently registered locker numbers: {:?}\n",
locker_numbers
);
println!("\nCurrently registered locker numbers: {locker_numbers:?}\n");
}

// Handle readline errors
Expand All @@ -320,7 +314,7 @@ fn handle_error(err: ReadlineError) {
println!("CTRL-D");
}
err => {
println!("Error: {:?}", err);
println!("Error: {err:?}");
}
}
}
Expand All @@ -333,7 +327,7 @@ fn get_two_strings(
string1: Option<String>,
) -> (String, String) {
let query = if string1.is_none() { s1 } else { s2 };
let readline = rl.readline(&format!("{}: ", query));
let readline = rl.readline(&format!("{query}: "));
match readline {
Ok(line) => match string1 {
Some(x) => (x, line),
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ fn handle_error(err: ReadlineError) {
println!("CTRL-D");
}
err => {
println!("Error: {:?}", err);
println!("Error: {err:?}");
}
}
}
Expand All @@ -241,7 +241,7 @@ fn get_two_strings(
string1: Option<String>,
) -> (String, String) {
let query = if string1.is_none() { s1 } else { s2 };
let readline = rl.readline(&format!("{}: ", query));
let readline = rl.readline(&format!("{query}: "));
match readline {
Ok(line) => match string1 {
Some(x) => (x, line),
Expand Down
2 changes: 1 addition & 1 deletion src/key_exchange/group/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl KeGroup for Curve25519 {
}

fn public_key(sk: Self::Sk) -> Self::Pk {
(&ED25519_BASEPOINT_TABLE * &sk).to_montgomery()
(ED25519_BASEPOINT_TABLE * &sk).to_montgomery()
}

fn diffie_hellman(pk: Self::Pk, sk: Self::Sk) -> GenericArray<u8, Self::PkLen> {
Expand Down
5 changes: 1 addition & 4 deletions src/key_exchange/group/ristretto255.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ impl KeGroup for Ristretto255 {
}

fn deserialize_pk(bytes: &[u8]) -> Result<Self::Pk, InternalError> {
if bytes.len() != 32 {
return Err(InternalError::PointError);
}

CompressedRistretto::from_slice(bytes)
.map_err(|_| InternalError::PointError)?
.decompress()
.filter(|point| point != &RistrettoPoint::identity())
.ok_or(InternalError::PointError)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//!
//! ### Minimum Supported Rust Version
//!
//! Rust **1.57** or higher.
//! Rust **1.60** or higher.
//!
//! # Overview
//!
Expand Down
2 changes: 1 addition & 1 deletion src/tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn parse_params(input: &str) -> String {
let key = iter.next().unwrap().split_whitespace().next().unwrap();
let val = iter.next().unwrap().split_whitespace().next().unwrap();

param = format!(" \"{}\": \"{}", key, val);
param = format!(" \"{key}\": \"{val}");
} else {
let s = line.trim().to_string();
if s.contains('~') || s.contains('#') {
Expand Down

0 comments on commit 5dc221f

Please sign in to comment.