From 02b29f9ca14bc41ba89592a2c7e8aa8373111590 Mon Sep 17 00:00:00 2001 From: Alberto Sonnino Date: Tue, 21 May 2024 06:37:06 +0100 Subject: [PATCH] ci: Update CI (#1) * Update rust toolchain * configure ci * configure pre-commit hooks --- .editorconfig | 32 ++++++++ .github/dependabot.yml | 30 ++++++++ .github/workflows/code.yml | 139 ++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 60 +++++++++++++++ .github/workflows/rust.yml | 21 ----- .github/workflows/updates.yml | 52 +++++++++++++ .licensesnip | 2 + .pre-commit-config.yaml | 81 ++++++++++++++++++++ Cargo.toml | 43 ++++++----- deny.toml | 89 ++++++++++++++++++++++ licensesnip.config.jsonc | 8 ++ rust-toolchain | 4 +- src/bip39.rs | 16 ++-- src/gf256.rs | 6 +- src/main.rs | 16 ++-- src/shamir.rs | 11 ++- src/utils.rs | 3 + 17 files changed, 555 insertions(+), 58 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/code.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/rust.yml create mode 100644 .github/workflows/updates.yml create mode 100644 .licensesnip create mode 100644 .pre-commit-config.yaml create mode 100644 deny.toml create mode 100644 licensesnip.config.jsonc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b884bdf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 100 +trim_trailing_whitespace = true + +[*.md] +indent_size = unset +max_line_length = 150 + +[{*.yml,*.yaml,*.toml}] +indent_size = 2 +max_line_length = 150 + +# Ignore paths +[{.git/**/*,**/*.lock,LICENSE,README.md,assets/*}] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = unset +max_line_length = unset +trim_trailing_whitespace = unset diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..65c435f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,30 @@ +# Documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + commit-message: + prefix: "fix" + prefix-development: "chore" + include: "scope" + groups: + cargo-minor-and-patch-dependencies: + update-types: + - "minor" + - "patch" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + commit-message: + prefix: "chore" + include: "scope" + groups: + github-actions-all: + patterns: ["*"] diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml new file mode 100644 index 0000000..995f464 --- /dev/null +++ b/.github/workflows/code.yml @@ -0,0 +1,139 @@ +name: Code + +on: + # Run workflow on every PR. + pull_request: + # Run workflow on the main branch after every merge. + # This is important to fill the GitHub Actions cache in a way that PRs can see it. + push: + branches: + - main + # Run workflow on the main branch every Sunday. + schedule: + - cron: "14 3 * * 0" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CLICOLOR_FORCE: 1 + # Incremental compilation is useful as part of an edit-build-test-edit cycle, as it lets the + # compiler avoid recompiling code that hasn't changed. The setting does not improve the current + # compilation but instead saves additional information to speed up future compilations (see + # https://doc.rust-lang.org/cargo/reference/profiles.html#incremental). Thus, this is only useful + # in CI if the result is cached, which we only do on the `main` branch. + CARGO_INCREMENTAL: ${{ github.ref == 'refs/heads/main' && '1' || '0' }} + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + RUSTDOCFLAGS: -D warnings + +jobs: + diff: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v4 + - name: Detect Changes + uses: dorny/paths-filter@v3.0.2 + id: diff + with: + filters: | + - 'crates/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain' + - 'deny.toml' + - '.github/workflows/code.yml' + + dependencies: + name: Check dependencies + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1.6.3 + with: + # do not check advisories on PRs to prevent sudden failure due to new announcement + command: check bans licenses sources + + dependencies-schedule: + name: Check dependencies (including vulnerabilities) + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1.6.3 + + test: + name: Test Rust code + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - name: Run tests + run: cargo test -- --include-ignored + + lint: + name: Lint Rust code + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - run: cargo install cargo-sort@1.0.9 + + - name: Check formatting with rustfmt + run: > + cargo fmt --all -- --check + --config group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical + - name: Check sorting of dependencies + run: cargo sort -w -c + - name: Lint using clippy (w/o tests) + run: cargo clippy --all-features --no-deps -- -D warnings + - name: Lint using clippy (w/ tests) + run: cargo clippy --all-features --tests --no-deps -- -D warnings + - name: Check documentation + run: cargo doc --no-deps --workspace + + build: + name: Build Rust code + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - name: Build Rust code + run: cargo build --verbose + + check-all: + name: Check if all code checks succeeded + if: always() + needs: + - diff + - dependencies + - test + - lint + - build + runs-on: ubuntu-latest + steps: + - name: Decide whether all needed jobs succeeded + uses: re-actors/alls-green@v1.2.2 + with: + allowed-skips: ${{ toJSON(needs) }} + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ec8dd8c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,60 @@ +name: Lint + +on: [pull_request] + +permissions: + contents: read + +jobs: + pr-title: + runs-on: ubuntu-latest + name: Check PR title format + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check PR title + uses: amannn/action-semantic-pull-request@v5.5.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + editorconfig: + runs-on: ubuntu-latest + name: Check editorconfig + steps: + - uses: actions/checkout@v4 + - run: pip install editorconfig-checker=="2.7.3" + - run: ec + + typos: + runs-on: ubuntu-latest + name: Check spelling + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.21.0 + + license-headers: + runs-on: ubuntu-latest + name: Check license headers + steps: + - uses: actions/checkout@v4 + - run: cargo install licensesnip@1.5.0 + - run: licensesnip check + + check-all: + name: Check if all lint jobs succeeded + if: always() + needs: + - pr-title + - editorconfig + - typos + - license-headers + runs-on: ubuntu-latest + steps: + - name: Decide whether all needed jobs succeeded + uses: re-actors/alls-green@v1.2.2 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 464d816..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Rust - -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/updates.yml b/.github/workflows/updates.yml new file mode 100644 index 0000000..5e3ad45 --- /dev/null +++ b/.github/workflows/updates.yml @@ -0,0 +1,52 @@ +name: Updates + +on: + # every month + schedule: + - cron: "14 3 1 * *" + # on demand + workflow_dispatch: + +jobs: + pre-commit: + name: "Update pre-commit hooks and run them on all files" + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: rustup update stable + - run: pip install pre-commit + - name: Run pre-commit autoupdate + run: > + pre-commit autoupdate + --repo https://github.com/pre-commit/pre-commit-hooks + --repo https://github.com/editorconfig-checker/editorconfig-checker.python + --repo https://github.com/crate-ci/typos + --repo https://github.com/EmbarkStudios/cargo-deny + - run: pre-commit run --all-files + - uses: peter-evans/create-pull-request@v6.0.5 + if: ${{ success() }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: chore/update-pre-commit-hooks + title: "chore: update pre-commit hooks" + commit-message: "chore: update pre-commit hooks" + body: Update pre-commit hooks to latest version. + - uses: peter-evans/create-pull-request@v6.0.5 + if: ${{ failure() }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: chore/update-pre-commit-hooks + title: "chore: update pre-commit hooks" + commit-message: "chore: update pre-commit hooks" + body: | + Update pre-commit hooks to latest version. + + **Warning**: Some checks did not succeed. Please check the [action output][run] before merging this PR. + + [run]: https://github.com/MystenLabs/walrus/actions/runs/${{ github.run_id }} diff --git a/.licensesnip b/.licensesnip new file mode 100644 index 0000000..591b633 --- /dev/null +++ b/.licensesnip @@ -0,0 +1,2 @@ +Copyright (c) Alberto Sonnino +SPDX-License-Identifier: Apache-2.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ec67b9d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,81 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: trailing-whitespace + - id: check-symlinks + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: "2.7.3" + hooks: + - id: editorconfig-checker + alias: ec + - repo: https://github.com/notken12/licensesnip + rev: 19b1186 + hooks: + - id: licensesnip + args: [] + pass_filenames: false + - repo: https://github.com/crate-ci/typos + rev: v1.19.0 + hooks: + - id: typos + pass_filenames: false + - repo: https://github.com/DevinR528/cargo-sort + rev: v1.0.9 + hooks: + - id: cargo-sort + args: ["--workspace"] + - repo: https://github.com/EmbarkStudios/cargo-deny + rev: 0.14.19 + hooks: + - id: cargo-deny + - repo: local + hooks: + - id: cargo-fmt + name: cargo-fmt + entry: cargo fmt + args: + - "--" + - "--config" + - "group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical" + language: rust + types: [rust] + pass_filenames: false + - id: cargo-check + name: cargo-check + entry: cargo check + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: cargo-test + name: cargo-test + entry: cargo test + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: clippy-with-tests + name: clippy-with-tests + entry: cargo clippy + args: ["--all-features", "--tests", "--", "-D", "warnings"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: clippy + name: clippy + entry: cargo clippy + args: ["--all-features", "--", "-D", "warnings"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: cargo-doc + name: cargo-doc + entry: env RUSTDOCFLAGS="-D warnings" cargo doc + args: ["--workspace", "--no-deps"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false diff --git a/Cargo.toml b/Cargo.toml index f9d8644..c16e992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,35 +10,38 @@ homepage = "https://github.com/asonnino/shamir-bip39" repository = "https://github.com/asonnino/shamir-bip39" license-file = "LICENSE" keywords = [ - "shamir", - "secret-sharing", - "bip39", - "mnemonic", - "wallet", - "bitcoin", - "ethereum", - "crypto", - "cryptocurrency", - "blockchain", - "recovery" + "shamir", + "secret-sharing", + "bip39", + "mnemonic", + "wallet", + "bitcoin", + "ethereum", + "crypto", + "cryptocurrency", + "blockchain", + "recovery", +] +categories = [ + "command-line-utilities", + "cryptography", + "cryptography::cryptocurrencies", ] -categories = ["command-line-utilities", "cryptography", "cryptography::cryptocurrencies"] publish = false [badges] maintenance = { status = "experimental" } [dependencies] -rand = "0.8.5" -eyre = "0.6.8" -color-eyre = "0.6.2" -fastcrypto = "0.1.5" +clap = { version = "4.5.4", features = ["derive"] } +color-eyre = "0.6.3" +colored = "2.1.0" +eyre = "0.6.12" +fastcrypto = "0.1.8" gf256 = "0.3.0" -clap = { version = "4.3.3", features = ["derive"] } -colored = "2.0.0" +itertools = { version = "0.13.0", optional = true } prettytable-rs = "0.10.0" -itertools = { version = "0.11.0", optional = true } +rand = "0.8.5" [features] double-check = ["itertools"] - diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..e01d48e --- /dev/null +++ b/deny.toml @@ -0,0 +1,89 @@ +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +version = 2 +ignore = [ + "RUSTSEC-2023-0071", + # Difference 2.0.0 is unmaintained. + "RUSTSEC-2020-0095", + # Rust-yaml is not maintained, but is a dependency in many of our packages. + "RUSTSEC-2024-0320", + # Ignore the h2 advisory as we do not have control over most of the H2 usage. + "RUSTSEC-2024-0332", +] + +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +version = 2 +# List of explicitly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. +allow = [ + "Apache-2.0", + "MIT", + "CC0-1.0", + "BSD-3-Clause", + "Unicode-DFS-2016", + "MPL-2.0", +] +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 + +[[licenses.clarify]] +name = "ring" +expression = "LicenseRef-ring" +license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = true + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "deny" +skip = [ + "block-buffer:0.9.0", # gf256 v0.3.0 + "convert_case:0.4.0", # gf256 v0.3.0 + "der:0.6.1", # gf256 v0.3.0 + "digest:0.9.0", # gf256 v0.3.0 + "hermit-abi:0.2.6", # gf256 v0.3.0 + "itertools:0.10.5", # gf256 v0.3.0 + "pem-rfc7468:0.6.0", # gf256 v0.3.0 + "pkcs8:0.9.0", # gf256 v0.3.0 + "sha2:0.9.9", # gf256 v0.3.0 + "spki:0.6.0", # gf256 v0.3.0 +] +skip-tree = [ + # Some crates manipulating prints to stdout depend on an older version of windows-sys + { name = "windows-sys", depth = 3, version = "0.48" }, + # The crate gf256 v0.3.0 depend on an older version of darling + { name = "darling", depth = 3, version = "0.12.4" }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "deny" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "deny" +allow-git = [] + +[sources.allow-org] +# 1 or more github.com organizations to allow git sources for +github = ["MystenLabs"] diff --git a/licensesnip.config.jsonc b/licensesnip.config.jsonc new file mode 100644 index 0000000..454f298 --- /dev/null +++ b/licensesnip.config.jsonc @@ -0,0 +1,8 @@ +{ + "use_gitignore": true, + "file_types": { + "move": { + "before_line": "// " + } + } +} diff --git a/rust-toolchain b/rust-toolchain index 4934985..6d31674 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,3 @@ -1.69.0 +[toolchain] +channel = "1.78" +components = ["clippy", "rustfmt"] diff --git a/src/bip39.rs b/src/bip39.rs index 1d52371..243e52a 100644 --- a/src/bip39.rs +++ b/src/bip39.rs @@ -1,13 +1,17 @@ -use crate::{ - shamir::{FieldArray, ShamirSecretSharing, ShamirShare}, - utils::{bits_to_bytes, bytes_to_bits}, -}; +// Copyright (c) Alberto Sonnino +// SPDX-License-Identifier: Apache-2.0 + +use std::{array::TryFromSliceError, fmt::Debug, fs::read_to_string, path::Path}; use eyre::{ensure, eyre, Result}; use fastcrypto::hash::{HashFunction, Sha256}; use gf256::gf256; use rand::{CryptoRng, RngCore}; -use std::{array::TryFromSliceError, fmt::Debug, fs::read_to_string, path::Path}; + +use crate::{ + shamir::{FieldArray, ShamirSecretSharing, ShamirShare}, + utils::{bits_to_bytes, bytes_to_bits}, +}; /// Parameters of the bip-39 specification (24 words variant). const DICTIONARY_INDICES_BITS: usize = 11; @@ -128,7 +132,7 @@ impl TryFrom<&[bool]> for Checksum { impl From<&Entropy> for Checksum { fn from(entropy: &Entropy) -> Self { - let digest = Sha256::digest(&entropy.to_bytes()); + let digest = Sha256::digest(entropy.to_bytes()); let bits = bytes_to_bits(digest.as_ref()); let checksum = bits[..CHECKSUM_BITS] .try_into() diff --git a/src/gf256.rs b/src/gf256.rs index 0913b37..e191ca9 100644 --- a/src/gf256.rs +++ b/src/gf256.rs @@ -1,3 +1,6 @@ +// Copyright (c) Alberto Sonnino +// SPDX-License-Identifier: Apache-2.0 + use gf256::gf256; use rand::{CryptoRng, Rng, RngCore}; @@ -48,7 +51,8 @@ impl ShamirSecretSharing for gf256 { } } -/// NOTE: Chaos test is not implemented for GF(256) because the field is too small to prevent collisions. +/// NOTE: No chaos test is implemented for the group GF(256) because the field is too small +/// to prevent collisions. #[cfg(test)] mod test { use gf256::gf256; diff --git a/src/main.rs b/src/main.rs index 9166cce..e2a2b44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +// Copyright (c) Alberto Sonnino +// SPDX-License-Identifier: Apache-2.0 + mod bip39; mod gf256; mod shamir; @@ -5,17 +8,20 @@ mod utils; use std::str::FromStr; -use bip39::{Bip39Dictionary, Bip39Secret}; use clap::{command, Parser}; use color_eyre::owo_colors::OwoColorize; use eyre::{ensure, Result}; use prettytable::{ format::{FormatBuilder, LinePosition, LineSeparator}, - Cell, Row, Table, + Cell, + Row, + Table, }; -use shamir::ShamirSecretSharing; -use crate::bip39::Bip39Share; +use crate::{ + bip39::{Bip39Dictionary, Bip39Secret, Bip39Share}, + shamir::ShamirSecretSharing, +}; #[derive(Parser)] #[command(author, version, about, long_about = None)] @@ -182,7 +188,7 @@ fn double_check_shares(secret: &Bip39Secret, shares: &[Bip39Share], t: usize) { for combination in (0..shares.len()).combinations(t) { let shares = combination .into_iter() - .map(|i| &shares[i as usize]) + .map(|i| &shares[i]) .collect::>(); let reconstructed = Bip39Secret::reconstruct(&shares); assert!( diff --git a/src/shamir.rs b/src/shamir.rs index e51043a..b16b39d 100644 --- a/src/shamir.rs +++ b/src/shamir.rs @@ -1,3 +1,6 @@ +// Copyright (c) Alberto Sonnino +// SPDX-License-Identifier: Apache-2.0 + use std::{ array, collections::HashMap, @@ -188,7 +191,7 @@ pub mod test { let reconstructed = T::reconstruct(&shares[..t as usize]); assert_eq!(secret, reconstructed); - return secret; + secret } pub fn test_reconstruct_sparse() -> T @@ -202,9 +205,9 @@ pub mod test { let _share_3 = shares.pop().unwrap(); let share_2 = shares.pop().unwrap(); let share_1 = shares.pop().unwrap(); - let reconstructed = T::reconstruct(&vec![share_1, share_2, share_4]); + let reconstructed = T::reconstruct(&[share_1, share_2, share_4]); assert_eq!(secret, reconstructed); - return secret; + secret } pub fn test_reconstruct_missing_shares() -> (T, T) @@ -220,7 +223,7 @@ pub mod test { let reconstructed = T::reconstruct(&shares[0..(t - 1) as usize]); assert_ne!(secret, reconstructed); - return (secret, reconstructed); + (secret, reconstructed) } pub fn chaos_test() diff --git a/src/utils.rs b/src/utils.rs index 2b42d87..04557b7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,6 @@ +// Copyright (c) Alberto Sonnino +// SPDX-License-Identifier: Apache-2.0 + /// Convert an iterator of bytes into a vector of bits. pub fn bytes_to_bits(bytes: &[u8]) -> Vec { bytes