pub struct RelayTicketIssuer { /* private fields */ }Expand description
Mints and verifies relay tickets from a per-pair secret.
Implementations§
Source§impl RelayTicketIssuer
impl RelayTicketIssuer
Sourcepub fn from_secret(secret: &[u8]) -> Self
pub fn from_secret(secret: &[u8]) -> Self
Derive the ticket key from the per-pair secret under the relay label.
Takes bytes rather than a string: the secret is random material, not text, and hex-decoding it at the boundary keeps that explicit.
Sourcepub fn mint(
&self,
target: &str,
request: &RequestBinding<'_>,
now: i64,
) -> Option<String>
pub fn mint( &self, target: &str, request: &RequestBinding<'_>, now: i64, ) -> Option<String>
Mint a ticket for request addressed to target, issued at now,
with a fresh random nonce. None only when the system cannot supply
randomness.
Sourcepub fn mint_with_nonce(
&self,
target: &str,
request: &RequestBinding<'_>,
now: i64,
nonce: &str,
) -> String
pub fn mint_with_nonce( &self, target: &str, request: &RequestBinding<'_>, now: i64, nonce: &str, ) -> String
Deterministic mint core (explicit nonce) for tests.
Sourcepub fn verify(
&self,
token: &str,
expected_target: &str,
request: &RequestBinding<'_>,
now: i64,
) -> Result<VerifiedRelayTicket, RelayTicketError>
pub fn verify( &self, token: &str, expected_target: &str, request: &RequestBinding<'_>, now: i64, ) -> Result<VerifiedRelayTicket, RelayTicketError>
Verify a ticket against the request it arrived with: authenticity first, then what it is bound to, then time.
Order matters. Checking the binding or the clock before the HMAC would answer questions about a string nobody has shown to be ours.
This does NOT spend the nonce; the caller does that with
VerifiedRelayTicket::spend at the point where a second arrival
would re-execute the request.