Skip to content
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

Open
wants to merge 11 commits into
base: v1.6-dev
Choose a base branch
from

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Oct 19, 2024

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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Introduced support for BLS signatures using the Bls12381G2Impl implementation.
    • Enhanced public key and private key handling across various modules, ensuring type safety with fixed-size arrays.
    • Added new error handling mechanisms for signature verification and key conversion processes.
    • Enhanced functionality for operator identity updates, quorum management, and validator set handling.
    • Made the dapi_grpc module publicly accessible in the SDK.
  • Bug Fixes

    • Improved error handling in signature verification processes, providing clearer error messages and handling invalid states.
  • Documentation

    • Updated documentation to reflect changes in public key types and signature handling methods.
  • Chores

    • Updated dependency versions for dashcore-rpc across multiple packages to ensure compatibility and access to the latest features.

@QuantumExplorer QuantumExplorer added this to the 1.4.2 milestone Oct 19, 2024
Copy link
Contributor

coderabbitai bot commented Oct 19, 2024

Walkthrough

The pull request includes updates to several files primarily focusing on the integration of the Bls12381G2Impl type for public and private key operations. Key changes involve updating the Cargo.toml dependencies, modifying method signatures to accommodate the new BLS implementation, and refining error handling and serialization processes. The changes enhance type safety and clarity in cryptographic operations across various modules, including validators, signature verification, and identity management.

Changes

File Path Change Summary
packages/rs-dpp/Cargo.toml Updated package version to 1.5.0, changed dashcore dependency version to 0.33.1 with new features, and updated [dev-dependencies] for once_cell.
packages/rs-dpp/src/bls/native_bls.rs Modified NativeBlsModule to use Bls12381G2Impl for key operations, updated methods for public key validation, signature verification, and signing processes.
packages/rs-dpp/src/core_types/validator/mod.rs Updated Validator enum to use BlsPublicKey<Bls12381G2Impl> in public key methods.
packages/rs-dpp/src/core_types/validator/v0/mod.rs Changed ValidatorV0 struct to use BlsPublicKey<Bls12381G2Impl>, updated encoding/decoding methods.
packages/rs-dpp/src/core_types/validator_set/mod.rs Updated ValidatorSet to use BlsPublicKey<Bls12381G2Impl> in public key methods.
packages/rs-dpp/src/core_types/validator_set/v0/mod.rs Modified ValidatorSetV0 to use BlsPublicKey<Bls12381G2Impl>, updated encoding/decoding methods.
packages/rs-dpp/src/errors/protocol_error.rs Added BlsError variant to ProtocolError enum.
packages/rs-dpp/src/identity/identity_public_key/key_type.rs Updated KeyType enum methods to handle BLS keys and changed return types to fixed-size arrays.
packages/rs-dpp/src/identity/identity_public_key/methods/hash/mod.rs Changed validate_private_key_bytes method to require a fixed-size array.
packages/rs-dpp/src/identity/identity_public_key/methods/hash/v0/mod.rs Updated validate_private_key_bytes method to accept a fixed-size array.
packages/rs-dpp/src/identity/identity_public_key/random.rs Changed return types for multiple methods to fixed-size arrays and added a new method for generating authentication keys.
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs Updated validate_private_key_bytes method to require a fixed-size array.
packages/rs-dpp/src/identity/identity_public_key/v0/random.rs Changed return types for multiple methods to fixed-size arrays.
packages/rs-dpp/src/identity/random.rs Updated method signatures to require fixed-size arrays for private keys.
packages/rs-dpp/src/identity/v0/random.rs Changed method signatures to require fixed-size arrays for private keys.
packages/rs-dpp/src/lib.rs Updated conditional compilation for bls_signatures and modified pub use statements.
packages/rs-dpp/src/signing.rs Updated signature verification logic to use Bls12381G2Impl and improved error handling.
packages/rs-drive-abci/Cargo.toml Updated dashcore-rpc dependency version to 0.15.9 and added bls-signatures dependency.
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs Enhanced operator identity update logic to manage public keys and payout addresses.
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_quorum_info/v0/mod.rs Improved quorum update logic with new methods for handling quorum lists.
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs Updated choose_quorum method to use BlsPublicKey<Bls12381G2Impl>.
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs Modified choose_quorum_v0 method to handle the new public key type.
packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs Replaced G2Element with Signature<Bls12381G2Impl> for chain lock signatures.
packages/rs-drive-abci/src/execution/platform_events/core_instant_send_lock/verify_recent_signature_locally/v0/mod.rs Updated signature verification to use Signature<Bls12381G2Impl>.
packages/rs-drive-abci/src/execution/validation/state_transition/common/asset_lock/transaction/fetch_asset_lock_transaction_output_sync/v0/mod.rs Changed transaction hash handling to improve clarity.
packages/rs-drive-abci/src/mimic/mod.rs Updated block signing logic to use SignatureSchemes::Basic.
packages/rs-drive-abci/src/mimic/test_quorum.rs Modified ValidatorInQuorum and TestQuorumInfo to use Bls12381G2Impl.
packages/rs-drive-abci/src/platform_types/commit/mod.rs Changed verify_signature method to use BlsPublicKey<Bls12381G2Impl>.
packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs Updated verify_signature method to use BlsPublicKey<Bls12381G2Impl>.
packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs Updated struct visibility and field types in PlatformStateForSavingV0.
packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs Introduced structures for managing validator sets.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs Added V1 variant to SignatureVerificationQuorumSetForSaving enum.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs Updated public key handling in QuorumForSavingV0.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs Introduced SignatureVerificationQuorumSetForSavingV1 structure.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs Added new module for_saving_v1.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs Updated VerificationQuorum to use ThresholdBlsPublicKey<Bls12381G2Impl>.
packages/rs-drive-abci/src/platform_types/validator/v0/mod.rs Updated NewValidatorIfMasternodeInState trait to use BlsPublicKey<Bls12381G2Impl>.
packages/rs-drive-abci/src/platform_types/validator_set/v0/mod.rs Updated ValidatorSetMethodsV0 to handle public keys more robustly.
packages/rs-drive-abci/src/query/system/current_quorums_info/v0/mod.rs Changed handling of threshold_public_key in ValidatorSetV0.
packages/rs-drive-abci/tests/strategy_tests/execution.rs Updated private key handling for consistency with BLS signatures.
packages/rs-drive-abci/tests/strategy_tests/main.rs Changed PrivateKey to SecretKey in imports.
packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs Updated private key generation to use new BLS implementation.
packages/rs-drive-abci/tests/strategy_tests/masternodes.rs Modified private key generation to align with new BLS implementation.
packages/rs-drive-abci/tests/strategy_tests/query.rs Updated ProofVerification struct to use Bls12381G2Impl.
packages/rs-drive-proof-verifier/src/unproved.rs Enhanced parsing logic for CurrentQuorumsInfo.
packages/rs-drive-proof-verifier/src/verify.rs Updated public key handling and signature verification logic.
packages/rs-sdk/Cargo.toml Updated dashcore-rpc dependency version to 0.15.9.
packages/simple-signer/Cargo.toml Updated dashcore-rpc dependency version to 0.15.9.
packages/simple-signer/src/signer.rs Changed private key fields to fixed-size arrays and updated signing logic.
packages/rs-sdk/src/lib.rs Added public export for dapi_grpc module.
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/methods/v0/mod.rs Updated try_from_identity method to use platform_value::Identifier.

Possibly related PRs

Suggested labels

rs-sdk, cleanup

Suggested reviewers

  • shumkov
  • pshenmic

🐰 In the meadow, where the code does flow,
A change so bright, it starts to glow.
With keys of BLS, we leap and bound,
In every function, new types are found.
The signatures dance, in a compressed array,
Hopping through logic, in a joyful display! 🐇✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 new Bls12381G2Impl type for both the quorums 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> to Option<BlsPublicKey<Bls12381G2Impl>> in the set_public_key method parameter is consistent with the earlier change in the public_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 to BlsPublicKey<Bls12381G2Impl> in both the public_key and set_public_key methods. These changes:

  1. Improve type safety by specifying the exact implementation of BlsPublicKey.
  2. Ensure compatibility with the new Rust-based BLS library.
  3. 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:

  1. Consider adding brief comments to the modified methods explaining the use of Bls12381G2Impl.
  2. 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 accept BlsPublicKey<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-signatures

The 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-signatures

If 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 handling

This 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) to BlsPublicKey::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 into EvoNodeStatus 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: Implement From instead of Into to follow Rust conventions

Implementing From is preferred over Into as it automatically provides the Into 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 the Display trait for better debug output

Using to_string() on public_key may not provide the most informative or readable output in debug logs. Consider implementing the Display trait for ThresholdBlsPublicKey<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 the signature variable

At line 104, the variable signature is reassigned with a different type (Signature), which shadows the parameter signature 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 types

The ValidatorInQuorum struct now uses BlsPrivateKey<Bls12381G2Impl> and BlsPublicKey<Bls12381G2Impl> for private_key and public_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 diagnostics

While 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 debugging

If 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 cases

The 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 cases

The 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 duplication

Both choose_quorum_v0 and choose_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 in filter_map

