Skip to main content

ExitAcknowledgementShareProcessor

Trait ExitAcknowledgementShareProcessor 

Source
pub trait ExitAcknowledgementShareProcessor<S: PixSpec> {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn retire_ssa(&self, ssa_id: SsaId<S::Pseudonym>);
    fn new_exit_commitment(
        &self,
        id: SsaId<S::Pseudonym>,
        polys_per_ssa: usize,
        shares_per_poly: usize,
    ) -> Result<PixGroup<S>, Self::Error>;
    fn insert_coefficient_commitments(
        &self,
        ssa_id: SsaId<S::Pseudonym>,
        index: CoefficientIndex,
        proof: Option<SsaCommitmentProof<S>>,
        commitments: impl Iterator<Item = (PolynomialIndex, PixGroupRepr<S>)>,
    ) -> Result<SsaCommitmentState<S::Pseudonym, S::DepositAddress>, Self::Error>;
    fn insert_encrypted_share(
        &self,
        peer: &OffchainPublicKey,
        challenge: HalfKeyChallenge,
        tagged_enc_share: TaggedEncryptedPartialSsaShare<S>,
    ) -> Result<(), Self::Error>;
    fn acknowledge_shares(
        &self,
        peer: OffchainPublicKey,
        acks: Vec<Acknowledgement>,
    ) -> Result<Vec<ShareResolution<<S as PixSpec>::Pseudonym, <S as PixSpec>::AddressPrivateKey>>, Self::Error>;

    // Provided methods
    fn has_pending_shares(&self, _peer: &OffchainPublicKey) -> bool { ... }
    fn is_expected_error(&self, _error: &Self::Error) -> bool { ... }
}
Expand description

Allows reconstruction of SSAs at the Exit node.

