-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(platform): replace bls library #2257
base: v1.4-dev
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request includes updates to several files primarily focusing on the integration of the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 54
🧹 Outside diff range and nitpick comments (37)
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs (1)
27-30
: LGTM: Function signature updated correctly.The changes to the
choose_quorum
function signature correctly implement the newBls12381G2Impl
type for both thequorums
parameter and the return type. This update enhances type safety and aligns with the new BLS implementation.Consider adding a brief comment explaining the
Bls12381G2Impl
type for better code documentation. For example:/// Choose a quorum using the Bls12381G2Impl for BLS operations pub fn choose_quorum<'a>( // ... (existing parameters) ) -> Result<Option<(ReversedQuorumHashBytes, &'a BlsPublicKey<Bls12381G2Impl>)>, Error> { // ... (existing implementation) }packages/rs-dpp/src/core_types/validator/mod.rs (3)
28-28
: LGTM! Consider adding a brief comment.The change from
&Option<BlsPublicKey>
to&Option<BlsPublicKey<Bls12381G2Impl>>
improves type safety and aligns with the PR objectives. This modification ensures compatibility with the new Rust-based BLS library without affecting the overall structure or logic.Consider adding a brief comment explaining the use of
Bls12381G2Impl
for future maintainers:/// Returns the BLS public key using the Bls12381G2Impl implementation fn public_key(&self) -> &Option<BlsPublicKey<Bls12381G2Impl>> {
78-78
: LGTM! Consider adding a brief comment.The change from
Option<BlsPublicKey>
toOption<BlsPublicKey<Bls12381G2Impl>>
in theset_public_key
method parameter is consistent with the earlier change in thepublic_key
method. It improves type safety and ensures compatibility with the new Rust-based BLS library.Consider adding a brief comment explaining the use of
Bls12381G2Impl
for future maintainers:/// Sets the BLS public key using the Bls12381G2Impl implementation fn set_public_key(&mut self, public_key: Option<BlsPublicKey<Bls12381G2Impl>>) {
Line range hint
1-120
: Summary: Changes align with PR objectives and improve type safety.The modifications in this file successfully integrate the new BLS library by updating the
BlsPublicKey
type toBlsPublicKey<Bls12381G2Impl>
in both thepublic_key
andset_public_key
methods. These changes:
- Improve type safety by specifying the exact implementation of
BlsPublicKey
.- Ensure compatibility with the new Rust-based BLS library.
- Maintain the overall structure and logic of the
Validator
enum and its associated traits.The localized nature of these changes aligns with the PR objectives, including the fact that no version change is required for the platform.
To further improve the code:
- Consider adding brief comments to the modified methods explaining the use of
Bls12381G2Impl
.- Ensure that any dependent code using these methods is updated to handle the new specific type
BlsPublicKey<Bls12381G2Impl>
.packages/rs-dpp/src/core_types/validator_set/mod.rs (1)
Line range hint
115-119
: LGTM! Consider using a reference parameter for consistency.The method signature for
set_threshold_public_key
has been correctly updated to acceptBlsPublicKey<Bls12381G2Impl>
. This change enhances type safety and is consistent with the previous modifications.For consistency with Rust conventions and to potentially improve performance, consider modifying the parameter to accept a reference:
fn set_threshold_public_key(&mut self, threshold_public_key: &BlsPublicKey<Bls12381G2Impl>)This change would allow the caller to pass a reference, avoiding unnecessary cloning if the
BlsPublicKey
is large or expensive to copy.packages/rs-drive-abci/Cargo.toml (1)
76-76
: Consider using crates.io version for bls-signaturesThe addition of the bls-signatures dependency aligns with the PR objectives to replace the bls library. Using a specific tag (1.3.3) ensures version consistency, which is good.
However, consider using a crates.io version instead of a Git dependency if available. This can improve build reproducibility and security. If a crates.io version is not available or if there's a specific reason for using the Git version, please document this decision.
You can check if a crates.io version is available by running:
#!/bin/bash # Description: Check if bls-signatures is available on crates.io # Test: Check crates.io for bls-signatures cargo search bls-signaturesIf a suitable version is available on crates.io, consider updating the dependency to use it instead of the Git repository.
packages/rs-drive-abci/src/execution/validation/state_transition/common/asset_lock/transaction/fetch_asset_lock_transaction_output_sync/v0/mod.rs (1)
52-52
: Improved type safety and clarity in hash handlingThis change enhances the code by explicitly declaring
hash
as a 32-byte array and using more precise methods to extract the raw hash bytes. It maintains the existing functionality while improving type safety and readability.Consider adding a comment explaining why the hash needs to be reversed, as this operation might not be immediately obvious to all readers:
// Reverse the hash bytes to match the expected format for error reporting hash.reverse();packages/rs-dpp/src/errors/protocol_error.rs (1)
1-1
: LGTM! Consider adding a comment for the new error variant.The addition of the
BlsError
variant is well-implemented and aligns with the PR objectives. The use of#[from]
and#[error(transparent)]
attributes is appropriate for seamless error handling and preservation of error details.Consider adding a brief comment above the new error variant to explain its purpose and when it might occur. This can help other developers understand the context of this error type. For example:
/// Error related to BLS (Boneh-Lynn-Shacham) signature operations #[error(transparent)] BlsError(#[from] BlsError),Also applies to: 251-254
packages/rs-drive-proof-verifier/src/unproved.rs (2)
252-253
: Improved error handling for BlsPublicKey parsing.The change from
BlsPublicKey::from_bytes(&vs.threshold_public_key)
toBlsPublicKey::try_from(vs.threshold_public_key.as_slice())
is a good improvement. It aligns with the PR objective of replacing the bls library and provides better error handling.Consider using
map_err
to provide a more specific error message:BlsPublicKey::try_from(vs.threshold_public_key.as_slice()) .map_err(|e| Error::ProtocolError { error: format!("Invalid BlsPublicKey format: {}", e), })?This would give more context about the specific parsing error.
Line range hint
290-304
: New implementation of FromUnproved for EvoNodeStatus looks good.The implementation is concise and follows the expected pattern for
FromUnproved
. It effectively converts the response intoEvoNodeStatus
and handles the lack of metadata appropriately.For improved clarity, consider adding a comment explaining why default metadata is used:
// Use default response metadata as GetStatusResponse doesn't include metadata Ok((Some(status), Default::default()))This would make the intention clearer for future maintainers.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs (1)
Line range hint
161-161
: ImplementFrom
instead ofInto
to follow Rust conventionsImplementing
From
is preferred overInto
as it automatically provides theInto
implementation and adheres to Rust best practices. This change also removes the need to suppress the Clippy warning.Update your implementation as follows:
-#[allow(clippy::from_over_into)] -impl Into<Vec<QuorumForSavingV0>> for Quorums<VerificationQuorum> { - fn into(self) -> Vec<QuorumForSavingV0> { +impl From<Quorums<VerificationQuorum>> for Vec<QuorumForSavingV0> { + fn from(value: Quorums<VerificationQuorum>) -> Self { value.into_iter() .map(|(hash, quorum)| QuorumForSavingV0 { hash: Bytes32::from(hash.as_byte_array()), public_key: bls_signatures::PublicKey::from_bytes( &quorum.public_key.0.to_compressed(), )?, index: quorum.index, }) .collect() } }This adheres to Rust conventions and enhances code maintainability.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs (1)
159-159
: Consider implementing theDisplay
trait for better debug outputUsing
to_string()
onpublic_key
may not provide the most informative or readable output in debug logs. Consider implementing theDisplay
trait forThresholdBlsPublicKey<Bls12381G2Impl>
to improve the formatting and clarity of the public key representation.packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs (1)
104-104
: Avoid shadowing thesignature
variableAt line 104, the variable
signature
is reassigned with a different type (Signature
), which shadows the parametersignature
of type&[u8; 96]
. This could lead to confusion and potential bugs. Consider renaming the local variable to improve code clarity.Apply this diff to rename the variable:
-let signature = Signature::Basic(g2_element); +let basic_signature = Signature::Basic(g2_element);And update subsequent references to use
basic_signature
.packages/rs-drive-abci/src/mimic/test_quorum.rs (1)
21-21
: Update documentation to reflect specific BLS key typesThe
ValidatorInQuorum
struct now usesBlsPrivateKey<Bls12381G2Impl>
andBlsPublicKey<Bls12381G2Impl>
forprivate_key
andpublic_key
. Ensure that any associated documentation and comments are updated to reflect these specific types, aiding understanding for future maintainers.Also applies to: 23-23
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs (2)
41-43
: Consider logging signature parsing errors for better diagnosticsWhile the code handles parsing failures by returning
Ok(Some(false))
, consider adding a debug or trace log statement to capture the parsing error details. This can aid in troubleshooting when signature parsing fails.
125-130
: Consider logging verification failures for enhanced debuggingIf the signature verification fails, consider logging additional details about the failure. This can help in diagnosing issues related to signature mismatches or invalid signatures.
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (2)
138-151
: Tests look good but consider adding edge casesThe test
test_bls_serialization_deserialization
verifies the serialization and deserialization of BLS keys. It would be beneficial to include edge cases, such as testing with invalid keys or boundary values, to strengthen the test coverage.
155-174
: Ensure signature serialization handles edge casesThe test
test_bls_serialization_deserialization_signature
checks signature serialization and deserialization. Consider adding tests for invalid signatures or corrupted data to ensure robustness.packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs (1)
Line range hint
19-47
: Refactor suggestion: Extract common logic to reduce duplicationBoth
choose_quorum_v0
andchoose_quorum_thread_safe_v0
functions contain similar logic for scoring and selecting quorums. Consider refactoring the shared logic into a helper function to enhance maintainability and reduce code duplication.Also applies to: 54-82
packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs (1)
Line range hint
280-284
: Potential issue with error propagation infilter_map
Using
filter_map
while attempting to propagate errors withreturn Some(Err(e.into()))
may not properly handle errors as intended. Thefilter_map
method skipsNone
values and collectsSome
values, but encapsulatingErr
inSome
can lead to unexpected behavior.Consider using
map
instead offilter_map
to properly handle errors:-let validator_set = members - .into_iter() - .filter_map(|quorum_member| { +let validator_set = members + .into_iter() + .map(|quorum_member| { if !quorum_member.valid { - return None; + return Ok(None); } let public_key = if let Some(public_key_share) = quorum_member.pub_key_share { match BlsPublicKey::try_from(public_key_share.as_slice()) .map_err(ExecutionError::BlsErrorFromDashCoreResponse) { Ok(public_key) => Some(public_key), Err(e) => return Err(e.into()), } } else { None }; let validator = ValidatorV0::new_validator_if_masternode_in_state( quorum_member.pro_tx_hash, public_key, state, )?; - Some(Ok((quorum_member.pro_tx_hash, validator))) + Ok(Some((quorum_member.pro_tx_hash, validator))) }) - .collect::<Result<BTreeMap<ProTxHash, ValidatorV0>, Error>>()?; + .collect::<Result<Vec<Option<(ProTxHash, ValidatorV0)>>, Error>>()?; + +let validator_set = validator_set + .into_iter() + .filter_map(|item| item) + .collect::<BTreeMap<ProTxHash, ValidatorV0>>();This ensures that errors are properly propagated and that valid members are correctly collected.
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_quorum_info/v0/mod.rs (1)
Line range hint
389-395
: Simplify error handling by using the?
operatorThe error handling can be streamlined by leveraging the
?
operator for more idiomatic Rust code.Apply this diff to simplify the code:
-let public_key = - match BlsPublicKey::try_from(quorum_info.quorum_public_key.as_slice()) - .map_err(ExecutionError::BlsErrorFromDashCoreResponse) - { - Ok(public_key) => public_key, - Err(e) => return Err(e.into()), - }; +let public_key = BlsPublicKey::try_from(quorum_info.quorum_public_key.as_slice()) + .map_err(ExecutionError::BlsErrorFromDashCoreResponse)?;packages/rs-dpp/src/identity/identity_public_key/random.rs (16)
Line range hint
141-151
: Update documentation to reflect the new return typeThe method
random_authentication_key_with_private_key
now returnsResult<(Self, [u8; 32]), ProtocolError>
, but the documentation still mentions the private key asVec<u8>
. Please update the documentation to reflect the correct return type.Apply this diff to correct the documentation:
-/// * `Result<(Self, Vec<u8>), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `Vec<u8>`. +/// * `Result<(Self, [u8; 32]), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `[u8; 32]`.
Line range hint
141-151
: Consider extracting RNG initialization to reduce code duplicationThe initialization of the random number generator (
StdRng
) from a seed is repeated across multiple methods. To adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this logic into a helper function to improve maintainability.Introduce a helper function:
fn init_rng(seed: Option<u64>) -> StdRng { match seed { Some(seed_value) => StdRng::seed_from_u64(seed_value), None => StdRng::from_entropy(), } }Then, update the methods to use the helper:
- let mut rng = match seed { - None => StdRng::from_entropy(), - Some(seed_value) => StdRng::seed_from_u64(seed_value), - }; + let mut rng = init_rng(seed);
Line range hint
179-187
: Update documentation to reflect the new return typeThe method
random_authentication_key_with_private_key_with_rng
now returnsResult<(Self, [u8; 32]), ProtocolError>
, but the documentation still references the private key asVec<u8>
. Please update the documentation accordingly.Apply this diff:
-/// * `Result<(Self, Vec<u8>), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `Vec<u8>`. +/// * `Result<(Self, [u8; 32]), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `[u8; 32]`.
Line range hint
275-285
: Update documentation to reflect the new return typeThe method
random_key_with_known_attributes
now returnsResult<(Self, [u8; 32]), ProtocolError>
, but the documentation mentions the private key asVec<u8>
. Please update it to reflect the correct return type.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
321-331
: Update documentation to reflect the new return typeIn the method
random_ecdsa_master_authentication_key_with_rng
, the return type has changed toResult<(Self, [u8; 32]), ProtocolError>
, but the comments still referenceVec<u8>
. Please update the documentation.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
387-397
: Update documentation to reflect the new return typeThe method
random_ecdsa_master_authentication_key
now returnsResult<(Self, [u8; 32]), ProtocolError>
, but the documentation still mentionsVec<u8>
. Please update it accordingly.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
414-424
: Update documentation to reflect the new return typeIn
random_ecdsa_critical_level_authentication_key
, the return type has changed toResult<(Self, [u8; 32]), ProtocolError>
. Update the documentation to match the new return type.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
445-455
: Update documentation to reflect the new return typeThe method
random_ecdsa_critical_level_authentication_key_with_rng
now returns the private key as[u8; 32]
. Please update the documentation accordingly.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
492-502
: Update documentation to reflect the new return typeIn
random_masternode_owner_key
, update the documentation to reflect that the private key is now[u8; 32]
.Apply this diff:
-/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode owner and the corresponding private key as a byte vector. +/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode owner and the corresponding private key as a `[u8; 32]` array.
Line range hint
521-531
: Update documentation to reflect the new return typeThe method
random_masternode_owner_key_with_rng
now returns[u8; 32]
for the private key. Please update the documentation.Apply this diff:
-/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode owner and the corresponding private key as a byte vector. +/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode owner and the corresponding private key as a `[u8; 32]` array.
Line range hint
561-571
: Update documentation to reflect the new return typeIn
random_masternode_transfer_key
, the private key is now[u8; 32]
. Update the documentation accordingly.Apply this diff:
-/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode transfer key and the corresponding private key as a byte vector. +/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode transfer key and the corresponding private key as a `[u8; 32]` array.
Line range hint
590-600
: Update documentation to reflect the new return typeThe method
random_masternode_transfer_key_with_rng
now returns[u8; 32]
for the private key. Please update the documentation.Apply this diff:
-/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode transfer key and the corresponding private key as a byte vector. +/// Returns a tuple containing the generated `IdentityPublicKey` for the masternode transfer key and the corresponding private key as a `[u8; 32]` array.
Line range hint
632-642
: Update documentation to reflect the new return typeIn
random_ecdsa_high_level_authentication_key
, update the documentation to indicate that the private key is[u8; 32]
.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
659-669
: Update documentation to reflect the new return typeThe method
random_ecdsa_high_level_authentication_key_with_rng
now returns[u8; 32]
for the private key. Please update the documentation accordingly.Apply this diff:
-/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct, +/// * `(Self, [u8; 32])`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
Line range hint
706-714
: Update documentation to reflect the new return typeIn
random_authentication_keys_with_private_keys_with_rng
, the private keys are now[u8; 32]
. Update the documentation to reflect this change.Apply this diff:
-/// Returns a `Vec` of tuples containing `Self` and `Vec<u8>` as the private keys. +/// Returns a `Vec` of tuples containing `Self` and `[u8; 32]` as the private keys.
Line range hint
723-738
: Update documentation to reflect the new return typeThe method
main_keys_with_random_authentication_keys_with_private_keys_with_rng
now returns private keys as[u8; 32]
. Please update the documentation accordingly.Apply this diff:
-/// Returns a `Vec` of tuples containing `Self` and `Vec<u8>` as the private keys. +/// Returns a `Vec` of tuples containing `Self` and `[u8; 32]` as the private keys.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (49)
- packages/rs-dpp/Cargo.toml (1 hunks)
- packages/rs-dpp/src/bls/native_bls.rs (2 hunks)
- packages/rs-dpp/src/core_types/validator/mod.rs (3 hunks)
- packages/rs-dpp/src/core_types/validator/v0/mod.rs (9 hunks)
- packages/rs-dpp/src/core_types/validator_set/mod.rs (3 hunks)
- packages/rs-dpp/src/core_types/validator_set/v0/mod.rs (13 hunks)
- packages/rs-dpp/src/errors/protocol_error.rs (2 hunks)
- packages/rs-dpp/src/identity/identity_public_key/key_type.rs (11 hunks)
- packages/rs-dpp/src/identity/identity_public_key/methods/hash/mod.rs (1 hunks)
- packages/rs-dpp/src/identity/identity_public_key/methods/hash/v0/mod.rs (1 hunks)
- packages/rs-dpp/src/identity/identity_public_key/random.rs (16 hunks)
- packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (9 hunks)
- packages/rs-dpp/src/identity/identity_public_key/v0/random.rs (8 hunks)
- packages/rs-dpp/src/identity/random.rs (2 hunks)
- packages/rs-dpp/src/identity/v0/random.rs (2 hunks)
- packages/rs-dpp/src/lib.rs (1 hunks)
- packages/rs-dpp/src/signing.rs (3 hunks)
- packages/rs-drive-abci/Cargo.toml (2 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs (4 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_quorum_info/v0/mod.rs (1 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs (2 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs (4 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs (4 hunks)
- packages/rs-drive-abci/src/execution/platform_events/core_instant_send_lock/verify_recent_signature_locally/v0/mod.rs (3 hunks)
- packages/rs-drive-abci/src/execution/validation/state_transition/common/asset_lock/transaction/fetch_asset_lock_transaction_output_sync/v0/mod.rs (2 hunks)
- packages/rs-drive-abci/src/mimic/mod.rs (2 hunks)
- packages/rs-drive-abci/src/mimic/test_quorum.rs (8 hunks)
- packages/rs-drive-abci/src/platform_types/commit/mod.rs (2 hunks)
- packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs (4 hunks)
- packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs (4 hunks)
- packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs (1 hunks)
- packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs (3 hunks)
- packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs (4 hunks)
- packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs (1 hunks)
- packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs (1 hunks)
- packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs (3 hunks)
- packages/rs-drive-abci/src/platform_types/validator/v0/mod.rs (2 hunks)
- packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs (10 hunks)
- packages/rs-drive-abci/src/query/system/current_quorums_info/v0/mod.rs (1 hunks)
- packages/rs-drive-abci/tests/strategy_tests/execution.rs (7 hunks)
- packages/rs-drive-abci/tests/strategy_tests/main.rs (1 hunks)
- packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs (3 hunks)
- packages/rs-drive-abci/tests/strategy_tests/masternodes.rs (3 hunks)
- packages/rs-drive-abci/tests/strategy_tests/query.rs (4 hunks)
- packages/rs-drive-proof-verifier/src/unproved.rs (1 hunks)
- packages/rs-drive-proof-verifier/src/verify.rs (3 hunks)
- packages/rs-sdk/Cargo.toml (1 hunks)
- packages/simple-signer/Cargo.toml (1 hunks)
- packages/simple-signer/src/signer.rs (4 hunks)
🧰 Additional context used
📓 Learnings (4)
packages/rs-dpp/src/core_types/validator/mod.rs (2)
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299 Timestamp: 2024-10-09T00:22:57.778Z Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299 Timestamp: 2024-10-08T13:22:18.391Z Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.
packages/rs-dpp/src/core_types/validator_set/mod.rs (2)
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299 Timestamp: 2024-10-08T13:22:18.391Z Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299 Timestamp: 2024-10-09T00:22:57.778Z Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs (2)
Learnt from: QuantumExplorer PR: dashpay/platform#2215 File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30 Timestamp: 2024-10-06T16:11:34.946Z Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Learnt from: QuantumExplorer PR: dashpay/platform#2215 File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30 Timestamp: 2024-10-09T00:22:57.778Z Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs (2)
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-drive-abci/src/platform_types/platform_state/mod.rs:141-141 Timestamp: 2024-10-09T00:22:57.778Z Learning: When converting `PlatformStateV0` to `PlatformStateForSavingV1` in `packages/rs-drive-abci/src/platform_types/platform_state/mod.rs`, only version `0` needs to be handled in the match on `platform_state_for_saving_structure_default` because the changes are retroactive.
Learnt from: QuantumExplorer PR: dashpay/platform#2227 File: packages/rs-drive-abci/src/platform_types/platform_state/mod.rs:141-141 Timestamp: 2024-10-08T13:28:03.529Z Learning: When converting `PlatformStateV0` to `PlatformStateForSavingV1` in `packages/rs-drive-abci/src/platform_types/platform_state/mod.rs`, only version `0` needs to be handled in the match on `platform_state_for_saving_structure_default` because the changes are retroactive.
🔇 Additional comments (134)
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs (1)
2-2
: Approved. Please clarify the versioning strategy.The addition of the
for_saving_v1
module is in line with the PR objectives, particularly regarding the changes in serialization for the Platform version. This approach allows for maintaining backward compatibility while introducing new features or changes.Could you please clarify:
- The differences between
for_saving
andfor_saving_v1
?- The timeline for transitioning fully to
v1
and deprecating the originalfor_saving
module?- Any impacts on existing code that uses the
for_saving
module?To help verify the usage and impact of this new module, please run the following script:
This will help us understand the current usage of both modules and identify any files that might need attention during the transition.
packages/rs-dpp/src/identity/identity_public_key/methods/hash/v0/mod.rs (1)
11-11
: Approve: Enhanced type safety for private key validationThe change from
&[u8]
to&[u8; 32]
forprivate_key_bytes
improves type safety by enforcing a fixed-size array of 32 bytes for private keys. This modification aligns well with standard private key sizes and can potentially improve performance through compiler optimizations.However, this is a breaking change that may affect existing code using this trait. Ensure that all implementations and callers of this method are updated accordingly.
To ensure consistency across the codebase, please run the following script:
This will help identify any inconsistencies in private key handling across the project.
✅ Verification successful
Verified: Private key byte array usage is consistent across the codebase
The change from
&[u8]
to&[u8; 32]
forprivate_key_bytes
has been consistently applied across all relevant parts of the codebase. All private key declarations and method calls adhere to the 32-byte requirement, ensuring enhanced type safety without introducing breaking changes.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of 32-byte private keys across the codebase # Search for other occurrences of private key byte arrays echo "Searching for private key byte array declarations:" rg --type rust '\[u8; (\d+)\].*private.*key' # Search for uses of validate_private_key_bytes method echo "Searching for validate_private_key_bytes method calls:" rg --type rust 'validate_private_key_bytes'Length of output: 2437
packages/simple-signer/Cargo.toml (1)
11-11
: Dependency update looks good, but let's verify the intention.The update of
dashcore-rpc
fromv0.15.8
tov0.15.9
seems appropriate. This minor version bump likely includes bug fixes or small improvements that could help address the compilation issues mentioned in the PR objectives.To ensure this change is intentional and aligns with the PR objectives:
- Could you confirm that this update is specifically related to addressing the compilation issues mentioned in the PR description?
- Have you tested the project with this new version to ensure compatibility and that it resolves the intended issues?
It would be beneficial to run the project's test suite with this new dependency version to catch any potential compatibility issues early.
packages/rs-dpp/src/identity/identity_public_key/methods/hash/mod.rs (1)
Line range hint
1-24
: LGTM: Well-structured implementation with good practicesThe overall structure and implementation of this file demonstrate good practices:
- Modular design with separate
v0
module, allowing for potential future versions.- Proper error handling using
Result<_, ProtocolError>
.- Network-specific validation support through the
Network
parameter.- Consistent use of appropriate data sizes (20-byte array for
public_key_hash
).The implementation correctly delegates calls to the V0 variant, maintaining a clean and extensible structure.
packages/rs-drive-abci/src/platform_types/validator/v0/mod.rs (2)
4-4
: LGTM: Import statement updated for new BLS implementationThe import statement has been correctly updated to include
Bls12381G2Impl
, which aligns with the PR objective of replacing the bls library with a Rust-based implementation.
11-11
: LGTM: Updated public_key type for new BLS implementationThe
public_key
parameter type has been correctly updated fromOption<BlsPublicKey>
toOption<BlsPublicKey<Bls12381G2Impl>>
in both the trait definition and its implementation. This change:
- Aligns with the PR objective of replacing the bls library.
- Provides more type safety by specifying the exact BLS implementation.
- Maintains backward compatibility by keeping the
Option
wrapper.To ensure consistency across the codebase, please run the following script to check for any remaining occurrences of the old
BlsPublicKey
type:This will help identify any places where the type update might have been missed.
Also applies to: 20-20
packages/rs-dpp/src/lib.rs (2)
Line range hint
1-1
: Overall assessment: Changes look good and align with PR objectives.The modifications to the BLS library import and the conditional compilation of
data_contracts
appear to be implemented correctly. These changes should help address the compilation issues on Windows platforms and potentially optimize the codebase. Ensure to run the suggested verification scripts to confirm the changes have been applied consistently across the project.
Line range hint
1-1
: LGTM! Verify the impact of conditional compilation fordata_contracts
.The addition of
#[cfg(feature = "system_contracts")]
for thedata_contracts
import is a good optimization. It ensures thatdata_contracts
is only included when the "system_contracts" feature is enabled, potentially reducing compilation time and binary size when not needed.To ensure the change has been applied correctly and assess its impact, run the following script:
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs (2)
6-6
: LGTM: Import change aligns with PR objective.The addition of
Bls12381G2Impl
and the renaming ofPublicKey
toBlsPublicKey
from thedpp::bls_signatures
module aligns with the PR objective of replacing the bls library. This change sets the foundation for the subsequent modifications in the file.
Line range hint
48-71
: Verify ifchoose_quorum_thread_safe
needs updating.The
choose_quorum_thread_safe
function remains unchanged whilechoose_quorum
has been updated to use the newBls12381G2Impl
type. Please clarify if this is intentional or ifchoose_quorum_thread_safe
should also be updated for consistency.If an update is needed, consider applying similar changes to
choose_quorum_thread_safe
:pub fn choose_quorum_thread_safe<'a, const T: usize>( llmq_quorum_type: QuorumType, - quorums: &'a BTreeMap<QuorumHash, [u8; T]>, + quorums: &'a BTreeMap<QuorumHash, BlsPublicKey<Bls12381G2Impl>>, request_id: &[u8; 32], platform_version: &PlatformVersion, - ) -> Result<Option<(ReversedQuorumHashBytes, &'a [u8; T])>, Error> { + ) -> Result<Option<(ReversedQuorumHashBytes, &'a BlsPublicKey<Bls12381G2Impl>)>, Error> { // ... (update implementation as needed) }To verify if this function is used elsewhere in the codebase and if it needs updating, you can run the following script:
✅ Verification successful
Verified: The
choose_quorum_thread_safe
function is correctly implemented and used appropriately within the codebase. No inconsistencies or issues were found regarding its current state.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usages of choose_quorum_thread_safe rg "choose_quorum_thread_safe" --type rustLength of output: 794
packages/rs-drive-abci/src/platform_types/commit/mod.rs (3)
8-8
: LGTM: New import added correctlyThe new import for
Bls12381G2Impl
is correctly added and is necessary for the updatedverify_signature
method signature.
86-86
: LGTM: Method signature updated correctlyThe
verify_signature
method signature has been correctly updated to use the more specificPublicKey<Bls12381G2Impl>
type. This change aligns with the PR objective to replace the bls library.To ensure this change doesn't break existing code, please run the following script to check for any other occurrences of
verify_signature
that might need updating:
Line range hint
1-92
: Summary: Changes align with PR objectivesThe changes in this file are well-implemented and align with the PR objective to replace the bls library. The new import and updated method signature for
verify_signature
are correct and consistent.To ensure the consistency of these changes across the codebase, please run the following script:
This script will help identify any inconsistencies or remaining old BLS library usages that might need attention.
packages/rs-drive-abci/src/query/system/current_quorums_info/v0/mod.rs (1)
43-47
: Approve changes with verification requestThe modifications to
threshold_public_key
processing look good and align with the PR objectives. The new implementation correctly handles the apparent change in thethreshold_public_key()
method's return type and ensures the key is stored in a compressed format.However, to ensure system-wide compatibility:
- Verify that this change in key representation is consistent with how
threshold_public_key
is used in other parts of the system.- Update relevant documentation to reflect this change in key representation.
To verify the usage of
threshold_public_key
across the codebase, please run the following script:This will help ensure that all usages of
threshold_public_key()
andValidatorSetV0
are consistent with the new implementation.✅ Verification successful
Verification Successful
The changes to
threshold_public_key
processing have been reviewed across the codebase and appear consistent with existing implementations. All usages ofthreshold_public_key()
align with the updated processing, ensuring compatibility throughout the system.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check usage of threshold_public_key() method across the codebase # Search for all occurrences of threshold_public_key() method echo "Occurrences of threshold_public_key() method:" rg --type rust -A 5 'threshold_public_key\(\)' # Search for all occurrences of ValidatorSetV0 struct initialization echo "\nOccurrences of ValidatorSetV0 struct initialization:" rg --type rust -A 10 'ValidatorSetV0\s*\{'Length of output: 26879
packages/rs-dpp/src/core_types/validator_set/mod.rs (1)
Line range hint
83-87
: LGTM! Signature update enhances type safety.The method signature for
threshold_public_key
has been correctly updated to return&BlsPublicKey<Bls12381G2Impl>
. This change:
- Ensures consistency with the updated import statement.
- Enhances type safety by specifying the exact implementation of
BlsPublicKey
.- Maintains the method's functionality while providing more precise type information.
packages/rs-drive-abci/Cargo.toml (2)
31-31
: Summary: Changes align with PR objectivesThe updates to the dependencies in this Cargo.toml file align well with the PR objectives:
- The dashcore-rpc update may help address compilation issues.
- The addition of the bls-signatures dependency replaces the previous bls library as intended.
These changes should contribute to resolving the compilation issues related to the bls-signatures library on Windows platforms, as mentioned in the PR objectives.
To ensure these changes have the desired effect, please verify that:
- The compilation issues on Windows platforms have been resolved.
- All tests are passing with these new dependencies.
You can run the following commands to check for any remaining issues:
#!/bin/bash # Description: Check for compilation issues and test results # Test: Attempt to build the project cargo build --target x86_64-pc-windows-msvc # Test: Run all tests cargo testIf these commands complete successfully, it would indicate that the PR objectives have been met.
Also applies to: 76-76
31-31
: LGTM: dashcore-rpc dependency updateThe update of dashcore-rpc from v0.15.8 to v0.15.9 is a minor version change, which should be backward-compatible. This change aligns with the PR objectives to address compilation issues.
To ensure compatibility, please verify that all tests pass with this new version. You can run the following command to check for any breaking changes or deprecations:
packages/rs-sdk/Cargo.toml (1)
36-36
: Approved: dashcore-rpc dependency update. Please clarify the reason for this change.The update of the dashcore-rpc dependency from v0.15.8 to v0.15.9 looks good. This minor version update likely includes backward-compatible new features or bug fixes.
However, could you please clarify the reason for this update? While it's not directly related to the main objective of replacing the bls library, it would be helpful to understand if this change is necessary to support the new BLS implementation or if it addresses any related issues.
To ensure compatibility with the new BLS implementation, please run the following verification script:
This script will help identify any BLS-related changes in the new version and check for potential breaking changes.
packages/rs-dpp/Cargo.toml (4)
Line range hint
3-3
: LGTM: Version bump is appropriate.The package version has been updated from 1.4.1 to 1.4.2, which is a minor version bump. This is appropriate for backwards-compatible changes and aligns with semantic versioning principles.
Line range hint
3-3
: Summary of Cargo.toml changesThe changes in this file include:
- A minor version bump from 1.4.1 to 1.4.2.
- An update to the dashcore dependency (0.32.0 to 0.33.1) with additional features.
- An update to the once_cell dev dependency (1.7 to 1.19.0).
These changes align with the PR objectives, particularly the dashcore update which supports the replacement of the bls library. While the changes appear appropriate, it's important to verify that they don't introduce any breaking changes or unexpected behavior in the codebase and test suite.
Please ensure all verification steps mentioned in the previous comments are executed and their results are reviewed before merging this PR.
Also applies to: 30-31, 58-58
30-31
: LGTM: Dashcore dependency updated with new features.The dashcore dependency has been updated from version 0.32.0 to 0.33.1, and new features have been added: "serde", "bls", and "eddsa". This update aligns with the PR objective of replacing the bls library and expands the package's capabilities in serialization and cryptographic operations.
To ensure the update doesn't introduce any breaking changes, please run the following script:
Line range hint
58-58
: LGTM: Once_cell dev dependency updated.The once_cell dev dependency has been updated from version 1.7 to 1.19.0. This significant version jump might introduce new features or performance improvements for tests.
To ensure the update doesn't introduce any issues in the test suite, please run the following script:
packages/rs-dpp/src/errors/protocol_error.rs (1)
1-1
: Verify the impact of the new BLS error handling.The addition of the
BlsError
variant enhances the protocol's error handling capabilities for BLS-related operations. This change aligns well with the PR objectives and maintains backward compatibility.To ensure the new error type is properly integrated, please run the following script:
This script will help verify that the new error type is consistently used and properly integrated into the existing error handling system.
Also applies to: 251-254
✅ Verification successful
BlsError integration verified successfully.
The
BlsError
variant is properly imported and utilized within the codebase. Error conversions using#[from]
are correctly implemented, ensuring seamless integration with the existing error handling system.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of BlsError in the codebase # Test 1: Check if BlsError is properly imported echo "Checking BlsError import:" rg --type rust "use dashcore::blsful::BlsError;" packages/rs-dpp/src # Test 2: Look for potential uses of the new BlsError variant echo "Checking potential uses of BlsError:" rg --type rust "BlsError\(" packages/rs-dpp/src # Test 3: Verify error conversion implementations echo "Checking for From<BlsError> implementations:" rg --type rust "impl From<BlsError>" packages/rs-dpp/srcLength of output: 728
packages/rs-dpp/src/identity/random.rs (2)
237-238
: LGTM! Verify impact on codebase.The change from
Vec<u8>
to[u8; 32]
for private keys is consistent with the previous function and aligns with the PR objectives. This modification can lead to improved performance and memory efficiency.Please ensure that all callers of this function have been updated to use the new
[u8; 32]
type for private keys. Run the following script to verify the usage:#!/bin/bash # Description: Verify all callers of random_identities_with_private_keys_with_rng use [u8; 32] for private keys # Test: Search for function calls and check the type used for private keys rg --type rust -e "random_identities_with_private_keys_with_rng" -A 10 -B 5
Line range hint
1-265
: Overall LGTM. Suggest comprehensive impact analysis.The changes in this file consistently update the private key type from
Vec<u8>
to[u8; 32]
in bothrandom_identity_with_main_keys_with_private_key
andrandom_identities_with_private_keys_with_rng
functions. These modifications align well with the PR objectives and can potentially improve performance and type safety.To ensure a smooth transition, I recommend conducting a comprehensive impact analysis across the entire codebase. This will help identify any areas that might need updates due to these changes. Consider running the following script:
This script will help identify any remaining
Vec<u8>
usages that might need to be updated to[u8; 32]
for consistency with these changes.packages/rs-dpp/src/identity/identity_public_key/v0/random.rs (9)
71-71
: Improved type safety and efficiency for private key representationThe change from
Vec<u8>
to[u8; 32]
for the private key data improves type safety and memory efficiency. This fixed-size array representation is consistent with common cryptographic key sizes and aligns well with the PR's objective of refactoring the BLS library implementation.
127-127
: Consistent private key representation across methodsThe change to use
[u8; 32]
for the private key data maintains consistency with other methods in this file. This standardization improves overall code coherence and type safety.
200-200
: Standardized private key size for ECDSA master authentication keyThe change to use
[u8; 32]
for the private key data aligns this method with the standardized approach used in other methods. This consistency is particularly important for ECDSA keys, ensuring uniform handling across different key types.
226-226
: Uniform private key representation for voting keysThe adoption of
[u8; 32]
for the private key data in the voting key generation method ensures consistency with other key types. This standardization simplifies key management and improves type safety for voting-related operations.
252-252
: Standardized private key format for owner keysThe change to
[u8; 32]
for the private key data in the owner key generation method maintains consistency with other key types. This uniformity is crucial for owner keys, which often require high security and standardized handling.
278-278
: Consistent private key representation for masternode transfer keysThe adoption of
[u8; 32]
for the private key data in the masternode transfer key generation method aligns with the standardized approach used throughout the file. This consistency is particularly important for masternode operations, ensuring uniform key handling across the platform.
304-304
: Uniform private key format for ECDSA critical level authentication keysThe change to
[u8; 32]
for the private key data in the ECDSA critical level authentication key generation method ensures consistency with other key types. This standardization is especially important for critical level keys, enhancing type safety and simplifying key management for high-security operations.
330-330
: Standardized private key representation for ECDSA high level authentication keysThe adoption of
[u8; 32]
for the private key data in the ECDSA high level authentication key generation method maintains consistency with other key types. This uniformity enhances type safety and simplifies key management across different security levels.
Line range hint
1-355
: Summary: Consistent and improved private key handlingThe changes in this file demonstrate a systematic approach to standardizing private key representation across all key generation methods. By consistently using
[u8; 32]
instead ofVec<u8>
, the code now offers:
- Improved type safety
- Better memory efficiency
- Consistent handling of private keys across different key types and security levels
- Alignment with common cryptographic key sizes
These modifications support the PR's objective of refactoring the BLS library implementation and enhance the overall quality and maintainability of the codebase.
packages/rs-drive-proof-verifier/src/unproved.rs (1)
Line range hint
1-304
: Overall, the changes in this file are well-implemented and align with the PR objectives.The modifications to
CurrentQuorumsInfo
and the addition ofEvoNodeStatus
implementation contribute to the goal of replacing the bls library and refactoring the platform. The code maintains good quality, follows Rust best practices, and improves error handling.To further enhance the code:
- Consider adding unit tests for the new
EvoNodeStatus
implementation to ensure its correctness.- Update the documentation comments for
FromUnproved
trait to reflect any changes in behavior due to the new BLS implementation.packages/rs-drive-abci/tests/strategy_tests/main.rs (3)
Line range hint
1-2257
: Summary: Minor import change with no direct impact on testsThe change in this file is limited to updating the import statement for the BLS private key type. After a thorough review, no direct uses of this type were found in the test implementations. The extensive test suite covers various aspects of the blockchain-like system, including chain execution, identity management, document operations, and more.
While the change doesn't introduce any immediate issues in this file, it's likely part of a broader refactoring effort. It's recommended to:
- Ensure that all related files in the project have been updated consistently.
- Verify that the new
SecretKey
type is fully compatible with the previousPrivateKey
type in terms of API and functionality.- Run the entire test suite to confirm that this change doesn't introduce any unexpected behavior in other parts of the system.
6-6
: Update import statement for BLS private key typeThe import statement has been changed from
PrivateKey
toSecretKey
, which is now aliased asBlsPrivateKey
. This change likely reflects an update in the underlying BLS signature library.To ensure this change doesn't introduce any issues, let's verify that all usages of
BlsPrivateKey
in the file are compatible with the newSecretKey
type:
Line range hint
1-2257
: No direct usage of BlsPrivateKey in test implementationsAfter reviewing the entire file, it appears that the
BlsPrivateKey
type (previouslyPrivateKey
) is not directly used in any of the test implementations. The change in the import statement seems to be isolated and doesn't have any immediate impact on the functionality of the tests in this file.However, it's important to note that this change might be part of a larger refactoring effort in the codebase. Other files that depend on this type might need similar updates.
To ensure there are no indirect uses or potential issues related to this change, let's check for any BLS-related functionality in the tests:
packages/rs-dpp/src/bls/native_bls.rs (5)
1-3
: Imports are correctly updated for the new BLS implementationThe necessary types and traits from
bls_signatures
are properly imported, ensuring that theBls12381G2Impl
implementation is used throughout the module.
11-13
: Public key validation logic is properly implementedThe
validate_public_key
method correctly usesPublicKey::<Bls12381G2Impl>::try_from(pk)
to attempt parsing the public key bytes. Error handling is appropriately managed by converting errors intoPublicKeyValidationError
.
29-31
: Check for potential failure infrom_compressed
methodThe
from_compressed
method could fail to produce aSignature
if the input bytes are invalid. Ensure that the error handling adequately reflects the cause of failure.Please confirm that the error message "signature derivation failed" provides sufficient detail. If more context is available, consider enhancing the error message.
57-64
: Signing operation implemented correctly with proper error propagationThe
sign
method correctly creates a signature using theSecretKey
and handles any potential errors using the?
operator, ensuring that errors are propagated appropriately.
61-64
: Confirm that all serialization methods handle errors appropriatelyWhen converting the signature to its compressed form, ensure that all methods (
as_raw_value
,to_compressed
, etc.) handle errors correctly or cannot fail. If any of these methods can fail, consider adding error handling to capture and manage those errors.Please verify whether these methods can fail and adjust the error handling if necessary.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs (3)
61-66
: Confirm the necessity of the#[bincode(with_serde)]
attributeThe
public_key
field inQuorumForSavingV1
is annotated with#[bincode(with_serde)]
. Ensure that this attribute is required for the correct serialization and deserialization ofThresholdBlsPublicKey<Bls12381G2Impl>
. If the type already implementsSerialize
andDeserialize
appropriately, this attribute might be redundant.To check if the attribute is necessary, you can run:
#!/bin/bash # Description: Search for Serialize and Deserialize implementations on ThresholdBlsPublicKey rg 'impl.*Serialize.*for ThresholdBlsPublicKey' packages/ rg 'impl.*Deserialize.*for ThresholdBlsPublicKey' packages/
70-79
: Ensure correct mapping in iterator conversionIn the
From<Vec<QuorumForSavingV1>> for Quorums<VerificationQuorum>
implementation, verify that the mapping fromQuorumForSavingV1
to(QuorumHash, VerificationQuorum)
is accurate and preserves the intended data relationships. Pay special attention to the construction ofQuorumHash
fromquorum.hash
.Consider running the following script to check for potential issues in the mapping logic:
#!/bin/bash # Description: Verify the correctness of QuorumHash construction from Bytes32 # Search for usages of QuorumHash::from_byte_array rg 'QuorumHash::from_byte_array' packages/ -A 3
28-42
: Verify the correctness of data conversion between versionsWhen implementing
From<SignatureVerificationQuorumSetV0> for SignatureVerificationQuorumSetForSavingV1
, ensure that all fields are correctly converted, especially if there are differences in the structures between versions. The same applies to the reverse conversion inFrom<SignatureVerificationQuorumSetForSavingV1> for SignatureVerificationQuorumSetV0
.To automate the verification, consider running the following script to compare the fields of both versions:
packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs (3)
7-10
: Usage of versioned enum with a single variant is acceptableDefining
ValidatorSet
as an enum with a single variantV0
is acceptable if future versions are anticipated. This approach facilitates forward compatibility and maintains a consistent pattern for versioning.
36-57
: Conversion implementation appears correctThe
From
implementation forValidatorSetV0
correctly maps all fields to the corresponding types indpp::core_types::validator_set::v0::ValidatorSetV0
.
80-103
: Conversion implementation is accurateThe
From
implementation forValidatorV0
appropriately handles the field mappings and considers the optionalpublic_key
.packages/rs-drive-proof-verifier/src/verify.rs (5)
4-5
: Updated imports to include specific BLS implementationThe addition of
Bls12381G2Impl
,Pairing
, andSignature
aligns with the shift to the Rust-based BLS library and is necessary for the updated cryptographic operations.
95-98
: Correct usage oftry_from
withBls12381G2Impl
The change to use
PublicKey::<Bls12381G2Impl>::try_from(pubkey_bytes.as_slice())
ensures that the public key is created using the specific BLS implementation, which enhances type safety and compatibility with the new library.
132-138
: Proper construction ofSignature::Basic
with robust error handlingThe signature is now constructed using
Signature::Basic
with theBls12381G2Impl
implementation. The use offrom_compressed
along withinto_option()
andok_or
effectively handles potential errors in signature deserialization.
140-140
: Simplified and efficient signature verificationReturning
Ok(signature.verify(public_key, sign_digest).is_ok())
streamlines the verification process, providing a clear and concise result of the signature check.
125-125
: Function signature updated to require specific public key typeThe
verify_signature_digest
function now explicitly expects a&bls_signatures::PublicKey<Bls12381G2Impl>
. Ensure that all calls to this function pass the correct public key type to prevent type mismatches.Run the following script to locate all usages of
verify_signature_digest
and verify that they have been updated:✅ Verification successful
All usages of
verify_signature_digest
pass the correct public key type.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all usages of `verify_signature_digest` to confirm the correct public key type is passed. # Expected: All function calls should use `PublicKey<Bls12381G2Impl>` rg --type rust 'verify_signature_digest\(' -A 3Length of output: 741
packages/rs-dpp/src/identity/v0/random.rs (3)
50-51
: Improve type safety by using fixed-size arrays for private keysChanging the private key type from
Vec<u8>
to[u8; 32]
enhances type safety by enforcing a fixed key length. This prevents potential runtime errors due to variable key sizes and ensures that all private keys are exactly 32 bytes long.
129-130
: Ensure consistency by updating generic constraints to[u8; 32]
Updating the generic type constraints from
Vec<u8>
to[u8; 32]
across the codebase ensures consistent handling of private keys with fixed lengths, enhancing type safety and reducing potential errors.
133-133
: Initializeprivate_key_map
with the updated private key typeThe
private_key_map
now correctly usesVec<(IdentityPublicKey, [u8; 32])>
, aligning with the updated private key type. This change maintains consistency and avoids mismatches in key handling.packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs (2)
130-130
: Verify the correctness of mappingV0
toV1
inFrom
implementationIn the
From<SignatureVerificationQuorumSet> for SignatureVerificationQuorumSetForSaving
implementation, theV0
variant is mapped toV1
:SignatureVerificationQuorumSet::V0(v0) => { SignatureVerificationQuorumSetForSaving::V1(v0.into()) }Please confirm that mapping a
V0
variant to aV1
variant is intentional and will not introduce compatibility issues.
142-144
: Ensure safe reverse mapping fromV1
toV0
In the
From<SignatureVerificationQuorumSetForSaving> for SignatureVerificationQuorumSet
implementation, theV1
variant is converted back toV0
:SignatureVerificationQuorumSetForSaving::V1(v1) => { SignatureVerificationQuorumSet::V0(v1.into()) }Verify that this reverse mapping maintains data integrity and does not result in any loss of information introduced in
V1
.packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs (3)
6-6
: Addition ofVerificationQuorum
import is appropriateThe inclusion of
VerificationQuorum
in the import list is necessary for the updated code and is correctly added.
138-138
: Updatepublic_key
type tobls_signatures::PublicKey
Changing the
public_key
field inQuorumForSavingV0
tobls_signatures::PublicKey
aligns with the transition to the new BLS library and is appropriate.
138-138
: Verify serialization support forbls_signatures::PublicKey
Ensure that
bls_signatures::PublicKey
implements the necessarySerialize
andDeserialize
traits required by#[bincode(with_serde)]
. If it doesn't, you may need to implement custom serialization or ensure that the library provides these implementations.packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs (1)
3-3
: ImportingBls12381G2Impl
is appropriateThe import of
Bls12381G2Impl
fromdpp::bls_signatures
is necessary for the updated BLS implementation and appears correct.packages/rs-drive-abci/src/execution/platform_events/core_instant_send_lock/verify_recent_signature_locally/v0/mod.rs (3)
1-1
: Updated imports to accommodate new BLS signature implementationThe import statement has been appropriately updated to include
Bls12381G2Impl
andSignature
fromdpp::bls_signatures
, aligning with the replacement of the BLS library. This change ensures compatibility with the new Rust-based BLS library.
23-26
: Correctly converting instant lock signature toSignature
The code correctly uses
Signature::<Bls12381G2Impl>::try_from
to convertinstant_lock.signature
into aSignature
object. This enhances type safety and ensures proper error handling for invalid signatures.
100-105
: Signature verification logic is correctly implementedThe signature verification uses the
verify
method of theSignature
object with the quorum public key and message digest. The code appropriately checks if the verification is successful and returnsOk(true)
.packages/rs-dpp/src/signing.rs (2)
1-1
: Imports updated to reflect new BLS libraryThe import of
Bls12381G2Impl
andPairing
fromcrate::bls_signatures
correctly aligns with the new BLS implementation.
12-13
: Ensure consistent use ofbls_signatures
aliasThe import statement on line 13 aliases
blsful
asbls_signatures
. Verify that all references tobls_signatures
within the codebase correctly point to thedashcore::blsful
module to avoid any confusion with other BLS libraries.Run the following script to check for inconsistent imports:
✅ Verification successful
Consistent use of
bls_signatures
alias verifiedAll import statements correctly alias
dashcore::blsful
asbls_signatures
. No inconsistencies found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all import statements of 'bls_signatures' to ensure consistent aliasing. rg --type rust --fixed-strings 'use' --word-regexp 'bls_signatures'Length of output: 120
Script:
#!/bin/bash # Description: Correctly find all import statements of 'bls_signatures' to ensure consistent aliasing. rg --type rust 'use\s+bls_signatures'Length of output: 39
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs (5)
2-4
: Approved: Updated BLS signature importsThe updated imports correctly reference the new BLS implementation, ensuring that the necessary types and traits are available for cryptographic operations.
152-152
: Approved: Enhanced type specificity forpublic_key
The
public_key
field now includes the specific type parameter<Bls12381G2Impl>
, which enhances type safety and clarity in theVerificationQuorum
struct.
210-216
: Approved: Proper deserialization of the private key with error handlingThe private key is correctly deserialized using
from_be_bytes
, and the error handling provides a clear message if deserialization fails. This ensures robustness against invalid private key data.
218-223
: Approved: Signing the message digest using BLS signature schemeThe signing process correctly utilizes the
SignatureSchemes::Basic
scheme, and errors during signing are appropriately handled withmap_err
. This ensures the signature generation is both correct and resilient to potential errors.
225-225
: Approved: Conversion of signature to compressed formatThe signature is effectively converted to its compressed form before being encapsulated in a
BLSSignature
and returned. This is necessary for efficient storage and transmission of the signature.packages/rs-dpp/src/core_types/validator/v0/mod.rs (9)
4-4
: Updated import statement to includeBls12381G2Impl
The import of
Bls12381G2Impl
and aliasingPublicKey
asBlsPublicKey
is appropriate for the changes in public key handling.
57-57
: Ensureto_compressed()
usage aligns with deserializationIn the
encode
method, usingpublic_key.0.to_compressed()
serializes the public key in compressed form. Verify that this matches the expected format and that the deserialization logic correctly handles this compressed data.
97-102
: Confirm deserialization withtry_from
matches serializationThe
decode
method now usesBlsPublicKey::try_from(public_key_bytes.as_slice())
. Ensure that this deserialization correctly decodes the compressed public key data serialized byto_compressed()
.
156-156
: Getter methodpublic_key
signature updated appropriatelyThe getter method now returns a reference to
Option<BlsPublicKey<Bls12381G2Impl>>
, matching the updated field type. All usages of this method should be reviewed to ensure compatibility.
176-176
: Setter methodset_public_key
signature updated appropriatelyThe setter method now accepts
Option<BlsPublicKey<Bls12381G2Impl>>
, reflecting the updated field type. Confirm that all calls to this method are updated to pass the correct type.
196-196
: Getter method implementation is consistent with updated typeThe implementation of the
public_key()
getter correctly returns the updated public key type.
230-230
: Setter method implementation is consistent with updated typeThe implementation of
set_public_key()
appropriately assigns the updated public key type to the field.
263-265
: Updated imports in test module are appropriateThe imports of
SecretKey
,StdRng
, andSeedableRng
are necessary for generating test keys using the new BLS implementation.
271-272
: Generating testpublic_key
with new BLS implementationUsing
SecretKey::<Bls12381G2Impl>::random(&mut rng).public_key()
to generate a public key in tests ensures compatibility with the new BLS library. Ensure that this reflects actual usage in the application.packages/rs-drive-abci/src/mimic/test_quorum.rs (2)
106-106
: Consistent use of specific BLS key types enhances code reliabilityUpdating
TestQuorumInfo
to specifyBlsPrivateKey<Bls12381G2Impl>
andBlsPublicKey<Bls12381G2Impl>
ensures type consistency across the codebase, which is beneficial for maintainability and correctness.Also applies to: 108-108
139-139
: Ensure compatibility with the new BLS libraryIn line 139, the private keys are generated using
bls_signatures::PrivateKey::generate_dash_many
. Verify that the newblsful
library provides equivalent functionality and that this method aligns with the updated cryptographic standards.To confirm compatibility, you can check the documentation or run tests specific to key generation.
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs (4)
1-1
: Updated imports align with new BLS implementationThe imports have been updated to include
Bls12381G2Impl
andSignature
, which is necessary for integrating the new BLS library.
41-43
: Signature parsing updated appropriatelyThe parsing of the chain lock signature now uses
Signature::<Bls12381G2Impl>::try_from(...)
, which aligns with the new BLS implementation. Error handling is appropriate.
125-130
: Updated signature verification with new BLS implementationThe signature verification now correctly uses the
verify
method on theSignature
instance, improving type safety and clarity.
171-176
: Second attempt signature verification updatedThe re-verification of the signature with the second quorum correctly utilizes the updated
verify
method, ensuring consistency with the new BLS implementation.packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (3)
90-90
: Verify the use offrom_byte_array
forSecretKey
The method
SecretKey::from_byte_array
is used to create aSecretKey
fromprivate_key_bytes
. Ensure that this method correctly handles invalid keys and that any potential errors are appropriately managed.Check the documentation and implementation of
SecretKey::from_byte_array
to confirm its behavior with invalid input.
5-5
: 🛠️ Refactor suggestionConsider importing
blsful
directly instead of viadashcore
The imports on lines 5 and 7 bring in
bls_signatures
andBls12381G2Impl
through thedashcore
crate. Since the goal is to replace the existing BLS library with the Rust-basedblsful
library, importingblsful
directly from its crate would make the dependency more explicit and reduce potential indirection.Apply this change to import
blsful
directly:-use dashcore::blsful::Bls12381G2Impl; +use blsful::Bls12381G2Impl;And ensure that
Cargo.toml
includes theblsful
dependency:[dependencies] blsful = "3.0.0-pre6"Also applies to: 7-7
⛔ Skipped due to learnings
Learnt from: QuantumExplorer PR: dashpay/platform#2235 File: packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs:8-9 Timestamp: 2024-10-10T05:10:50.059Z Learning: In the codebase, importing `Secp256k1` from `dashcore::key::Secp256k1` is acceptable.
54-54
: Verify all call sites ofvalidate_private_key_bytes
The parameter
private_key_bytes
has been changed from a slice&[u8]
to a fixed-size array&[u8; 32]
. This enhances type safety but may affect existing call sites. Ensure that all calls tovalidate_private_key_bytes
pass a reference to a 32-byte array to prevent compilation errors.Run the following script to identify affected call sites:
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs (2)
133-138
: Test code updates correctly align with the new BLS implementationThe test code now uses
SecretKey::random(&mut rng).public_key()
to generate public keys, which is appropriate for the newBlsPublicKey<Bls12381G2Impl>
type. The use of a seeded random number generator ensures deterministic test results.
15-17
: Ensure all usages ofchoose_quorum_v0
are updated to reflect the new public key typeThe function
choose_quorum_v0
now usesBlsPublicKey<Bls12381G2Impl>
in its parameters and return type. Please verify that all callers of this function have been updated accordingly to prevent any type mismatch or compilation errors.Run the following script to find all usages of
choose_quorum_v0
and check for compatibility:✅ Verification successful
[/run_scripts]
[/run_scripts]
All usages of
choose_quorum_v0
have been updated to use the newBlsPublicKey<Bls12381G2Impl>
type.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all usages of `choose_quorum_v0` and ensure they use the updated public key type. # Test: Search for all calls to `choose_quorum_v0` in the codebase. rg --type rust 'choose_quorum_v0' -A 3 -B 1Length of output: 8855
Script:
#!/bin/bash # Description: Verify that all usages of `choose_quorum_v0` pass `quorums` with the updated public key type. # Search for all calls to `choose_quorum_v0` and check the type of `quorums`. ast-grep --lang rust --pattern ' call_expr!( function: "choose_quorum_v0", args: [ _, _quorums: &"_" ] ) ' | grep 'BlsPublicKey<Bls12381G2Impl>'Length of output: 202
Script:
#!/bin/bash # Description: Verify that all declarations of `quorums` use the updated public key type `BlsPublicKey<Bls12381G2Impl>`. # Step 1: Find all declarations of `quorums` and check their types. ast-grep --lang rust --pattern ' let_decl!( pattern: "quorums", type: "BTreeMap<QuorumHash, BlsPublicKey<Bls12381G2Impl>>" ) ' # Step 2: Find all calls to `choose_quorum_v0` to ensure they use the correctly typed `quorums`. rg --type rust 'choose_quorum_v0' -A 3 -B 1 | grep 'BlsPublicKey<Bls12381G2Impl>'Length of output: 400
packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs (8)
58-59
: LGTM: Consistent encoding of threshold public keysThe code correctly compresses and encodes the threshold public keys for comparison in the error message.
136-138
: The previous refactoring suggestion applies here as well.
155-157
: The previous refactoring suggestion applies here as well.
195-195
: The previous refactoring suggestion applies here as well.
204-204
: The previous refactoring suggestion applies here as well.
242-242
: The previous refactoring suggestion applies here as well.
251-251
: The previous refactoring suggestion applies here as well.
299-299
: LGTM: Proper handling of threshold public key conversionThe conversion of
quorum_public_key
into aBlsPublicKey
with appropriate error mapping is correctly implemented.packages/rs-dpp/src/core_types/validator_set/v0/mod.rs (10)
11-11
: Import ofBls12381G2Impl
aligns with library updateThe import of
Bls12381G2Impl
fromdashcore::blsful
correctly reflects the change to the new BLS library.
38-38
: Updatethreshold_public_key
type to useBls12381G2Impl
Changing
threshold_public_key
toBlsPublicKey<Bls12381G2Impl>
ensures compatibility with the new BLS library and is appropriate.
219-219
: Updated getter signature forthreshold_public_key
The getter method now correctly returns
&BlsPublicKey<Bls12381G2Impl>
.
233-233
: Updated setter signature forthreshold_public_key
The setter method now correctly accepts
BlsPublicKey<Bls12381G2Impl>
.
261-263
: Getter implementation forthreshold_public_key
is correctThe implementation correctly returns a reference to
threshold_public_key
.
283-285
: Setter implementation forthreshold_public_key
is correctThe implementation correctly sets
threshold_public_key
.
292-295
: Imports in test module are appropriateAdding imports for
SecretKey
,PubkeyHash
,StdRng
, andSeedableRng
is necessary for the tests.
307-308
: Initialize RNG with fixed seed for deterministic testsUsing a fixed seed ensures that the tests are reproducible.
308-308
: Generate public key using the new BLS libraryGenerating the public key with
SecretKey::<Bls12381G2Impl>::random(&mut rng).public_key()
aligns with the new library.
327-327
: Generatethreshold_public_key
using the new BLS libraryCreating
threshold_public_key
asSecretKey::<Bls12381G2Impl>::random(&mut rng).public_key()
is correct.packages/rs-dpp/src/identity/identity_public_key/key_type.rs (2)
279-281
: Consistent use ofblsful
for BLS key generationIn lines 279-281, the code correctly uses
blsful::SecretKey
for BLS key generation and handling. This aligns with the PR objective.
203-203
: Ensureprivate_key_bytes
is correctly passed as[u8; 32]
At line 203, the parameter
private_key_bytes
has changed to a reference to a[u8; 32]
. Please verify that all calls topublic_key_data_from_private_key_data
passprivate_key_bytes
as a fixed-size array to match the updated signature.Run the following script to find all usages of
public_key_data_from_private_key_data
and check the argument types:✅ Verification successful
Verification of
private_key_bytes
ParameterAll calls to
public_key_data_from_private_key_data
correctly passprivate_key_bytes
as[u8; 32]
.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all calls to `public_key_data_from_private_key_data` and display their contexts. rg --type rust -A 2 -B 2 'public_key_data_from_private_key_data\('Length of output: 554
packages/rs-drive-abci/src/mimic/mod.rs (3)
16-16
: Import ofSignatureSchemes
Added CorrectlyThe import statement
use dpp::bls_signatures::SignatureSchemes;
is necessary for specifying the signature scheme in signing operations and has been added appropriately.
518-521
: Explicitly Specifying Signature Scheme Enhances ClarityBy specifying
SignatureSchemes::Basic
in thesign
method, the code now makes explicit which signature scheme is being used. This improves code readability and reduces potential ambiguity, especially important when multiple signature schemes are available.
523-523
: Ensure Consistency in Signature Serialization FormatThe block signature is now being converted using
as_raw_value().to_compressed().to_vec()
. Please verify that this serialization method is compatible with any components that consumecommit_info.block_signature
. Inconsistencies in the expected format may lead to deserialization errors or signature verification failures.Run the following script to search for usages of
commit_info.block_signature
deserialization:packages/rs-drive-abci/tests/strategy_tests/query.rs (2)
8-8
: ImportingBls12381G2Impl
for Specific BLS ImplementationThe updated import statement correctly includes
Bls12381G2Impl
, which is necessary for the new BLS signature implementation. This aligns with the PR objective of replacing the BLS library with the Rust-basedblsful
crate.
129-133
: Improved Error Handling in Signature VerificationThe signature verification logic now correctly handles both success and error cases, providing detailed error messages when verification fails. This enhances the robustness and diagnosability of the code.
packages/rs-drive-abci/tests/strategy_tests/masternodes.rs (1)
5-5
: Import statement correctly updated to new BLS implementationThe import of
Bls12381G2Impl
andSecretKey as BlsPrivateKey
appropriately reflects the switch to the new Rust-based BLS library, aligning with the PR objectives.packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs (4)
1-1
: Importold_structures
module for backward compatibilityThe addition of
mod old_structures;
introduces theold_structures
module, which is used to handle legacy data structures likeValidatorSet
. This is appropriate for maintaining backward compatibility with previous versions.
148-148
: Updatevalidator_sets
to useold_structures::ValidatorSet
The
validator_sets
field inPlatformStateForSavingV0
now referencesold_structures::ValidatorSet
. This change aligns with the introduction of legacy structures to manage state versions appropriately.
272-272
: Ensure correct conversion fromold_structures::ValidatorSet
toValidatorSet
In the
From<PlatformStateForSavingV0>
implementation forPlatformStateV0
, you're convertingold_structures::ValidatorSet
toValidatorSet
usingv.into()
. Verify that theInto
trait is properly implemented for this conversion and that all necessary fields are correctly mapped to prevent data inconsistency.
131-131
: Verify the reduced visibility ofPlatformStateForSavingV0
The visibility of
PlatformStateForSavingV0
has been changed frompub
topub(super)
, restricting its access to the current module and its submodules. Ensure that this struct is not used outside of its module and that this change doesn't break any external dependencies.✅ Verification successful
Reduced visibility of
PlatformStateForSavingV0
verified.
No usages found outside theplatform_state
module, ensuring that the visibility change does not impact external dependencies.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `PlatformStateForSavingV0` is not used outside its own module. # Search for usages of `PlatformStateForSavingV0` outside the `v0` module. rg --type rust 'PlatformStateForSavingV0' --glob '!*platform_state/v0/*' -A 5Length of output: 3503
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs (1)
403-403
: Import statement updated to includeBls12381G2Impl
The import statement correctly includes
Bls12381G2Impl
and aliasesSecretKey
asBlsPrivateKey
, aligning with the new BLS library implementation.packages/rs-drive-abci/tests/strategy_tests/execution.rs (6)
23-23
: Imports are correctly updated for the new BLS implementationThe added import of
Bls12381G2Impl
, aliasingSecretKey
asBlsPrivateKey
, and includingSignatureSchemes
are appropriate and necessary for integrating the new BLS library.
355-355
: Ensure consistent use of big-endian byte order in serializationThe change from
to_bytes()
toto_be_bytes()
alters the serialization to big-endian format. Verify that all serialization and deserialization of private keys consistently use big-endian methods (to_be_bytes()
andfrom_be_bytes()
), to maintain compatibility and prevent deserialization errors.Also applies to: 382-382, 656-656
731-738
: Proper error handling for key operations in test codeUsing
.expect()
in test code is acceptable for simplicity. The conversion of the quorum private key and the signing operation are correctly implemented.
742-742
: LGTM!The signature is correctly converted to a compressed format before inclusion.
855-857
: Updated public key formatting in validator updatesThe public key for validator updates is correctly converted to compressed format, aligning with the expected data structures.
867-871
: Correctly compressing the current quorum's public keyThe quorum's public key is properly compressed and converted to a vector, ensuring consistency in serialization.
packages/simple-signer/src/signer.rs (4)
5-5
: Appropriate imports for updated BLS implementationThe addition of
Bls12381G2Impl
andSignatureSchemes
imports is necessary for the updated BLS signing process.
20-22
: Switch to fixed-size arrays enhances type safetyUpdating
private_keys
andprivate_keys_in_creation
to use[u8; 32]
instead ofVec<u8>
ensures that private keys are always 32 bytes long. This change enhances type safety and prevents potential errors due to incorrect key lengths.
50-50
: Updateadd_key
method to accept fixed-size arraysChanging the
add_key
method to accept[u8; 32]
aligns with the updated private key type, ensuring consistency throughout the code.
55-55
: Updateadd_keys
method to accept fixed-size arraysSimilarly, updating
add_keys
to accept[u8; 32]
maintains consistency and prevents issues with key lengths.
@@ -14,7 +14,7 @@ impl IdentityPublicKeyHashMethodsV0 for IdentityPublicKey { | |||
|
|||
fn validate_private_key_bytes( | |||
&self, | |||
private_key_bytes: &[u8], | |||
private_key_bytes: &[u8; 32], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
🛠️ Refactor suggestion
Inconsistent usage of private_key_bytes
detected
Multiple functions still use &[u8]
for private_key
, which can lead to type inconsistencies and potential errors after this change. Please update all relevant functions to use &[u8; 32]
to maintain type safety across the codebase.
🔗 Analysis chain
Improved type safety, but verify compatibility
The change from &[u8]
to &[u8; 32]
for the private_key_bytes
parameter improves type safety by enforcing a fixed-size array of 32 bytes. This is likely aligned with the expected size of private keys in the BLS scheme being used.
However, consider the following points:
- This change might break existing code that passes slices of different lengths. Ensure all callers of this method are updated accordingly.
- Verify that this change is consistent with the new Rust-based BLS library (blsful) mentioned in the PR objectives.
- Consider adding a comment explaining why 32 bytes are required, for better code documentation.
To ensure consistency across the codebase, run the following script:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for other occurrences of private key byte handling
# and ensure they also use [u8; 32] for consistency.
# Search for private key related functions
rg --type rust "fn.*private_key.*(&\[u8\]|&\[u8; \d+\])" -g '!target/'
# Search for BLS-related imports to verify consistency with the new library
rg --type rust "use.*bls" -g '!target/'
Length of output: 10949
#[cfg(feature = "bls-signatures")] | ||
pub use dashcore::blsful as bls_signatures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Issues Found: Remaining References to bls_signatures
Several files still import or use bls_signatures
, indicating that the replacement to blsful as bls_signatures
is incomplete. Please update the following files to use the new BLS library:
packages/simple-signer/src/signer.rs
packages/rs-drive-proof-verifier/src/verify.rs
packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs
packages/rs-drive-abci/tests/strategy_tests/query.rs
packages/rs-drive-abci/tests/strategy_tests/main.rs
packages/rs-drive-abci/tests/strategy_tests/masternodes.rs
packages/rs-drive-abci/tests/strategy_tests/execution.rs
packages/rs-dpp/src/signing.rs
packages/rs-dpp/src/core_types/validator/mod.rs
packages/rs-dpp/src/core_types/validator_set/mod.rs
packages/rs-dpp/src/core_types/validator_set/v0/mod.rs
packages/rs-dpp/src/core_types/validator/v0/mod.rs
packages/rs-dpp/src/identity/identity_public_key/key_type.rs
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs
packages/rs-dpp/src/bls/native_bls.rs
packages/rs-drive-abci/src/error/mod.rs
packages/rs-drive-abci/src/error/execution.rs
packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs
packages/rs-drive-abci/src/platform_types/validator/v0/mod.rs
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs
packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs
packages/rs-drive-abci/src/platform_types/commit/mod.rs
packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs
packages/rs-drive-abci/src/mimic/test_quorum.rs
packages/rs-drive-abci/src/mimic/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_instant_send_lock/verify_recent_signature_locally/v0/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_quorum_info/v0/mod.rs
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs
packages/rs-drive-abci/src/abci/error.rs
packages/simple-signer/src/signer.rs
packages/rs-drive-proof-verifier/src/verify.rs
packages/rs-drive-proof-verifier/src/unproved.rs
packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs
packages/rs-dpp/src/identity/identity_public_key/key_type.rs
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs
packages/rs-dpp/src/bls/native_bls.rs
packages/rs-dpp/src/core_types/validator/mod.rs
packages/rs-dpp/src/core_types/validator_set/mod.rs
packages/rs-dpp/src/core_types/validator_set/v0/mod.rs
packages/rs-dpp/src/core_types/validator/v0/mod.rs
Please ensure all references to bls_signatures
are updated to blsful as bls_signatures
to maintain consistency across the codebase.
🔗 Analysis chain
LGTM! Verify usage of the new BLS library.
The change from bls_signatures
to blsful
aligns with the PR objective to replace the BLS library. The as bls_signatures
clause maintains the existing module name, which should minimize changes required in other parts of the codebase.
To ensure the change has been applied consistently, run the following script:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of the new BLS library and check for any remaining references to the old library.
# Test 1: Check for any remaining imports of the old bls_signatures library
echo "Checking for any remaining imports of the old bls_signatures library:"
rg --type rust 'use .*bls_signatures' -g '!lib.rs'
# Test 2: Verify the usage of the new blsful library
echo "Verifying the usage of the new blsful library:"
rg --type rust 'use .*blsful'
# Test 3: Check for any uses of bls_signatures that might need updating
echo "Checking for any uses of bls_signatures that might need updating:"
rg --type rust 'bls_signatures::'
Length of output: 13437
Script:
#!/bin/bash
# Description: Comprehensive check for any remaining references to bls_signatures in the codebase.
# Test 1: Search for any import statements of bls_signatures outside lib.rs
echo "Checking for import statements of bls_signatures outside lib.rs:"
rg --type rust 'use .*bls_signatures' -g '!lib.rs'
# Test 2: Search for any usage of bls_signatures within the codebase
echo "Searching for any usage of bls_signatures in the codebase:"
rg --type rust 'bls_signatures::'
# Test 3: Verify that all instances of bls_signatures have been replaced with blsful as bls_signatures
echo "Ensuring all bls_signatures imports use 'blsful as bls_signatures':"
rg --type rust 'use .*blsful\s+as\s+bls_signatures'
# Test 4: Check for any configuration issues related to the bls-signatures feature flag
echo "Verifying conditional compilation for bls-signatures feature flag:"
rg --type rust '#\[cfg\(feature = "bls-signatures"\)\]'
Length of output: 15268
@@ -1,4 +1,4 @@ | |||
use crate::bls_signatures::PublicKey as BlsPublicKey; | |||
use crate::bls_signatures::{Bls12381G2Impl, PublicKey as BlsPublicKey}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistencies Found: BlsPublicKey
Usage Without Bls12381G2Impl
Parameter
The verification script identified multiple instances where BlsPublicKey
is used without the Bls12381G2Impl
parameter. These inconsistencies need to be addressed to ensure uniform usage across the codebase.
Affected Files:
packages/rs-drive-abci/src/platform_types/validator/v0/mod.rs
packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs
packages/rs-dpp/src/core_types/validator_set/mod.rs
packages/rs-dpp/src/core_types/validator/mod.rs
packages/rs-drive-proof-verifier/src/unproved.rs
- (and others as listed in the script output)
Please update these instances to include the Bls12381G2Impl
parameter with BlsPublicKey
to maintain consistency and adherence to the PR objectives.
🔗 Analysis chain
LGTM! Verify usage of Bls12381G2Impl
across the codebase.
The import statement has been correctly updated to include Bls12381G2Impl
for the BlsPublicKey
type. This change aligns with the PR objective of replacing the bls library.
To ensure consistency across the codebase, please run the following script:
This script will help identify any inconsistencies in the usage of BlsPublicKey<Bls12381G2Impl>
across the Rust files in the project.
Action Required: Update Shell Script to Enable PCRE2 in rg
Command
The initial script encountered a regex parse error because negative look-around is not supported by default. To resolve this, please update the script to enable PCRE2 by adding the --pcre2
flag to the rg
commands.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of Bls12381G2Impl with BlsPublicKey
# Test: Search for BlsPublicKey usage
echo "Checking BlsPublicKey usage:"
rg --type rust "BlsPublicKey(?!<Bls12381G2Impl>)" -g '!target/'
# Test: Search for Bls12381G2Impl usage
echo "Checking Bls12381G2Impl usage:"
rg --type rust "Bls12381G2Impl" -g '!target/'
Length of output: 13544
Script:
#!/bin/bash
# Description: Verify the usage of Bls12381G2Impl with BlsPublicKey
# Test: Search for BlsPublicKey usage
echo "Checking BlsPublicKey usage:"
rg --pcre2 --type rust "BlsPublicKey(?!<Bls12381G2Impl>)" -g '!target/'
# Test: Search for Bls12381G2Impl usage
echo "Checking Bls12381G2Impl usage:"
rg --type rust "Bls12381G2Impl" -g '!target/'
Length of output: 17545
+ IntoIterator<Item = (IdentityPublicKey, [u8; 32])> | ||
+ Extend<(IdentityPublicKey, [u8; 32])>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Callers of random_identity_with_main_keys_with_private_key
are still using <Vec<_>>
instead of [u8; 32]
.
Please update all callers to use the new [u8; 32]
type for private keys to ensure consistency and prevent potential issues.
Affected files:
packages/strategy-tests/src/lib.rs
packages/rs-drive-abci/tests/strategy_tests/main.rs
packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs
🔗 Analysis chain
LGTM! Verify impact on codebase.
The change from Vec<u8>
to [u8; 32]
for private keys is a good improvement. It aligns with the PR objectives of replacing the BLS library and can lead to better performance and memory efficiency.
Please ensure that all callers of this function have been updated to use the new [u8; 32]
type for private keys. Run the following script to verify the usage:
Please run the corrected verification script below to ensure all callers use [u8; 32]
for private keys.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify all callers of random_identity_with_main_keys_with_private_key use [u8; 32] for private keys
# Test: Search for function calls and check the type used for private keys
rg --type rust -e "random_identity_with_main_keys_with_private_key" -A 10 -B 5
Length of output: 7396
Script:
#!/bin/bash
# Description: Verify all callers of random_identity_with_main_keys_with_private_key use [u8; 32] for private keys
# Corrected command: Ensure proper usage of rg with correct syntax
rg --type rust -e "random_identity_with_main_keys_with_private_key" -A 10 -B 5
Length of output: 25117
let public_key = | ||
PublicKey::<Bls12381G2Impl>::try_from(public_key).map_err(anyhow::Error::msg)?; | ||
let signature_96_bytes = signature | ||
.try_into() | ||
.map_err(|_| anyhow!("signature wrong size"))?; | ||
let g2_element = | ||
<Bls12381G2Impl as Pairing>::Signature::from_compressed(&signature_96_bytes) | ||
.into_option() | ||
.ok_or(anyhow!("signature derivation failed"))?; | ||
|
||
let signature = Signature::Basic(g2_element); | ||
|
||
match signature.verify(&public_key, data) { | ||
Ok(_) => Ok(true), | ||
Err(_) => Err(anyhow!("Verification failed").into()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust error handling for signature verification failure
In the verify_signature
method, when signature verification fails, it currently returns an error:
Err(anyhow!("Verification failed").into())
Since failing to verify a signature is a valid outcome and not necessarily an exceptional error, it would be more appropriate to return Ok(false)
to indicate a failed verification without propagating an error.
Apply this diff to adjust the error handling:
match signature.verify(&public_key, data) {
Ok(_) => Ok(true),
- Err(_) => Err(anyhow!("Verification failed").into()),
+ Err(_) => Ok(false),
}
let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) | ||
.expect("expected to generate a private key") | ||
.to_bytes() | ||
.to_vec(); | ||
let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes( | ||
&private_key_operator_bytes.try_into().unwrap(), | ||
) | ||
.unwrap(); | ||
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Simplify private key generation by avoiding unnecessary conversions
Similarly, this code can be simplified by eliminating the unnecessary conversion to and from bytes when generating the private key.
Apply this diff to simplify the code:
- let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng)
- .expect("expected to generate a private key")
- .to_bytes()
- .to_vec();
- let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes(
- &private_key_operator_bytes.try_into().unwrap(),
- )
- .unwrap();
+ let private_key_operator = bls_signatures::PrivateKey::generate_dash(&mut rng)
+ .expect("expected to generate a private key");
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec();
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) | |
.expect("expected to generate a private key") | |
.to_bytes() | |
.to_vec(); | |
let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes( | |
&private_key_operator_bytes.try_into().unwrap(), | |
) | |
.unwrap(); | |
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec(); | |
let private_key_operator = bls_signatures::PrivateKey::generate_dash(&mut rng) | |
.expect("expected to generate a private key"); | |
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec(); |
let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) | ||
.expect("expected to generate a private key") | ||
.to_bytes() | ||
.to_vec(); | ||
let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes( | ||
&private_key_operator_bytes.try_into().unwrap(), | ||
) | ||
.unwrap(); | ||
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Simplify private key generation by avoiding unnecessary conversions
As with the earlier instance, the private key is generated and then reconstructed from bytes. Directly utilizing the generated private key without conversion simplifies the code and reduces overhead.
Apply this diff to simplify the code:
- let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng)
- .expect("expected to generate a private key")
- .to_bytes()
- .to_vec();
- let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes(
- &private_key_operator_bytes.try_into().unwrap(),
- )
- .unwrap();
+ let private_key_operator = bls_signatures::PrivateKey::generate_dash(&mut rng)
+ .expect("expected to generate a private key");
let new_pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec();
Committable suggestion was skipped due to low confidence.
let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng) | ||
.expect("expected to generate a private key") | ||
.to_bytes() | ||
.to_vec(); | ||
let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes( | ||
&private_key_operator_bytes.try_into().unwrap(), | ||
) | ||
.unwrap(); | ||
let pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Simplify private key generation by avoiding unnecessary conversions
The current implementation generates a private key, converts it to bytes, and then reconstructs it from bytes. This process can be streamlined by directly using the private key without the conversion, enhancing code clarity and efficiency.
Apply this diff to simplify the code:
- let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng)
- .expect("expected to generate a private key")
- .to_bytes()
- .to_vec();
- let private_key_operator = BlsPrivateKey::<Bls12381G2Impl>::from_be_bytes(
- &private_key_operator_bytes.try_into().unwrap(),
- )
- .unwrap();
+ let private_key_operator = bls_signatures::PrivateKey::generate_dash(rng)
+ .expect("expected to generate a private key");
let pub_key_operator = private_key_operator.public_key().0.to_compressed().to_vec();
Committable suggestion was skipped due to low confidence.
.sign(SignatureSchemes::Basic, data) | ||
.map_err(|e| ProtocolError::Generic(format!("unable to sign {}", e)))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide more informative error when BLS signing fails
The current error message "unable to sign"
is generic. Providing more context can aid in debugging signing issues.
Consider updating the error handling as follows:
.sign(SignatureSchemes::Basic, data)
- .map_err(|e| ProtocolError::Generic(format!("unable to sign {}", e)))?;
+ .map_err(|e| ProtocolError::Generic(format!("BLS signing failed: {}", e)))?;
This change offers more specific information about the signing failure.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
.sign(SignatureSchemes::Basic, data) | |
.map_err(|e| ProtocolError::Generic(format!("unable to sign {}", e)))?; | |
.sign(SignatureSchemes::Basic, data) | |
.map_err(|e| ProtocolError::Generic(format!("BLS signing failed: {}", e)))?; |
let pk = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key) | ||
.into_option() | ||
.ok_or(ProtocolError::Generic( | ||
"bls private key from bytes isn't correct".to_string(), | ||
))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error handling when creating BLS SecretKey
The error message "bls private key from bytes isn't correct"
could be more descriptive. Additionally, consider using ok_or_else
for lazy evaluation of the error message.
Consider updating the code as follows:
let pk = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key)
.into_option()
- .ok_or(ProtocolError::Generic(
- "bls private key from bytes isn't correct".to_string(),
- ))?;
+ .ok_or_else(|| ProtocolError::Generic(
+ "Failed to create BLS SecretKey from private key bytes".to_string(),
+ ))?;
This change provides a more informative error message and avoids unnecessary allocation when the result is Some
.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
let pk = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key) | |
.into_option() | |
.ok_or(ProtocolError::Generic( | |
"bls private key from bytes isn't correct".to_string(), | |
))?; | |
let pk = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key) | |
.into_option() | |
.ok_or_else(|| ProtocolError::Generic( | |
"Failed to create BLS SecretKey from private key bytes".to_string(), | |
))?; |
Issue being fixed or feature implemented
bls-signatures built from c++ had a lot of compilation issues for Windows. In this PR we replace it with https://crates.io/crates/blsful/3.0.0-pre6
What was done?
Of note: the serialization for Platform version does change and needs to be checked, it should work though
How Has This Been Tested?
Tests still pass
Breaking Changes
Should not require a platform version change.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Bls12381G2Impl
implementation.Bug Fixes
Documentation
Chores
dashcore-rpc
across multiple packages to ensure compatibility and access to the latest features.