Using filter_map while attempting to propagate errors with return Some(Err(e.into())) may not properly handle errors as intended. The filter_map method skips None values and collects Some values, but encapsulating Err in Some can lead to unexpected behavior.

Consider using map instead of filter_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 ? operator

The 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 type

The method random_authentication_key_with_private_key now returns Result<(Self, [u8; 32]), ProtocolError>, but the documentation still mentions the private key as Vec<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 duplication

The 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 type

The method random_authentication_key_with_private_key_with_rng now returns Result<(Self, [u8; 32]), ProtocolError>, but the documentation still references the private key as Vec<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 type

The method random_key_with_known_attributes now returns Result<(Self, [u8; 32]), ProtocolError>, but the documentation mentions the private key as Vec<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 type

In the method random_ecdsa_master_authentication_key_with_rng, the return type has changed to Result<(Self, [u8; 32]), ProtocolError>, but the comments still reference Vec<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 type

The method random_ecdsa_master_authentication_key now returns Result<(Self, [u8; 32]), ProtocolError>, but the documentation still mentions Vec<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 type

In random_ecdsa_critical_level_authentication_key, the return type has changed to Result<(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 type

The 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 type

In 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 type

The 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 type

In 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 type

The 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 type

In 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 type

The 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 type

In 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 type

The 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

📥 Commits

Files that changed from the base of the PR and between a2034fd and 91cbe4a.

⛔ 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:

  1. The differences between for_saving and for_saving_v1?
  2. The timeline for transitioning fully to v1 and deprecating the original for_saving module?
  3. 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 validation

The change from &[u8] to &[u8; 32] for private_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] for private_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 from v0.15.8 to v0.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:

  1. Could you confirm that this update is specifically related to addressing the compilation issues mentioned in the PR description?
  2. 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 practices

The overall structure and implementation of this file demonstrate good practices:

  1. Modular design with separate v0 module, allowing for potential future versions.
  2. Proper error handling using Result<_, ProtocolError>.
  3. Network-specific validation support through the Network parameter.
  4. 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 implementation

The 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 implementation

The public_key parameter type has been correctly updated from Option<BlsPublicKey> to Option<BlsPublicKey<Bls12381G2Impl>> in both the trait definition and its implementation. This change:

  1. Aligns with the PR objective of replacing the bls library.
  2. Provides more type safety by specifying the exact BLS implementation.
  3. 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 for data_contracts.

The addition of #[cfg(feature = "system_contracts")] for the data_contracts import is a good optimization. It ensures that data_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 of PublicKey to BlsPublicKey from the dpp::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 if choose_quorum_thread_safe needs updating.

The choose_quorum_thread_safe function remains unchanged while choose_quorum has been updated to use the new Bls12381G2Impl type. Please clarify if this is intentional or if choose_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 rust

Length of output: 794

packages/rs-drive-abci/src/platform_types/commit/mod.rs (3)

8-8: LGTM: New import added correctly

The new import for Bls12381G2Impl is correctly added and is necessary for the updated verify_signature method signature.


86-86: LGTM: Method signature updated correctly

The verify_signature method signature has been correctly updated to use the more specific PublicKey<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 objectives

The 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 request

The modifications to threshold_public_key processing look good and align with the PR objectives. The new implementation correctly handles the apparent change in the threshold_public_key() method's return type and ensures the key is stored in a compressed format.

However, to ensure system-wide compatibility:

  1. Verify that this change in key representation is consistent with how threshold_public_key is used in other parts of the system.
  2. 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() and ValidatorSetV0 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 of threshold_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:

  1. Ensures consistency with the updated import statement.
  2. Enhances type safety by specifying the exact implementation of BlsPublicKey.
  3. 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 objectives

The updates to the dependencies in this Cargo.toml file align well with the PR objectives:

  1. The dashcore-rpc update may help address compilation issues.
  2. 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:

  1. The compilation issues on Windows platforms have been resolved.
  2. 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 test

If 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 update

The 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 changes

The changes in this file include:

  1. A minor version bump from 1.4.1 to 1.4.2.
  2. An update to the dashcore dependency (0.32.0 to 0.33.1) with additional features.
  3. 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/src

Length 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 both random_identity_with_main_keys_with_private_key and random_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 representation

The 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 methods

The 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 key

The 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 keys

The 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 keys

The 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 keys

The 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 keys

The 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 keys

The 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 handling

The changes in this file demonstrate a systematic approach to standardizing private key representation across all key generation methods. By consistently using [u8; 32] instead of Vec<u8>, the code now offers:

  1. Improved type safety
  2. Better memory efficiency
  3. Consistent handling of private keys across different key types and security levels
  4. 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 of EvoNodeStatus 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:

  1. Consider adding unit tests for the new EvoNodeStatus implementation to ensure its correctness.
  2. 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 tests

The 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:

  1. Ensure that all related files in the project have been updated consistently.
  2. Verify that the new SecretKey type is fully compatible with the previous PrivateKey type in terms of API and functionality.
  3. 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 type

The import statement has been changed from PrivateKey to SecretKey, which is now aliased as BlsPrivateKey. 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 new SecretKey type:


Line range hint 1-2257: No direct usage of BlsPrivateKey in test implementations

After reviewing the entire file, it appears that the BlsPrivateKey type (previously PrivateKey) 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 implementation

The necessary types and traits from bls_signatures are properly imported, ensuring that the Bls12381G2Impl implementation is used throughout the module.


11-13: Public key validation logic is properly implemented

The validate_public_key method correctly uses PublicKey::<Bls12381G2Impl>::try_from(pk) to attempt parsing the public key bytes. Error handling is appropriately managed by converting errors into PublicKeyValidationError.


29-31: Check for potential failure in from_compressed method

The from_compressed method could fail to produce a Signature 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 propagation

The sign method correctly creates a signature using the SecretKey and handles any potential errors using the ? operator, ensuring that errors are propagated appropriately.


61-64: Confirm that all serialization methods handle errors appropriately

When 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)] attribute

The public_key field in QuorumForSavingV1 is annotated with #[bincode(with_serde)]. Ensure that this attribute is required for the correct serialization and deserialization of ThresholdBlsPublicKey<Bls12381G2Impl>. If the type already implements Serialize and Deserialize 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 conversion

In the From<Vec<QuorumForSavingV1>> for Quorums<VerificationQuorum> implementation, verify that the mapping from QuorumForSavingV1 to (QuorumHash, VerificationQuorum) is accurate and preserves the intended data relationships. Pay special attention to the construction of QuorumHash from quorum.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 versions

When 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 in From<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 acceptable

Defining ValidatorSet as an enum with a single variant V0 is acceptable if future versions are anticipated. This approach facilitates forward compatibility and maintains a consistent pattern for versioning.


36-57: Conversion implementation appears correct

The From implementation for ValidatorSetV0 correctly maps all fields to the corresponding types in dpp::core_types::validator_set::v0::ValidatorSetV0.


80-103: Conversion implementation is accurate

The From implementation for ValidatorV0 appropriately handles the field mappings and considers the optional public_key.

packages/rs-drive-proof-verifier/src/verify.rs (5)

4-5: Updated imports to include specific BLS implementation

The addition of Bls12381G2Impl, Pairing, and Signature aligns with the shift to the Rust-based BLS library and is necessary for the updated cryptographic operations.


95-98: Correct usage of try_from with Bls12381G2Impl

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 of Signature::Basic with robust error handling

The signature is now constructed using Signature::Basic with the Bls12381G2Impl implementation. The use of from_compressed along with into_option() and ok_or effectively handles potential errors in signature deserialization.


140-140: Simplified and efficient signature verification

Returning 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 type

The 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 3

Length of output: 741

packages/rs-dpp/src/identity/v0/random.rs (3)

50-51: Improve type safety by using fixed-size arrays for private keys

Changing 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: Initialize private_key_map with the updated private key type

