Skip to content

Commit 895c2ab

Browse files
authored
feat: add BLS crypto module (#15)
* feat: setup initial project structure * feat: update CI to use nightly toolchain for rustfmt * feat: update CI to use nightly toolchain for rustfmt * fix: fmt * refactor: reorganize workspace members and remove charon-types crate * feat: add core types and dependencies for Charon * feat: add is_valid method and tests for DutyType * feat: enhance Charon core types with new methods and error handling for PubKey * chore: remove unused proptest dependency from workspace * feat: implement Default trait for UnsignedDataSet, ParSignedDataSet, and SignedDataSet * refactor: update PubKey methods for improved error handling and add try_from implementation * docs: clarify slot duration comment and add debug prints for PubKey serialization/deserialization tests * fix: remove unnecessary println * feat: add tbls crypto boilerplate * feat: add initial implementation of tbls * feat: add tests for the bls implementation * feat: integrate blsful implementation and refactor tbls module - Added `thiserror` dependency for improved error handling. - Introduced `blsful` module for TBLS implementation. - Refactored `tbls` module to utilize new types and error handling. - Created `tblsconv` module for type conversions between byte slices and cryptographic types. - Removed the old `herumi` implementation and replaced it with the new `blsful` based implementation. - Added utility functions for key and signature conversions. - Updated types and error definitions for better clarity and consistency. * style: improve code formatting and documentation in tblsconv module - Reformatted comments for better readability. - Adjusted spacing and alignment in error messages for consistency. - Ensured clarity in documentation regarding expected byte lengths for key and signature conversions. * chore: clean up Cargo.toml by removing duplicate dependencies and organizing workspace lints * chore: update Cargo.lock with new dependencies and versions * chore: fix clippy warnings * refactor: replace blsful implementation with blst for threshold BLS signatures - Updated dependencies in Cargo.toml and Cargo.lock to use the blst library. - Removed blsful module and its associated code, including type conversions and utility functions. - Introduced a new blst_impl module for the BLST implementation of threshold BLS signatures. - Refactored tbls module to utilize the new blst implementation. - Cleaned up error handling and types to align with the new library. - Added workspace lints and improved documentation throughout the codebase. * refactor: update lints and improve function signatures in blst implementation * fix: add more retries in generate_insecure_secret * fix: review comments, optimize type convertion * fix: improve error handling for scalar to secret key conversion * fix: review comments, improve error naming and add zero division check
1 parent e846c3a commit 895c2ab

8 files changed

Lines changed: 1463 additions & 35 deletions

File tree

Cargo.lock

Lines changed: 161 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ hex = { version = "^0.4.3" }
3131
serde = { version = "1.0", features = ["derive"] }
3232
serde_json = { version = "^1.0" }
3333
tokio = { version = "1", features = ["full"] }
34+
blst = "0.3.13"
35+
rand_core = "0.6"
36+
thiserror = "2.0.12"
37+
rand = {version = "0.8", features = ["std_rng"]}
3438

3539
[workspace.lints.rust]
3640
missing_docs = "deny"

crates/charon-core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ license.workspace = true
77
publish.workspace = true
88

99
[dependencies]
10-
chrono.workspace = true
11-
hex.workspace = true
1210
serde.workspace = true
1311
serde_json.workspace = true
12+
hex.workspace = true
13+
chrono.workspace = true
1414

1515
[lints]
1616
workspace = true

crates/charon-crypto/Cargo.toml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ license.workspace = true
77
publish.workspace = true
88

99
[dependencies]
10+
rand.workspace = true
11+
blst.workspace = true
12+
rand_core.workspace = true
13+
serde.workspace = true
14+
thiserror.workspace = true
15+
hex.workspace = true
1016

11-
[lints]
12-
workspace = true
17+
[lints.rust]
18+
# Allow unsafe code for blst C bindings (overrides workspace forbid)
19+
unsafe_code = "deny"
20+
missing_docs = "deny"
21+
22+
[lints.clippy]
23+
arithmetic_side_effects = "deny"
24+
cast_lossless = "deny"
25+
cast_possible_truncation = "deny"
26+
cast_possible_wrap = "deny"
27+
cast_precision_loss = "deny"
28+
cast_sign_loss = "deny"
29+
needless_return = "deny"
30+
panicking_overflow_checks = "deny"
31+
unwrap_used = "deny"

0 commit comments

Comments
 (0)