pub struct VerifiedTicket(/* private fields */);
Expand description
Holds a ticket that has been already verified.
This structure guarantees that Ticket::get_hash()
of VerifiedTicket::verified_ticket()
is always equal to VerifiedTicket::verified_hash
Implementations§
Source§impl VerifiedTicket
impl VerifiedTicket
Sourcepub fn win_prob(&self) -> WinningProbability
pub fn win_prob(&self) -> WinningProbability
Returns the verified encoded winning probability of the ticket
Sourcepub fn is_winning(
&self,
response: &Response,
chain_keypair: &ChainKeypair,
domain_separator: &Hash,
) -> bool
pub fn is_winning( &self, response: &Response, chain_keypair: &ChainKeypair, domain_separator: &Hash, ) -> bool
Checks if this ticket is considered a win. Requires access to the private key to compute the VRF values.
Computes the ticket’s luck value and compares it against the ticket’s probability. If luck <= probability, the ticket is considered a win.
§Ticket luck value
This ticket’s luck value
is the first 7 bytes of Keccak256 hash
of the concatenation of ticket’s hash, VRF’s encoded v
value,
PoR response and the ticket’s signature.
§Winning probability
Each ticket specifies a probability, given as an integer in [0, 2^56 - 1] where 0 -> 0% and 2^56 - 1 -> 100% win probability. If the ticket’s luck value is greater than the stated probability, it is considered a winning ticket.
Sourcepub fn verified_ticket(&self) -> &Ticket
pub fn verified_ticket(&self) -> &Ticket
Ticket with already verified signature.
Sourcepub fn verified_hash(&self) -> &Hash
pub fn verified_hash(&self) -> &Hash
Fixed ticket hash that is guaranteed to be equal to
Ticket::get_hash
of VerifiedTicket::verified_ticket
.
Sourcepub fn verified_issuer(&self) -> &Address
pub fn verified_issuer(&self) -> &Address
Verified issuer of the ticket.
The returned address is guaranteed to be equal to the signer
recovered from the VerifiedTicket::verified_ticket
’s signature.
Sourcepub fn verified_signature(&self) -> &Signature
pub fn verified_signature(&self) -> &Signature
Shorthand to retrieve reference to the verified ticket signature
Sourcepub fn into_unacknowledged(self, own_key: HalfKey) -> UnacknowledgedTicket
pub fn into_unacknowledged(self, own_key: HalfKey) -> UnacknowledgedTicket
Creates a new unacknowledged ticket from the VerifiedTicket, given our own part of the PoR challenge.
Sourcepub fn into_acknowledged(self, response: Response) -> AcknowledgedTicket
pub fn into_acknowledged(self, response: Response) -> AcknowledgedTicket
Shorthand to acknowledge the ticket if the matching response is already known. This is used upon receiving an aggregated ticket.
Trait Implementations§
Source§impl Clone for VerifiedTicket
impl Clone for VerifiedTicket
Source§fn clone(&self) -> VerifiedTicket
fn clone(&self) -> VerifiedTicket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for VerifiedTicket
impl Debug for VerifiedTicket
Source§impl<'de> Deserialize<'de> for VerifiedTicket
impl<'de> Deserialize<'de> for VerifiedTicket
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for VerifiedTicket
impl Display for VerifiedTicket
Source§impl Ord for VerifiedTicket
impl Ord for VerifiedTicket
Source§impl PartialEq for VerifiedTicket
impl PartialEq for VerifiedTicket
Source§impl PartialOrd for VerifiedTicket
impl PartialOrd for VerifiedTicket
Source§impl Serialize for VerifiedTicket
impl Serialize for VerifiedTicket
impl Eq for VerifiedTicket
impl StructuralPartialEq for VerifiedTicket
Auto Trait Implementations§
impl Freeze for VerifiedTicket
impl RefUnwindSafe for VerifiedTicket
impl Send for VerifiedTicket
impl Sync for VerifiedTicket
impl Unpin for VerifiedTicket
impl UnwindSafe for VerifiedTicket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.