FromProof

Trait FromProof 

Source
pub trait FromProof<Req> {
    type Request;
    type Response;

    // Required method
    fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>(
        request: I,
        response: O,
        network: Network,
        platform_version: &PlatformVersion,
        provider: &'a dyn ContextProvider,
    ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
       where Self: Sized + 'a;

    // Provided methods
    fn maybe_from_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>(
        request: I,
        response: O,
        network: Network,
        platform_version: &PlatformVersion,
        provider: &'a dyn ContextProvider,
    ) -> Result<Option<Self>, Error>
       where Self: Sized + 'a { ... }
    fn from_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>(
        request: I,
        response: O,
        network: Network,
        platform_version: &PlatformVersion,
        provider: &'a dyn ContextProvider,
    ) -> Result<Self, Error>
       where Self: Sized + 'a { ... }
    fn from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>(
        request: I,
        response: O,
        network: Network,
        platform_version: &PlatformVersion,
        provider: &'a dyn ContextProvider,
    ) -> Result<(Self, ResponseMetadata), Error>
       where Self: Sized + 'a { ... }
    fn from_proof_with_metadata_and_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>(
        request: I,
        response: O,
        network: Network,
        platform_version: &PlatformVersion,
        provider: &'a dyn ContextProvider,
    ) -> Result<(Self, ResponseMetadata, Proof), Error>
       where Self: Sized + 'a { ... }
}
Expand description

Parse and verify the received proof and retrieve the requested object, if any.

Use FromProof::maybe_from_proof() or FromProof::from_proof() to parse and verify proofs received from the Dash Platform (including verification of grovedb-generated proofs and cryptographic proofs generated by Tenderdash).

gRPC responses, received from the Dash Platform in response to requests containing prove: true, contain GroveDB proof structure (including encapsulated objects) and metadata required to verify cryptographic proof generated by the Tenderdash. This trait provides methods that parse and verify the proof and retrieve the requested object (or information that the object does not exist) in one step.

This trait is implemented by several objects defined in Dash Platform Protocol, like Identity, DataContract, Documents, etc. It is also implemented by several helper objects from [types] module.

Required Associated Types§

Source

type Request

Request type for which this trait is implemented.

Source

type Response

Response type for which this trait is implemented.

Required Methods§

Source

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Parse and verify the received proof and retrieve the requested object, if any.

§Arguments
  • request: The request sent to the server.
  • response: The response received from the server.
  • network: The network we are using, Mainnet/Testnet/Devnet or Regtest
  • platform_version: The platform version that should be used.
  • provider: A callback implementing ContextProvider that provides quorum details required to verify the proof.
§Returns
  • Ok(Some((object, metadata))) when the requested object was found in the proof.
  • Ok(None) when the requested object was not found in the proof; this can be interpreted as proof of non-existence. For collections, returns Ok(None) if none of the requested objects were found.
  • Err(Error) when either the provided data is invalid or proof validation failed.

Provided Methods§

Source

fn maybe_from_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<Option<Self>, Error>
where Self: Sized + 'a,

Parse and verify the received proof and retrieve the requested object, if any.

§Arguments
  • request: The request sent to the server.
  • response: The response received from the server.
  • network: The network we are using, Mainnet/Testnet/Devnet or Regtest
  • platform_version: The platform version that should be used.
  • provider: A callback implementing ContextProvider that provides quorum details required to verify the proof.
§Returns
  • Ok(Some(object, metadata)) when the requested object was found in the proof.
  • Ok(None) when the requested object was not found in the proof; this can be interpreted as proof of non-existence. For collections, returns Ok(None) if none of the requested objects were found.
  • Err(Error) when either the provided data is invalid or proof validation failed.
Source

fn from_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<Self, Error>
where Self: Sized + 'a,

Retrieve the requested object from the proof.

Runs full verification of the proof and retrieves enclosed objects.

This method uses FromProof::maybe_from_proof() internally and throws an error if the requested object does not exist in the proof.

§Arguments
  • request: The request sent to the server.
  • response: The response received from the server.
  • network: The network we are using, Mainnet/Testnet/Devnet or Regtest
  • platform_version: The platform version that should be used.
  • provider: A callback implementing ContextProvider that provides quorum details required to verify the proof.
§Returns
  • Ok(object) when the requested object was found in the proof.
  • Err(Error::DocumentMissingInProof) when the requested object was not found in the proof.
  • Err(Error) when either the provided data is invalid or proof validation failed.
Source

fn from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Self, ResponseMetadata), Error>
where Self: Sized + 'a,

Retrieve the requested object from the proof with metadata.

Runs full verification of the proof and retrieves enclosed objects.

This method uses FromProof::maybe_from_proof_with_metadata() internally and throws an error if the requested object does not exist in the proof.

