Expand description
§verse-session-id
ID with signature/verification functions.
Used as session ID in @VerseEngine/verse-core.
§Usage
§Signature Verification
use verse_session_id::*;
...
pub fn verify_string(session_id: &str, signature: &str, data: &str) -> bool {
let Ok(sid) = session_id.parse::<SessionId>() else {
return false;
};
let Ok(ss) = signature.parse::<SignatureSet>() else {
return false;
};
sid.verify(vec![data.as_bytes()], &ss).is_ok()
}
§Generate ID
let id_pair = new_session_id_pair()?;
let session_id = id_pair.get_id();
// to string
let s = format!("{}", session_id);
§Create a signature
pub fn sign_string(&self, data: &str) -> Result<String> {
let id_pair = ...;
Ok(id_pair
.sign(vec![data.as_bytes()])?
.to_string())
}
Macros§
Structs§
- Session
Id - Session ID The session ID is the public key for ED25519.
- Signature
Set - Signature
Constants§
- SESSION_
ID_ SIZE - Bytes of Session ID
- SIGNATURE_
SALT_ SIZE - Signature Salt Size
- SIGNATURE_
SIZE - Signature Size
Traits§
- ISession
IdPair - Session
IdCompatible - Session
IdPublic - Session ID as public key
Functions§
- new_
session_ id_ pair - Generate SessionIdPair
Type Aliases§
- RawSession
Id - Session ID data
- Session
IdPair - Session ID and private key pair (ED25519).