There are 3 inputs that the implementor is dependent on (in order):

  1. SSA commitments from the Client (delivered via insert_coefficient_commitments)
  2. Extraction of pending encrypted shares (added via insert_encrypted_share
  3. Decryption of pending encrypted shares via [Acknowledgement]s (via acknowledge_shares)

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn retire_ssa(&self, ssa_id: SsaId<S::Pseudonym>)

Releases all reconstructor state for a finished or torn-down SSA cycle.

Called on full recovery and on session closure. Implementations must be idempotent — retiring an unknown or already-retired cycle is a no-op.

Source

fn new_exit_commitment( &self, id: SsaId<S::Pseudonym>, polys_per_ssa: usize, shares_per_poly: usize, ) -> Result<PixGroup<S>, Self::Error>

Generates a new random Exit SSA commitment and registers it internally under the given id.

Source

fn insert_coefficient_commitments( &self, ssa_id: SsaId<S::Pseudonym>, index: CoefficientIndex, proof: Option<SsaCommitmentProof<S>>, commitments: impl Iterator<Item = (PolynomialIndex, PixGroupRepr<S>)>, ) -> Result<SsaCommitmentState<S::Pseudonym, S::DepositAddress>, Self::Error>

Adds the client commitment data.

Each “data packet” should contain an ssa_id of the corresponding SSA. The index is the polynomial coefficient index that is common to all the polynomial coefficient commitments included in commitments. In other words, the commitments argument contains commitments to the same polynomial coefficients across multiple polynomials (each one with its own polynomial index).

proof carries the sender’s SsaCommitmentProof and is expected on messages delivering constant terms (index == 0), since those are what determine the commitment it opens. The first one supplied for an SSA is kept and the rest ignored — any single valid proof suffices. A cycle whose constant terms are all present but which never carried a valid proof is rejected, and no deposit address is published for it.

Source

fn insert_encrypted_share( &self, peer: &OffchainPublicKey, challenge: HalfKeyChallenge, tagged_enc_share: TaggedEncryptedPartialSsaShare<S>, ) -> Result<(), Self::Error>

Adds an encrypted partial SSA share awaiting acknowledgement from peer to be decrypted.

The challenge is the acknowledgement challenge that must correspond to the acknowledgement that will be awaited.

Source

fn acknowledge_shares( &self, peer: OffchainPublicKey, acks: Vec<Acknowledgement>, ) -> Result<Vec<ShareResolution<<S as PixSpec>::Pseudonym, <S as PixSpec>::AddressPrivateKey>>, Self::Error>

Finds and acknowledges previously inserted encrypted share, using incoming [Acknowledgement]s from the upstream peer.

Function should first check if any acknowledgements are expected from the given peer.

Furthermore, the function must verify each given acknowledgement and find if it evaluates to any solutions to challenges of previously inserted encrypted shares.

On success, the resolutions contain any fully recovered SSA shares that were completed as result of the given acknowledgements, or particular cases that lead to invalid (unverifiable) share. That might indicate faulty behavior of the Entry, or a malicious attempt to disrupt the protocol.

Challenges for which encrypted shares were not found are skipped.

Must return an error if no acknowledgements from the given peer were expected.

This operation is expected to be somewhat long-running and significantly blocking.

Provided Methods§

Source

fn has_pending_shares(&self, _peer: &OffchainPublicKey) -> bool

Returns true if the peer has pending encrypted shares awaiting an acknowledgement.

This is a cheap, non-blocking check used by the pipeline to avoid spawning a blocking thread-pool task for acknowledge_shares when there are no pending shares for the peer. Implementations should return false when no shares are pending.

The default implementation returns true for safety — callers must still handle the case where acknowledge_shares returns no results.

Source

fn is_expected_error(&self, _error: &Self::Error) -> bool

Returns true if the given error is an expected “not for us” skip (e.g. no acknowledgements from the peer were expected), so the caller can log it at a lower severity.

The default implementation returns false. Implementations with a concrete error type should override this to identify expected error variants.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, S: PixSpec, T: 'a + ExitAcknowledgementShareProcessor<S> + ?Sized> ExitAcknowledgementShareProcessor<S> for &'a T

Source§

type Error = <T as ExitAcknowledgementShareProcessor<S>>::Error

Source§

fn has_pending_shares(&self, _peer: &OffchainPublicKey) -> bool

Source§

fn is_expected_error(&self, _error: &Self::Error) -> bool

Source§

fn retire_ssa(&self, ssa_id: SsaId<S::Pseudonym>)

Source§

fn new_exit_commitment( &self, id: SsaId<S::Pseudonym>, polys_per_ssa: usize, shares_per_poly: usize, ) -> Result<PixGroup<S>, Self::Error>

Source§

fn insert_coefficient_commitments( &self, ssa_id: SsaId<S::Pseudonym>, index: CoefficientIndex, proof: Option<SsaCommitmentProof<S>>, commitments: impl Iterator<Item = (PolynomialIndex, PixGroupRepr<S>)>, ) -> Result<SsaCommitmentState<S::Pseudonym, S::DepositAddress>, Self::Error>

Source§

fn insert_encrypted_share( &self, peer: &OffchainPublicKey, challenge: HalfKeyChallenge, tagged_enc_share: TaggedEncryptedPartialSsaShare<S>, ) -> Result<(), Self::Error>

Source§

fn acknowledge_shares( &self, peer: OffchainPublicKey, acks: Vec<Acknowledgement>, ) -> Result<Vec<ShareResolution<<S as PixSpec>::Pseudonym, <S as PixSpec>::AddressPrivateKey>>, Self::Error>

Source§

impl<S: PixSpec, T: ExitAcknowledgementShareProcessor<S> + ?Sized> ExitAcknowledgementShareProcessor<S> for Arc<T>

Source§

type Error = <T as ExitAcknowledgementShareProcessor<S>>::Error

Source§

fn has_pending_shares(&self, _peer: &OffchainPublicKey) -> bool

Source§

fn is_expected_error(&self, _error: &Self::Error) -> bool

Source§

fn retire_ssa(&self, ssa_id: SsaId<S::Pseudonym>)

Source§

fn new_exit_commitment( &self, id: SsaId<S::Pseudonym>, polys_per_ssa: usize, shares_per_poly: usize, ) -> Result<PixGroup<S>, Self::Error>

Source§

fn insert_coefficient_commitments( &self, ssa_id: SsaId<S::Pseudonym>, index: CoefficientIndex, proof: Option<SsaCommitmentProof<S>>, commitments: impl Iterator<Item = (PolynomialIndex, PixGroupRepr<S>)>, ) -> Result<SsaCommitmentState<S::Pseudonym, S::DepositAddress>, Self::Error>

Source§

fn insert_encrypted_share( &self, peer: &OffchainPublicKey, challenge: HalfKeyChallenge, tagged_enc_share: TaggedEncryptedPartialSsaShare<S>, ) -> Result<(), Self::Error>

Source§

fn acknowledge_shares( &self, peer: OffchainPublicKey, acks: Vec<Acknowledgement>, ) -> Result<Vec<ShareResolution<<S as PixSpec>::Pseudonym, <S as PixSpec>::AddressPrivateKey>>, Self::Error>

Source§

impl<S: PixSpec, T: ExitAcknowledgementShareProcessor<S> + ?Sized> ExitAcknowledgementShareProcessor<S> for Box<T>

Source§

type Error = <T as ExitAcknowledgementShareProcessor<S>>::Error

Source§

fn has_pending_shares(&self, _peer: &OffchainPublicKey) -> bool

Source§

fn is_expected_error(&self, _error: &Self::Error) -> bool

Source§

fn retire_ssa(&self, ssa_id: SsaId<S::Pseudonym>)

Source§

fn new_exit_commitment( &self, id: SsaId<S::Pseudonym>, polys_per_ssa: usize, shares_per_poly: usize, ) -> Result<PixGroup<S>, Self::Error>

Source§

fn insert_coefficient_commitments( &self, ssa_id: SsaId<S::Pseudonym>, index: CoefficientIndex, proof: Option<SsaCommitmentProof<S>>, commitments: impl Iterator<Item = (PolynomialIndex, PixGroupRepr<S>)>, ) -> Result<SsaCommitmentState<S::Pseudonym, S::DepositAddress>, Self::Error>

Source§

fn insert_encrypted_share( &self, peer: &OffchainPublicKey, challenge: HalfKeyChallenge, tagged_enc_share: TaggedEncryptedPartialSsaShare<S>, ) -> Result<(), Self::Error>

Source§

fn acknowledge_shares( &self, peer: OffchainPublicKey, acks: Vec<Acknowledgement>, ) -> Result<Vec<ShareResolution<<S as PixSpec>::Pseudonym, <S as PixSpec>::AddressPrivateKey>>, Self::Error>

Implementors§