The private_key_map now correctly uses Vec<(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 mapping V0 to V1 in From implementation

In the From<SignatureVerificationQuorumSet> for SignatureVerificationQuorumSetForSaving implementation, the V0 variant is mapped to V1:

SignatureVerificationQuorumSet::V0(v0) => {
    SignatureVerificationQuorumSetForSaving::V1(v0.into())
}

Please confirm that mapping a V0 variant to a V1 variant is intentional and will not introduce compatibility issues.


142-144: Ensure safe reverse mapping from V1 to V0

In the From<SignatureVerificationQuorumSetForSaving> for SignatureVerificationQuorumSet implementation, the V1 variant is converted back to V0:

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 of VerificationQuorum import is appropriate

The inclusion of VerificationQuorum in the import list is necessary for the updated code and is correctly added.


138-138: Update public_key type to bls_signatures::PublicKey

Changing the public_key field in QuorumForSavingV0 to bls_signatures::PublicKey aligns with the transition to the new BLS library and is appropriate.


138-138: Verify serialization support for bls_signatures::PublicKey

Ensure that bls_signatures::PublicKey implements the necessary Serialize and Deserialize 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: Importing Bls12381G2Impl is appropriate

The import of Bls12381G2Impl from dpp::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 implementation

The import statement has been appropriately updated to include Bls12381G2Impl and Signature from dpp::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 to Signature

The code correctly uses Signature::<Bls12381G2Impl>::try_from to convert instant_lock.signature into a Signature object. This enhances type safety and ensures proper error handling for invalid signatures.


100-105: Signature verification logic is correctly implemented

The signature verification uses the verify method of the Signature object with the quorum public key and message digest. The code appropriately checks if the verification is successful and returns Ok(true).

packages/rs-dpp/src/signing.rs (2)

1-1: Imports updated to reflect new BLS library

The import of Bls12381G2Impl and Pairing from crate::bls_signatures correctly aligns with the new BLS implementation.


12-13: Ensure consistent use of bls_signatures alias

The import statement on line 13 aliases blsful as bls_signatures. Verify that all references to bls_signatures within the codebase correctly point to the dashcore::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 verified

All import statements correctly alias dashcore::blsful as bls_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 imports

The 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 for public_key

The public_key field now includes the specific type parameter <Bls12381G2Impl>, which enhances type safety and clarity in the VerificationQuorum struct.


210-216: Approved: Proper deserialization of the private key with error handling

The 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 scheme

The signing process correctly utilizes the SignatureSchemes::Basic scheme, and errors during signing are appropriately handled with map_err. This ensures the signature generation is both correct and resilient to potential errors.


225-225: Approved: Conversion of signature to compressed format

The 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 include Bls12381G2Impl

The import of Bls12381G2Impl and aliasing PublicKey as BlsPublicKey is appropriate for the changes in public key handling.


57-57: Ensure to_compressed() usage aligns with deserialization

In the encode method, using public_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 with try_from matches serialization

The decode method now uses BlsPublicKey::try_from(public_key_bytes.as_slice()). Ensure that this deserialization correctly decodes the compressed public key data serialized by to_compressed().


156-156: Getter method public_key signature updated appropriately

The 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 method set_public_key signature updated appropriately

The 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 type

The implementation of the public_key() getter correctly returns the updated public key type.


230-230: Setter method implementation is consistent with updated type

The implementation of set_public_key() appropriately assigns the updated public key type to the field.


263-265: Updated imports in test module are appropriate

The imports of SecretKey, StdRng, and SeedableRng are necessary for generating test keys using the new BLS implementation.


271-272: Generating test public_key with new BLS implementation

Using 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 reliability

Updating TestQuorumInfo to specify BlsPrivateKey<Bls12381G2Impl> and BlsPublicKey<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 library

In line 139, the private keys are generated using bls_signatures::PrivateKey::generate_dash_many. Verify that the new blsful 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 implementation

The imports have been updated to include Bls12381G2Impl and Signature, which is necessary for integrating the new BLS library.


41-43: Signature parsing updated appropriately

The 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 implementation

The signature verification now correctly uses the verify method on the Signature instance, improving type safety and clarity.


171-176: Second attempt signature verification updated

The 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 of from_byte_array for SecretKey

The method SecretKey::from_byte_array is used to create a SecretKey from private_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 suggestion

Consider importing blsful directly instead of via dashcore

The imports on lines 5 and 7 bring in bls_signatures and Bls12381G2Impl through the dashcore crate. Since the goal is to replace the existing BLS library with the Rust-based blsful library, importing blsful 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 the blsful 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 of validate_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 to validate_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 implementation

The test code now uses SecretKey::random(&mut rng).public_key() to generate public keys, which is appropriate for the new BlsPublicKey<Bls12381G2Impl> type. The use of a seeded random number generator ensures deterministic test results.


15-17: Ensure all usages of choose_quorum_v0 are updated to reflect the new public key type

The function choose_quorum_v0 now uses BlsPublicKey<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 new BlsPublicKey<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 1

Length 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 keys

The 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 conversion

The conversion of quorum_public_key into a BlsPublicKey with appropriate error mapping is correctly implemented.

packages/rs-dpp/src/core_types/validator_set/v0/mod.rs (10)

11-11: Import of Bls12381G2Impl aligns with library update

The import of Bls12381G2Impl from dashcore::blsful correctly reflects the change to the new BLS library.


38-38: Update threshold_public_key type to use Bls12381G2Impl

Changing threshold_public_key to BlsPublicKey<Bls12381G2Impl> ensures compatibility with the new BLS library and is appropriate.


219-219: Updated getter signature for threshold_public_key

The getter method now correctly returns &BlsPublicKey<Bls12381G2Impl>.


233-233: Updated setter signature for threshold_public_key

The setter method now correctly accepts BlsPublicKey<Bls12381G2Impl>.


261-263: Getter implementation for threshold_public_key is correct

The implementation correctly returns a reference to threshold_public_key.


283-285: Setter implementation for threshold_public_key is correct

The implementation correctly sets threshold_public_key.


292-295: Imports in test module are appropriate

Adding imports for SecretKey, PubkeyHash, StdRng, and SeedableRng is necessary for the tests.


307-308: Initialize RNG with fixed seed for deterministic tests

Using a fixed seed ensures that the tests are reproducible.


308-308: Generate public key using the new BLS library

Generating the public key with SecretKey::<Bls12381G2Impl>::random(&mut rng).public_key() aligns with the new library.


327-327: Generate threshold_public_key using the new BLS library

Creating threshold_public_key as SecretKey::<Bls12381G2Impl>::random(&mut rng).public_key() is correct.

packages/rs-dpp/src/identity/identity_public_key/key_type.rs (2)

279-281: Consistent use of blsful for BLS key generation

In lines 279-281, the code correctly uses blsful::SecretKey for BLS key generation and handling. This aligns with the PR objective.


203-203: Ensure private_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 to public_key_data_from_private_key_data pass private_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 Parameter

All calls to public_key_data_from_private_key_data correctly pass private_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 of SignatureSchemes Added Correctly

The 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 Clarity

By specifying SignatureSchemes::Basic in the sign 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 Format

The 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 consume commit_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: Importing Bls12381G2Impl for Specific BLS Implementation

The 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-based blsful crate.


129-133: Improved Error Handling in Signature Verification

The 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 implementation

The import of Bls12381G2Impl and SecretKey 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: Import old_structures module for backward compatibility

The addition of mod old_structures; introduces the old_structures module, which is used to handle legacy data structures like ValidatorSet. This is appropriate for maintaining backward compatibility with previous versions.


148-148: Update validator_sets to use old_structures::ValidatorSet

The validator_sets field in PlatformStateForSavingV0 now references old_structures::ValidatorSet. This change aligns with the introduction of legacy structures to manage state versions appropriately.


272-272: Ensure correct conversion from old_structures::ValidatorSet to ValidatorSet

In the From<PlatformStateForSavingV0> implementation for PlatformStateV0, you're converting old_structures::ValidatorSet to ValidatorSet using v.into(). Verify that the Into 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 of PlatformStateForSavingV0

The visibility of PlatformStateForSavingV0 has been changed from pub to pub(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 the platform_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 5

Length 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 include Bls12381G2Impl

The import statement correctly includes Bls12381G2Impl and aliases SecretKey as BlsPrivateKey, 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 implementation

The added import of Bls12381G2Impl, aliasing SecretKey as BlsPrivateKey, and including SignatureSchemes are appropriate and necessary for integrating the new BLS library.


355-355: Ensure consistent use of big-endian byte order in serialization

The change from to_bytes() to to_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() and from_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 code

Using .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 updates

The 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 key

The 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 implementation

The addition of Bls12381G2Impl and SignatureSchemes imports is necessary for the updated BLS signing process.


20-22: Switch to fixed-size arrays enhances type safety

Updating private_keys and private_keys_in_creation to use [u8; 32] instead of Vec<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: Update add_key method to accept fixed-size arrays

Changing the add_key method to accept [u8; 32] aligns with the updated private key type, ensuring consistency throughout the code.


55-55: Update add_keys method to accept fixed-size arrays

Similarly, 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],
Copy link
Contributor

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:

  1. This change might break existing code that passes slices of different lengths. Ensure all callers of this method are updated accordingly.
  2. Verify that this change is consistent with the new Rust-based BLS library (blsful) mentioned in the PR objectives.
  3. 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

Comment on lines +92 to +93
#[cfg(feature = "bls-signatures")]
pub use dashcore::blsful as bls_signatures;
Copy link
Contributor

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};
Copy link
Contributor

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

Comment on lines +69 to +70
+ IntoIterator<Item = (IdentityPublicKey, [u8; 32])>
+ Extend<(IdentityPublicKey, [u8; 32])>,
Copy link
Contributor

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

Comment on lines +23 to +37
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()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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),
}

Comment on lines +1047 to +1055
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();
Copy link
Contributor

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.

Suggested change
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();

Comment on lines +955 to +963
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();
Copy link
Contributor

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.

Comment on lines +436 to +444
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();
Copy link
Contributor

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.

Comment on lines +91 to +92
.sign(SignatureSchemes::Basic, data)
.map_err(|e| ProtocolError::Generic(format!("unable to sign {}", e)))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
.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)))?;

Comment on lines +85 to +89
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(),
))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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(),
))?;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/rs-sdk/src/lib.rs (1)

79-79: Approved, but consider adding documentation for the new export.

The addition of pub use dapi_grpc; is consistent with the existing pattern of re-exporting related modules and aligns with the PR objective of refactoring the platform to use a new BLS implementation. This change enhances the SDK's interface by allowing users to directly access dapi_grpc functionalities.

However, to improve clarity for SDK users:

