Skip to content

Commit

Permalink
Merge pull request #38 from trilitech/emturner@dalek
Browse files Browse the repository at this point in the history
crypto: switch to ed25519_dalek
  • Loading branch information
emturner authored May 12, 2023
2 parents 9ae1450 + b77c3c1 commit c4b2d31
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.60.0
- uses: dtolnay/rust-toolchain@stable
- name: install cargo-audit
run: cargo install cargo-audit
- name: audit dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
sudo apt-get install libhidapi-dev libev4 clang libclang-dev llvm-dev g++
- name: OSX dependencies
if: runner.os == 'macOS'
run: brew install pkg-config gmp libev hidapi libffi
run: brew install pkg-config gmp libev hidapi libffi llvm
- name: cargo check (default features)
run: cargo check
- name: cargo check (no default features)
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- Nothing.
- Ed25519 implementation switched from `ed25519_compact` to `ed25519-dalek`.
- `PublicKeyEd25519::sign` no longer takes an `Iterator`, instead only one `AsRef<u8>` is allowed.

### Deprecated

Expand Down
130 changes: 116 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] }
strum = "0.20"
strum_macros = "0.20"
zeroize = { version = "1.5" }
ed25519-compact = { version ="2.0", default-features = false }
ed25519-dalek = { version = "2.0.0-rc.2", default-features = false }
cryptoxide = { version = "0.4.4", default-features = false, features = ["sha2", "blake2"] }
blst = "0.3.10"

Expand Down
14 changes: 7 additions & 7 deletions crypto/src/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests {
let sig = BlsSignature(bytes.to_vec());
let sig = min_pk::Signature::try_from(&sig);

assert_eq!(sig, Err(CryptoError::InvalidSignature));
assert!(matches!(sig, Err(CryptoError::InvalidSignature)));
}

#[test]
Expand Down Expand Up @@ -286,7 +286,7 @@ mod tests {
let pk = PublicKeyBls(bytes.to_vec());
let pk = min_pk::PublicKey::try_from(&pk);

assert_eq!(pk, Err(CryptoError::InvalidPublicKey));
assert!(matches!(pk, Err(CryptoError::InvalidPublicKey)));
}

#[test]
Expand Down Expand Up @@ -328,7 +328,7 @@ mod tests {
let msg_keys = [(&msg[..], &pk)];
let res = sig.aggregate_verify(&mut msg_keys.into_iter());

assert_eq!(res, Ok(true));
assert!(matches!(res, Ok(true)));
}

// Values taken from tezt test, that was failing due to public key not being
Expand Down Expand Up @@ -409,7 +409,7 @@ mod tests {
let msg_keys = [(&msg[..], &pk)];
let res = sig.aggregate_verify(&mut msg_keys.into_iter());

assert_eq!(res, Ok(false));
assert!(matches!(res, Ok(false)));
}

// Test to ensure that we use the correct hashing scheme to convert between
Expand Down Expand Up @@ -463,7 +463,7 @@ mod tests {

let res = sig.aggregate_verify(&mut msg_keys.into_iter());

assert_eq!(res, Ok(true));
assert!(matches!(res, Ok(true)));
}

#[test]
Expand All @@ -490,7 +490,7 @@ mod tests {

let res = sig.aggregate_verify(&mut msg_keys.into_iter());

assert_eq!(res, Ok(true));
assert!(matches!(res, Ok(true)));
}

#[test]
Expand All @@ -505,7 +505,7 @@ mod tests {

let res = sig.aggregate_verify(&mut msg_keys.into_iter());

assert_eq!(res, Ok(false));
assert!(matches!(res, Ok(false)));
}
}
}
Loading

0 comments on commit c4b2d31

Please sign in to comment.