Struct VerifiedTicket
pub struct VerifiedTicket {
ticket: Ticket,
hash: HashBase<CoreWrapper<Keccak256Core>>,
issuer: Address,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
}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
Fields§
§ticket: Ticket§hash: HashBase<CoreWrapper<Keccak256Core>>§issuer: Address§channel_id: HashBase<CoreWrapper<Keccak256Core>>Implementations§
§impl VerifiedTicket
impl VerifiedTicket
pub fn win_prob(&self) -> WinningProbability
pub fn win_prob(&self) -> WinningProbability
Returns the verified encoded winning probability of the ticket
pub fn is_winning(
&self,
response: &Response,
chain_keypair: &ChainKeypair,
domain_separator: &HashBase<CoreWrapper<Keccak256Core>>,
) -> bool
pub fn is_winning( &self, response: &Response, chain_keypair: &ChainKeypair, domain_separator: &HashBase<CoreWrapper<Keccak256Core>>, ) -> 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
where the input is 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.
pub fn verified_ticket(&self) -> &Ticket
pub fn verified_ticket(&self) -> &Ticket
Ticket with already verified signature.
pub fn verified_hash(&self) -> &HashBase<CoreWrapper<Keccak256Core>>
pub fn verified_hash(&self) -> &HashBase<CoreWrapper<Keccak256Core>>
Fixed ticket hash that is guaranteed to be equal to
[Ticket::get_hash] of VerifiedTicket::verified_ticket.
pub 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.
pub fn channel_id(&self) -> &HashBase<CoreWrapper<Keccak256Core>>
pub fn channel_id(&self) -> &HashBase<CoreWrapper<Keccak256Core>>
Channel ID of the ticket.
The ticket is guaranteed to belong to the channel with the returned ChannelId.
pub fn verified_signature(&self) -> &ChainSignature<NativeEcdsaSigningEngine>
pub fn verified_signature(&self) -> &ChainSignature<NativeEcdsaSigningEngine>
Shorthand to retrieve reference to the verified ticket signature
pub fn leak(self) -> Ticket
pub fn leak(self) -> Ticket
Deconstructs self back into the unverified [Ticket].
pub 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.
pub 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.
Trait Implementations§
§impl Clone for VerifiedTicket
impl Clone for VerifiedTicket
§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 more§impl Debug for VerifiedTicket
impl Debug for VerifiedTicket
§impl<'de> Deserialize<'de> for VerifiedTicket
impl<'de> Deserialize<'de> for VerifiedTicket
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VerifiedTicket, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VerifiedTicket, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Display for VerifiedTicket
impl Display for VerifiedTicket
§impl Ord for VerifiedTicket
impl Ord for VerifiedTicket
§impl PartialEq for VerifiedTicket
impl PartialEq for VerifiedTicket
§impl PartialOrd for VerifiedTicket
impl PartialOrd for VerifiedTicket
§impl Serialize for VerifiedTicket
impl Serialize for VerifiedTicket
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy 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<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> 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> Pointable for T
impl<T> Pointable for T
§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.