Consider adding a brief comment explaining the purpose and contents of the dapi_grpc module, similar to how other exports are documented in this file. For example:

/// Re-export of the DAPI gRPC module, providing gRPC client implementations for Dash Platform services.
pub use dapi_grpc;

This will help users understand what functionality they can expect from this newly exposed module.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 91cbe4a and 7f814ad.

📒 Files selected for processing (1)
  • packages/rs-sdk/src/lib.rs (1 hunks)
🧰 Additional context used

@shumkov shumkov removed this from the 1.4.2 milestone Oct 28, 2024
@shumkov shumkov mentioned this pull request Oct 30, 2024
20 tasks
@shumkov shumkov changed the base branch from v1.4-dev to v1.6-dev November 1, 2024 01:53
@lklimek lklimek changed the base branch from v1.6-dev-ugly to v1.6-dev November 13, 2024 08:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (14)
packages/rs-dpp/src/bls/native_bls.rs (2)

23-37: Enhance error messages and signature verification flow

While the implementation is functionally correct, consider these improvements:

  1. The signature derivation error could be more descriptive by including the reason for failure.
  2. Consider adding context to error messages using .context() from anyhow.
 let g2_element =
     <Bls12381G2Impl as Pairing>::Signature::from_compressed(&signature_96_bytes)
         .into_option()
-        .ok_or(anyhow!("signature derivation failed"))?;
+        .ok_or(anyhow!("Failed to derive G2 element from compressed signature"))?;

 let signature = Signature::Basic(g2_element);

 match signature.verify(&public_key, data) {
     Ok(_) => Ok(true),
-    Err(_) => Err(anyhow!("Verification failed").into()),
+    Err(e) => Err(anyhow!("Signature verification failed").context(e).into()),
 }

57-64: Consider adding documentation for the signing scheme

The implementation correctly uses SignatureSchemes::Basic, but it would be helpful to document why this specific scheme was chosen and any implications it has for compatibility or security.

+    /// Signs the data using BLS Basic Signature Scheme as defined in the BLS IETF draft.
+    /// This scheme is chosen for its simplicity and security properties.
     fn sign(&self, data: &[u8], private_key: &[u8]) -> Result<Vec<u8>, ProtocolError> {
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs (1)

122-123: Consider architectural implications of version asymmetry

While SignatureVerificationQuorumSetForSaving has both V0 and V1 variants, SignatureVerificationQuorumSet only has V0. This asymmetry in versioning between the runtime and storage structures could lead to confusion. Consider either:

  1. Adding V1 to SignatureVerificationQuorumSet for consistency, or
  2. Documenting why this asymmetry exists and its implications
packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs (1)

107-108: Consider implementing signature caching

The TODO comment suggests caching to prevent potential hashing-based attacks. This is a valid security consideration.

Consider implementing a simple LRU cache for the calculated hashes to mitigate potential DoS attacks while balancing memory usage:

use lru::LruCache;
use std::sync::Mutex;

lazy_static! {
    static ref HASH_CACHE: Mutex<LruCache<Vec<u8>, Vec<u8>>> = Mutex::new(LruCache::new(100));
}
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (2)

73-83: Simplify BLS key validation logic

The current implementation uses expect() after an explicit None check, which is redundant and less idiomatic.

Consider simplifying with:

-let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
-    bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key_bytes).into();
-if private_key.is_none() {
-    return Ok(false);
-}
-let private_key = private_key.expect("expected private key");
-Ok(&private_key.public_key().0.to_compressed() == self.data.as_slice())
+bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key_bytes)
+    .map(|private_key| &private_key.public_key().0.to_compressed() == self.data.as_slice())
+    .map_or(Ok(false), Ok)

137-176: Consider adding error case tests

While the happy path tests are thorough, consider adding tests for error cases such as:

  • Invalid key length
  • Corrupted key data
  • Invalid signature data

Example test case:

#[test]
fn test_bls_serialization_with_invalid_data() {
    let invalid_key = [0u8; 31]; // Wrong length
    let result = dashcore::blsful::SecretKey::<Bls12381G2Impl>::from_be_bytes(&invalid_key);
    assert!(result.is_err());
}
packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_quorum_info/v0/mod.rs (2)

Line range hint 389-396: Improved error handling with Rust idioms

The conversion of quorum public keys now follows Rust's error handling best practices:

  1. Using try_from instead of from_bytes aligns with the PR's objective of migrating to the Rust-based BLS library
  2. The error mapping with map_err provides clear context about where the BLS error occurred
  3. The pattern matching ensures proper error propagation

Consider simplifying the error handling using the ? operator:

-                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()),
-                };
+                BlsPublicKey::try_from(quorum_info.quorum_public_key.as_slice())
+                    .map_err(ExecutionError::BlsErrorFromDashCoreResponse)?;

Line range hint 1-476: Consider architectural improvements for better maintainability

While the code is well-structured, consider the following improvements:

  1. Extract the sorting logic in update_quorum_info_v0 into a dedicated method for better maintainability
  2. Consider introducing a dedicated error type for quorum-related operations to centralize error handling
  3. The QuorumSetType enum could be enhanced with methods to reduce code duplication in quorum type handling

Example of extracting sorting logic:

impl ValidatorSet {
    fn sort_by_height_and_hash(&mut self) {
        self.sort_by(|_, quorum_a, _, quorum_b| {
            let primary_comparison = quorum_b.core_height().cmp(&quorum_a.core_height());
            if primary_comparison == std::cmp::Ordering::Equal {
                quorum_b
                    .quorum_hash()
                    .cmp(quorum_a.quorum_hash())
                    .then_with(|| quorum_b.core_height().cmp(&quorum_a.core_height()))
            } else {
                primary_comparison
            }
        });
    }
}
packages/rs-drive-abci/tests/strategy_tests/query.rs (1)

8-8: Remove unused import BlsResult

The BlsResult type is imported but not used in the code.

-use dpp::bls_signatures::{Bls12381G2Impl, BlsResult};
+use dpp::bls_signatures::Bls12381G2Impl;
packages/rs-dpp/src/identity/identity_public_key/random.rs (2)

Line range hint 723-766: Consider making the key matrix size configurable

The used_key_matrix implementation has hardcoded indices and a fixed size of 16. This could be improved by:

  1. Making the matrix size configurable based on platform version or requirements
  2. Using constants or enums for the special indices (4, 8, 12) to improve maintainability

Example improvement:

- let mut used_key_matrix = [false; 16].to_vec();
+ const KEY_MATRIX_SIZE: usize = 16;
+ const MASTER_KEY_INDICES: &[usize] = &[4, 8, 12];
+ let mut used_key_matrix = vec![false; KEY_MATRIX_SIZE];
  used_key_matrix[0] = true;
  used_key_matrix[1] = true;
  used_key_matrix[2] = true;
- used_key_matrix[4] = true; //also a master key
- used_key_matrix[8] = true; //also a master key
- used_key_matrix[12] = true; //also a master key
+ // Mark master key indices as used
+ MASTER_KEY_INDICES.iter().for_each(|&idx| used_key_matrix[idx] = true);

Line range hint 632-658: Update return type documentation

The documentation still references Vec<u8> in the return type description, but the actual return type has been changed to [u8; 32]. Please update the documentation to reflect this change.

For example, in the documentation for random_ecdsa_high_level_authentication_key and similar methods:

- * `(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,

Also applies to: 659-685

packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs (1)

Line range hint 131-148: Well-designed versioning strategy for state management.

The implementation uses a robust versioning strategy that:

  1. Maintains backward compatibility through versioned structures
  2. Supports smooth transitions between implementations
  3. Facilitates future version changes with minimal impact

This approach aligns well with the PR's objective of replacing the BLS library while ensuring system stability.

packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs (2)

36-57: Consider adding unit tests for From<ValidatorSetV0>.

Adding unit tests for the From implementation of ValidatorSetV0 can help ensure its correctness and prevent future regressions.

Would you like assistance in generating unit tests for these conversions?


80-103: Consider adding unit tests for From<ValidatorV0>.

Similarly, adding unit tests for the From implementation of ValidatorV0 would be beneficial for ensuring correctness.

Would you like assistance in generating unit tests for these conversions?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7f814ad and ab74355.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (48)
  • 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/rs-sdk/src/lib.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (33)
  • packages/rs-dpp/Cargo.toml
  • packages/rs-dpp/src/core_types/validator/mod.rs
  • packages/rs-dpp/src/core_types/validator_set/mod.rs
  • packages/rs-dpp/src/errors/protocol_error.rs
  • packages/rs-dpp/src/identity/identity_public_key/methods/hash/mod.rs
  • packages/rs-dpp/src/identity/identity_public_key/methods/hash/v0/mod.rs
  • packages/rs-dpp/src/identity/identity_public_key/v0/random.rs
  • packages/rs-dpp/src/identity/random.rs
  • packages/rs-dpp/src/identity/v0/random.rs
  • packages/rs-dpp/src/lib.rs
  • packages/rs-dpp/src/signing.rs
  • packages/rs-drive-abci/Cargo.toml
  • 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/execution/platform_events/core_chain_lock/choose_quorum/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_instant_send_lock/verify_recent_signature_locally/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/common/asset_lock/transaction/fetch_asset_lock_transaction_output_sync/v0/mod.rs
  • packages/rs-drive-abci/src/mimic/mod.rs
  • packages/rs-drive-abci/src/mimic/test_quorum.rs
  • packages/rs-drive-abci/src/platform_types/commit/mod.rs
  • packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs
  • packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs
  • packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs
  • packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorums.rs
  • 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/query/system/current_quorums_info/v0/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/main.rs
  • packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs
  • packages/rs-drive-proof-verifier/src/unproved.rs
  • packages/rs-drive-proof-verifier/src/verify.rs
  • packages/rs-sdk/Cargo.toml
  • packages/rs-sdk/src/lib.rs
🧰 Additional context used
📓 Learnings (4)
packages/rs-dpp/src/core_types/validator/v0/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-11-12T14:57:47.419Z
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-11-12T14:56:12.334Z
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/v0/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-11-12T14:56:12.334Z
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-11-12T14:57:47.419Z
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/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-11-12T14:56:12.334Z
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-11-12T14:57:47.419Z
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.
packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/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-11-12T14:56:12.334Z
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-11-12T14:57:47.419Z
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.
🪛 GitHub Check: Rust packages (wasm-dpp) / Linting
packages/rs-dpp/src/identity/identity_public_key/key_type.rs

[warning] 11-11: unused import: blsful
warning: unused import: blsful
--> packages/rs-dpp/src/identity/identity_public_key/key_type.rs:11:16
|
11 | use dashcore::{blsful, ed25519_dalek, Network};
| ^^^^^^
|
= note: #[warn(unused_imports)] on by default

🔇 Additional comments (47)
packages/rs-dpp/src/bls/native_bls.rs (4)

1-3: LGTM: Imports are appropriate for the new BLS implementation

The imports correctly include all necessary types from the new BLS implementation.


11-14: LGTM: Good use of Rust's type conversion traits

The change to use try_from is more idiomatic and provides better type safety. Error handling is appropriate with custom error types.


45-49: LGTM with existing suggestions

The implementation is functionally correct. Please refer to the previous review comments regarding error message consistency and encapsulation of field access.


Line range hint 1-64: Verify consistent BLS implementation usage across the codebase

Since this is a significant change in the BLS implementation, let's verify that all callers are updated appropriately.

packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs (2)

7-7: Skip comment - Issue already reported

A past review comment already addresses the confusing module structure in the import path.


130-130: Verify version conversion compatibility

The implementation converts all runtime V0 structures to V1 for storage and converts both stored V0 and V1 structures back to runtime V0. While this aligns with the PR objective of changing serialization, please verify:

  1. That V0 to V1 conversion preserves all necessary data
  2. That both V0 and V1 stored formats can be safely converted back to runtime V0

Also applies to: 142-144

✅ Verification successful

Let me gather more information about the version conversion implementation to verify the data preservation and compatibility.


Let me gather more information about the struct definitions and conversion implementations to understand the data preservation.


Let me check the QuorumForSaving types and their conversions to understand the full conversion chain.


Based on the code analysis, I can now provide a final response about the version conversion safety.

Version conversion implementation is safe and preserves data

The version conversion implementation is safe because:

  1. The conversion from V0 to V1 preserves all data fields:

    • Both V0 and V1 have identical structure fields (config, current_quorums, previous_quorums)
    • The only difference is in the type of public_key in QuorumForSaving: V0 uses bls_signatures::PublicKey while V1 uses ThresholdBlsPublicKey<Bls12381G2Impl>
    • The conversion is implemented with proper field mapping using into() for each field
  2. The conversion back to runtime V0 is safe:

    • Both V0 and V1 stored formats can be converted back to runtime V0 structure
    • The conversion maintains all necessary fields and their relationships
    • The public key type conversion is handled through the BLS library's conversion traits
  3. The implementation follows Rust's type safety:

    • Uses proper type conversions through From/Into traits
    • Maintains struct field integrity during conversions
    • Preserves optional fields (previous_quorums) correctly
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests verifying version conversion compatibility
rg -A 5 "test.*conversion|test.*compatibility" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

# Look for potential data loss in conversion implementations
ast-grep --pattern 'impl From<$_> for $_'

Length of output: 501334


Script:

#!/bin/bash
# Look for SignatureVerificationQuorumSet version conversion implementations
ast-grep --pattern 'impl From<$_> for SignatureVerificationQuorumSetForSaving'

# Look for tests verifying version conversions
rg -l "test.*quorum.*conversion|test.*quorum.*compat" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

# Look for the actual struct definitions to compare fields
ast-grep --pattern 'struct SignatureVerificationQuorumSetForSavingV0'
ast-grep --pattern 'struct SignatureVerificationQuorumSetForSavingV1'
ast-grep --pattern 'struct SignatureVerificationQuorumSetV0'

Length of output: 2984


Script:

#!/bin/bash
# Look for struct definitions and their fields
rg -A 10 "struct SignatureVerificationQuorumSetForSavingV0" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/
rg -A 10 "struct SignatureVerificationQuorumSetForSavingV1" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/
rg -A 10 "struct SignatureVerificationQuorumSetV0" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

# Look for the implementation of conversion between V0 and V1
rg -A 10 "impl From<SignatureVerificationQuorumSetV0> for SignatureVerificationQuorumSetForSavingV1" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

Length of output: 6554


Script:

#!/bin/bash
# Look for QuorumForSaving struct definitions
rg -A 5 "struct QuorumForSavingV0" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/
rg -A 5 "struct QuorumForSavingV1" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

# Look for conversion implementations between QuorumForSaving versions
rg -A 10 "impl From<.*> for QuorumForSaving" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

# Look for tests related to quorum conversions
rg -A 10 "#\[test\].*quorum" packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/

Length of output: 1897

packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs (4)

9-9: LGTM: Imports are properly scoped

The new imports are correctly specified for the BLS signature implementation changes.


85-85: LGTM: Type change aligns with new BLS implementation

The public key type is correctly updated to use the specific Bls12381G2Impl implementation.


92-105: LGTM: Robust signature verification implementation

The new verification logic properly handles:

  • Empty signature validation
  • Proper error types and messages
  • Correct signature verification flow using the BLS12-381 G2 implementation

191-191: LGTM: Test properly updated for new implementation

The test correctly uses the new PublicKey instantiation method and maintains good coverage of both success and failure scenarios.

packages/rs-dpp/src/core_types/validator/v0/mod.rs (5)

97-102: LGTM! Improved error handling in deserialization

The use of try_from with specific error messages enhances error handling and validation during deserialization.


156-156: LGTM! Consistent trait implementations

The trait implementations are correctly updated to use the new BLS type while maintaining the same behavior.

Also applies to: 176-176, 196-196, 230-230


263-265: LGTM! Appropriate test key generation

The test uses a deterministic RNG (seeded with 0) for reproducible test cases. Based on previous learnings from PR #2227, using SecretKey::random() for test key generation is an acceptable approach here.

Also applies to: 271-272


57-57: Validate compressed public key format compatibility

The change from to_bytes() to to_compressed() affects the serialization format. While compressed format is more space-efficient, please ensure:

  1. All consumers can handle compressed BLS public keys
  2. The format is compatible with network consensus requirements
  3. The change is documented in release notes

Let's check if compressed format is used consistently:

✅ Verification successful

Based on the search results, I can see that to_compressed() is consistently used across the codebase for BLS public key serialization, particularly in:

  1. Identity public key handling:
private_key.public_key().0.to_compressed().to_vec()
  1. Validator and quorum operations:
public_key.0.to_compressed().encode(encoder)
threshold_public_key.0.to_compressed().to_vec()
  1. Signature operations:
signature.as_raw_value().to_compressed()

The change from to_bytes() to to_compressed() appears to be part of a consistent pattern across the codebase for BLS key serialization. The compressed format is already the standard approach used throughout the system.

Compressed BLS public key format is used consistently

The change to use to_compressed() aligns with the existing codebase conventions. No compatibility issues expected as this is the standard serialization format used across the platform.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for BLS key serialization patterns
rg "to_(compressed|bytes)\(\)" --type rust

Length of output: 38173


4-4: Verify backward compatibility with existing validator data

The change from Option<BlsPublicKey> to Option<BlsPublicKey<Bls12381G2Impl>> modifies the serialization format. While this aligns with the PR objective to replace the BLS library, it requires careful consideration of:

  1. Migration strategy for existing validator data
  2. Version compatibility in network communications
  3. Impact on platform serialization

Let's check for existing validator data serialization:

Also applies to: 29-29

✅ Verification successful

Let me gather more information about the serialization implementation and any version handling mechanisms.


Let me check one more aspect about the serialization implementation to understand how the BLS public key is handled.


Based on the gathered information, I can now provide a final response:

BLS key serialization format is backward compatible

The serialization implementation maintains backward compatibility through:

  1. Consistent encoding format using a boolean flag to indicate presence/absence of public key
  2. Fixed-size serialization (48 bytes) for BLS public keys when present
  3. Proper versioning with ValidatorV0 struct

The type change from Option<BlsPublicKey> to Option<BlsPublicKey<Bls12381G2Impl>> is safe because:

  • The underlying serialization format remains unchanged (compressed G2 points)
  • The encoding/decoding implementation handles the BLS keys in a version-aware manner
  • Test cases verify the serialization roundtrip
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for validator serialization/deserialization usage
rg -A 3 "ValidatorV0.*encode|ValidatorV0.*decode" --type rust

Length of output: 1696


Script:

#!/bin/bash
# Check for version handling in serialization
rg -A 5 "impl.*Encode.*ValidatorV0|impl.*Decode.*ValidatorV0" --type rust

# Check for any migration or version compatibility code
rg -A 3 "version|migration.*validator" --type rust --glob "packages/rs-dpp/src/core_types/validator/**"

# Look for any test cases handling serialization
rg -A 5 "#\[test\].*validator.*serialization|#\[test\].*validator.*encode" --type rust

Length of output: 2664


Script:

#!/bin/bash
# Check the actual serialization implementation for BLS keys
rg -B 5 -A 10 "public_key" packages/rs-dpp/src/core_types/validator/v0/mod.rs

# Look for any test cases specifically related to BLS key serialization
rg -A 5 "test.*bls.*key|test.*public.*key" packages/rs-dpp/src/core_types/validator/v0/mod.rs

Length of output: 6467

packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (4)

1-13: LGTM: Import changes are well-structured

The imports are properly organized with appropriate feature flags for optional dependencies.


56-56: LGTM: Improved type safety with fixed-size array

The change from &[u8] to &[u8; 32] enforces the correct key size at compile-time.


92-95: LGTM: Improved ECDSA key validation

The error handling is properly implemented with pattern matching, and the use of from_byte_array aligns with the fixed-size array parameter.


210-210: Previous comment about invalid test keys still applies

Referring to the previous review comment about using truly invalid private keys instead of all-zero arrays.

Also applies to: 251-251, 292-292

packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/v0/mod.rs (4)

2-2: LGTM: Import changes align with the BLS library replacement.

The addition of Bls12381G2Impl import is consistent with the PR objective to replace the BLS library with the Rust-based implementation.


19-23: LGTM: Score vector type update is consistent.

The score vector type has been properly updated to use BlsPublicKey<Bls12381G2Impl> while maintaining the original scoring logic for deterministic quorum selection.


Line range hint 99-138: LGTM: Test changes improve key generation security.

The changes improve the test implementation by:

  • Using a proper random number generator with a fixed seed for deterministic tests
  • Generating keys through SecretKey::random().public_key() which is a more secure approach
  • Maintaining the same test assertions, confirming that the behavior is preserved

14-18: Verify callers handle the new BLS public key type.

The method signature has been updated to use BlsPublicKey<Bls12381G2Impl>. While the change is correct, we should verify that all callers have been updated to handle the new type.

✅ Verification successful

Let me verify the implementation of the caller to ensure it handles the new type correctly.


Let me check the imports and type declarations in the caller module to verify the BLS type consistency.


BLS public key type changes are properly handled

The verification shows that the caller module (choose_quorum/mod.rs) correctly imports and uses the parameterized BlsPublicKey<Bls12381G2Impl> type consistently. The type is properly propagated through:

  • The import statement using the same type
  • The wrapper function choose_quorum with matching parameter and return types
  • The version dispatch to choose_quorum_v0
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all callers of choose_quorum_v0 to verify they handle the new type
rg -l "choose_quorum_v0" | grep -v "choose_quorum/v0/mod.rs" | while read -r file; do
  echo "=== $file ==="
  rg -A 5 "choose_quorum_v0" "$file"
done

Length of output: 642


Script:

#!/bin/bash
# Get the full implementation of the caller
cat packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/choose_quorum/mod.rs

Length of output: 2528


Script:

#!/bin/bash
# Check if there are any other files importing or using BlsPublicKey
rg "BlsPublicKey" packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/ -A 2

Length of output: 2828

packages/rs-dpp/src/core_types/validator_set/v0/mod.rs (3)

11-11: LGTM: BLS implementation type is now explicit

The addition of Bls12381G2Impl as a type parameter for BlsPublicKey aligns with the PR objective of replacing the BLS library and makes the implementation choice explicit.

Also applies to: 38-38


219-219: LGTM: Trait definitions consistently updated

The getter and setter methods have been correctly updated to use BlsPublicKey<Bls12381G2Impl>, maintaining consistency with the struct definition.

Also applies to: 233-233, 261-262, 283-285


292-295: LGTM: Test setup improved with proper key generation

The test modifications correctly use SecretKey::<Bls12381G2Impl>::random() for key generation, which is more robust than the previous approach. This aligns with the known limitation that deterministic BLS keys cannot be easily used in tests.

Also applies to: 307-308, 327-327

packages/rs-dpp/src/identity/identity_public_key/key_type.rs (4)

Line range hint 344-379: LGTM: Key type conversion and serialization

The implementation maintains backward compatibility for key type values and properly handles serialization.

🧰 Tools
🪛 GitHub Check: Rust packages (wasm-dpp) / Linting

[warning] 11-11: unused import: blsful
warning: unused import: blsful
--> packages/rs-dpp/src/identity/identity_public_key/key_type.rs:11:16
|
11 | use dashcore::{blsful, ed25519_dalek, Network};
| ^^^^^^
|
= note: #[warn(unused_imports)] on by default


169-170: ⚠️ Potential issue

Use blsful for BLS key generation

The random_public_key_data_v0 method still uses the old bls_signatures library for key generation.

Apply this diff to use blsful:

-let private_key = bls_signatures::SecretKey::<Bls12381G2Impl>::random(rng);
-private_key.public_key().0.to_compressed().to_vec()
+let private_key = blsful::SecretKey::<Bls12381G2Impl>::random(rng);
+private_key.public_key().0.to_compressed().to_vec()

Likely invalid or redundant comment.


218-229: 🛠️ Refactor suggestion

Improve BLS private key error handling

The current implementation uses unnecessary unwrapping and could be simplified using Rust's ? operator.

Apply this diff to improve error handling:

-let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
-    bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
-        private_key_bytes,
-    )
-    .into();
-if private_key.is_none() {
-    return Err(ProtocolError::BlsError(BlsError::DeserializationError(
-        "private key bytes not a valid secret key".to_string(),
-    )));
-}
-let private_key = private_key.expect("expected private key");
+let private_key = blsful::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key_bytes)
+    .map_err(|_| ProtocolError::BlsError(BlsError::DeserializationError(
+        "private key bytes not a valid secret key".to_string(),
+    )))?;

Likely invalid or redundant comment.


203-203: Verify impact of signature changes

The method signatures have been updated to use fixed-size arrays ([u8; 32]) instead of slices (&[u8]). While this improves type safety, it's a breaking change that might affect consumers of this API.

Also applies to: 266-266, 320-320

packages/rs-drive-abci/tests/strategy_tests/query.rs (2)

72-72: Type alias suggestion is still applicable


Line range hint 109-133: LGTM! Improved error handling and type safety

The changes enhance the robustness of signature verification by:

  • Using try_from for safer deserialization
  • Providing detailed error messages
  • Properly propagating errors
packages/rs-drive-abci/tests/strategy_tests/masternodes.rs (3)

5-5: LGTM: Import changes align with the new BLS implementation

The import statement correctly brings in the new BLS implementation components while maintaining clear naming through the as alias.


212-220: Previous review comments are still applicable

The private key generation process can be simplified as suggested in the previous review comments.


350-358: Previous review comments are still applicable

The private key generation process can be simplified as suggested in the previous review comments.

packages/rs-dpp/src/identity/identity_public_key/random.rs (2)

141-141: Excellent improvement in type safety for private keys!

The change from Vec<u8> to [u8; 32] for private keys is a significant improvement that:

  • Provides compile-time guarantees for key length
  • Improves memory efficiency with stack allocation
  • Prevents potential security issues from variable-length keys

Also applies to: 179-179, 275-275, 321-321, 349-349, 387-387, 414-414, 445-445, 492-492, 521-521, 561-561, 590-590, 632-632, 659-659, 706-706, 723-723


Line range hint 179-195: Well-implemented error handling and version checks

The code demonstrates excellent error handling practices:

  • Consistent version checking across all methods
  • Clear and descriptive error messages
  • Proper use of Rust's Result pattern

Also applies to: 445-465, 590-610

packages/rs-drive-abci/src/platform_types/platform_state/v0/mod.rs (3)

1-1: LGTM! Good encapsulation practices.

The introduction of the old_structures module and the visibility restriction of PlatformStateForSavingV0 to pub(super) demonstrate good encapsulation practices, helping maintain a clear separation between old and new implementations while restricting unnecessary exposure.

Also applies to: 131-131


272-272: LGTM! Robust conversion implementation.

The conversion implementation between state versions is thorough and handles all fields correctly. The error handling for potential conversion failures and the maintenance of backward compatibility are particularly well done.


148-148: Verify conversion between old and new ValidatorSet types.

The change to use old_structures::ValidatorSet aligns with the PR objective of replacing the BLS library. However, we should verify the conversion implementations between the old and new ValidatorSet types to ensure data integrity.

✅ Verification successful

Based on the search results, I can now generate the final response:

Conversion between old and new ValidatorSet types is properly implemented

Found implementation in platform_state/v0/old_structures/mod.rs that converts:

  • old_structures::ValidatorSet -> dpp::core_types::validator_set::ValidatorSet
  • old_structures::ValidatorSetV0 -> dpp::core_types::validator_set::v0::ValidatorSetV0

The conversion maintains all required fields including quorum hash, index, core height, members, and threshold public key, ensuring data integrity during the BLS library transition.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for ValidatorSet conversion implementations
# Look for From/TryFrom implementations between old and new ValidatorSet types

ast-grep --pattern 'impl From<old_structures::ValidatorSet> for ValidatorSet'
ast-grep --pattern 'impl TryFrom<ValidatorSet> for old_structures::ValidatorSet'

Length of output: 162


Script:

#!/bin/bash
# Let's try a broader search for ValidatorSet conversions and implementations
# First, let's find all files that mention ValidatorSet
rg -l "ValidatorSet"

# Then search for any impl blocks related to ValidatorSet conversions
rg "impl.*ValidatorSet" -A 5

# Also search for any struct definitions of ValidatorSet to understand the types
rg "struct ValidatorSet" -A 10

Length of output: 20042

packages/rs-drive-abci/tests/strategy_tests/execution.rs (4)

23-23: LGTM: Import aligns with BLS library replacement.

The import correctly includes the necessary BLS types from the new Rust-based library.


355-358: LGTM: Consistent key serialization changes.

The migration from to_bytes() to to_be_bytes() is applied consistently across all instances, ensuring proper big-endian byte representation required by the new BLS library.

Also applies to: 382-385, 656-659


731-738: LGTM: Proper BLS signature generation implementation.

The signature generation correctly:

  • Uses the Basic signature scheme
  • Handles key conversion and message signing
  • Compresses the signature for storage

Also applies to: 742-742


855-857: LGTM: Proper validator public key handling.

The validator update implementation correctly:

  • Uses compressed BLS public key format
  • Maintains proper validator set structure
  • Handles threshold public key compression consistently

Also applies to: 867-871

packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs (3)

7-10: Verify the visibility of ValidatorSet enum.

The ValidatorSet enum is declared with pub(super) visibility. Ensure that this visibility level aligns with the intended usage, especially if it needs to be accessed outside of its parent module.


23-34: Verify the visibility of ValidatorSetV0 struct.

Similarly, the ValidatorSetV0 struct is declared with pub(super) visibility. Confirm that this visibility is appropriate for its intended use.


65-67: Ensure secure handling of sensitive data in ValidatorV0.

The ValidatorV0 struct includes node_ip and node_id, which may be sensitive information. Please verify that appropriate measures are in place to protect this data during serialization and storage.

@@ -8,13 +8,14 @@
#[cfg(feature = "random-public-keys")]
use dashcore::secp256k1::rand::SeedableRng;
use dashcore::secp256k1::Secp256k1;
use dashcore::{bls_signatures, ed25519_dalek, Network};
use dashcore::{blsful, ed25519_dalek, Network};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Clean up BLS-related imports

The code currently imports both blsful and bls_signatures, which is inconsistent with the PR's objective to replace the bls-signatures library with blsful. Additionally, the blsful import is unused.

Apply this diff to clean up the imports:

-use dashcore::{blsful, ed25519_dalek, Network};
+use dashcore::{ed25519_dalek, Network};
-use crate::bls_signatures::{Bls12381G2Impl, BlsError};
-use crate::{bls_signatures, ProtocolError};
+use crate::blsful::{Bls12381G2Impl, BlsError};
+use crate::ProtocolError;

Also applies to: 15-15, 18-18

🧰 Tools
🪛 GitHub Check: Rust packages (wasm-dpp) / Linting

[warning] 11-11: unused import: blsful
warning: unused import: blsful
--> packages/rs-dpp/src/identity/identity_public_key/key_type.rs:11:16
|
11 | use dashcore::{blsful, ed25519_dalek, Network};
| ^^^^^^
|
= note: #[warn(unused_imports)] on by default

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (1)
packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (1)

137-174: Consider adding error test cases

The new BLS serialization tests cover the happy path well, but consider adding test cases for:

  • Invalid key bytes
  • Invalid signature bytes
  • Edge cases in compression/decompression
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ab74355 and e6bda11.

📒 Files selected for processing (4)
  • packages/rs-dpp/src/errors/protocol_error.rs (1 hunks)
  • packages/rs-dpp/src/identity/identity_public_key/key_type.rs (10 hunks)
  • packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (13 hunks)
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/methods/v0/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-dpp/src/errors/protocol_error.rs
🔇 Additional comments (9)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/methods/v0/mod.rs (1)

17-17: LGTM! Change aligns with PR objectives

The type change to platform_value::Identifier is consistent with the BLS library replacement. As noted in the PR objectives, this will affect serialization but should continue to function correctly.

packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (2)

12-16: LGTM: Clean feature-gated imports

The conditional imports for BLS-related dependencies are properly feature-gated and well-organized.


58-58: LGTM: Improved type safety with fixed-size array

The parameter type change from &[u8] to &[u8; 32] enhances type safety by enforcing the correct key size at compile time.

packages/rs-dpp/src/identity/identity_public_key/key_type.rs (6)

207-207: LGTM! Type safety improvement

The parameter type change from &[u8] to &[u8; 32] improves type safety by ensuring the correct key size at compile time.


213-214: LGTM! Correct ECDSA key handling

The use of from_byte_array is appropriate for the fixed-size array parameter and includes proper error handling.

Also applies to: 243-244


252-252: LGTM! Correct EdDSA key handling

The use of from_bytes is appropriate for the fixed-size array parameter.


260-262: LGTM! Clear error handling

The error message clearly indicates that the operation is not supported.


268-268: LGTM! Consistent type safety improvements

The changes consistently use fixed-size arrays for private keys across all key types, improving type safety. The BLS implementation correctly uses the new blsful library.

Also applies to: 277-277, 281-283, 292-292, 299-299, 310-310, 322-322


173-174: ⚠️ Potential issue

Update BLS key generation to use blsful

The code still uses the old bls_signatures library for key generation. This should be updated to use the new blsful library for consistency.

Apply this diff:

-let private_key = bls_signatures::SecretKey::<Bls12381G2Impl>::random(rng);
-private_key.public_key().0.to_compressed().to_vec()
+let private_key = blsful::SecretKey::<Bls12381G2Impl>::random(rng);
+private_key.public_key().0.to_compressed().to_vec()

Likely invalid or redundant comment.

@@ -15,7 +14,7 @@ pub trait IdentityCreditTransferTransitionMethodsV0 {
#[cfg(feature = "state-transition-signing")]
fn try_from_identity<S: Signer>(
identity: &Identity,
to_identity_with_identifier: Identifier,
to_identity_with_identifier: platform_value::Identifier,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Issues found in trait implementations

The trait implementations are not consistent with the trait definition:

  • Trait definition in methods/v0/mod.rs uses platform_value::Identifier
  • But implementations in both methods/mod.rs and v0/v0_methods.rs use plain Identifier

This needs to be updated in:

  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/methods/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rs
🔗 Analysis chain

Verify all trait implementations are updated

The parameter type change from Identifier to platform_value::Identifier requires updates to all implementations of this trait.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all implementations of IdentityCreditTransferTransitionMethodsV0 
# and verify they use platform_value::Identifier

# Search for trait implementations
ast-grep --pattern 'impl $_ for IdentityCreditTransferTransitionMethodsV0'

# Search for try_from_identity method implementations
rg -A 10 'fn try_from_identity.*to_identity_with_identifier'

Length of output: 139


Script:

#!/bin/bash
# Let's try a different approach to find implementations

# First, find all files that might contain the trait name
rg -l "IdentityCreditTransferTransitionMethodsV0" 

# Then search for the specific method signature
rg -l "try_from_identity.*to_identity_with_identifier"

# Look for any struct that might implement this trait
ast-grep --pattern 'struct $_ {
  $$$
}'

# Also search for the trait definition to understand its full path
rg "trait IdentityCreditTransferTransitionMethodsV0"

Length of output: 36005


Script:

#!/bin/bash
# Let's search for the implementation of the trait and verify the parameter type

# Search for the implementation with more context
rg -A 20 "impl.*IdentityCreditTransferTransitionMethodsV0" 

# Also search for the actual implementation of try_from_identity with more context
rg -A 20 "fn try_from_identity.*to_identity_with_identifier"

# Look for any other usages of this parameter type
rg "to_identity_with_identifier:\s*(?:platform_value::)?Identifier"

Length of output: 7357

Comment on lines +75 to +85
let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
private_key_bytes,
)
.into();
if private_key.is_none() {
return Ok(false);
}
let private_key = private_key.expect("expected private key");

Ok(g1_element.to_bytes().as_slice() == self.data.as_slice())
Ok(private_key.public_key().0.to_compressed() == self.data.as_slice())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace expect() with proper error handling

Using expect() could cause a panic if the None check fails. While the code checks for None before calling expect(), it's more idiomatic to use pattern matching.

Consider refactoring to:

-    let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
-        bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
-            private_key_bytes,
-        )
-        .into();
-    if private_key.is_none() {
-        return Ok(false);
-    }
-    let private_key = private_key.expect("expected private key");
-    Ok(private_key.public_key().0.to_compressed() == self.data.as_slice())
+    if let Some(private_key) = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
+        private_key_bytes,
+    ).into() {
+        Ok(private_key.public_key().0.to_compressed() == self.data.as_slice())
+    } else {
+        Ok(false)
+    }
📝 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.

Suggested change
let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
private_key_bytes,
)
.into();
if private_key.is_none() {
return Ok(false);
}
let private_key = private_key.expect("expected private key");
Ok(g1_element.to_bytes().as_slice() == self.data.as_slice())
Ok(private_key.public_key().0.to_compressed() == self.data.as_slice())
if let Some(private_key) = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
private_key_bytes,
).into() {
Ok(private_key.public_key().0.to_compressed() == self.data.as_slice())
} else {
Ok(false)
}

Comment on lines 25 to 29
#[cfg(feature = "bls-signatures")]
use {
crate::bls_signatures::{self as bls_signatures, Bls12381G2Impl, BlsError},
dashcore::{blsful, ed25519_dalek},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Clean up BLS-related imports

The imports still reference both bls_signatures and blsful, which is inconsistent with the PR's objective to replace the bls-signatures library. Additionally, some imports are unused.

Apply this diff to clean up the imports:

-#[cfg(feature = "bls-signatures")]
-use {
-    crate::bls_signatures::{self as bls_signatures, Bls12381G2Impl, BlsError},
-    dashcore::{blsful, ed25519_dalek},
-};
+#[cfg(feature = "bls-signatures")]
+use {
+    crate::blsful::{Bls12381G2Impl, BlsError},
+    dashcore::ed25519_dalek,
+};
📝 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.

Suggested change
#[cfg(feature = "bls-signatures")]
use {
crate::bls_signatures::{self as bls_signatures, Bls12381G2Impl, BlsError},
dashcore::{blsful, ed25519_dalek},
};
#[cfg(feature = "bls-signatures")]
use {
crate::blsful::{Bls12381G2Impl, BlsError},
dashcore::ed25519_dalek,
};

Comment on lines +222 to +233
let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
private_key_bytes,
)
.into();
if private_key.is_none() {
return Err(ProtocolError::BlsError(BlsError::DeserializationError(
"private key bytes not a valid secret key".to_string(),
)));
}
let private_key = private_key.expect("expected private key");
let public_key_bytes = private_key.public_key().0.to_compressed().to_vec();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update BLS key derivation to use blsful

The code still uses the old bls_signatures library for key derivation. This should be updated to use the new blsful library and improve error handling.

Apply this diff:

-let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
-    bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
-        private_key_bytes,
-    )
-    .into();
-if private_key.is_none() {
-    return Err(ProtocolError::BlsError(BlsError::DeserializationError(
-        "private key bytes not a valid secret key".to_string(),
-    )));
-}
-let private_key = private_key.expect("expected private key");
+let private_key = blsful::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key_bytes)
+    .map_err(|_| {
+        ProtocolError::BlsError(BlsError::DeserializationError(
+            "private key bytes not a valid secret key".to_string(),
+        ))
+    })?;
📝 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.

Suggested change
let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
private_key_bytes,
)
.into();
if private_key.is_none() {
return Err(ProtocolError::BlsError(BlsError::DeserializationError(
"private key bytes not a valid secret key".to_string(),
)));
}
let private_key = private_key.expect("expected private key");
let public_key_bytes = private_key.public_key().0.to_compressed().to_vec();
let private_key = blsful::SecretKey::<Bls12381G2Impl>::from_be_bytes(private_key_bytes)
.map_err(|_| {
ProtocolError::BlsError(BlsError::DeserializationError(
"private key bytes not a valid secret key".to_string(),
))
})?;
let public_key_bytes = private_key.public_key().0.to_compressed().to_vec();

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e6bda11 and b86245e.

📒 Files selected for processing (4)
  • packages/rs-dpp/Cargo.toml (1 hunks)
  • packages/rs-dpp/src/identity/identity_public_key/key_type.rs (10 hunks)
  • packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs (13 hunks)
  • packages/rs-sdk/src/lib.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/rs-dpp/Cargo.toml
  • packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs
  • packages/rs-sdk/src/lib.rs
🔇 Additional comments (3)
packages/rs-dpp/src/identity/identity_public_key/key_type.rs (3)

11-11: Skip review of imports

These changes were already addressed in previous review comments.

Also applies to: 15-19


249-251: LGTM: Proper EdDSA key handling

The implementation correctly uses the ed25519-dalek API for both key generation and conversion, with proper feature flag handling.

Also applies to: 294-297


219-230: 🛠️ Refactor suggestion

Simplify BLS key conversion error handling

The current implementation uses Option and unwrap, which is less idiomatic than using Result directly. The unwrap is also redundant since we already check for None.

Apply this diff to simplify the error handling:

-                    let private_key: Option<bls_signatures::SecretKey<Bls12381G2Impl>> =
-                        bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
-                            private_key_bytes,
-                        )
-                        .into();
-                    if private_key.is_none() {
-                        return Err(ProtocolError::BlsError(BlsError::DeserializationError(
-                            "private key bytes not a valid secret key".to_string(),
-                        )));
-                    }
-                    let private_key = private_key.expect("expected private key");
+                    let private_key = bls_signatures::SecretKey::<Bls12381G2Impl>::from_be_bytes(
+                        private_key_bytes,
+                    )
+                    .ok_or_else(|| {
+                        ProtocolError::BlsError(BlsError::DeserializationError(
+                            "private key bytes not a valid secret key".to_string(),
+                        ))
+                    })?;

Likely invalid or redundant comment.

Comment on lines +170 to +171
let private_key = bls_signatures::SecretKey::<Bls12381G2Impl>::random(rng);
private_key.public_key().0.to_compressed().to_vec()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistent BLS library usage

The code uses different BLS libraries in different methods:

  • random_public_key_data_v0 uses the old bls_signatures library
  • random_public_and_private_key_data_v0 uses the new blsful library

This inconsistency could lead to compatibility issues.

Apply this diff to use the new blsful library consistently:

-                let private_key = bls_signatures::SecretKey::<Bls12381G2Impl>::random(rng);
-                private_key.public_key().0.to_compressed().to_vec()
+                let private_key = dashcore::blsful::SecretKey::<Bls12381G2Impl>::random(rng);
+                private_key.public_key().0.to_compressed().to_vec()

Also applies to: 279-281

Comment on lines +15 to +16
#[cfg(feature = "bls-signatures")]
use crate::bls_signatures::{self as bls_signatures, Bls12381G2Impl, BlsError};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Multiple files still use the old bls-signatures library and need migration

The verification reveals that the migration to blsful is incomplete. Several files still use the old bls_signatures library:

  • packages/simple-signer/src/signer.rs
  • packages/rs-drive-proof-verifier/src/{verify.rs,unproved.rs}
  • packages/rs-drive-abci/ (multiple files)
  • packages/rs-dpp/ (multiple files including the one under review)

The new blsful library is only partially adopted in a few files under packages/rs-dpp/. This indicates an inconsistent state where both libraries are being used simultaneously.

🔗 Analysis chain

Verify complete migration to blsful

Let's verify that all usages of the old bls-signatures library have been identified for replacement.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for remaining uses of bls_signatures in the codebase
echo "Searching for remaining bls_signatures usages..."
rg "bls_signatures::" --type rust

# Search for new blsful usages to ensure consistent adoption
echo "Verifying blsful adoption..."
rg "blsful::" --type rust

Length of output: 10414

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
Dockerfile (1)

257-284: Improve cargo-binstall installation process

The implementation is good but could be optimized:

  1. The custom User-Agent in the curl command (line 269) seems unnecessary and could be removed
  2. Multiple source $HOME/.cargo/env commands (lines 272, 275) could be consolidated

Consider applying these changes:

RUN <<EOS
set -ex;
if [ "$TARGETARCH" = "amd64" ]; then
    CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl";
elif [ "$TARGETARCH" = "arm64" ]; then
    CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl";
else
    echo "Unsupported architecture: $TARGETARCH"; exit 1;
fi;
DOWNLOAD_URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v${BINSTALL_VERSION}/cargo-binstall-${CARGO_BINSTALL_ARCH}.tgz";
- curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto '=https' --tlsv1.2 -sSf "$DOWNLOAD_URL" | tar -xvzf -;
+ curl -L --proto '=https' --tlsv1.2 -sSf "$DOWNLOAD_URL" | tar -xzf -;
./cargo-binstall -y --force cargo-binstall;
rm ./cargo-binstall;
source $HOME/.cargo/env;
- cargo binstall -V
-
- source $HOME/.cargo/env;
-
cargo binstall [email protected] [email protected] \
    --locked \
    --no-discover-github-token \
    --disable-telemetry \
    --no-track \
    --no-confirm
EOS
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b86245e and 6164e1b.

📒 Files selected for processing (2)
  • Dockerfile (1 hunks)
  • packages/rs-dpp/src/signing.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-dpp/src/signing.rs
🔇 Additional comments (1)
Dockerfile (1)

289-289: Verify the external base image security and stability

The change from deps to lklimek/dash-platform-build-base introduces an external dependency. This requires verification of:

  1. Image provenance and security
  2. Version stability and update policy
  3. Compatibility with the build requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants