#[repr(C)]pub struct Token {
pub(crate) t: TokenPreimage,
r: Scalar,
}Expand description
A Token consists of a randomly chosen preimage and blinding factor.
Since a token includes the blinding factor it should be treated as a client secret and NEVER revealed to the server.
Fields§
§t: TokenPreimaget is a TokenPreimage
r: Scalarr is a Scalar which is the blinding factor
Implementations§
Source§impl Token
impl Token
Sourcepub fn random<D, T>(rng: &mut T) -> Self
pub fn random<D, T>(rng: &mut T) -> Self
Generates a new random Token using the provided random number generator.
Sourcepub(crate) fn hash_from_bytes_with_blind<D>(
bytes: &[u8],
blinding_scalar: Scalar,
) -> Self
pub(crate) fn hash_from_bytes_with_blind<D>( bytes: &[u8], blinding_scalar: Scalar, ) -> Self
Creates a new Token, using hashing to derive a TokenPreimage and the specified blind
Sourcepub fn hash_from_bytes<D, T>(rng: &mut T, bytes: &[u8]) -> Self
pub fn hash_from_bytes<D, T>(rng: &mut T, bytes: &[u8]) -> Self
Creates a new Token, using hashing to derive a TokenPreimage and a random blind
Sourcepub fn blind(&self) -> BlindedToken
pub fn blind(&self) -> BlindedToken
Blinds the Token, returning a BlindedToken to be sent to the server.
Sourcepub(crate) fn unblind(
&self,
Q: &SignedToken,
) -> Result<UnblindedToken, TokenError>
pub(crate) fn unblind( &self, Q: &SignedToken, ) -> Result<UnblindedToken, TokenError>
Using the blinding factor of the original Token, unblind a SignedToken
returned from the server.
Returns a TokenError if the SignedToken point is not valid.
fn bytes_length_error() -> TokenError
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Token, TokenError>
pub fn from_bytes(bytes: &[u8]) -> Result<Token, TokenError>
Construct a Token from a slice of bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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
Mutably borrows from an owned value. Read more