pub struct Token {
pub header: Header,
pub payload: Payload,
pub message_hash: [u8; 32],
pub signature: Vec<u8>,
pub token: String,
}
Expand description
EWT Authentication Token
Fields
header: Header
payload: Payload
message_hash: [u8; 32]
The hashed value of the message:
keccak256(header_json_base64.payload_json_base64)
signature: Vec<u8>
The signature after signing the message to_ethereum_signed(keccak256("{header_base64}.{payload_base64}"))
The signature is in the form of {r}{s}{v}{mode}
where mode
is 01
for Ethereum Signature
token: String
Will result in authentication token string in the format of:
{header_base64_encoded}.{payload_base64_encoded}.{signature_base64_encoded}
All fields are base64 encoded
Implementations
sourceimpl Token
impl Token
sourcepub fn sign(
signer: &SecretKey,
payload: Payload
) -> Result<Self, EwtSigningError>
pub fn sign(
signer: &SecretKey,
payload: Payload
) -> Result<Self, EwtSigningError>
Signs a payload given a signer account & password.
For the Header
it uses ETH_HEADER
.
Ethereum web token
signing of payload with 1 difference:
it’s not the JSON string representation that gets signed
but the keccak256(payload_json)
.
pub fn verify(token: &str) -> Result<(Token, VerifyPayload), EwtVerifyError>
Trait Implementations
sourceimpl Display for Token
impl Display for Token
The EWT Token string is returned, ready to be used in an Authentication header.
impl Eq for Token
impl StructuralEq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.