From 0f26760b78bf5c3e48fb090332416bad4eebb031 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 3 Mar 2025 21:03:26 +0700 Subject: [PATCH 01/14] temp work --- .../protos/platform/v0/platform.proto | 26 ++ .../mod.rs | 67 +++++ .../v0/mod.rs | 168 +++++++++++++ .../mod.rs | 6 +- .../v0/mod.rs | 8 +- .../src/query/identity_based_queries/mod.rs | 3 +- packages/rs-drive-abci/src/query/service.rs | 44 +--- .../tests/strategy_tests/query.rs | 2 +- packages/rs-drive-proof-verifier/src/proof.rs | 2 +- .../mod.rs | 53 ++++ .../v0/mod.rs | 53 ++++ .../mod.rs | 48 +++- .../v0/mod.rs | 36 ++- .../fetch/fetch_by_public_key_hashes/mod.rs | 6 +- .../src/drive/identity/fetch/prove/mod.rs | 1 + .../mod.rs | 52 ++++ .../v0/mod.rs | 234 ++++++++++++++++++ .../v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../src/drive/identity/fetch/queries/mod.rs | 35 ++- packages/rs-drive/src/verify/identity/mod.rs | 8 +- .../v0/mod.rs | 2 +- .../mod.rs | 66 +++++ .../v0/mod.rs | 68 +++++ .../mod.rs | 6 +- .../v0/mod.rs | 4 +- .../mod.rs | 65 +++++ .../v0/mod.rs | 78 ++++++ .../mod.rs | 8 +- .../v0/mod.rs | 2 +- .../mod.rs | 8 +- .../v0/mod.rs | 2 +- .../drive_abci_query_versions/mod.rs | 2 +- .../drive_abci_query_versions/v1.rs | 2 +- .../drive_identity_method_versions/mod.rs | 2 + .../drive_identity_method_versions/v1.rs | 2 + .../drive_verify_method_versions/mod.rs | 6 +- .../drive_verify_method_versions/v1.rs | 6 +- .../src/version/mocks/v2_test.rs | 2 +- 40 files changed, 1097 insertions(+), 92 deletions(-) create mode 100644 packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs create mode 100644 packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs rename packages/rs-drive-abci/src/query/identity_based_queries/{identity_by_public_key_hash => identity_by_unique_public_key_hash}/mod.rs (92%) rename packages/rs-drive-abci/src/query/identity_based_queries/{identity_by_public_key_hash => identity_by_unique_public_key_hash}/v0/mod.rs (94%) create mode 100644 packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs create mode 100644 packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs create mode 100644 packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs rename packages/rs-drive/src/verify/identity/{verify_full_identity_by_public_key_hash => verify_full_identity_by_unique_public_key_hash}/mod.rs (89%) rename packages/rs-drive/src/verify/identity/{verify_full_identity_by_public_key_hash => verify_full_identity_by_unique_public_key_hash}/v0/mod.rs (96%) create mode 100644 packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs create mode 100644 packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs rename packages/rs-drive/src/verify/identity/{verify_identity_id_by_public_key_hash => verify_identity_id_by_unique_public_key_hash}/mod.rs (86%) rename packages/rs-drive/src/verify/identity/{verify_identity_id_by_public_key_hash => verify_identity_id_by_unique_public_key_hash}/v0/mod.rs (98%) rename packages/rs-drive/src/verify/identity/{verify_identity_ids_by_public_key_hashes => verify_identity_ids_by_unique_public_key_hashes}/mod.rs (87%) rename packages/rs-drive/src/verify/identity/{verify_identity_ids_by_public_key_hashes => verify_identity_ids_by_unique_public_key_hashes}/v0/mod.rs (98%) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index d35efdd131a..5cf0a4c7fdd 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -33,6 +33,8 @@ service Platform { rpc getDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc getIdentityByPublicKeyHash(GetIdentityByPublicKeyHashRequest) returns (GetIdentityByPublicKeyHashResponse); + rpc getIdentityByNonUniquePublicKeyHash(GetIdentityByNonUniquePublicKeyHashRequest) + returns (GetIdentityByNonUniquePublicKeyHashResponse); rpc waitForStateTransitionResult(WaitForStateTransitionResultRequest) returns (WaitForStateTransitionResultResponse); rpc getConsensusParams(GetConsensusParamsRequest) @@ -620,6 +622,30 @@ message GetIdentityByPublicKeyHashResponse { oneof version { GetIdentityByPublicKeyHashResponseV0 v0 = 1; } } +message GetIdentityByNonUniquePublicKeyHashRequest { + message GetIdentityByNonUniquePublicKeyHashRequestV0 { + bytes public_key_hash = 1; + optional bytes start_after = 2; // Give one result after a previous result + bool prove = 3; + } + oneof version { GetIdentityByNonUniquePublicKeyHashRequestV0 v0 = 1; } +} + +message GetIdentityByNonUniquePublicKeyHashResponse { + message GetIdentityByNonUniquePublicKeyHashResponseV0 { + message IdentityResponse { + optional bytes identity = 1; + } + oneof result { + IdentityResponse identity = 1; + Proof proof = 2; + } + + ResponseMetadata metadata = 3; // Metadata about the blockchain state + } + oneof version { GetIdentityByNonUniquePublicKeyHashResponseV0 v0 = 1; } +} + message WaitForStateTransitionResultRequest { message WaitForStateTransitionResultRequestV0 { bytes state_transition_hash = 1; // The hash of the state transition to wait for diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs new file mode 100644 index 00000000000..8bfd4ed12e3 --- /dev/null +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs @@ -0,0 +1,67 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, GetIdentityByPublicKeyHashResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of an identity by a public key hash + pub fn query_identity_by_non_unique_public_key_hash( + &self, + GetIdentityByNonUniquePublicKeyHashRequest { version }: GetIdentityByNonUniquePublicKeyHashRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError( + "could not decode identity by public key non unique hash query".to_string(), + ), + )); + }; + + let feature_version_bounds = &platform_version + .drive_abci + .query + .identity_based_queries + .identity_by_unique_public_key_hash; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "identity_by_non_unique_public_key_hash".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + + match version { + RequestVersion::V0(request_v0) => { + let request = self.query_identity_by_non_unique_public_key_hash_v0( + request_v0, + platform_state, + platform_version, + )?; + + Ok( + request.map(|response_v0| GetIdentityByNonUniquePublicKeyHashResponse { + version: Some(ResponseVersion::V0(response_v0)), + }), + ) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs new file mode 100644 index 00000000000..07f23174845 --- /dev/null +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs @@ -0,0 +1,168 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request::GetIdentityByNonUniquePublicKeyHashRequestV0; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::{ + get_identity_by_non_unique_public_key_hash_response_v0, GetIdentityByNonUniquePublicKeyHashResponseV0, +}; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::get_identity_by_non_unique_public_key_hash_response_v0::IdentityResponse; +use dpp::check_validation_result_with_data; +use dpp::platform_value::{Bytes20, Bytes32}; +use dpp::serialization::PlatformSerializable; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; + +impl Platform { + pub(super) fn query_identity_by_non_unique_public_key_hash_v0( + &self, + GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash, + start_after, + prove, + }: GetIdentityByNonUniquePublicKeyHashRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let public_key_hash = + check_validation_result_with_data!(Bytes20::from_vec(public_key_hash) + .map(|bytes| bytes.0) + .map_err(|_| QueryError::InvalidArgument( + "public key hash must be 20 bytes long".to_string() + ))); + + let start_after = if let Some(start_after) = start_after { + Some(check_validation_result_with_data!(Bytes32::from_vec(start_after) + .map(|bytes| bytes.0) + .map_err(|_| QueryError::InvalidArgument( + "public key hash must be 20 bytes long".to_string() + )))) + } else { + None + }; + + + let response = if prove { + let proof = self.drive.prove_full_identity_by_non_unique_public_key_hash( + public_key_hash, + start_after, + None, + platform_version, + )?; + + GetIdentityByNonUniquePublicKeyHashResponseV0 { + result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let maybe_identity = self.drive.fetch_full_identity_by_non_unique_public_key_hash( + public_key_hash, + start_after, + None, + platform_version, + )?; + + let serialized_identity = maybe_identity.map(|identity| + + identity + .serialize_consume_to_bytes() + .map_err(Error::Protocol) + + ).transpose()?; + + + GetIdentityByNonUniquePublicKeyHashResponseV0 { + metadata: Some(self.response_metadata_v0(platform_state)), + result: Some( + get_identity_by_non_unique_public_key_hash_response_v0::Result::Identity( + IdentityResponse { + identity: serialized_identity, + }, + ), + ), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::query::tests::setup_platform; + use dpp::dashcore::Network; + use dapi_grpc::platform::v0::ResponseMetadata; + + #[test] + fn test_invalid_public_key_hash() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + + let request = GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash: vec![0; 8], + start_after: None, + prove: false, + }; + + let result = platform + .query_identity_by_non_unique_public_key_hash_v0(request, &state, version) + .expect("expected query to succeed"); + + assert!(matches!( + result.errors.as_slice(), + [QueryError::InvalidArgument(msg)] if msg == &"public key hash must be 20 bytes long".to_string() + )); + } + + #[test] + fn test_identity_not_found() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + + let public_key_hash = vec![0; 20]; + let request = GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash: public_key_hash.clone(), + start_after: None, + prove: false, + }; + + let result = platform + .query_identity_by_non_unique_public_key_hash_v0(request, &state, version) + .expect("expected query to succeed"); + + assert_eq!(result.data, Some(GetIdentityByNonUniquePublicKeyHashResponseV0 { + metadata: Some(ResponseMetadata { height: 0, core_chain_locked_height: 0, epoch: 0, time_ms: 0, protocol_version: 9, chain_id: "chain_id".to_string() }), + result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Identity(IdentityResponse { + identity: None, + })), + })); + } + + #[test] + fn test_identity_absence_proof() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + + let public_key_hash = vec![0; 20]; + let request = GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash: public_key_hash.clone(), + start_after: None, + prove: true, + }; + + let result = platform + .query_identity_by_non_unique_public_key_hash_v0(request, &state, version) + .expect("expected query to succeed"); + + assert!(matches!( + result.data, + Some(GetIdentityByNonUniquePublicKeyHashResponseV0 { + result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof( + _ + )), + metadata: Some(_), + }) + )); + } +} diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs similarity index 92% rename from packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/mod.rs rename to packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs index db20b658b6f..2585d26afb8 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs @@ -32,7 +32,7 @@ impl Platform { .drive_abci .query .identity_based_queries - .identity_by_public_key_hash; + .identity_by_unique_public_key_hash; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -41,7 +41,7 @@ impl Platform { if !feature_version_bounds.check_version(feature_version) { return Ok(QueryValidationResult::new_with_error( QueryError::UnsupportedQueryVersion( - "identity_by_public_key_hash".to_string(), + "identity_by_unique_public_key_hash".to_string(), feature_version_bounds.min_version, feature_version_bounds.max_version, platform_version.protocol_version, @@ -52,7 +52,7 @@ impl Platform { match version { RequestVersion::V0(request_v0) => { - let request = self.query_identity_by_public_key_hash_v0( + let request = self.query_identity_by_unique_public_key_hash_v0( request_v0, platform_state, platform_version, diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/v0/mod.rs similarity index 94% rename from packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs rename to packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/v0/mod.rs index 0d3db5c8023..012f289e027 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/v0/mod.rs @@ -14,7 +14,7 @@ use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; impl Platform { - pub(super) fn query_identity_by_public_key_hash_v0( + pub(super) fn query_identity_by_unique_public_key_hash_v0( &self, GetIdentityByPublicKeyHashRequestV0 { public_key_hash, @@ -91,7 +91,7 @@ mod tests { }; let result = platform - .query_identity_by_public_key_hash_v0(request, &state, version) + .query_identity_by_unique_public_key_hash_v0(request, &state, version) .expect("expected query to succeed"); assert!(matches!( @@ -111,7 +111,7 @@ mod tests { }; let result = platform - .query_identity_by_public_key_hash_v0(request, &state, version) + .query_identity_by_unique_public_key_hash_v0(request, &state, version) .expect("expected query to succeed"); assert!(matches!( @@ -131,7 +131,7 @@ mod tests { }; let result = platform - .query_identity_by_public_key_hash_v0(request, &state, version) + .query_identity_by_unique_public_key_hash_v0(request, &state, version) .expect("expected query to succeed"); assert!(matches!( diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs index 29fea765215..f42ff1c4412 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs @@ -3,7 +3,8 @@ mod balance_and_revision; mod balances; mod identities_contract_keys; mod identity; -mod identity_by_public_key_hash; +mod identity_by_unique_public_key_hash; +mod identity_by_non_unique_public_key_hash; mod identity_contract_nonce; mod identity_nonce; mod keys; diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 156ae629983..09a0dc9853e 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -9,40 +9,7 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{ - BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, - GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, - GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, - GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, - GetContestedResourcesResponse, GetCurrentQuorumsInfoRequest, GetCurrentQuorumsInfoResponse, - GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, - GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, - GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, - GetEvonodesProposedEpochBlocksByIdsRequest, GetEvonodesProposedEpochBlocksByRangeRequest, - GetEvonodesProposedEpochBlocksResponse, GetGroupActionSignersRequest, - GetGroupActionSignersResponse, GetGroupActionsRequest, GetGroupActionsResponse, - GetGroupInfoRequest, GetGroupInfoResponse, GetGroupInfosRequest, GetGroupInfosResponse, - GetIdentitiesBalancesRequest, GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, - GetIdentitiesContractKeysResponse, GetIdentitiesTokenBalancesRequest, - GetIdentitiesTokenBalancesResponse, GetIdentitiesTokenInfosRequest, - GetIdentitiesTokenInfosResponse, GetIdentityBalanceAndRevisionRequest, - GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, - GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, - GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, - GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, - GetIdentityResponse, GetIdentityTokenBalancesRequest, GetIdentityTokenBalancesResponse, - GetIdentityTokenInfosRequest, GetIdentityTokenInfosResponse, GetPathElementsRequest, - GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, - GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, - GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, - GetStatusRequest, GetStatusResponse, GetTokenPreProgrammedDistributionsRequest, - GetTokenPreProgrammedDistributionsResponse, GetTokenStatusesRequest, GetTokenStatusesResponse, - GetTokenTotalSupplyRequest, GetTokenTotalSupplyResponse, GetTotalCreditsInPlatformRequest, - GetTotalCreditsInPlatformResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, - WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, -}; +use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetCurrentQuorumsInfoRequest, GetCurrentQuorumsInfoResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetEvonodesProposedEpochBlocksByIdsRequest, GetEvonodesProposedEpochBlocksByRangeRequest, GetEvonodesProposedEpochBlocksResponse, GetGroupActionSignersRequest, GetGroupActionSignersResponse, GetGroupActionsRequest, GetGroupActionsResponse, GetGroupInfoRequest, GetGroupInfoResponse, GetGroupInfosRequest, GetGroupInfosResponse, GetIdentitiesBalancesRequest, GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentitiesTokenBalancesRequest, GetIdentitiesTokenBalancesResponse, GetIdentitiesTokenInfosRequest, GetIdentitiesTokenInfosResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetIdentityTokenBalancesRequest, GetIdentityTokenBalancesResponse, GetIdentityTokenInfosRequest, GetIdentityTokenInfosResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, GetStatusRequest, GetStatusResponse, GetTokenPreProgrammedDistributionsRequest, GetTokenPreProgrammedDistributionsResponse, GetTokenStatusesRequest, GetTokenStatusesResponse, GetTokenTotalSupplyRequest, GetTokenTotalSupplyResponse, GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse}; use dapi_grpc::tonic::{Code, Request, Response, Status}; use dpp::version::PlatformVersion; use std::fmt::Debug; @@ -411,6 +378,15 @@ impl PlatformService for QueryService { .await } + async fn get_identity_by_non_unique_public_key_hash(&self, request: Request) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_identity_by_non_unique_public_key_hash, + "get_identity_by_non_unique_public_key_hash", + ) + .await + } + async fn wait_for_state_transition_result( &self, _request: Request, diff --git a/packages/rs-drive-abci/tests/strategy_tests/query.rs b/packages/rs-drive-abci/tests/strategy_tests/query.rs index 4a4103c4dbc..5e0aaba3d85 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/query.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/query.rs @@ -266,7 +266,7 @@ impl QueryStrategy { let (proof_root_hash, identity): ( RootHash, Option, - ) = Drive::verify_full_identity_by_public_key_hash( + ) = Drive::verify_full_identity_by_unique_public_key_hash( &proof.grovedb_proof, key_hash, platform_version, diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 6399a3e691d..50e232de483 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -325,7 +325,7 @@ impl FromProof for Identity { }; // Extract content from proof and verify Drive/GroveDB proofs - let (root_hash, maybe_identity) = Drive::verify_full_identity_by_public_key_hash( + let (root_hash, maybe_identity) = Drive::verify_full_identity_by_unique_public_key_hash( &proof.grovedb_proof, public_key_hash, platform_version, diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs new file mode 100644 index 00000000000..58438b01e71 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs @@ -0,0 +1,53 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::{drive::DriveError, Error}; +use dpp::identity::Identity; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches an identity with all its related information from storage based on a non unique public key hash. + /// + /// This function leverages the versioning system to direct the fetch operation to the appropriate handler based on the `DriveVersion` provided. + /// + /// # Arguments + /// + /// * `public_key_hash` - A non-unique public key hash corresponding to the identity to be fetched. + /// * `after` - An identity ID after which we want to get back our identity. Basically "don't get back this identity, get the next one" + /// * `transaction` - Transaction arguments. + /// * `drive_version` - A reference to the drive version. + /// + /// # Returns + /// + /// Returns a `Result` containing an `Option` of the `Identity` if it exists, otherwise an `Error` if the fetch operation fails or the version is not supported. + pub fn fetch_full_identity_by_non_unique_public_key_hash( + &self, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .identity + .fetch + .public_key_hashes + .fetch_full_identity_by_non_unique_public_key_hash + { + 0 => self.fetch_full_identity_by_non_unique_public_key_hash_v0( + public_key_hash, + after, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_full_identity_by_non_unique_public_key_hash".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs new file mode 100644 index 00000000000..44fb166d486 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -0,0 +1,53 @@ +use crate::drive::Drive; + +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; + +use dpp::identity::Identity; +use dpp::version::PlatformVersion; + +use grovedb::TransactionArg; + +impl Drive { + /// Fetches an identity with all its information from storage. + pub(super) fn fetch_full_identity_by_non_unique_public_key_hash_v0( + &self, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut drive_operations: Vec = vec![]; + self.fetch_full_identity_by_non_unique_public_key_hash_operations_v0( + public_key_hash, + after, + transaction, + &mut drive_operations, + platform_version, + ) + } + + /// Given an identity, fetches the identity with its flags from storage. + pub(super) fn fetch_full_identity_by_non_unique_public_key_hash_operations_v0( + &self, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let identity_ids = self.fetch_identity_ids_by_non_unique_public_key_hash_operations( + public_key_hash, + Some(1), + after, + transaction, + drive_operations, + platform_version, + )?; + if let Some(identity_id) = identity_ids.first() { + self.fetch_full_identity(*identity_id, transaction, platform_version) + } else { + Ok(None) + } + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs index 9c444e59731..892d91c7bf5 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs @@ -2,8 +2,9 @@ mod v0; use crate::drive::Drive; use crate::error::{drive::DriveError, Error}; -use dpp::version::drive_versions::DriveVersion; use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; +use crate::fees::op::LowLevelDriveOperation; impl Drive { /// Fetches identity ids from storage based on a non-unique public key hash. @@ -13,8 +14,9 @@ impl Drive { /// # Arguments /// /// * `public_key_hash` - A non-unique public key hash corresponding to the identity ids to be fetched. + /// * `limit` - An optional limit. /// * `transaction` - Transaction arguments. - /// * `drive_version` - A reference to the drive version. + /// * `platform_version` - A reference to the platform version. /// /// # Returns /// @@ -22,10 +24,12 @@ impl Drive { pub fn fetch_identity_ids_by_non_unique_public_key_hash( &self, public_key_hash: [u8; 20], + limit: Option, + after: Option<[u8;32]>, transaction: TransactionArg, - drive_version: &DriveVersion, + platform_version: &PlatformVersion, ) -> Result, Error> { - match drive_version + match platform_version.drive .methods .identity .fetch @@ -34,8 +38,10 @@ impl Drive { { 0 => self.fetch_identity_ids_by_non_unique_public_key_hash_v0( public_key_hash, + limit, + after, transaction, - drive_version, + platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "fetch_identity_ids_by_non_unique_public_key_hash".to_string(), @@ -44,4 +50,36 @@ impl Drive { })), } } + + pub(crate) fn fetch_identity_ids_by_non_unique_public_key_hash_operations( + &self, + public_key_hash: [u8; 20], + limit: Option, + after: Option<[u8;32]>, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version.drive + .methods + .identity + .fetch + .public_key_hashes + .fetch_identity_ids_by_non_unique_public_key_hash + { + 0 => self.fetch_identity_ids_by_non_unique_public_key_hash_operations_v0( + public_key_hash, + limit, + after, + transaction, + drive_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_identity_ids_by_non_unique_public_key_hash_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } } diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs index ee462d63281..1eb970654f7 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs @@ -6,48 +6,62 @@ use crate::query::QueryItem; use grovedb::query_result_type::QueryResultType; -use dpp::version::drive_versions::DriveVersion; - use grovedb::{PathQuery, TransactionArg}; use std::ops::RangeFull; +use platform_version::version::PlatformVersion; impl Drive { /// Fetches identity ids from storage. pub(super) fn fetch_identity_ids_by_non_unique_public_key_hash_v0( &self, public_key_hash: [u8; 20], + limit: Option, + after: Option<[u8;32]>, transaction: TransactionArg, - drive_version: &DriveVersion, + platform_version: &PlatformVersion, ) -> Result, Error> { let mut drive_operations: Vec = vec![]; self.fetch_identity_ids_by_non_unique_public_key_hash_operations_v0( public_key_hash, + limit, + after, transaction, &mut drive_operations, - drive_version, + platform_version, ) } - /// Gets identity ids from non unique public key hashes. + /// Gets identity ids from non-unique public key hashes. pub(super) fn fetch_identity_ids_by_non_unique_public_key_hash_operations_v0( &self, public_key_hash: [u8; 20], + limit: Option, + after: Option<[u8;32]>, transaction: TransactionArg, drive_operations: &mut Vec, - drive_version: &DriveVersion, + platform_version: &PlatformVersion, ) -> Result, Error> { let non_unique_key_hashes = non_unique_key_hashes_sub_tree_path_vec(public_key_hash); - let path_query = PathQuery::new_single_query_item( - non_unique_key_hashes, - QueryItem::RangeFull(RangeFull), - ); + let mut path_query = if let Some(after) = after { + PathQuery::new_single_query_item( + non_unique_key_hashes, + QueryItem::RangeAfter(after.to_vec()..), + ) + } else { + PathQuery::new_single_query_item( + non_unique_key_hashes, + QueryItem::RangeFull(RangeFull), + ) + }; + path_query.query.limit = limit; + let (results, _) = self.grove_get_path_query( &path_query, transaction, QueryResultType::QueryKeyElementPairResultType, drive_operations, - drive_version, + &platform_version.drive, )?; results .to_keys() diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs index 859982396ab..849fdbe8626 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs @@ -7,6 +7,7 @@ mod has_any_of_unique_public_key_hashes; mod has_non_unique_public_key_hash; mod has_non_unique_public_key_hash_already_for_identity; mod has_unique_public_key_hash; +mod fetch_full_identity_by_non_unique_public_key_hash; #[cfg(feature = "server")] #[cfg(test)] @@ -23,7 +24,6 @@ mod tests { fn test_fetch_all_keys_on_identity() { let drive = setup_drive(None, None); let platform_version = PlatformVersion::latest(); - let drive_version = &platform_version.drive; let transaction = drive.grove.start_transaction(); @@ -71,8 +71,10 @@ mod tests { let identity_ids = drive .fetch_identity_ids_by_non_unique_public_key_hash( hash, + None, + None, Some(&transaction), - &drive_version, + platform_version, ) .expect("expected to get identity ids"); assert!(identity_ids.contains(&identity.id().to_buffer())); diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs index b095b6bf427..01678cef1eb 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs @@ -5,3 +5,4 @@ mod prove_full_identity_by_unique_public_key_hash; mod prove_identities_contract_keys; mod prove_identity_id_by_unique_public_key_hash; mod prove_identity_ids_by_unique_public_key_hashes; +mod prove_full_identity_by_non_unique_public_key_hash; diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs new file mode 100644 index 00000000000..5703fc6920b --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs @@ -0,0 +1,52 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches an identity with all its information from storage. + /// + /// This function uses the versioning system to call the appropriate handler based on the provided `DriveVersion`. + /// + /// # Arguments + /// + /// * `public_key_hash` - The public key hash for which to fetch the identity. + /// * `after` - An identity ID after which we want to get back our identity. Basically "don't get back this identity, get the next one" + /// * `transaction` - Transaction arguments. + /// * `drive_version` - A reference to the drive version. + /// + /// # Returns + /// + /// Returns a `Result` containing a vector of bytes representing the proved identity, otherwise an `Error` if the operation fails or the version is not supported. + pub fn prove_full_identity_by_non_unique_public_key_hash( + &self, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .identity + .prove + .prove_full_identity_by_non_unique_public_key_hash + { + 0 => self.prove_full_identity_by_non_unique_public_key_hash_v0( + public_key_hash, + after, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "prove_full_identity_by_non_unique_public_key_hash".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs new file mode 100644 index 00000000000..7231d8bee9b --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -0,0 +1,234 @@ +use crate::drive::Drive; + +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches an identity with all its information from storage. + pub(super) fn prove_full_identity_by_non_unique_public_key_hash_v0( + &self, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let identity_ids = self.fetch_identity_ids_by_non_unique_public_key_hash_operations( + public_key_hash, + Some(1), + after, + transaction, + &mut vec![], + platform_version, + )?; + if let Some(identity_id) = identity_ids.first() { + let query = Self::full_identity_with_non_unique_public_key_hash_query( + public_key_hash, + *identity_id, + after, + &platform_version.drive.grove_version, + )?; + self.grove_get_proved_path_query( + &query, + transaction, + &mut vec![], + &platform_version.drive, + ) + } else { + // We only prove the absence of the public key hash + let query = Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); + self.grove_get_proved_path_query( + &query, + transaction, + &mut vec![], + &platform_version.drive, + ) + } + } +} + +#[cfg(test)] +mod tests { + use rand::prelude::StdRng; + use rand::SeedableRng; + use super::*; + use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; + use dpp::block::block_info::BlockInfo; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; + use dpp::identity::identity_public_key::methods::hash::IdentityPublicKeyHashMethodsV0; + use dpp::identity::{Identity, IdentityPublicKey, KeyType}; + use dpp::version::PlatformVersion; + + #[test] + fn should_prove_a_single_identity() { + let drive = setup_drive_with_initial_state_structure(None); + + let platform_version = PlatformVersion::latest(); + + let identity = Identity::random_identity(3, Some(14), platform_version) + .expect("expected a random identity"); + + drive + .add_new_identity( + identity.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add an identity"); + + let first_key_hash = identity + .public_keys() + .values() + .find(|public_key| public_key.key_type().is_unique_key_type()) + .expect("expected a unique key") + .public_key_hash() + .expect("expected to hash data"); + + let proof = drive + .prove_full_identity_by_unique_public_key_hash(first_key_hash, None, platform_version) + .expect("should not error when proving an identity"); + + let (_, proved_identity) = Drive::verify_full_identity_by_unique_public_key_hash( + proof.as_slice(), + first_key_hash, + platform_version, + ) + .expect("expect that this be verified"); + + assert_eq!(proved_identity, Some(identity)); + } + + #[test] + fn should_prove_a_single_identity_with_non_unique_key() { + let drive = setup_drive_with_initial_state_structure(None); + + let platform_version = PlatformVersion::latest(); + + let identity = Identity::random_identity(3, Some(14), platform_version) + .expect("expected a random identity"); + + drive + .add_new_identity( + identity.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add an identity"); + + let first_key_hash = identity + .public_keys() + .values() + .find(|public_key| !public_key.key_type().is_unique_key_type()) + .expect("expected a unique key") + .public_key_hash() + .expect("expected to hash data"); + + let proof = drive + .prove_full_identity_by_non_unique_public_key_hash(first_key_hash, None, None, platform_version) + .expect("should not error when proving an identity"); + + let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( + proof.as_slice(), + first_key_hash, + None, + platform_version, + ) + .expect("expect that this be verified"); + + assert_eq!(proved_identity, Some(identity)); + } + + #[test] + fn should_prove_a_single_identity_with_non_unique_key_when_two_have_same_key() { + let drive = setup_drive_with_initial_state_structure(None); + + let platform_version = PlatformVersion::latest(); + + let mut identity_1 = Identity::random_identity(3, Some(14), platform_version) + .expect("expected a random identity"); + + let mut identity_2 = Identity::random_identity(3, Some(15), platform_version) + .expect("expected a random identity"); + + let mut rng = StdRng::seed_from_u64(506); + + let key = IdentityPublicKey::random_voting_key_with_rng(3, &mut rng, platform_version).expect("expected key").0; + + identity_1.add_public_key(key.clone()); + identity_2.add_public_key(key.clone()); + + drive + .add_new_identity( + identity_1.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add an identity"); + + drive + .add_new_identity( + identity_2.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add an identity"); + + let key_hash = key.public_key_hash().expect("expected key hash"); + + let proof = drive + .prove_full_identity_by_non_unique_public_key_hash(key_hash, None, None, platform_version) + .expect("should not error when proving an identity"); + + let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( + proof.as_slice(), + key_hash, + None, + platform_version, + ) + .expect("expect that this be verified"); + + assert_eq!(proved_identity, Some(identity_1.clone())); + + let proof = drive + .prove_full_identity_by_non_unique_public_key_hash(key_hash, Some(identity_1.id().to_buffer()), None, platform_version) + .expect("should not error when proving an identity"); + + let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( + proof.as_slice(), + key_hash, + Some(identity_1.id().to_buffer()), + platform_version, + ) + .expect("expect that this be verified"); + + assert_eq!(proved_identity, Some(identity_2.clone())); + + let proof = drive + .prove_full_identity_by_non_unique_public_key_hash(key_hash, Some(identity_2.id().to_buffer()), None, platform_version) + .expect("should not error when proving an identity"); + + let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( + proof.as_slice(), + key_hash, + Some(identity_2.id().to_buffer()), + platform_version, + ) + .expect("expect that this be verified"); + + assert_eq!(proved_identity, None); + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs index f474fa52315..085920640ba 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs @@ -87,7 +87,7 @@ mod tests { .prove_full_identity_by_unique_public_key_hash(first_key_hash, None, platform_version) .expect("should not error when proving an identity"); - let (_, proved_identity) = Drive::verify_full_identity_by_public_key_hash( + let (_, proved_identity) = Drive::verify_full_identity_by_unique_public_key_hash( proof.as_slice(), first_key_hash, platform_version, diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs index 8900c2e2dcc..83af15538f1 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs @@ -65,7 +65,7 @@ mod tests { ) .expect("should not error when proving an identity"); - let (_, proved_identity_id) = Drive::verify_identity_id_by_public_key_hash( + let (_, proved_identity_id) = Drive::verify_identity_id_by_unique_public_key_hash( proof.as_slice(), false, first_key_hash, diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs index 1b4636e6b5a..d9c54243db5 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs @@ -89,7 +89,7 @@ mod tests { .expect("should not error when proving an identity"); let (_, proved_identity_id): ([u8; 32], BTreeMap<[u8; 20], Option<[u8; 32]>>) = - Drive::verify_identity_ids_by_public_key_hashes( + Drive::verify_identity_ids_by_unique_public_key_hashes( proof.as_slice(), false, &key_hashes, diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index f7832d2274f..685b7353c46 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -1,6 +1,6 @@ use crate::drive::balances::balance_path_vec; use crate::drive::identity::key::fetch::IdentityKeysRequest; -use crate::drive::{identity_tree_path_vec, unique_key_hashes_tree_path_vec, Drive}; +use crate::drive::{identity_tree_path_vec, non_unique_key_hashes_tree_path, non_unique_key_hashes_tree_path_vec, unique_key_hashes_tree_path_vec, Drive}; use std::ops::RangeFull; use crate::error::Error; @@ -90,6 +90,22 @@ impl Drive { PathQuery::new_single_key(unique_key_hashes, public_key_hash.to_vec()) } + /// The query for proving an identity id from a non-unique public key hash. + /// This should be used for absence proofs + pub fn identity_id_by_non_unique_public_key_hash_query(public_key_hash: [u8; 20], after: Option<[u8;32]>) -> PathQuery { + let non_unique_key_hashes = non_unique_key_hashes_tree_path_vec(); + let mut query = Query::new_single_key(public_key_hash.to_vec()); + let sub_query = if let Some(after) = after { + Query::new_single_query_item(QueryItem::RangeFrom( + after.to_vec().., + )) + } else { + Query::new_range_full() + }; + query.set_subquery(sub_query); + PathQuery::new(non_unique_key_hashes, SizedQuery::new(query, None, None)) + } + /// The query for proving identity ids from a vector of public key hashes. pub fn identity_ids_by_unique_public_key_hash_query( public_key_hashes: &[[u8; 20]], @@ -213,6 +229,23 @@ impl Drive { .map_err(Error::GroveDB) } + /// This query gets the full identity and the public key hash + pub fn full_identity_with_non_unique_public_key_hash_query( + public_key_hash: [u8; 20], + identity_id: [u8; 32], + after: Option<[u8;32]>, + grove_version: &GroveVersion, + ) -> Result { + let full_identity_query = Self::full_identity_query(&identity_id, grove_version)?; + let identity_id_by_public_key_hash_query = + Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); + PathQuery::merge( + vec![&full_identity_query, &identity_id_by_public_key_hash_query], + grove_version, + ) + .map_err(Error::GroveDB) + } + /// The query full identities with key hashes too pub fn full_identities_with_keys_hashes_query( identity_ids: &[[u8; 32]], diff --git a/packages/rs-drive/src/verify/identity/mod.rs b/packages/rs-drive/src/verify/identity/mod.rs index dd24b00f678..9e0482bc79e 100644 --- a/packages/rs-drive/src/verify/identity/mod.rs +++ b/packages/rs-drive/src/verify/identity/mod.rs @@ -1,13 +1,15 @@ mod verify_full_identities_by_public_key_hashes; mod verify_full_identity_by_identity_id; -mod verify_full_identity_by_public_key_hash; +mod verify_full_identity_by_unique_public_key_hash; +mod verify_full_identity_by_non_unique_public_key_hash; mod verify_identities_contract_keys; mod verify_identity_balance_and_revision_for_identity_id; mod verify_identity_balance_for_identity_id; mod verify_identity_balances_for_identity_ids; mod verify_identity_contract_nonce; -mod verify_identity_id_by_public_key_hash; -mod verify_identity_ids_by_public_key_hashes; +mod verify_identity_id_by_unique_public_key_hash; +mod verify_identity_ids_by_unique_public_key_hashes; mod verify_identity_keys_by_identity_id; mod verify_identity_nonce; mod verify_identity_revision_for_identity_id; +mod verify_identity_id_by_non_unique_public_key_hash; diff --git a/packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs index 7c1f0545d05..43ce89e6d00 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs @@ -48,7 +48,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result<(RootHash, T), Error> { let (root_hash, identity_ids_by_key_hashes) = - Self::verify_identity_ids_by_public_key_hashes::>( + Self::verify_identity_ids_by_unique_public_key_hashes::>( proof, true, public_key_hashes, diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs new file mode 100644 index 00000000000..b290bec46fe --- /dev/null +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs @@ -0,0 +1,66 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; + +use crate::error::Error; + +use crate::verify::RootHash; + +pub use dpp::prelude::Identity; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Verifies the full identity of a user by their public key hash. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `public_key_hash`: A 20-byte array representing the hash of the public key of the user. + /// - `after`: A 32 byte array representing an identity after which we want to get the identity. + /// - `platform_version`: The platform version against which to verify the identity. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option` of `Identity`. The `RootHash` represents the root hash of GroveDB, and the + /// `Option` represents the full identity of the user if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof of authentication is not valid. + /// - The public key hash does not correspond to a valid identity ID. + /// - The identity ID does not correspond to a valid full identity. + /// - An unknown or unsupported platform version is provided. + /// + pub fn verify_full_identity_by_non_unique_public_key_hash( + proof: &[u8], + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + match platform_version + .drive + .methods + .verify + .identity + .verify_full_identity_by_non_unique_public_key_hash + { + 0 => Self::verify_full_identity_by_non_unique_public_key_hash_v0( + proof, + public_key_hash, + after, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_full_identity_by_non_unique_public_key_hash".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs new file mode 100644 index 00000000000..ee3024d1a7a --- /dev/null +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -0,0 +1,68 @@ +use crate::drive::Drive; + +use crate::error::Error; + +use crate::verify::RootHash; + +pub use dpp::prelude::Identity; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Verifies the full identity of a user by their public key hash. + /// + /// This function takes a byte slice `proof` and a 20-byte array `public_key_hash` as arguments, + /// then it verifies the identity of the user with the given public key hash. + /// + /// The `proof` should contain the proof of authentication from the user. + /// The `public_key_hash` should contain the hash of the public key of the user. + /// + /// The function first verifies the identity ID associated with the given public key hash + /// by calling `verify_identity_id_by_non_unique_public_key_hash()`. It then uses this identity ID to verify + /// the full identity by calling `verify_full_identity_by_identity_id()`. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option` of `Identity`. The `RootHash` represents the root hash of GroveDB, and the + /// `Option` represents the full identity of the user if it exists. + /// + /// If the verification fails at any point, it will return an `Error`. + /// + /// # Errors + /// + /// This function will return an `Error` if: + /// + /// * The proof of authentication is not valid. + /// * The public key hash does not correspond to a valid identity ID. + /// * The identity ID does not correspond to a valid full identity. + /// + #[inline(always)] + pub(super) fn verify_full_identity_by_non_unique_public_key_hash_v0( + proof: &[u8], + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + let (root_hash, identity_id) = Self::verify_identity_id_by_non_unique_public_key_hash( + proof, + true, + public_key_hash, + after, + platform_version, + )?; + let maybe_identity = identity_id + .map(|identity_id| { + Self::verify_full_identity_by_identity_id( + proof, + true, + identity_id, + platform_version, + ) + .map(|(_, maybe_identity)| maybe_identity) + }) + .transpose()? + .flatten(); + Ok((root_hash, maybe_identity)) + } +} diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/mod.rs similarity index 89% rename from packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/mod.rs rename to packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/mod.rs index 6ce7cc6f263..17cd33c1995 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/mod.rs @@ -36,7 +36,7 @@ impl Drive { /// - The identity ID does not correspond to a valid full identity. /// - An unknown or unsupported platform version is provided. /// - pub fn verify_full_identity_by_public_key_hash( + pub fn verify_full_identity_by_unique_public_key_hash( proof: &[u8], public_key_hash: [u8; 20], platform_version: &PlatformVersion, @@ -48,13 +48,13 @@ impl Drive { .identity .verify_full_identity_by_public_key_hash { - 0 => Self::verify_full_identity_by_public_key_hash_v0( + 0 => Self::verify_full_identity_by_unique_public_key_hash_v0( proof, public_key_hash, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "verify_full_identity_by_public_key_hash".to_string(), + method: "verify_full_identity_by_unique_public_key_hash".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs similarity index 96% rename from packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/v0/mod.rs rename to packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs index e481343470a..88fe2894242 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs @@ -38,12 +38,12 @@ impl Drive { /// * The identity ID does not correspond to a valid full identity. /// #[inline(always)] - pub(super) fn verify_full_identity_by_public_key_hash_v0( + pub(super) fn verify_full_identity_by_unique_public_key_hash_v0( proof: &[u8], public_key_hash: [u8; 20], platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { - let (root_hash, identity_id) = Self::verify_identity_id_by_public_key_hash( + let (root_hash, identity_id) = Self::verify_identity_id_by_unique_public_key_hash( proof, true, public_key_hash, diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs new file mode 100644 index 00000000000..5cf78fb3964 --- /dev/null +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs @@ -0,0 +1,65 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; + +use crate::error::Error; + +use crate::verify::RootHash; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Verifies the identity ID of a user by their public key hash. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `is_proof_subset`: A boolean indicating whether the proof is a subset. + /// - `public_key_hash`: A 20-byte array representing the hash of the public key of the user. + /// - `after`: A 32 byte array representing an identity after which we want to get the identity id. + /// - `platform_version`: The platform version against which to verify the identity ID. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option` of a 32-byte array. The `RootHash` represents the root hash of GroveDB, + /// and the `Option<[u8; 32]>` represents the identity ID of the user if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - An unknown or unsupported platform version is provided. + /// - Any other error as documented in the specific versioned function. + /// + pub fn verify_identity_id_by_non_unique_public_key_hash( + proof: &[u8], + is_proof_subset: bool, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option<[u8; 32]>), Error> { + match platform_version + .drive + .methods + .verify + .identity + .verify_identity_id_by_non_unique_public_key_hash + { + 0 => Self::verify_identity_id_by_non_unique_public_key_hash_v0( + proof, + is_proof_subset, + public_key_hash, + after, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_identity_id_by_non_unique_public_key_hash".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs new file mode 100644 index 00000000000..01429e1e628 --- /dev/null +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs @@ -0,0 +1,78 @@ +use crate::drive::{non_unique_key_hashes_sub_tree_path_vec, Drive}; + +use crate::error::proof::ProofError; +use crate::error::Error; + +use crate::verify::RootHash; + +use grovedb::GroveDb; +use platform_version::version::PlatformVersion; + +impl Drive { + /// Verifies the identity ID of a user by their public key hash. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `is_proof_subset`: A boolean indicating whether the proof is a subset. + /// - `public_key_hash`: A 20-byte array representing the hash of the public key of the user. + /// - `after`: A 32 byte array representing an identity after which we want to get the identity id. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option` of a 32-byte array. The `RootHash` represents the root hash of GroveDB, + /// and the `Option<[u8; 32]>` represents the identity ID of the user if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof of authentication is not valid. + /// - The public key hash does not correspond to a valid identity ID. + /// - The proved key value is not for the correct path or key in unique key hashes. + /// - More than one identity ID is found. + /// + #[inline(always)] + pub(super) fn verify_identity_id_by_non_unique_public_key_hash_v0( + proof: &[u8], + is_proof_subset: bool, + public_key_hash: [u8; 20], + after: Option<[u8;32]>, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option<[u8; 32]>), Error> { + let mut path_query = Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); + path_query.query.limit = Some(1); + let (root_hash, mut proved_key_values) = if is_proof_subset { + GroveDb::verify_subset_query( + proof, + &path_query, + &platform_version.drive.grove_version, + )? + } else { + GroveDb::verify_query( + proof, + &path_query, + &platform_version.drive.grove_version, + )? + }; + + if proved_key_values.len() == 1 { + let (path, key, _) = proved_key_values.remove(0); + if path != non_unique_key_hashes_sub_tree_path_vec(public_key_hash) { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back an element for the correct path in non unique key hashes" + .to_string(), + ))); + } + let identity_id = key + .try_into() + .map_err(|_| { + Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) + })?; + Ok((root_hash, Some(identity_id))) + } else { + Ok((root_hash, None)) + } + } +} diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs similarity index 86% rename from packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/mod.rs rename to packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs index 75182ffeefc..4422e600e01 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs @@ -33,7 +33,7 @@ impl Drive { /// - An unknown or unsupported platform version is provided. /// - Any other error as documented in the specific versioned function. /// - pub fn verify_identity_id_by_public_key_hash( + pub fn verify_identity_id_by_unique_public_key_hash( proof: &[u8], is_proof_subset: bool, public_key_hash: [u8; 20], @@ -44,16 +44,16 @@ impl Drive { .methods .verify .identity - .verify_identity_id_by_public_key_hash + .verify_identity_id_by_unique_public_key_hash { - 0 => Self::verify_identity_id_by_public_key_hash_v0( + 0 => Self::verify_identity_id_by_unique_public_key_hash_v0( proof, is_proof_subset, public_key_hash, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "verify_identity_id_by_public_key_hash".to_string(), + method: "verify_identity_id_by_unique_public_key_hash".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs similarity index 98% rename from packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/v0/mod.rs rename to packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs index ceb8ae05b07..cccc1aa0f15 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_id_by_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs @@ -33,7 +33,7 @@ impl Drive { /// - More than one identity ID is found. /// #[inline(always)] - pub(super) fn verify_identity_id_by_public_key_hash_v0( + pub(super) fn verify_identity_id_by_unique_public_key_hash_v0( proof: &[u8], is_proof_subset: bool, public_key_hash: [u8; 20], diff --git a/packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/mod.rs similarity index 87% rename from packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/mod.rs rename to packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/mod.rs index 20a9d98c3d8..6d1f70f8a04 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/mod.rs @@ -36,7 +36,7 @@ impl Drive { /// - An unknown or unsupported platform version is provided. /// - Any other error as documented in the specific versioned function. /// - pub fn verify_identity_ids_by_public_key_hashes< + pub fn verify_identity_ids_by_unique_public_key_hashes< T: FromIterator<([u8; 20], Option<[u8; 32]>)>, >( proof: &[u8], @@ -49,16 +49,16 @@ impl Drive { .methods .verify .identity - .verify_identity_ids_by_public_key_hashes + .verify_identity_ids_by_unique_public_key_hashes { - 0 => Self::verify_identity_ids_by_public_key_hashes_v0( + 0 => Self::verify_identity_ids_by_unique_public_key_hashes_v0( proof, is_proof_subset, public_key_hashes, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "verify_identity_ids_by_public_key_hashes".to_string(), + method: "verify_identity_ids_by_unique_public_key_hashes".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/v0/mod.rs similarity index 98% rename from packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/v0/mod.rs rename to packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/v0/mod.rs index 6d1c6dc7d85..90beab8eaf3 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_ids_by_public_key_hashes/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/v0/mod.rs @@ -37,7 +37,7 @@ impl Drive { /// - The number of proved key values does not match the number of public key hashes provided. /// - The value size of the identity ID is incorrect. /// - pub(crate) fn verify_identity_ids_by_public_key_hashes_v0< + pub(crate) fn verify_identity_ids_by_unique_public_key_hashes_v0< T: FromIterator<([u8; 20], Option<[u8; 32]>)>, >( proof: &[u8], diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs index 7a5d65bd3ea..ac3412fd85e 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs @@ -52,7 +52,7 @@ pub struct DriveAbciQueryIdentityVersions { pub balance: FeatureVersionBounds, pub identities_balances: FeatureVersionBounds, pub balance_and_revision: FeatureVersionBounds, - pub identity_by_public_key_hash: FeatureVersionBounds, + pub identity_by_unique_public_key_hash: FeatureVersionBounds, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs index 494dfa6f097..829c9a218d2 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs @@ -67,7 +67,7 @@ pub const DRIVE_ABCI_QUERY_VERSIONS_V1: DriveAbciQueryVersions = DriveAbciQueryV max_version: 0, default_current_version: 0, }, - identity_by_public_key_hash: FeatureVersionBounds { + identity_by_unique_public_key_hash: FeatureVersionBounds { min_version: 0, max_version: 0, default_current_version: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs index 7528ec11a40..6930d7e4930 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs @@ -94,6 +94,7 @@ pub struct DriveIdentityFetchPublicKeyHashesMethodVersions { pub has_non_unique_public_key_hash: FeatureVersion, pub has_non_unique_public_key_hash_already_for_identity: FeatureVersion, pub has_unique_public_key_hash: FeatureVersion, + pub fetch_full_identity_by_non_unique_public_key_hash: FeatureVersion, } #[derive(Clone, Debug, Default)] @@ -132,6 +133,7 @@ pub struct DriveIdentityProveMethodVersions { pub prove_full_identity_by_unique_public_key_hash: FeatureVersion, pub prove_identity_id_by_unique_public_key_hash: FeatureVersion, pub prove_identity_ids_by_unique_public_key_hashes: FeatureVersion, + pub prove_full_identity_by_non_unique_public_key_hash: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs index 3db719ae7fa..f3c1bedd59f 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs @@ -27,6 +27,7 @@ pub const DRIVE_IDENTITY_METHOD_VERSIONS_V1: DriveIdentityMethodVersions = has_non_unique_public_key_hash: 0, has_non_unique_public_key_hash_already_for_identity: 0, has_unique_public_key_hash: 0, + fetch_full_identity_by_non_unique_public_key_hash: 0, }, attributes: DriveIdentityFetchAttributesMethodVersions { revision: 0, @@ -58,6 +59,7 @@ pub const DRIVE_IDENTITY_METHOD_VERSIONS_V1: DriveIdentityMethodVersions = prove_full_identity_by_unique_public_key_hash: 0, prove_identity_id_by_unique_public_key_hash: 0, prove_identity_ids_by_unique_public_key_hashes: 0, + prove_full_identity_by_non_unique_public_key_hash: 0, }, keys: DriveIdentityKeysMethodVersions { fetch: DriveIdentityKeysFetchMethodVersions { diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs index f8082f48198..90cd83d5291 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs @@ -35,13 +35,15 @@ pub struct DriveVerifyIdentityMethodVersions { pub verify_full_identity_by_public_key_hash: FeatureVersion, pub verify_identity_balance_for_identity_id: FeatureVersion, pub verify_identity_balances_for_identity_ids: FeatureVersion, - pub verify_identity_id_by_public_key_hash: FeatureVersion, - pub verify_identity_ids_by_public_key_hashes: FeatureVersion, + pub verify_identity_id_by_unique_public_key_hash: FeatureVersion, + pub verify_identity_ids_by_unique_public_key_hashes: FeatureVersion, pub verify_identity_keys_by_identity_id: FeatureVersion, pub verify_identity_nonce: FeatureVersion, pub verify_identity_contract_nonce: FeatureVersion, pub verify_identities_contract_keys: FeatureVersion, pub verify_identity_revision_for_identity_id: FeatureVersion, + pub verify_full_identity_by_non_unique_public_key_hash: FeatureVersion, + pub verify_identity_id_by_non_unique_public_key_hash: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs index 666ab416ca7..a848e92c7dd 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs @@ -21,13 +21,15 @@ pub const DRIVE_VERIFY_METHOD_VERSIONS_V1: DriveVerifyMethodVersions = DriveVeri verify_full_identity_by_public_key_hash: 0, verify_identity_balance_for_identity_id: 0, verify_identity_balances_for_identity_ids: 0, - verify_identity_id_by_public_key_hash: 0, - verify_identity_ids_by_public_key_hashes: 0, + verify_identity_id_by_unique_public_key_hash: 0, + verify_identity_ids_by_unique_public_key_hashes: 0, verify_identity_keys_by_identity_id: 0, verify_identity_nonce: 0, verify_identity_contract_nonce: 0, verify_identities_contract_keys: 0, verify_identity_revision_for_identity_id: 0, + verify_full_identity_by_non_unique_public_key_hash: 0, + verify_identity_id_by_non_unique_public_key_hash: 0, }, group: DriveVerifyGroupMethodVersions { verify_group_info: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 9a11e69178a..b9d2e964a33 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -200,7 +200,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, - identity_by_public_key_hash: FeatureVersionBounds { + identity_by_unique_public_key_hash: FeatureVersionBounds { min_version: 0, max_version: 0, default_current_version: 0, From 8d997084709fd5bb39f415ea26bd65adf1ffe71d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 6 Mar 2025 21:04:45 +0700 Subject: [PATCH 02/14] more work --- .../protos/platform/v0/platform.proto | 7 +- .../mod.rs | 5 +- .../v0/mod.rs | 108 ++++++++----- .../src/query/identity_based_queries/mod.rs | 2 +- packages/rs-drive-abci/src/query/service.rs | 43 +++++- .../mod.rs | 2 +- .../v0/mod.rs | 4 +- .../mod.rs | 12 +- .../v0/mod.rs | 11 +- .../fetch/fetch_by_public_key_hashes/mod.rs | 2 +- .../src/drive/identity/fetch/prove/mod.rs | 2 +- .../mod.rs | 41 +++-- .../v0/mod.rs | 145 ++++++++---------- .../src/drive/identity/fetch/queries/mod.rs | 18 ++- ...non_unique_public_key_hash_double_proof.rs | 21 +++ packages/rs-drive/src/drive/identity/mod.rs | 4 + packages/rs-drive/src/verify/identity/mod.rs | 4 +- .../mod.rs | 43 ++++-- .../v0/mod.rs | 56 ++++--- .../mod.rs | 2 +- .../v0/mod.rs | 25 +-- 21 files changed, 340 insertions(+), 217 deletions(-) create mode 100644 packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 5cf0a4c7fdd..b2d0c3defef 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -636,9 +636,14 @@ message GetIdentityByNonUniquePublicKeyHashResponse { message IdentityResponse { optional bytes identity = 1; } + + message IdentityProvedResponse { + Proof grovedb_identity_public_key_hash_proof = 1; + optional bytes identity_proof_bytes = 2; // A hack, we return 2 proofs + } oneof result { IdentityResponse identity = 1; - Proof proof = 2; + IdentityProvedResponse proof = 2; } ResponseMetadata metadata = 3; // Metadata about the blockchain state diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs index 8bfd4ed12e3..33403fad6a5 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs @@ -5,7 +5,10 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, GetIdentityByPublicKeyHashResponse}; +use dapi_grpc::platform::v0::{ + GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, + GetIdentityByPublicKeyHashResponse, +}; use dpp::version::PlatformVersion; mod v0; diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs index 07f23174845..a9a3ac7dd42 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs @@ -7,7 +7,7 @@ use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request: use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::{ get_identity_by_non_unique_public_key_hash_response_v0, GetIdentityByNonUniquePublicKeyHashResponseV0, }; -use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::get_identity_by_non_unique_public_key_hash_response_v0::IdentityResponse; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::get_identity_by_non_unique_public_key_hash_response_v0::{IdentityProvedResponse, IdentityResponse}; use dpp::check_validation_result_with_data; use dpp::platform_value::{Bytes20, Bytes32}; use dpp::serialization::PlatformSerializable; @@ -19,7 +19,7 @@ impl Platform { &self, GetIdentityByNonUniquePublicKeyHashRequestV0 { public_key_hash, - start_after, + start_after, prove, }: GetIdentityByNonUniquePublicKeyHashRequestV0, platform_state: &PlatformState, @@ -33,46 +33,58 @@ impl Platform { ))); let start_after = if let Some(start_after) = start_after { - Some(check_validation_result_with_data!(Bytes32::from_vec(start_after) - .map(|bytes| bytes.0) - .map_err(|_| QueryError::InvalidArgument( - "public key hash must be 20 bytes long".to_string() - )))) + Some(check_validation_result_with_data!(Bytes32::from_vec( + start_after + ) + .map(|bytes| bytes.0) + .map_err(|_| QueryError::InvalidArgument( + "public key hash must be 20 bytes long".to_string() + )))) } else { None }; - let response = if prove { - let proof = self.drive.prove_full_identity_by_non_unique_public_key_hash( - public_key_hash, - start_after, - None, - platform_version, - )?; + let proof = self + .drive + .prove_full_identity_by_non_unique_public_key_hash( + public_key_hash, + start_after, + None, + platform_version, + )?; GetIdentityByNonUniquePublicKeyHashResponseV0 { - result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof( - self.response_proof_v0(platform_state, proof), - )), + result: Some( + get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof( + IdentityProvedResponse { + grovedb_identity_public_key_hash_proof: Some(self.response_proof_v0( + platform_state, + proof.identity_id_public_key_hash_proof, + )), + identity_proof_bytes: proof.identity_proof, + }, + ), + ), metadata: Some(self.response_metadata_v0(platform_state)), } } else { - let maybe_identity = self.drive.fetch_full_identity_by_non_unique_public_key_hash( - public_key_hash, - start_after, - None, - platform_version, - )?; - - let serialized_identity = maybe_identity.map(|identity| - - identity - .serialize_consume_to_bytes() - .map_err(Error::Protocol) - - ).transpose()?; - + let maybe_identity = self + .drive + .fetch_full_identity_by_non_unique_public_key_hash( + public_key_hash, + start_after, + None, + platform_version, + )?; + + let serialized_identity = maybe_identity + .map(|identity| { + identity + .serialize_consume_to_bytes() + .map_err(Error::Protocol) + }) + .transpose()?; GetIdentityByNonUniquePublicKeyHashResponseV0 { metadata: Some(self.response_metadata_v0(platform_state)), @@ -94,8 +106,8 @@ impl Platform { mod tests { use super::*; use crate::query::tests::setup_platform; - use dpp::dashcore::Network; use dapi_grpc::platform::v0::ResponseMetadata; + use dpp::dashcore::Network; #[test] fn test_invalid_public_key_hash() { @@ -132,12 +144,24 @@ mod tests { .query_identity_by_non_unique_public_key_hash_v0(request, &state, version) .expect("expected query to succeed"); - assert_eq!(result.data, Some(GetIdentityByNonUniquePublicKeyHashResponseV0 { - metadata: Some(ResponseMetadata { height: 0, core_chain_locked_height: 0, epoch: 0, time_ms: 0, protocol_version: 9, chain_id: "chain_id".to_string() }), - result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Identity(IdentityResponse { - identity: None, - })), - })); + assert_eq!( + result.data, + Some(GetIdentityByNonUniquePublicKeyHashResponseV0 { + metadata: Some(ResponseMetadata { + height: 0, + core_chain_locked_height: 0, + epoch: 0, + time_ms: 0, + protocol_version: 9, + chain_id: "chain_id".to_string() + }), + result: Some( + get_identity_by_non_unique_public_key_hash_response_v0::Result::Identity( + IdentityResponse { identity: None } + ) + ), + }) + ); } #[test] @@ -158,9 +182,9 @@ mod tests { assert!(matches!( result.data, Some(GetIdentityByNonUniquePublicKeyHashResponseV0 { - result: Some(get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof( - _ - )), + result: Some( + get_identity_by_non_unique_public_key_hash_response_v0::Result::Proof(_) + ), metadata: Some(_), }) )); diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs index f42ff1c4412..98b92b25128 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/mod.rs @@ -3,8 +3,8 @@ mod balance_and_revision; mod balances; mod identities_contract_keys; mod identity; -mod identity_by_unique_public_key_hash; mod identity_by_non_unique_public_key_hash; +mod identity_by_unique_public_key_hash; mod identity_contract_nonce; mod identity_nonce; mod keys; diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 09a0dc9853e..9d77f180745 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -9,7 +9,41 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetCurrentQuorumsInfoRequest, GetCurrentQuorumsInfoResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetEvonodesProposedEpochBlocksByIdsRequest, GetEvonodesProposedEpochBlocksByRangeRequest, GetEvonodesProposedEpochBlocksResponse, GetGroupActionSignersRequest, GetGroupActionSignersResponse, GetGroupActionsRequest, GetGroupActionsResponse, GetGroupInfoRequest, GetGroupInfoResponse, GetGroupInfosRequest, GetGroupInfosResponse, GetIdentitiesBalancesRequest, GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentitiesTokenBalancesRequest, GetIdentitiesTokenBalancesResponse, GetIdentitiesTokenInfosRequest, GetIdentitiesTokenInfosResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetIdentityTokenBalancesRequest, GetIdentityTokenBalancesResponse, GetIdentityTokenInfosRequest, GetIdentityTokenInfosResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, GetStatusRequest, GetStatusResponse, GetTokenPreProgrammedDistributionsRequest, GetTokenPreProgrammedDistributionsResponse, GetTokenStatusesRequest, GetTokenStatusesResponse, GetTokenTotalSupplyRequest, GetTokenTotalSupplyResponse, GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse}; +use dapi_grpc::platform::v0::{ + BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, + GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, + GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, + GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, + GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, + GetContestedResourcesResponse, GetCurrentQuorumsInfoRequest, GetCurrentQuorumsInfoResponse, + GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, + GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, + GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, + GetEvonodesProposedEpochBlocksByIdsRequest, GetEvonodesProposedEpochBlocksByRangeRequest, + GetEvonodesProposedEpochBlocksResponse, GetGroupActionSignersRequest, + GetGroupActionSignersResponse, GetGroupActionsRequest, GetGroupActionsResponse, + GetGroupInfoRequest, GetGroupInfoResponse, GetGroupInfosRequest, GetGroupInfosResponse, + GetIdentitiesBalancesRequest, GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, + GetIdentitiesContractKeysResponse, GetIdentitiesTokenBalancesRequest, + GetIdentitiesTokenBalancesResponse, GetIdentitiesTokenInfosRequest, + GetIdentitiesTokenInfosResponse, GetIdentityBalanceAndRevisionRequest, + GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, + GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, + GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, + GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, + GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, + GetIdentityResponse, GetIdentityTokenBalancesRequest, GetIdentityTokenBalancesResponse, + GetIdentityTokenInfosRequest, GetIdentityTokenInfosResponse, GetPathElementsRequest, + GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, + GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, + GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, + GetStatusRequest, GetStatusResponse, GetTokenPreProgrammedDistributionsRequest, + GetTokenPreProgrammedDistributionsResponse, GetTokenStatusesRequest, GetTokenStatusesResponse, + GetTokenTotalSupplyRequest, GetTokenTotalSupplyResponse, GetTotalCreditsInPlatformRequest, + GetTotalCreditsInPlatformResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, + WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, +}; use dapi_grpc::tonic::{Code, Request, Response, Status}; use dpp::version::PlatformVersion; use std::fmt::Debug; @@ -378,13 +412,16 @@ impl PlatformService for QueryService { .await } - async fn get_identity_by_non_unique_public_key_hash(&self, request: Request) -> Result, Status> { + async fn get_identity_by_non_unique_public_key_hash( + &self, + request: Request, + ) -> Result, Status> { self.handle_blocking_query( request, Platform::::query_identity_by_non_unique_public_key_hash, "get_identity_by_non_unique_public_key_hash", ) - .await + .await } async fn wait_for_state_transition_result( diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs index 58438b01e71..7945cb0799c 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs @@ -25,7 +25,7 @@ impl Drive { pub fn fetch_full_identity_by_non_unique_public_key_hash( &self, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs index 44fb166d486..fa6dd8b1618 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -13,7 +13,7 @@ impl Drive { pub(super) fn fetch_full_identity_by_non_unique_public_key_hash_v0( &self, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -31,7 +31,7 @@ impl Drive { pub(super) fn fetch_full_identity_by_non_unique_public_key_hash_operations_v0( &self, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs index 892d91c7bf5..13c3e8111f8 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs @@ -2,9 +2,9 @@ mod v0; use crate::drive::Drive; use crate::error::{drive::DriveError, Error}; +use crate::fees::op::LowLevelDriveOperation; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::fees::op::LowLevelDriveOperation; impl Drive { /// Fetches identity ids from storage based on a non-unique public key hash. @@ -25,11 +25,12 @@ impl Drive { &self, public_key_hash: [u8; 20], limit: Option, - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - match platform_version.drive + match platform_version + .drive .methods .identity .fetch @@ -55,12 +56,13 @@ impl Drive { &self, public_key_hash: [u8; 20], limit: Option, - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result, Error> { - match platform_version.drive + match platform_version + .drive .methods .identity .fetch diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs index 1eb970654f7..0eeacb54b23 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs @@ -8,8 +8,8 @@ use grovedb::query_result_type::QueryResultType; use grovedb::{PathQuery, TransactionArg}; -use std::ops::RangeFull; use platform_version::version::PlatformVersion; +use std::ops::RangeFull; impl Drive { /// Fetches identity ids from storage. @@ -17,7 +17,7 @@ impl Drive { &self, public_key_hash: [u8; 20], limit: Option, - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -37,7 +37,7 @@ impl Drive { &self, public_key_hash: [u8; 20], limit: Option, - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, @@ -49,10 +49,7 @@ impl Drive { QueryItem::RangeAfter(after.to_vec()..), ) } else { - PathQuery::new_single_query_item( - non_unique_key_hashes, - QueryItem::RangeFull(RangeFull), - ) + PathQuery::new_single_query_item(non_unique_key_hashes, QueryItem::RangeFull(RangeFull)) }; path_query.query.limit = limit; diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs index 849fdbe8626..cbd75b76d42 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs @@ -1,4 +1,5 @@ mod fetch_full_identities_by_unique_public_key_hashes; +mod fetch_full_identity_by_non_unique_public_key_hash; mod fetch_full_identity_by_unique_public_key_hash; mod fetch_identity_id_by_unique_public_key_hash; mod fetch_identity_ids_by_non_unique_public_key_hash; @@ -7,7 +8,6 @@ mod has_any_of_unique_public_key_hashes; mod has_non_unique_public_key_hash; mod has_non_unique_public_key_hash_already_for_identity; mod has_unique_public_key_hash; -mod fetch_full_identity_by_non_unique_public_key_hash; #[cfg(feature = "server")] #[cfg(test)] diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs index 01678cef1eb..7ca607c9f0a 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/mod.rs @@ -1,8 +1,8 @@ mod prove_full_identities; mod prove_full_identities_by_unique_public_key_hashes; mod prove_full_identity; +mod prove_full_identity_by_non_unique_public_key_hash; mod prove_full_identity_by_unique_public_key_hash; mod prove_identities_contract_keys; mod prove_identity_id_by_unique_public_key_hash; mod prove_identity_ids_by_unique_public_key_hashes; -mod prove_full_identity_by_non_unique_public_key_hash; diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs index 5703fc6920b..5712e0df0d4 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs @@ -4,31 +4,54 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; +use crate::drive::identity::identity_and_non_unique_public_key_hash_double_proof::IdentityAndNonUniquePublicKeyHashDoubleProof; use dpp::version::PlatformVersion; use grovedb::TransactionArg; impl Drive { - /// Fetches an identity with all its information from storage. + /// Generates a proof for an identity associated with a given non-unique public key hash. /// - /// This function uses the versioning system to call the appropriate handler based on the provided `DriveVersion`. + /// This function retrieves an identity along with its associated proofs from storage. + /// It utilizes versioning to call the appropriate handler based on the provided + /// `PlatformVersion`. /// /// # Arguments /// - /// * `public_key_hash` - The public key hash for which to fetch the identity. - /// * `after` - An identity ID after which we want to get back our identity. Basically "don't get back this identity, get the next one" - /// * `transaction` - Transaction arguments. - /// * `drive_version` - A reference to the drive version. + /// - `public_key_hash` - A 20-byte array representing the hash of the public key + /// for which the identity should be fetched. + /// - `after` - An optional identity ID specifying the starting point for retrieval. + /// If provided, the function will return the identity that appears after the given ID, + /// ensuring that the specified identity itself is not included. + /// - `transaction` - A transaction argument used for database operations. + /// - `platform_version` - A reference to the platform version, ensuring that the + /// correct version-specific function is used. /// /// # Returns /// - /// Returns a `Result` containing a vector of bytes representing the proved identity, otherwise an `Error` if the operation fails or the version is not supported. + /// Returns a `Result` containing an [`IdentityAndNonUniquePublicKeyHashDoubleProof`], which + /// includes both the proof of the identity and the proof linking the public key hash to + /// an identity ID. If the operation fails or the platform version is unsupported, an `Error` + /// is returned. + /// + /// # Errors + /// + /// This function will return an `Error` if: + /// - The identity retrieval operation fails. + /// - The provided public key hash does not correspond to a known identity. + /// - The requested platform version is unknown or not supported. + /// + /// # Versioning + /// + /// - Currently, only version `0` of `prove_full_identity_by_non_unique_public_key_hash` + /// is implemented. If an unsupported version is provided, an `UnknownVersionMismatch` + /// error is returned. pub fn prove_full_identity_by_non_unique_public_key_hash( &self, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs index 7231d8bee9b..93c8d26c519 100644 --- a/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -2,6 +2,7 @@ use crate::drive::Drive; use crate::error::Error; +use crate::drive::identity::identity_and_non_unique_public_key_hash_double_proof::IdentityAndNonUniquePublicKeyHashDoubleProof; use dpp::version::PlatformVersion; use grovedb::TransactionArg; @@ -10,10 +11,10 @@ impl Drive { pub(super) fn prove_full_identity_by_non_unique_public_key_hash_v0( &self, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result { let identity_ids = self.fetch_identity_ids_by_non_unique_public_key_hash_operations( public_key_hash, Some(1), @@ -22,36 +23,38 @@ impl Drive { &mut vec![], platform_version, )?; - if let Some(identity_id) = identity_ids.first() { - let query = Self::full_identity_with_non_unique_public_key_hash_query( - public_key_hash, - *identity_id, - after, - &platform_version.drive.grove_version, - )?; - self.grove_get_proved_path_query( - &query, + // We only prove the absence of the public key hash + let mut path_query = + Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); + path_query.query.limit = Some(1); + let identity_id_public_key_hash_proof = self.grove_get_proved_path_query( + &path_query, + transaction, + &mut vec![], + &platform_version.drive, + )?; + let identity_proof = if let Some(identity_id) = identity_ids.first() { + let full_identity_query = + Self::full_identity_query(&identity_id, &platform_version.drive.grove_version)?; + Some(self.grove_get_proved_path_query( + &full_identity_query, transaction, &mut vec![], &platform_version.drive, - ) + )?) } else { - // We only prove the absence of the public key hash - let query = Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); - self.grove_get_proved_path_query( - &query, - transaction, - &mut vec![], - &platform_version.drive, - ) - } + None + }; + + Ok(IdentityAndNonUniquePublicKeyHashDoubleProof { + identity_proof, + identity_id_public_key_hash_proof, + }) } } #[cfg(test)] mod tests { - use rand::prelude::StdRng; - use rand::SeedableRng; use super::*; use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; use dpp::block::block_info::BlockInfo; @@ -60,9 +63,11 @@ mod tests { use dpp::identity::identity_public_key::methods::hash::IdentityPublicKeyHashMethodsV0; use dpp::identity::{Identity, IdentityPublicKey, KeyType}; use dpp::version::PlatformVersion; + use rand::prelude::StdRng; + use rand::SeedableRng; #[test] - fn should_prove_a_single_identity() { + fn should_prove_a_single_identity_with_non_unique_key() { let drive = setup_drive_with_initial_state_structure(None); let platform_version = PlatformVersion::latest(); @@ -84,64 +89,27 @@ mod tests { let first_key_hash = identity .public_keys() .values() - .find(|public_key| public_key.key_type().is_unique_key_type()) + .find(|public_key| !public_key.key_type().is_unique_key_type()) .expect("expected a unique key") .public_key_hash() .expect("expected to hash data"); let proof = drive - .prove_full_identity_by_unique_public_key_hash(first_key_hash, None, platform_version) - .expect("should not error when proving an identity"); - - let (_, proved_identity) = Drive::verify_full_identity_by_unique_public_key_hash( - proof.as_slice(), - first_key_hash, - platform_version, - ) - .expect("expect that this be verified"); - - assert_eq!(proved_identity, Some(identity)); - } - - #[test] - fn should_prove_a_single_identity_with_non_unique_key() { - let drive = setup_drive_with_initial_state_structure(None); - - let platform_version = PlatformVersion::latest(); - - let identity = Identity::random_identity(3, Some(14), platform_version) - .expect("expected a random identity"); - - drive - .add_new_identity( - identity.clone(), - false, - &BlockInfo::default(), - true, + .prove_full_identity_by_non_unique_public_key_hash( + first_key_hash, + None, None, platform_version, ) - .expect("expected to add an identity"); - - let first_key_hash = identity - .public_keys() - .values() - .find(|public_key| !public_key.key_type().is_unique_key_type()) - .expect("expected a unique key") - .public_key_hash() - .expect("expected to hash data"); - - let proof = drive - .prove_full_identity_by_non_unique_public_key_hash(first_key_hash, None, None, platform_version) .expect("should not error when proving an identity"); let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( - proof.as_slice(), + &proof, first_key_hash, None, platform_version, ) - .expect("expect that this be verified"); + .expect("expect that this be verified"); assert_eq!(proved_identity, Some(identity)); } @@ -159,12 +127,14 @@ mod tests { .expect("expected a random identity"); let mut rng = StdRng::seed_from_u64(506); - - let key = IdentityPublicKey::random_voting_key_with_rng(3, &mut rng, platform_version).expect("expected key").0; + + let key = IdentityPublicKey::random_voting_key_with_rng(3, &mut rng, platform_version) + .expect("expected key") + .0; identity_1.add_public_key(key.clone()); identity_2.add_public_key(key.clone()); - + drive .add_new_identity( identity_1.clone(), @@ -186,48 +156,63 @@ mod tests { platform_version, ) .expect("expected to add an identity"); - + let key_hash = key.public_key_hash().expect("expected key hash"); let proof = drive - .prove_full_identity_by_non_unique_public_key_hash(key_hash, None, None, platform_version) + .prove_full_identity_by_non_unique_public_key_hash( + key_hash, + None, + None, + platform_version, + ) .expect("should not error when proving an identity"); let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( - proof.as_slice(), + &proof, key_hash, None, platform_version, ) - .expect("expect that this be verified"); + .expect("expect that this be verified"); assert_eq!(proved_identity, Some(identity_1.clone())); let proof = drive - .prove_full_identity_by_non_unique_public_key_hash(key_hash, Some(identity_1.id().to_buffer()), None, platform_version) + .prove_full_identity_by_non_unique_public_key_hash( + key_hash, + Some(identity_1.id().to_buffer()), + None, + platform_version, + ) .expect("should not error when proving an identity"); let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( - proof.as_slice(), + &proof, key_hash, Some(identity_1.id().to_buffer()), platform_version, ) - .expect("expect that this be verified"); + .expect("expect that this be verified"); assert_eq!(proved_identity, Some(identity_2.clone())); let proof = drive - .prove_full_identity_by_non_unique_public_key_hash(key_hash, Some(identity_2.id().to_buffer()), None, platform_version) + .prove_full_identity_by_non_unique_public_key_hash( + key_hash, + Some(identity_2.id().to_buffer()), + None, + platform_version, + ) .expect("should not error when proving an identity"); let (_, proved_identity) = Drive::verify_full_identity_by_non_unique_public_key_hash( - proof.as_slice(), + &proof, key_hash, Some(identity_2.id().to_buffer()), platform_version, ) - .expect("expect that this be verified"); + .expect("expect that this be verified"); assert_eq!(proved_identity, None); } diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index 685b7353c46..6e1b1e4b65d 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -1,6 +1,9 @@ use crate::drive::balances::balance_path_vec; use crate::drive::identity::key::fetch::IdentityKeysRequest; -use crate::drive::{identity_tree_path_vec, non_unique_key_hashes_tree_path, non_unique_key_hashes_tree_path_vec, unique_key_hashes_tree_path_vec, Drive}; +use crate::drive::{ + identity_tree_path_vec, non_unique_key_hashes_tree_path, non_unique_key_hashes_tree_path_vec, + unique_key_hashes_tree_path_vec, Drive, +}; use std::ops::RangeFull; use crate::error::Error; @@ -92,13 +95,14 @@ impl Drive { /// The query for proving an identity id from a non-unique public key hash. /// This should be used for absence proofs - pub fn identity_id_by_non_unique_public_key_hash_query(public_key_hash: [u8; 20], after: Option<[u8;32]>) -> PathQuery { + pub fn identity_id_by_non_unique_public_key_hash_query( + public_key_hash: [u8; 20], + after: Option<[u8; 32]>, + ) -> PathQuery { let non_unique_key_hashes = non_unique_key_hashes_tree_path_vec(); let mut query = Query::new_single_key(public_key_hash.to_vec()); let sub_query = if let Some(after) = after { - Query::new_single_query_item(QueryItem::RangeFrom( - after.to_vec().., - )) + Query::new_single_query_item(QueryItem::RangeFrom(after.to_vec()..)) } else { Query::new_range_full() }; @@ -233,7 +237,7 @@ impl Drive { pub fn full_identity_with_non_unique_public_key_hash_query( public_key_hash: [u8; 20], identity_id: [u8; 32], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, grove_version: &GroveVersion, ) -> Result { let full_identity_query = Self::full_identity_query(&identity_id, grove_version)?; @@ -243,7 +247,7 @@ impl Drive { vec![&full_identity_query, &identity_id_by_public_key_hash_query], grove_version, ) - .map_err(Error::GroveDB) + .map_err(Error::GroveDB) } /// The query full identities with key hashes too diff --git a/packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs b/packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs new file mode 100644 index 00000000000..ccd439ca080 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs @@ -0,0 +1,21 @@ +/// Represents a proof containing an optional identity proof and a required +/// proof for the identity ID and non-unique public key hash. +/// +/// This struct is used to verify the authenticity and validity of an identity +/// and its associated non-unique public key hash. +/// +/// # Fields +/// +/// * `identity_proof` - An optional proof for the identity, represented as a +/// serialized byte vector. This may be `None` if no additional proof is required. +/// * `identity_id_public_key_hash_proof` - A required proof verifying the +/// association between an identity ID and its non-unique public key hash, +/// stored as a serialized byte vector. +pub struct IdentityAndNonUniquePublicKeyHashDoubleProof { + /// Optional proof of identity, stored as a serialized byte vector. + pub identity_proof: Option>, + + /// Proof linking an identity ID to a non-unique public key hash, + /// stored as a serialized byte vector. + pub identity_id_public_key_hash_proof: Vec, +} diff --git a/packages/rs-drive/src/drive/identity/mod.rs b/packages/rs-drive/src/drive/identity/mod.rs index 1922e74b884..a75be0ea563 100644 --- a/packages/rs-drive/src/drive/identity/mod.rs +++ b/packages/rs-drive/src/drive/identity/mod.rs @@ -40,6 +40,10 @@ pub mod key; #[cfg(feature = "server")] pub mod update; +/// A module for a struct encapsulating an identity and a non-unique public key hash to identity id proof +#[cfg(any(feature = "server", feature = "verify"))] +pub mod identity_and_non_unique_public_key_hash_double_proof; + use crate::drive::identity::contract_info::ContractInfoStructure; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/verify/identity/mod.rs b/packages/rs-drive/src/verify/identity/mod.rs index 9e0482bc79e..a9308182abb 100644 --- a/packages/rs-drive/src/verify/identity/mod.rs +++ b/packages/rs-drive/src/verify/identity/mod.rs @@ -1,15 +1,15 @@ mod verify_full_identities_by_public_key_hashes; mod verify_full_identity_by_identity_id; -mod verify_full_identity_by_unique_public_key_hash; mod verify_full_identity_by_non_unique_public_key_hash; +mod verify_full_identity_by_unique_public_key_hash; mod verify_identities_contract_keys; mod verify_identity_balance_and_revision_for_identity_id; mod verify_identity_balance_for_identity_id; mod verify_identity_balances_for_identity_ids; mod verify_identity_contract_nonce; +mod verify_identity_id_by_non_unique_public_key_hash; mod verify_identity_id_by_unique_public_key_hash; mod verify_identity_ids_by_unique_public_key_hashes; mod verify_identity_keys_by_identity_id; mod verify_identity_nonce; mod verify_identity_revision_for_identity_id; -mod verify_identity_id_by_non_unique_public_key_hash; diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs index b290bec46fe..4e593caeb67 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs @@ -10,37 +10,50 @@ use crate::verify::RootHash; pub use dpp::prelude::Identity; +use crate::drive::identity::identity_and_non_unique_public_key_hash_double_proof::IdentityAndNonUniquePublicKeyHashDoubleProof; use dpp::version::PlatformVersion; impl Drive { - /// Verifies the full identity of a user by their public key hash. + /// Verifies the full identity of a user using their non-unique public key hash. + /// + /// This function acts as a dispatcher that selects the appropriate version-specific + /// verification method based on the provided platform version. /// /// # Parameters /// - /// - `proof`: A byte slice representing the proof of authentication from the user. - /// - `public_key_hash`: A 20-byte array representing the hash of the public key of the user. - /// - `after`: A 32 byte array representing an identity after which we want to get the identity. - /// - `platform_version`: The platform version against which to verify the identity. + /// - `proof`: A proof containing both the identity proof (if applicable) and the + /// proof linking the public key hash to an identity ID. + /// - `public_key_hash`: A 20-byte array representing the hash of the user's public key. + /// - `after`: An optional 32-byte array specifying an identity after which + /// the search should begin when retrieving the identity. + /// - `platform_version`: A reference to the platform version, ensuring that + /// the correct verification method is used. /// /// # Returns /// - /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and - /// an `Option` of `Identity`. The `RootHash` represents the root hash of GroveDB, and the - /// `Option` represents the full identity of the user if it exists. + /// Returns a `Result` containing: + /// - `RootHash`: The root hash of GroveDB after verification. + /// - `Option`: The full identity of the user, if it exists. /// - /// # Errors + /// If no identity is found, the returned `Option` will be `None`. /// - /// Returns an `Error` if: + /// # Errors /// - /// - The proof of authentication is not valid. + /// This function returns an `Error` if: + /// - The provided proof is invalid. /// - The public key hash does not correspond to a valid identity ID. - /// - The identity ID does not correspond to a valid full identity. - /// - An unknown or unsupported platform version is provided. + /// - The identity ID exists but does not correspond to a valid full identity. + /// - The provided platform version is unknown or unsupported. + /// + /// # Versioning /// + /// - Currently, only version `0` of `verify_full_identity_by_non_unique_public_key_hash` + /// is implemented. If an unsupported version is provided, an `UnknownVersionMismatch` + /// error is returned. pub fn verify_full_identity_by_non_unique_public_key_hash( - proof: &[u8], + proof: &IdentityAndNonUniquePublicKeyHashDoubleProof, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { match platform_version diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs index ee3024d1a7a..ccb81c1d6fb 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -6,56 +6,70 @@ use crate::verify::RootHash; pub use dpp::prelude::Identity; +use crate::drive::identity::identity_and_non_unique_public_key_hash_double_proof::IdentityAndNonUniquePublicKeyHashDoubleProof; +use crate::error::proof::ProofError; use dpp::version::PlatformVersion; impl Drive { - /// Verifies the full identity of a user by their public key hash. + /// Verifies the full identity of a user using their non-unique public key hash. /// - /// This function takes a byte slice `proof` and a 20-byte array `public_key_hash` as arguments, - /// then it verifies the identity of the user with the given public key hash. + /// This function performs a two-step verification process: + /// 1. It verifies the identity ID associated with the given public key hash + /// by calling [`verify_identity_id_by_non_unique_public_key_hash()`]. + /// 2. If an identity ID is found, it then verifies the full identity by calling + /// [`verify_full_identity_by_identity_id()`]. /// - /// The `proof` should contain the proof of authentication from the user. - /// The `public_key_hash` should contain the hash of the public key of the user. + /// # Arguments /// - /// The function first verifies the identity ID associated with the given public key hash - /// by calling `verify_identity_id_by_non_unique_public_key_hash()`. It then uses this identity ID to verify - /// the full identity by calling `verify_full_identity_by_identity_id()`. + /// * `proof` - A proof containing both the identity proof (if applicable) and + /// the proof linking the public key hash to an identity ID. + /// * `public_key_hash` - A 20-byte array representing the hash of the user's public key. + /// * `after` - An optional 32-byte array used to specify a search point in the proof verification process. + /// * `platform_version` - A reference to the platform version, ensuring compatibility. /// /// # Returns /// - /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and - /// an `Option` of `Identity`. The `RootHash` represents the root hash of GroveDB, and the - /// `Option` represents the full identity of the user if it exists. + /// If verification is successful, returns a `Result` containing: + /// - `RootHash` - The root hash of GroveDB after verification. + /// - `Option` - The full identity of the user, if it exists. /// - /// If the verification fails at any point, it will return an `Error`. + /// If no identity is found, the returned `Option` will be `None`. /// /// # Errors /// /// This function will return an `Error` if: - /// - /// * The proof of authentication is not valid. + /// * The provided proof is invalid. /// * The public key hash does not correspond to a valid identity ID. - /// * The identity ID does not correspond to a valid full identity. + /// * The identity ID exists but the associated identity proof is missing. + /// * The identity verification process fails. + /// + /// # Inline Optimization /// + /// This function is marked with `#[inline(always)]` to hint the compiler to + /// aggressively inline it for performance optimization. #[inline(always)] pub(super) fn verify_full_identity_by_non_unique_public_key_hash_v0( - proof: &[u8], + proof: &IdentityAndNonUniquePublicKeyHashDoubleProof, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { let (root_hash, identity_id) = Self::verify_identity_id_by_non_unique_public_key_hash( - proof, - true, + &proof.identity_id_public_key_hash_proof, + false, public_key_hash, after, platform_version, )?; let maybe_identity = identity_id .map(|identity_id| { + let Some(identity_proof) = &proof.identity_proof else { + return Err(Error::Proof(ProofError::IncompleteProof("identity is not in proof even though identity id is set from non unique public key hash"))); + }; + println!("hex {}", hex::encode(&identity_proof)); Self::verify_full_identity_by_identity_id( - proof, - true, + identity_proof.as_slice(), + false, identity_id, platform_version, ) diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs index 5cf78fb3964..0d1ccae9f99 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs @@ -38,7 +38,7 @@ impl Drive { proof: &[u8], is_proof_subset: bool, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option<[u8; 32]>), Error> { match platform_version diff --git a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs index 01429e1e628..1d3730b5562 100644 --- a/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs @@ -38,23 +38,16 @@ impl Drive { proof: &[u8], is_proof_subset: bool, public_key_hash: [u8; 20], - after: Option<[u8;32]>, + after: Option<[u8; 32]>, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option<[u8; 32]>), Error> { - let mut path_query = Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); + let mut path_query = + Self::identity_id_by_non_unique_public_key_hash_query(public_key_hash, after); path_query.query.limit = Some(1); let (root_hash, mut proved_key_values) = if is_proof_subset { - GroveDb::verify_subset_query( - proof, - &path_query, - &platform_version.drive.grove_version, - )? + GroveDb::verify_subset_query(proof, &path_query, &platform_version.drive.grove_version)? } else { - GroveDb::verify_query( - proof, - &path_query, - &platform_version.drive.grove_version, - )? + GroveDb::verify_query(proof, &path_query, &platform_version.drive.grove_version)? }; if proved_key_values.len() == 1 { @@ -65,11 +58,9 @@ impl Drive { .to_string(), ))); } - let identity_id = key - .try_into() - .map_err(|_| { - Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) - })?; + let identity_id = key.try_into().map_err(|_| { + Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) + })?; Ok((root_hash, Some(identity_id))) } else { Ok((root_hash, None)) From c97b77be71b46eb89e380bcdf3025984c1344a38 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 10 Mar 2025 12:48:33 +0100 Subject: [PATCH 03/14] fix(drive): invalid range operator in unique public key hash query --- packages/rs-drive/src/drive/identity/fetch/queries/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index 6e1b1e4b65d..d6319239947 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -1,8 +1,8 @@ use crate::drive::balances::balance_path_vec; use crate::drive::identity::key::fetch::IdentityKeysRequest; use crate::drive::{ - identity_tree_path_vec, non_unique_key_hashes_tree_path, non_unique_key_hashes_tree_path_vec, - unique_key_hashes_tree_path_vec, Drive, + identity_tree_path_vec, non_unique_key_hashes_tree_path_vec, unique_key_hashes_tree_path_vec, + Drive, }; use std::ops::RangeFull; @@ -102,7 +102,7 @@ impl Drive { let non_unique_key_hashes = non_unique_key_hashes_tree_path_vec(); let mut query = Query::new_single_key(public_key_hash.to_vec()); let sub_query = if let Some(after) = after { - Query::new_single_query_item(QueryItem::RangeFrom(after.to_vec()..)) + Query::new_single_query_item(QueryItem::RangeAfter(after.to_vec()..)) } else { Query::new_range_full() }; From 445d22ba485942e458cf3161233c5ec66d365244 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 12 Mar 2025 15:51:12 +0100 Subject: [PATCH 04/14] feat(sdk): get identity by non-unique keys --- packages/dapi-grpc/build.rs | 7 +- packages/rs-dapi-client/src/transport/grpc.rs | 9 ++ packages/rs-drive-proof-verifier/src/proof.rs | 96 ++++++++++++++++++- .../src/drive/identity/fetch/queries/mod.rs | 6 +- packages/rs-drive/src/drive/mod.rs | 4 +- .../rs-sdk/src/platform/types/identity.rs | 34 ++++++- packages/rs-sdk/tests/fetch/identity.rs | 28 ++++++ 7 files changed, 175 insertions(+), 9 deletions(-) diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index 4c8f1d1aa35..2fc395e9a34 100644 --- a/packages/dapi-grpc/build.rs +++ b/packages/dapi-grpc/build.rs @@ -63,7 +63,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { // Derive features for versioned messages // // "GetConsensusParamsRequest" is excluded as this message does not support proofs - const VERSIONED_REQUESTS: [&str; 34] = [ + const VERSIONED_REQUESTS: [&str; 35] = [ "GetDataContractHistoryRequest", "GetDataContractRequest", "GetDataContractsRequest", @@ -75,6 +75,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetIdentityContractNonceRequest", "GetIdentityBalanceAndRevisionRequest", "GetIdentityBalanceRequest", + "GetIdentityByNonUniquePublicKeyHashRequest", "GetIdentityByPublicKeyHashRequest", "GetIdentityKeysRequest", "GetIdentityRequest", @@ -104,7 +105,11 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { // - "GetConsensusParamsResponse" // - "GetStatusResponse" // + // The following responses are excluded as they need custom proof handling: + // - "GetIdentityByNonUniquePublicKeyHashResponse" + // // "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests + const VERSIONED_RESPONSES: [&str; 33] = [ "GetDataContractHistoryResponse", "GetDataContractResponse", diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs index 8c6195bd055..1451b708050 100644 --- a/packages/rs-dapi-client/src/transport/grpc.rs +++ b/packages/rs-dapi-client/src/transport/grpc.rs @@ -489,3 +489,12 @@ impl_transport_request_grpc!( RequestSettings::default(), get_status ); + +// rpc getIdentityByNonUniquePublicKeyHash(GetIdentityByNonUniquePublicKeyHashRequest) returns (GetIdentityByNonUniquePublicKeyHashResponse); +impl_transport_request_grpc!( + platform_proto::GetIdentityByNonUniquePublicKeyHashRequest, + platform_proto::GetIdentityByNonUniquePublicKeyHashResponse, + PlatformGrpcClient, + RequestSettings::default(), + get_identity_by_non_unique_public_key_hash +); diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 2c2619754b3..ed90d3def78 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -10,7 +10,8 @@ use dapi_grpc::platform::v0::get_protocol_version_upgrade_vote_status_request::{ }; use dapi_grpc::platform::v0::security_level_map::KeyKindRequestType as GrpcKeyKind; use dapi_grpc::platform::v0::{ - get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_keys_request, get_identity_nonce_request, get_identity_request, get_path_elements_request, get_prefunded_specialized_balance_request, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, Proof, ResponseMetadata + get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_non_unique_public_key_hash_request, + get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_keys_request, get_identity_nonce_request, get_identity_request, get_path_elements_request, get_prefunded_specialized_balance_request, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, Proof, ResponseMetadata }; use dapi_grpc::platform::{ v0::{self as platform, key_request_type, KeyRequestType as GrpcKeyType}, @@ -32,6 +33,7 @@ use dpp::state_transition::proof_result::StateTransitionProofResult; use dpp::state_transition::StateTransition; use dpp::version::PlatformVersion; use dpp::voting::votes::Vote; +use drive::drive::identity::identity_and_non_unique_public_key_hash_double_proof::IdentityAndNonUniquePublicKeyHashDoubleProof; use drive::drive::identity::key::fetch::{ IdentityKeysRequest, KeyKindRequestType, KeyRequestType, PurposeU8, SecurityLevelU8, }; @@ -346,6 +348,98 @@ impl FromProof for Identity { } } +impl FromProof for Identity { + type Request = platform::GetIdentityByNonUniquePublicKeyHashRequest; + type Response = platform::GetIdentityByNonUniquePublicKeyHashResponse; + fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( + request: I, + response: O, + _network: Network, + platform_version: &PlatformVersion, + provider: &'a dyn ContextProvider, + ) -> Result<(Option, ResponseMetadata, Proof), Error> + where + Self: Sized + 'a, + { + let request = request.into(); + let response = response.into(); + // Parse response to read proof and metadata + // note that proof in this case is different + // let proof = response.proof().or(Err(Error::NoProofInResult))?; + use platform::get_identity_by_non_unique_public_key_hash_response::{ + get_identity_by_non_unique_public_key_hash_response_v0::Result as V0Result, Version::V0, + }; + + let (proved_response, mtd) = match response.version { + Some(V0(v0)) => { + let proof = if let V0Result::Proof(p) = v0.result.ok_or(Error::NoProofInResult)? { + p + } else { + return Err(Error::NoProofInResult); + }; + + (proof, v0.metadata.ok_or(Error::EmptyResponseMetadata)?) + } + _ => return Err(Error::EmptyResponseMetadata), + }; + + // let mtd = response.metadata().or(Err(Error::EmptyResponseMetadata))?; + + let (public_key_hash, after_identity) = match request.version.ok_or(Error::EmptyVersion)? { + get_identity_by_non_unique_public_key_hash_request::Version::V0(v0) => { + let public_key_hash = + v0.public_key_hash + .try_into() + .map_err(|_| Error::RequestError { + error: "Invalid public key hash length".to_string(), + })?; + + let after = v0 + .start_after + .map(|a| { + a.try_into().map_err(|_| Error::RequestError { + error: "Invalid start_after length".to_string(), + }) + }) + .transpose()?; + (public_key_hash, after) + } + }; + + // we need to convert some data to handle non-default proof structure for this response + let proof = proved_response + .grovedb_identity_public_key_hash_proof + .ok_or(Error::NoProofInResult)?; + + let proof_tuple = IdentityAndNonUniquePublicKeyHashDoubleProof { + identity_proof: proved_response.identity_proof_bytes, + identity_id_public_key_hash_proof: proof.grovedb_proof.clone(), + }; + + // Extract content from proof and verify Drive/GroveDB proofs + let (root_hash, maybe_identity) = + Drive::verify_full_identity_by_non_unique_public_key_hash( + &proof_tuple, + public_key_hash, + after_identity, + platform_version, + ) + .map_err(|e| match e { + drive::error::Error::GroveDB(e) => Error::GroveDBError { + proof_bytes: proof.grovedb_proof.clone(), + height: mtd.height, + time_ms: mtd.time_ms, + error: e.to_string(), + }, + _ => e.into(), + })?; + + verify_tenderdash_proof(&proof, &mtd, &root_hash, provider)?; + + Ok((maybe_identity, mtd.clone(), proof)) + } +} + impl FromProof for IdentityPublicKeys { type Request = platform::GetIdentityKeysRequest; type Response = platform::GetIdentityKeysResponse; diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index d6319239947..15be478e44e 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -1,9 +1,7 @@ use crate::drive::balances::balance_path_vec; use crate::drive::identity::key::fetch::IdentityKeysRequest; -use crate::drive::{ - identity_tree_path_vec, non_unique_key_hashes_tree_path_vec, unique_key_hashes_tree_path_vec, - Drive, -}; +use crate::drive::non_unique_key_hashes_tree_path_vec; +use crate::drive::{identity_tree_path_vec, unique_key_hashes_tree_path_vec, Drive}; use std::ops::RangeFull; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index ce1fb9a74e5..9e11bddcd25 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -261,7 +261,7 @@ pub(crate) fn non_unique_key_hashes_tree_path() -> [&'static [u8]; 1] { } /// Returns the path to the masternode key hashes. -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] pub(crate) fn non_unique_key_hashes_tree_path_vec() -> Vec> { vec![vec![ RootTree::NonUniquePublicKeyKeyHashesToIdentities as u8, @@ -278,7 +278,7 @@ pub(crate) fn non_unique_key_hashes_sub_tree_path(public_key_hash: &[u8]) -> [&[ } /// Returns the path to the masternode key hashes sub tree. -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] pub(crate) fn non_unique_key_hashes_sub_tree_path_vec(public_key_hash: [u8; 20]) -> Vec> { vec![ vec![RootTree::NonUniquePublicKeyKeyHashesToIdentities as u8], diff --git a/packages/rs-sdk/src/platform/types/identity.rs b/packages/rs-sdk/src/platform/types/identity.rs index 4b7b7754d0f..41f9b26fa34 100644 --- a/packages/rs-sdk/src/platform/types/identity.rs +++ b/packages/rs-sdk/src/platform/types/identity.rs @@ -9,6 +9,7 @@ use crate::{ use dapi_grpc::platform::v0::get_identities_balances_request::GetIdentitiesBalancesRequestV0; use dapi_grpc::platform::v0::get_identity_balance_and_revision_request::GetIdentityBalanceAndRevisionRequestV0; use dapi_grpc::platform::v0::get_identity_balance_request::GetIdentityBalanceRequestV0; +use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request::GetIdentityByNonUniquePublicKeyHashRequestV0; use dapi_grpc::platform::v0::get_identity_by_public_key_hash_request::GetIdentityByPublicKeyHashRequestV0; use dapi_grpc::platform::v0::get_identity_contract_nonce_request::GetIdentityContractNonceRequestV0; use dapi_grpc::platform::v0::get_identity_nonce_request::GetIdentityNonceRequestV0; @@ -31,7 +32,8 @@ delegate_enum! { IdentityResponse, Identity, (GetIdentity,proto::GetIdentityRequest,proto::GetIdentityResponse), - (GetIdentityByPublicKeyHash, proto::GetIdentityByPublicKeyHashRequest, proto::GetIdentityByPublicKeyHashResponse) + (GetIdentityByPublicKeyHash, proto::GetIdentityByPublicKeyHashRequest, proto::GetIdentityByPublicKeyHashResponse), + (GetIdentityByNonUniquePublicKeyHash, proto::GetIdentityByNonUniquePublicKeyHashRequest, proto::GetIdentityByNonUniquePublicKeyHashResponse) } impl Query for dpp::prelude::Identifier { @@ -74,6 +76,36 @@ impl Query for PublicKeyHash { } } +/// Non-unique public key hash that can be used as a [Query] to find an identity. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct NonUniquePublicKeyHashQuery { + keyhash: [u8; 32], + after: Option<[u8; 32]>, +} + +impl Query for NonUniquePublicKeyHashQuery { + fn query(self, prove: bool) -> Result { + if !prove { + unimplemented!("queries without proofs are not supported yet"); + } + + let request = proto::GetIdentityByNonUniquePublicKeyHashRequest { + version: Some( + proto::get_identity_by_non_unique_public_key_hash_request::Version::V0( + GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash: self.keyhash.to_vec(), + start_after: self.after.map(|a| a.to_vec()), + prove, + }, + ), + ), + } + .into(); + + Ok(request) + } +} + impl Query for dpp::prelude::Identifier { fn query(self, prove: bool) -> Result { if !prove { diff --git a/packages/rs-sdk/tests/fetch/identity.rs b/packages/rs-sdk/tests/fetch/identity.rs index ad5a458960f..0fd0d356983 100644 --- a/packages/rs-sdk/tests/fetch/identity.rs +++ b/packages/rs-sdk/tests/fetch/identity.rs @@ -116,3 +116,31 @@ async fn test_identity_public_keys_all_read() { assert_eq!(id, pubkey.id()); } } + +/// Given some non-unique public key, when I fetch identity that uses this key, I get associated identities containing this key. +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] +async fn test_fetch_identity_by_non_unique_public_keys() { + setup_logs(); + + let cfg = Config::new(); + let id: dpp::prelude::Identifier = cfg.existing_identity_id; + + let sdk = cfg + .setup_api("test_fetch_identity_by_non_unique_public_keys") + .await; + + let public_keys = IdentityPublicKey::fetch_many(&sdk, id) + .await + .expect("fetch identity public keys"); + + assert!(!public_keys.is_empty()); + tracing::debug!(?public_keys, ?id, "fetched identity public keys"); + + // key IDs must match + for item in public_keys { + let id = item.0; + let pubkey = item.1.expect("public key should exist"); + + assert_eq!(id, pubkey.id()); + } +} From d428660fe3dc871a98abfb127fd1f8993a62b4f4 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:10:04 +0100 Subject: [PATCH 05/14] build(deps): update grovedb to current develop --- Cargo.lock | 18 +++++++++--------- packages/rs-drive/Cargo.toml | 12 ++++++------ packages/rs-platform-version/Cargo.toml | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d27f89a6e38..c38dbe3e294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "grovedb" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "axum", "bincode", @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "integer-encoding", "intmap", @@ -2170,7 +2170,7 @@ dependencies = [ [[package]] name = "grovedb-epoch-based-storage-flags" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "grovedb-costs", "hex", @@ -2182,7 +2182,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "bincode", "blake3", @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "grovedb-path" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "hex", ] @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "grovedb-storage" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "blake3", "grovedb-costs", @@ -2232,7 +2232,7 @@ dependencies = [ [[package]] name = "grovedb-version" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "thiserror 2.0.11", "versioned-feature-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2241,7 +2241,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "hex", "itertools 0.14.0", @@ -2250,7 +2250,7 @@ dependencies = [ [[package]] name = "grovedbg-types" version = "3.0.0" -source = "git+https://github.com/dashpay/grovedb?rev=44c2244bbccd3e6e684729e8cf620644f7ebbf70#44c2244bbccd3e6e684729e8cf620644f7ebbf70" +source = "git+https://github.com/dashpay/grovedb?rev=f89e03e4e0ac12aa2feea5c94b38c09f4909facc#f89e03e4e0ac12aa2feea5c94b38c09f4909facc" dependencies = [ "serde", "serde_with 3.9.0", diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 741425585ed..7e3d9e0087b 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -52,12 +52,12 @@ enum-map = { version = "2.0.3", optional = true } intmap = { version = "3.0.1", features = ["serde"], optional = true } chrono = { version = "0.4.35", optional = true } itertools = { version = "0.13", optional = true } -grovedb = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70", optional = true, default-features = false } -grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70", optional = true } -grovedb-path = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70" } -grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70", optional = true } -grovedb-version = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70" } -grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70" } +grovedb = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc", optional = true, default-features = false } +grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc", optional = true } +grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc" } +grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc", optional = true } +grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc" } +grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc" } [dev-dependencies] criterion = "0.5" diff --git a/packages/rs-platform-version/Cargo.toml b/packages/rs-platform-version/Cargo.toml index e678d3be655..ecde4a02d23 100644 --- a/packages/rs-platform-version/Cargo.toml +++ b/packages/rs-platform-version/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" thiserror = { version = "1.0.63" } bincode = { version = "2.0.0-rc.3" } versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" } -grovedb-version = { git = "https://github.com/dashpay/grovedb", rev= "44c2244bbccd3e6e684729e8cf620644f7ebbf70" } +grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "f89e03e4e0ac12aa2feea5c94b38c09f4909facc" } once_cell = "1.19.0" [features] From 059f3563e38a49f14221a1a005d3f52dc34c5870 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:24:06 +0100 Subject: [PATCH 06/14] test: test identity by non-unique pubkey hashes --- .../rs-sdk/src/platform/types/identity.rs | 6 +- packages/rs-sdk/tests/fetch/config.rs | 4 +- packages/rs-sdk/tests/fetch/identity.rs | 55 +++++++++++++++---- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/packages/rs-sdk/src/platform/types/identity.rs b/packages/rs-sdk/src/platform/types/identity.rs index 41f9b26fa34..963dcaa45f9 100644 --- a/packages/rs-sdk/src/platform/types/identity.rs +++ b/packages/rs-sdk/src/platform/types/identity.rs @@ -79,8 +79,8 @@ impl Query for PublicKeyHash { /// Non-unique public key hash that can be used as a [Query] to find an identity. #[derive(Clone, Debug, PartialEq, Eq)] pub struct NonUniquePublicKeyHashQuery { - keyhash: [u8; 32], - after: Option<[u8; 32]>, + pub key_hash: [u8; 20], + pub after: Option<[u8; 32]>, } impl Query for NonUniquePublicKeyHashQuery { @@ -93,7 +93,7 @@ impl Query for NonUniquePublicKeyHashQuery { version: Some( proto::get_identity_by_non_unique_public_key_hash_request::Version::V0( GetIdentityByNonUniquePublicKeyHashRequestV0 { - public_key_hash: self.keyhash.to_vec(), + public_key_hash: self.key_hash.to_vec(), start_after: self.after.map(|a| a.to_vec()), prove, }, diff --git a/packages/rs-sdk/tests/fetch/config.rs b/packages/rs-sdk/tests/fetch/config.rs index a93eb2402c5..eb4b644b7ab 100644 --- a/packages/rs-sdk/tests/fetch/config.rs +++ b/packages/rs-sdk/tests/fetch/config.rs @@ -190,8 +190,8 @@ impl Config { #[cfg(all(feature = "network-testing", not(feature = "offline-testing")))] let sdk = { let core_host = self.core_host.as_ref().unwrap_or(&self.platform_host); - // Dump all traffic to disk - let builder = dash_sdk::SdkBuilder::new(self.address_list()).with_core( + // Dump all traffic to disk] + let mut builder = dash_sdk::SdkBuilder::new(self.address_list()).with_core( core_host, self.core_port, &self.core_user, diff --git a/packages/rs-sdk/tests/fetch/identity.rs b/packages/rs-sdk/tests/fetch/identity.rs index 0fd0d356983..5a18bec7795 100644 --- a/packages/rs-sdk/tests/fetch/identity.rs +++ b/packages/rs-sdk/tests/fetch/identity.rs @@ -1,4 +1,4 @@ -use dash_sdk::platform::types::identity::PublicKeyHash; +use dash_sdk::platform::types::identity::{NonUniquePublicKeyHashQuery, PublicKeyHash}; use dash_sdk::platform::{Fetch, FetchMany}; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; @@ -129,18 +129,49 @@ async fn test_fetch_identity_by_non_unique_public_keys() { .setup_api("test_fetch_identity_by_non_unique_public_keys") .await; - let public_keys = IdentityPublicKey::fetch_many(&sdk, id) + // First, fetch an identity to get a non-unique public key + let identity = Identity::fetch(&sdk, id) .await - .expect("fetch identity public keys"); - - assert!(!public_keys.is_empty()); - tracing::debug!(?public_keys, ?id, "fetched identity public keys"); - - // key IDs must match - for item in public_keys { - let id = item.0; - let pubkey = item.1.expect("public key should exist"); + .expect("fetch identity") + .expect("found identity"); - assert_eq!(id, pubkey.id()); + let pubkeys = identity.public_keys(); + + assert_ne!( + pubkeys.len(), + 0, + "identity must have at least one public key" + ); + + for non_unique_key in pubkeys.iter() { + let key_hash = non_unique_key.1.public_key_hash().expect("public key hash"); + let mut query = NonUniquePublicKeyHashQuery { + key_hash, + after: None, + }; + + // Now fetch identities by this non-unique public key hash + let mut count = 0; + while let Some(found) = Identity::fetch(&sdk, query) + .await + .expect("fetch identities by non-unique key hash") + { + count += 1; + tracing::debug!( + ?found, + ?key_hash, + ?count, + "fetched identities by non-unique public key hash" + ); + + query = NonUniquePublicKeyHashQuery { + key_hash, + after: Some(*found.id().as_bytes()), + }; + } + assert_ne!( + count, 0, + "found at least one identity by non-unique public key hash" + ); } } From 22e665fad61ba3d5433137a1b8b88071fbc3313a Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:24:35 +0100 Subject: [PATCH 07/14] fix(sdk): dash core client fails to get quorum --- packages/rs-sdk/src/core/dash_core_client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-sdk/src/core/dash_core_client.rs b/packages/rs-sdk/src/core/dash_core_client.rs index d59af4207c5..67d1dea28ce 100644 --- a/packages/rs-sdk/src/core/dash_core_client.rs +++ b/packages/rs-sdk/src/core/dash_core_client.rs @@ -133,7 +133,7 @@ impl LowLevelDashCoreClient { let core = self.core.lock().expect("Core lock poisoned"); let quorum_info = core - .get_quorum_info(json::QuorumType::from(quorum_type), &quorum_hash, None) + .get_quorum_info_reversed(json::QuorumType::from(quorum_type), &quorum_hash, None) .map_err(|e: dashcore_rpc::Error| ContextProviderError::Generic(e.to_string()))?; let key = quorum_info.quorum_public_key; let pubkey = as TryInto<[u8; 48]>>::try_into(key).map_err(|_e| { From 03a2ac2bec6f54b1e5930d55cbb9ce33cf3590b2 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:50:28 +0100 Subject: [PATCH 08/14] chore: minor fixes --- .../v0/mod.rs | 2 +- packages/rs-drive-verify-c-binding/src/lib.rs | 13 ++++++++----- .../v0/mod.rs | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs index a9a3ac7dd42..d16a3f66304 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs @@ -38,7 +38,7 @@ impl Platform { ) .map(|bytes| bytes.0) .map_err(|_| QueryError::InvalidArgument( - "public key hash must be 20 bytes long".to_string() + "start_after must be 32 bytes long identity ID".to_string() )))) } else { None diff --git a/packages/rs-drive-verify-c-binding/src/lib.rs b/packages/rs-drive-verify-c-binding/src/lib.rs index 220bb70cc13..cb32ff6624b 100644 --- a/packages/rs-drive-verify-c-binding/src/lib.rs +++ b/packages/rs-drive-verify-c-binding/src/lib.rs @@ -100,7 +100,7 @@ pub unsafe extern "C" fn verify_full_identity_by_identity_id( } #[no_mangle] -pub unsafe extern "C" fn verify_identity_id_by_public_key_hash( +pub unsafe extern "C" fn verify_identity_id_by_unique_public_key_hash( proof_array: *const u8, proof_len: usize, is_proof_subset: bool, @@ -109,8 +109,11 @@ pub unsafe extern "C" fn verify_identity_id_by_public_key_hash( let proof = unsafe { slice::from_raw_parts(proof_array, proof_len) }; let public_key_hash = unsafe { std::ptr::read(public_key_hash) }; - let verification_result = - Drive::verify_identity_id_by_public_key_hash(proof, is_proof_subset, public_key_hash); + let verification_result = Drive::verify_identity_id_by_unique_public_key_hash( + proof, + is_proof_subset, + public_key_hash, + ); match verification_result { Ok((root_hash, maybe_identity_id)) => { @@ -680,13 +683,13 @@ mod tests { } #[test] - fn verify_identity_id_by_public_key_hash() { + fn verify_identity_id_by_unique_public_key_hash() { let proof = multiple_identity_proof(); let public_key_hash: PublicKeyHash = [ 31, 8, 21, 38, 154, 252, 1, 45, 228, 66, 96, 206, 178, 138, 68, 150, 211, 24, 65, 132, ]; let (_root_hash, maybe_identity_id) = - Drive::verify_identity_id_by_public_key_hash(proof, true, public_key_hash) + Drive::verify_identity_id_by_unique_public_key_hash(proof, true, public_key_hash) .expect("should verify"); let expected_identity_id: [u8; 32] = [ 15, 126, 159, 152, 150, 254, 206, 186, 180, 193, 157, 65, 233, 215, 241, 108, 23, 39, diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs index 88fe2894242..342df383e39 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs @@ -18,7 +18,7 @@ impl Drive { /// The `public_key_hash` should contain the hash of the public key of the user. /// /// The function first verifies the identity ID associated with the given public key hash - /// by calling `verify_identity_id_by_public_key_hash()`. It then uses this identity ID to verify + /// by calling `verify_identity_id_by_unique_public_key_hash()`. It then uses this identity ID to verify /// the full identity by calling `verify_full_identity_by_identity_id()`. /// /// # Returns From 3eed93316b9fca32cce1378e25fa52d39e7e661e Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:16:13 +0100 Subject: [PATCH 09/14] test(drive-abci): identity by non-unique pubkey start after --- .../v0/mod.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs index d16a3f66304..f31423a2aea 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs @@ -129,6 +129,33 @@ mod tests { )); } + #[test] + fn test_invalid_start_after() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + + let negative_tests: Vec<&[u8]> = vec![&[0u8; 4], &[0u8; 20], &[0u8; 64]]; + + for test in negative_tests { + let request = GetIdentityByNonUniquePublicKeyHashRequestV0 { + public_key_hash: vec![0; 20], + start_after: Some(test.to_vec()), + prove: false, + }; + + let result = platform + .query_identity_by_non_unique_public_key_hash_v0(request, &state, version) + .expect("expected query to succeed"); + + assert!( + matches!( + result.errors.as_slice(), + [QueryError::InvalidArgument(msg)] if msg == &"start_after must be 32 bytes long identity ID".to_string()), + "errors: {:?}", + result.errors, + ); + } + } + #[test] fn test_identity_not_found() { let (platform, state, version) = setup_platform(None, Network::Testnet, None); From 4fea858db205f1641d3c257b343de1176a2b8a60 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:24:38 +0100 Subject: [PATCH 10/14] chore: minor changes to verify --- .../identity_by_non_unique_public_key_hash/mod.rs | 4 ++-- packages/rs-drive/src/drive/identity/fetch/queries/mod.rs | 3 ++- .../v0/mod.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs index 33403fad6a5..9a1c7c104d5 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs @@ -7,7 +7,6 @@ use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_request: use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::Version as ResponseVersion; use dapi_grpc::platform::v0::{ GetIdentityByNonUniquePublicKeyHashRequest, GetIdentityByNonUniquePublicKeyHashResponse, - GetIdentityByPublicKeyHashResponse, }; use dpp::version::PlatformVersion; @@ -28,7 +27,8 @@ impl Platform { ), )); }; - + // TODO why `identity_by_unique_public_key_hash`? + // Shouldn't we rename or add new field like `identity_by_non_unique_public_key_hash`? let feature_version_bounds = &platform_version .drive_abci .query diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index 15be478e44e..e5dfc9d56bb 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -102,10 +102,11 @@ impl Drive { let sub_query = if let Some(after) = after { Query::new_single_query_item(QueryItem::RangeAfter(after.to_vec()..)) } else { + // TODO: why not limit 1? Query::new_range_full() }; query.set_subquery(sub_query); - PathQuery::new(non_unique_key_hashes, SizedQuery::new(query, None, None)) + PathQuery::new(non_unique_key_hashes, SizedQuery::new(query, Some(1), None)) } /// The query for proving identity ids from a vector of public key hashes. diff --git a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs index ccb81c1d6fb..7f500fc7c8d 100644 --- a/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs +++ b/packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs @@ -66,7 +66,7 @@ impl Drive { let Some(identity_proof) = &proof.identity_proof else { return Err(Error::Proof(ProofError::IncompleteProof("identity is not in proof even though identity id is set from non unique public key hash"))); }; - println!("hex {}", hex::encode(&identity_proof)); + Self::verify_full_identity_by_identity_id( identity_proof.as_slice(), false, From dbad665baf96af0d1ccb58720311d89f618ac702 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:35:35 +0100 Subject: [PATCH 11/14] chore: revert limit 1 => limit none --- packages/rs-drive/src/drive/identity/fetch/queries/mod.rs | 2 +- packages/rs-sdk/tests/fetch/identity.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs index e5dfc9d56bb..846a260eee1 100644 --- a/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/queries/mod.rs @@ -106,7 +106,7 @@ impl Drive { Query::new_range_full() }; query.set_subquery(sub_query); - PathQuery::new(non_unique_key_hashes, SizedQuery::new(query, Some(1), None)) + PathQuery::new(non_unique_key_hashes, SizedQuery::new(query, None, None)) } /// The query for proving identity ids from a vector of public key hashes. diff --git a/packages/rs-sdk/tests/fetch/identity.rs b/packages/rs-sdk/tests/fetch/identity.rs index 5a18bec7795..5496ea69831 100644 --- a/packages/rs-sdk/tests/fetch/identity.rs +++ b/packages/rs-sdk/tests/fetch/identity.rs @@ -171,7 +171,7 @@ async fn test_fetch_identity_by_non_unique_public_keys() { } assert_ne!( count, 0, - "found at least one identity by non-unique public key hash" + "no identities found by non-unique public key hash" ); } } From 8e484e80e8fb9582fdaa94b82a62dbe8f08d1d8c Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 18:08:37 +0100 Subject: [PATCH 12/14] chore: add non-unique key to test identities --- .../initialization/create_genesis_state/test/tokens.rs | 10 +++++++--- packages/rs-sdk/tests/fetch/identity.rs | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs index 28147c64bea..89b46e2da16 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs @@ -1,8 +1,6 @@ -use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use dpp::block::block_info::BlockInfo; -use dpp::dashcore::Network; use dpp::data_contract::associated_token::token_configuration::v0::TokenConfigurationV0; use dpp::data_contract::associated_token::token_configuration_convention::v0::TokenConfigurationConventionV0; use dpp::data_contract::associated_token::token_distribution_rules::v0::TokenDistributionRulesV0; @@ -110,6 +108,10 @@ impl Platform { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { + let mut rng = StdRng::seed_from_u64(0u64); + let non_unique_key = + IdentityPublicKey::random_voting_key_with_rng(11, &mut rng, platform_version)?; + for id in [IDENTITY_ID_1, IDENTITY_ID_2, IDENTITY_ID_3] { // Create identity without keys let mut identity = Identity::create_basic_identity(id, platform_version)?; @@ -117,7 +119,9 @@ impl Platform { // Generate keys let seed = id.to_buffer()[0]; let mut rng = StdRng::seed_from_u64(seed as u64); - let keys = IdentityPublicKey::main_keys_with_random_authentication_keys_with_private_keys_with_rng(3, &mut rng, platform_version)?; + let mut keys = IdentityPublicKey::main_keys_with_random_authentication_keys_with_private_keys_with_rng(3, &mut rng, platform_version)?; + // every identity has the same non-unique key + keys.push(non_unique_key.clone()); for (key, private_key) in keys.iter() { let private_key = hex::encode(private_key); diff --git a/packages/rs-sdk/tests/fetch/identity.rs b/packages/rs-sdk/tests/fetch/identity.rs index 5496ea69831..7148a295c46 100644 --- a/packages/rs-sdk/tests/fetch/identity.rs +++ b/packages/rs-sdk/tests/fetch/identity.rs @@ -135,12 +135,16 @@ async fn test_fetch_identity_by_non_unique_public_keys() { .expect("fetch identity") .expect("found identity"); - let pubkeys = identity.public_keys(); + let pubkeys: Vec<_> = identity + .public_keys() + .iter() + .filter(|public_key| !public_key.1.key_type().is_unique_key_type()) + .collect(); assert_ne!( pubkeys.len(), 0, - "identity must have at least one public key" + "identity must have at least one non-unique public key" ); for non_unique_key in pubkeys.iter() { From 830e6057f93a272b2083f02dad7585eda30860eb Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:03:58 +0100 Subject: [PATCH 13/14] test(sdk): test vectors for test_fetch_identity_by_non_unique_public_keys --- .../.gitkeep | 0 ...96e167d0327209295b4a98e14c6eb0d2b7e631.json | Bin 0 -> 72399 bytes ...e5f90edeec5e32ae9d35ca2f654e5a8b47ef3d.json | Bin 0 -> 45144 bytes ...ad441005468aa9ae346220fcc77830f30f06c7.json | Bin 0 -> 106415 bytes ...e9355939311eca86a05923cfb53d11b746428a.json | Bin 0 -> 114110 bytes ...2839f231c080d4ffacee80457ecc1db6a4bbbb.json | Bin 0 -> 104070 bytes ...04f02b4d71142b0d84600aa6fd73436efb869b.json | 1 + 7 files changed, 1 insertion(+) create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/.gitkeep create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_28e9fda4d74589e1756f49026696e167d0327209295b4a98e14c6eb0d2b7e631.json create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_3606368b19c21647e14e80f609e5f90edeec5e32ae9d35ca2f654e5a8b47ef3d.json create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_3796e6d3ed7346055d82e39618ad441005468aa9ae346220fcc77830f30f06c7.json create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_5f9f951aa5d5af07c588813f31e9355939311eca86a05923cfb53d11b746428a.json create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_a6d61bfcc12549cc29bf4e9abe2839f231c080d4ffacee80457ecc1db6a4bbbb.json create mode 100644 packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/quorum_pubkey-106-15957be6ce59202ce3df8dbd0604f02b4d71142b0d84600aa6fd73436efb869b.json diff --git a/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/.gitkeep b/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_28e9fda4d74589e1756f49026696e167d0327209295b4a98e14c6eb0d2b7e631.json b/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_28e9fda4d74589e1756f49026696e167d0327209295b4a98e14c6eb0d2b7e631.json new file mode 100644 index 0000000000000000000000000000000000000000..fee35a717a9328a88eca8b555e2eeaf385b6de42 GIT binary patch literal 72399 zcmeI4(Qcd95rli~r!aiY3sMp-GcQo&st*w4F1j!ZB!%k)C=9=QzB%VerfRF^d}@fm zAwb8L?B(v6nVsG9Q|*TrFJHd;``!ERf4ckm{oD8ddG+1P4}6Pn{&x57-*12U`QaP+ z*7oQtzJB`?U;i-vc|u;k+-)vj{Mj&gVC2V7^7ZC$%OAJnH|plAli%ml zyHR+cNa5RHk%PSc^hSBd?PkB<>4bm|NKqncTx|n^g!0~h$wpzbxh@dB|7BmClOf|c9i*4{U3#-p|7L9laz22C_)gs zs8A##1Z|%x@5hIlT5QpXXN=~q1L^*q0YAi@XjDfBTy^#t6NtN>Xs|~a1IvlC;&BwY zu*Me8qyw2ga3OP|C4OG&SKa9-WOi=qWM;)7iXKl?pKHO=6LIErsdJ1(0}Eg(AIlj9 zGE8qrpVepT6fNJYB@?0V^wc)!bKHreC7trmOb2BVc(t%=H;fkDf{0$0qHzL6uSTOQ z5{dQ{we{}dK!|Aju3T#Gb(_Fvc#fp3pQI_0dtASq(Iz%<}9j6#r@bo0?o z$^IZ-tyN*cSp;?VjgWLa9PA}6z|6%{xHM5}my4uJ7mApN5w(F6Mj_?|_N+O|R<0hF z1ft2l3moGUOalu=3Xdg9wQ6n|J$E@BlJ3DIu$AT1v%n-psyo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$slan{LfOg3~OMkkvGGPbSFi*6GxG<9vXRV>OA z+fqU3orTv`sR2ez`O+oAXeUBMp?1K^mxi69tuke zbu`d4OEFes)hlrwG`NYXS|>cuu7jrD75x7QIxmM*oz&nFVYH;-VI*5BEG5XvEaQ@x zoXtfN43~OS=Csg8OrxJFgUv;6YVJ9ry_$|8dk+ryHV*_@=6(l?ymJo=&oRMX(>%y z=KY4gT40(ffMf!;v+EbxR8D_E(O)rGc!^nP$vF6mfuU(%xjQqyY4KS|81hM1kh`jDNsP=_QzeIn=g|{GYNiAd>_?h+N-c|49?_c&+N;}!<|DR7!IqqjtJo)q! OPs|?bcl6`CPyYc(FHNuj literal 0 HcmV?d00001 diff --git a/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_3796e6d3ed7346055d82e39618ad441005468aa9ae346220fcc77830f30f06c7.json b/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_3796e6d3ed7346055d82e39618ad441005468aa9ae346220fcc77830f30f06c7.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0b4a4182283cad0f1a0d444703a2dde6f1369c GIT binary patch literal 106415 zcmeI5O>dl6a)q<@uMoWEg3S+6oMkqXAV88$R)c}zBnrlufjzP10Sv?cJ?DAvl|@F9 z&GS@-HYN?UB{j+FsycP*RNdQc>HAM!y!iCDuiyORf4=_m%@=RJ`}^5KpPr`O;8!{^`p;nUx|_&z_HAO6ehufO@?t1o~20$;j(@GQ^&d{}<= z$JgI|_J?KryTcay7cZ_}UOaeqbM^4q>DA4nr?)r|Zjy-@Sbl!`0;@r>E=F!=F9fJo@3&%STbXeDt%g9zDA{J+?eu{)o!&-+B1- zn>U|-{pPdJ|Le``uLJT!93Q>f`N@kHzXA+CSi(Pl{ncMyr+9C^{`U3$fgg_F`SpiS ze)#0?KKcIBfBEC5zxmzi>iXhzd2xMpJZ>)TPI;RDPA@O+_|D~in&0!K)8*~@{pxh_ zGEei{-K%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kmAN}?RzVYZw`$>NL{SW^G1qGz% literal 0 HcmV?d00001 diff --git a/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_5f9f951aa5d5af07c588813f31e9355939311eca86a05923cfb53d11b746428a.json b/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_5f9f951aa5d5af07c588813f31e9355939311eca86a05923cfb53d11b746428a.json new file mode 100644 index 0000000000000000000000000000000000000000..03a98a10115aaa66a917d100a2cceab02420d83a GIT binary patch literal 114110 zcmeI5&u^XQafQ3~UtxI71uuVyVwT-BMS-@Pu7bdD8x=7U*r_cCFbx0iJPvdBub zd7c3nqq)GfWl|i@%$YN1X1+^HKYa4(r=R`Po45b`hc{on{qpVi|M>mCe*M*deD&r3 zeD~(xzx&TWfB9ek^5*;Be(~)eKl{z6KjcgE#eaSC&9`5E{nbyO;8T|mKFY^`IV?Z_ z)0^)<|Kqa#-C>LUr=MQEx_I!>&DFz?POonseRzBO_`}x^KYVO?efRM9PB)J%uTJ-m ze)sNC45#bMhrfIKD2A)cM@~=Ir-xsAx_R`)r&o`nc=hOOUqAZj>h#$1bomo1zkl!H zvv1#i@y*-MzxeOBZ@vl0k8phdRRQ(>kCyN+-+cYoH!0rRZ@zo8zu?E?SN{Fu zCqI7j51;(-*}whiv)}ygbaj1ky1cl)I$k#ycc*-qe@?G1?)aU{{b7F1r%so*>({H( z#jAXnU+!M#GZBDbu69+%%W_|5X7MJ(i<*OsmU~KyhHhhWbCGU;U!RA8J^b$*AYCx5?|y%P%=aeLqacYI zkE>jK`Q<7PH9mgl7vj3PC!)N9-ZO(*g-R(?pu^*X@+QaUewTN|+jTgCCEeRcpb_5z z8vpU?-Rtfm+REqinY)Yp*7G4fors+3K(DZUXTgVokuaV^M%+HXh99XIRZEAyBW(WT zDB1g#IR%)_NDzNq=A-^cw71s~>o9-U?+-b2{P*eV_Lrgs5JCVHAb>@X>H&p6*18|K zB9KQ218ctOU7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foEOxP&&4K!^U0fYX{lm$yMIFOX17|v9z0b zjFzO_z!GR!UWo`j75lzkJk0oLd6nfvlx)*pXo6!%ta=U;qH^4^UocK~r(6n6D30ER+lqhM;Wq;M|Iz|t>5xXS<%RX7q9g+SZ$>O;k<=QFAG z<-;W8>}dv=A~h!|nXP@R0*DhLy#u7_Yzb;r3HW_>zEx9hF$)5S2=eGSha^F&63FSl zw7nPG1c^s+AO{@P4tR9k*9W<>Yboulgm%RdwCtHlgb@cfMBIT8D{r=U1=FyKX1G(ZtT@FiZcPM3Kwi+} zC|MgGIH;f8BStFuL)79S}R literal 0 HcmV?d00001 diff --git a/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_a6d61bfcc12549cc29bf4e9abe2839f231c080d4ffacee80457ecc1db6a4bbbb.json b/packages/rs-sdk/tests/vectors/test_fetch_identity_by_non_unique_public_keys/msg_IdentityRequest_a6d61bfcc12549cc29bf4e9abe2839f231c080d4ffacee80457ecc1db6a4bbbb.json new file mode 100644 index 0000000000000000000000000000000000000000..4af3de76387412e9987a01137e9938b648ed4dbe GIT binary patch literal 104070 zcmeI5O>dl6a)q<@uQ0skg3S+6oMkpi5Fp7WtHHo0OZ=#=s#B*<)xF&&fB59nPe1#IS8x95kFQ?8`SQ*8fB*fzeEs_0Uw`@E z-@W>`@BZVfFaPtOUw!|NUwr$g&wlsm5Bb)7^Iukzy9eHeCqPSNBQ_Khvnyg ze)aw5e_FP`KWwr8^wX;s7Y{zVxqA4~>E+F%4{vWDfB5p@hmS3U96; zt9OrLI9*>p{Oawa7_KfKIXzvU9)9oX=FvBwUObB8#iQ?i`RJpo(__oiH*Y@w;=kU!`X(U1{_d-<9(?gH-+cYoSNZgtZ@zoAt$#fJ=D$CF^5Z9e_sI{R z{p+7U``zzPSJxM(%Zux)<8gCwcglzPb9!-c$5$@*hxt37I$hqbzpqXgFY;mjx_g<= zU~qZyk}qPw-!VSj9mX%Qy}P*2HwH4kdVha$m+!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C6A7hy+&!1!q!-9vNWK zo2q-$R6Gh|CrE+G0cOiFYL~VZwaai3J5qv-J7L%Z0+|JqQ|KNIw{@5Z`}M|1LGQ&N zaQ4#jQy`WG@1+u1=!MJh*)?foL=89=upUF9#s-Q$Fq2E zUI2dQH6&hekQW!)aSVD4M$W zWZOCR>mnYLVDE8->guS=fm4^GQ0BvzX~Xn|pm&5qj5Z-J*}+73tBLw;ie~RSh`#Gn zgC1GG`&x5^>D{47$*#wQINgapg%hpX^GZ;0CDkgPfZZSv(4GZ1_|Vf&pbhtg5(*|L z=!|Uk4d`%dDJs46P*YQJBy^{nC6!LQqL%%3iax~9jh^-`Uh$>o4nYRbK0CTTwxT6t zm1~N=?zl_K2%5P&_O$@?<=b%z`CYYe6wP=QTZg)6g3^6Ad3qspxv#~}u}78eOM-5TbI2q}=T3Fs zszv@=%V6B~;)%NqzP=C`s+S!_ko0>m)C);xNX7f2lUiRm;!NB2LXDv+TurU?c#l84 z>Is>QBox807h5n4yLx2+`JN%TQ}Pug-QjL0=-3sfeckaG!u0#VY9C>U$ILI6qZ;lM zvF~(>7_vE*s%`=qMO5%q6=W!gZqn;VAQkIJv_e>|9#pVU2qA{)zMf|I3eEaBF-#%U zOriVwP+^OJ#Zg-IESU7dB9a0(vgjcZXp{l_JTiUE4LQ3a)%| z(@26!767Lgy$xw!L}=E>$vhRlmUi`$LUwMURW!q$f@Q^N$XV)xU`R}K$wWpWl@nMa z3rVdP^Au}8O7N+2_}}Xu_~#0=*F8L{otdI5WGJ7Ig*3QZGt%8XEWwk9D1<&J^a<<78Z+3Wdk1b6V)0vmU3OHAwaaJa_Xy|z7ZT0 jPkgu7{q@B!e&^}x_G91l!7u;J7ao0Te~`ca@Z Date: Fri, 14 Mar 2025 10:14:15 +0100 Subject: [PATCH 14/14] test: update assertion --- packages/rs-sdk/tests/fetch/identity.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rs-sdk/tests/fetch/identity.rs b/packages/rs-sdk/tests/fetch/identity.rs index 7148a295c46..dd564623f4a 100644 --- a/packages/rs-sdk/tests/fetch/identity.rs +++ b/packages/rs-sdk/tests/fetch/identity.rs @@ -173,9 +173,9 @@ async fn test_fetch_identity_by_non_unique_public_keys() { after: Some(*found.id().as_bytes()), }; } - assert_ne!( - count, 0, - "no identities found by non-unique public key hash" + assert_eq!( + count, 3, + "expected exactly 3 identities with this non-unique public key" ); } }