Skip to content

Commit

Permalink
Merge branch 'main' into st-zeroize-scalar
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/ristretto/ristretto_keys.rs
  • Loading branch information
stringhandler committed Sep 28, 2023
2 parents f9c6252 + f9b6cb8 commit 1bbd1e2
Show file tree
Hide file tree
Showing 24 changed files with 298 additions and 385 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/check_licence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install ripgrep
run: |
wget https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep_13.0.0_amd64.deb
Expand Down
59 changes: 18 additions & 41 deletions .github/workflows/clippy-check.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,34 @@
name: Clippy and FMT
name: Formatting, lints, and code checks
on: [push, pull_request]

jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Install components
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
components: clippy, rustfmt
toolchain: nightly
override: true
- name: Toolchain thumbv8m.main-none-eabi
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: nightly
target: thumbv8m.main-none-eabi
override: true
targets: thumbv8m.main-none-eabi
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
toolchain: nightly
args: --all -- --check
- name: Install cargo-lints
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-lints
- name: Clippy lints
uses: actions-rs/cargo@v1
with:
command: lints
toolchain: nightly
args: clippy --all-targets --all-features
- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --release --all-targets
- name: Cargo check no default
uses: actions-rs/cargo@v1
with:
command: check
args: --release --no-default-features
run: cargo +nightly fmt --all -- --check
- name: Install linter
run: cargo install cargo-lints
- name: Run linter
run: cargo +nightly lints clippy --all-targets --all-features
- name: Check code
run: cargo +stable check --release --all-targets
- name: Check code (no default features)
run: cargo +stable check --release --no-default-features
# This check here is to ensure that it builds for no-std rust targets
- name: Cargo check for no-std
uses: actions-rs/cargo@v1
with:
command: check
toolchain: nightly
args: --no-default-features --target=thumbv8m.main-none-eabi -Zavoid-dev-deps

- name: Check code (no-std)
run: cargo +nightly check --no-default-features --target=thumbv8m.main-none-eabi -Zavoid-dev-deps
- name: Check benchmarks
run: cargo +nightly check --benches
5 changes: 2 additions & 3 deletions .github/workflows/source-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y jq lcov
- name: Download Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTUP_TOOLCHAIN }}
override: true
components: llvm-tools-preview
- name: Install requirements for code coverage
run: |
Expand Down
43 changes: 11 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,19 @@ jobs:
rust:
- stable
steps:
- name: checkout
uses: actions/checkout@v2
- name: toolchain
uses: actions-rs/toolchain@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install components
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
toolchain: stable
- name: test/debug
uses: actions-rs/cargo@v1
with:
command: test
run: cargo +stable test
- name: test/release
uses: actions-rs/cargo@v1
with:
command: test
args: --release
run: cargo +stable test --release
- name: test/debug features
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
run: cargo +stable test --all-features
- name: test/release features
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features
- name: docs build
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features
- name: bench
uses: actions-rs/cargo@v1
with:
command: check
args: --benches
run: cargo +stable test --release --all-features
- name: Build documentation
run: cargo doc --all-features --no-deps
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.18.0"
edition = "2018"

[dependencies]
tari_utilities = { version = "0.5", default-features = false, features = ["zero"] }
tari_utilities = { version = "0.6", default-features = false, features = ["zero"] }
blake2 = { version = "0.10", default-features = false }
borsh = { version = "0.10" , optional = true , default-features = false}
bulletproofs_plus = { package = "tari_bulletproofs_plus", version = "0.3", optional = true }
Expand All @@ -27,7 +27,7 @@ snafu = { version = "0.7", default-features = false}
zeroize = {version = "1" , default-features = false}

[dev-dependencies]
tari_utilities = { version = "0.5", features = ["std"] }
tari_utilities = { version = "0.6", features = ["std"] }
serde = { version = "1.0"}
bincode = { version = "1.1" }
criterion = { version = "0.5", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions benches/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn sign_message(c: &mut Criterion) {
b.iter_batched(
gen_keypair,
|d| {
let _sig = RistrettoSchnorr::sign_message(&d.k, d.m, &mut OsRng).unwrap();
let _sig = RistrettoSchnorr::sign(&d.k, d.m, &mut OsRng).unwrap();
},
BatchSize::SmallInput,
);
Expand All @@ -60,10 +60,10 @@ fn verify_message(c: &mut Criterion) {
b.iter_batched(
|| {
let d = gen_keypair();
let s = RistrettoSchnorr::sign_message(&d.k, d.m, &mut OsRng).unwrap();
let s = RistrettoSchnorr::sign(&d.k, d.m, &mut OsRng).unwrap();
(d, s)
},
|(d, s)| assert!(s.verify_message(&d.p, d.m)),
|(d, s)| assert!(s.verify(&d.p, d.m)),
BatchSize::SmallInput,
);
});
Expand Down
28 changes: 10 additions & 18 deletions lints.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
deny = [
# Prevent spelling mistakes in lints
'unknown_lints',
# clippy groups:
'clippy::correctness',
# All clippy allows must have a reason
# TODO: enable lint-reasons feature
# 'clippy::allow_attributes_without_reason',
# Docs

# Use the default groups:
# correctness, suspicious, style, complexity, perf
'clippy::all',

# Require documentation
'missing_docs',
# 'clippy::missing_errors_doc',
# 'clippy::missing_safety_doc',
# 'clippy::missing_panics_doc',

# Common mistakes
'clippy::await_holding_lock',
'unused_variables',
'unused_imports',
'dead_code',
'unused_extern_crates',
'unused_must_use',
'unreachable_patterns',
'let_underscore_drop',

'clippy::cloned_instead_of_copied',
'clippy::create_dir',
'clippy::dbg_macro',
'clippy::else_if_without_else',
'clippy::enum_glob_use',
'clippy::inline_always',
'let_underscore_drop',
'clippy::let_unit_value',
'clippy::match_on_vec_items',
'clippy::match_wild_err_arm',
# In crypto code, it is fairly common to have similar names e.g. `owner_pk` and `owner_k`
# 'clippy::similar_names',
'clippy::needless_borrow',

# style
'clippy::style',
# Style preferences
'clippy::explicit_into_iter_loop',
'clippy::explicit_iter_loop',
'clippy::if_not_else',
Expand All @@ -46,7 +38,7 @@ deny = [
'clippy::too_many_lines',
'clippy::trivially_copy_pass_by_ref',

# casting mistakes
# Casting mistakes
'clippy::cast_lossless',
'clippy::cast_possible_truncation',
'clippy::cast_possible_wrap',
Expand Down
4 changes: 2 additions & 2 deletions src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ where P: PublicKey
impl<P> ByteArray for HomomorphicCommitment<P>
where P: PublicKey
{
fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError> {
let p = P::from_bytes(bytes)?;
fn from_canonical_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError> {
let p = P::from_canonical_bytes(bytes)?;
Ok(Self(p))
}

Expand Down
2 changes: 1 addition & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub enum HashingError {
reason: String,
},
/// The digest does not produce enough output
#[snafu(display("The digest does produce enough output.`{bytes}' bytes are required."))]
#[snafu(display("The digest does not produce enough output.`{bytes}' bytes are required."))]
DigestTooShort {
/// The number of bytes required
bytes: usize,
Expand Down
Loading

0 comments on commit 1bbd1e2

Please sign in to comment.