§Arguments
  • request: The request sent to the server.
  • response: The response received from the server.
  • network: The network we are using, Mainnet/Testnet/Devnet or Regtest
  • platform_version: The platform version that should be used.
  • provider: A callback implementing ContextProvider that provides quorum details required to verify the proof.
§Returns
  • Ok(Some(object, metadata)) when the requested object was found in the proof.
  • Err(Error::DocumentMissingInProof) when the requested object was not found in the proof.
  • Err(Error) when either the provided data is invalid or proof validation failed.
Source

fn from_proof_with_metadata_and_proof<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Self, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Retrieve the requested object from the proof with metadata.

Runs full verification of the proof and retrieves enclosed objects.

This method uses FromProof::maybe_from_proof_with_metadata() internally and throws an error if the requested object does not exist in the proof.

§Arguments
  • request: The request sent to the server.
  • response: The response received from the server.
  • network: The network we are using, Mainnet/Testnet/Devnet or Regtest
  • platform_version: The platform version that should be used.
  • provider: A callback implementing ContextProvider that provides quorum details required to verify the proof.
§Returns
  • Ok(Some(object, metadata, proof)) when the requested object was found in the proof.
  • Err(Error::DocumentMissingInProof) when the requested object was not found in the proof.
  • Err(Error) when either the provided data is invalid or proof validation failed.

Implementations on Foreign Types§

Source§

impl FromProof<BroadcastStateTransitionRequest> for StateTransitionProofResult

Source§

type Request = BroadcastStateTransitionRequest

Source§

type Response = WaitForStateTransitionResultResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetAddressesTrunkStateRequest> for GroveTrunkQueryResult

Source§

type Request = GetAddressesTrunkStateRequest

Source§

type Response = GetAddressesTrunkStateResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( _request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where GroveTrunkQueryResult: 'a,

Source§

impl FromProof<GetContestedResourceIdentityVotesRequest> for Vote

Source§

type Request = GetContestedResourceIdentityVotesRequest

Source§

type Response = GetContestedResourceIdentityVotesResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetDataContractRequest> for (DataContract, Vec<u8>)

Source§

type Request = GetDataContractRequest

Source§

type Response = GetDataContractResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where DataContract: 'a,

Source§

impl FromProof<GetDataContractRequest> for DataContract

Source§

type Request = GetDataContractRequest

Source§

type Response = GetDataContractResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where DataContract: 'a,

Source§

impl FromProof<GetEpochsInfoRequest> for ExtendedEpochInfo

Source§

type Request = GetEpochsInfoRequest

Source§

type Response = GetEpochsInfoResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetGroupInfoRequest> for Group

Source§

type Request = GetGroupInfoRequest

Source§

type Response = GetGroupInfoResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetIdentitiesContractKeysRequest> for IdentitiesContractKeys

Source§

type Request = GetIdentitiesContractKeysRequest

Source§

type Response = GetIdentitiesContractKeysResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: 'a,

Source§

impl FromProof<GetIdentityByNonUniquePublicKeyHashRequest> for Identity

Source§

type Request = GetIdentityByNonUniquePublicKeyHashRequest

Source§

type Response = GetIdentityByNonUniquePublicKeyHashResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetIdentityByPublicKeyHashRequest> for Identity

Source§

type Request = GetIdentityByPublicKeyHashRequest

Source§

type Response = GetIdentityByPublicKeyHashResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Identity: 'a,

Source§

impl FromProof<GetIdentityRequest> for Identity

Source§

type Request = GetIdentityRequest

Source§

type Response = GetIdentityResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Identity: Sized + 'a,

Source§

impl FromProof<GetNullifiersTrunkStateRequest> for GroveTrunkQueryResult

Source§

type Request = GetNullifiersTrunkStateRequest

Source§

type Response = GetNullifiersTrunkStateResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where GroveTrunkQueryResult: 'a,

Source§

impl FromProof<GetTokenContractInfoRequest> for TokenContractInfo

Source§

type Request = GetTokenContractInfoRequest

Source§

type Response = GetTokenContractInfoResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Source§

impl FromProof<GetTokenPerpetualDistributionLastClaimRequest> for RewardDistributionMoment

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Parse & verify the last‑claim proof returned by Platform.

Source§

type Request = GetTokenPerpetualDistributionLastClaimRequest

Source§

type Response = GetTokenPerpetualDistributionLastClaimResponse

Source§

impl FromProof<GetTokenTotalSupplyRequest> for TotalSingleTokenBalance

Source§

type Request = GetTokenTotalSupplyRequest

Source§

type Response = GetTokenTotalSupplyResponse

Source§

fn maybe_from_proof_with_metadata<'a, I: Into<Self::Request>, O: Into<Self::Response>>( request: I, response: O, _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option<Self>, ResponseMetadata, Proof), Error>
where Self: Sized + 'a,

Implementors§

Source§

impl FromProof<GetAddressInfoRequest> for AddressInfo

Source§

impl FromProof<GetAddressesInfosRequest> for AddressInfos

Source§

impl FromProof<GetAddressesTrunkStateRequest> for PlatformAddressTrunkState

Source§

impl FromProof<GetContestedResourceIdentityVotesRequest> for ResourceVotesByIdentity

Source§

impl FromProof<GetContestedResourceVoteStateRequest> for Contenders

Source§

impl FromProof<GetContestedResourceVotersForIdentityRequest> for Voters

Source§

impl FromProof<GetContestedResourcesRequest> for ContestedResources

Source§

impl FromProof<GetDataContractHistoryRequest> for DataContractHistory

Source§

impl FromProof<GetDataContractsRequest> for DataContracts

Source§

impl FromProof<GetEpochsInfoRequest> for ExtendedEpochInfos

Source§

impl FromProof<GetEvonodesProposedEpochBlocksByIdsRequest> for ProposerBlockCounts

Source§

impl FromProof<GetEvonodesProposedEpochBlocksByRangeRequest> for ProposerBlockCounts

Source§

impl FromProof<GetFinalizedEpochInfosRequest> for FinalizedEpochInfos

Source§

impl FromProof<GetGroupActionSignersRequest> for GroupActionSigners

Source§

impl FromProof<GetGroupActionsRequest> for GroupActions

Source§

impl FromProof<GetGroupInfosRequest> for Groups

Source§

impl FromProof<GetIdentitiesBalancesRequest> for IdentityBalances

Source§

impl FromProof<GetIdentitiesTokenBalancesRequest> for IdentitiesTokenBalances

Source§

impl FromProof<GetIdentitiesTokenInfosRequest> for IdentitiesTokenInfos

Source§

impl FromProof<GetIdentityBalanceAndRevisionRequest> for IdentityBalanceAndRevision

Source§

impl FromProof<GetIdentityBalanceRequest> for IdentityBalance

Source§

impl FromProof<GetIdentityContractNonceRequest> for IdentityContractNonceFetcher

Source§

impl FromProof<GetIdentityKeysRequest> for IdentityPublicKeys

Source§

impl FromProof<GetIdentityNonceRequest> for IdentityNonceFetcher

Source§

impl FromProof<GetIdentityTokenBalancesRequest> for IdentityTokenBalances

Source§

impl FromProof<GetIdentityTokenInfosRequest> for IdentityTokenInfos

Source§

impl FromProof<GetMostRecentShieldedAnchorRequest> for MostRecentShieldedAnchor

Source§

impl FromProof<GetNullifiersTrunkStateRequest> for NullifiersTrunkState

Source§

impl FromProof<GetPathElementsRequest> for Elements

Source§

impl FromProof<GetPrefundedSpecializedBalanceRequest> for PrefundedSpecializedBalance

Source§

impl FromProof<GetProtocolVersionUpgradeStateRequest> for ProtocolVersionUpgrades

Source§

impl FromProof<GetProtocolVersionUpgradeVoteStatusRequest> for MasternodeProtocolVotes

Source§

impl FromProof<GetRecentAddressBalanceChangesRequest> for RecentAddressBalanceChanges

Source§

impl FromProof<GetRecentCompactedAddressBalanceChangesRequest> for RecentCompactedAddressBalanceChanges

Source§

impl FromProof<GetRecentCompactedNullifierChangesRequest> for RecentCompactedNullifierChanges

Source§

impl FromProof<GetRecentNullifierChangesRequest> for RecentNullifierChanges

Source§

impl FromProof<GetShieldedAnchorsRequest> for ShieldedAnchors

Source§

impl FromProof<GetShieldedEncryptedNotesRequest> for ShieldedEncryptedNotes

Source§

impl FromProof<GetShieldedNullifiersRequest> for ShieldedNullifierStatuses

Source§

impl FromProof<GetShieldedPoolStateRequest> for ShieldedPoolState

Source§

impl FromProof<GetTokenDirectPurchasePricesRequest> for TokenDirectPurchasePrices

Source§

impl FromProof<GetTokenPreProgrammedDistributionsRequest> for TokenPreProgrammedDistributions

Source§

impl FromProof<GetTokenStatusesRequest> for TokenStatuses

Source§

impl FromProof<GetTotalCreditsInPlatformRequest> for TotalCreditsInPlatform

Source§

impl FromProof<GetVotePollsByEndDateRequest> for VotePollsGroupedByTimestamp

Source§

impl<'dq, Q> FromProof<Q> for Documents
where Q: TryInto<DriveDocumentQuery<'dq>> + Clone + 'dq, Q::Error: Display,