SessionCrypto class final
The X25519 keypair backing one TON Connect session.
Per the session specification each side generates one keypair per session.
The public key, hex-encoded, is the client_id used to address the peer on
the HTTP bridge; the secret key never leaves the device.
A session is the pair of two client_id values. Generating a new keypair
therefore starts a new session — restoring a persisted connection MUST reuse
the stored secret key, which is what SessionCrypto.fromSecretKey is for.
- Annotations
-
- @immutable
Constructors
- SessionCrypto()
- Generates a fresh session keypair from the platform's secure RNG.
- SessionCrypto.fromSecretKey(String secretKeyHex)
-
Restores a session keypair from a previously persisted secret key.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- secretKeyHex → String
-
The 32-byte X25519 secret key as lowercase hex.
no setter
- sessionId → String
-
This session's
client_id: the 64-character lowercase hex encoding of the 32-byte X25519 public key.no setter
Methods
-
decrypt(
String encodedMessage, String senderClientId) → String -
Decrypts a base64
nonce ++ ciphertextpayload fromsenderClientId. -
encrypt(
String message, String receiverClientId) → String -
Encrypts
messagefor the peer identified byreceiverClientId. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited