data x25519
X25519 key agreement (RFC 7748). Hash the shared secret (or use HKDF) before using it as a key.
Example:
use std.crypto { x25519 }
fn main() io, rand {
let alice = x25519.generate()
let bob = x25519.generate()
let a = x25519.shared(&alice.secretKey, bob.publicKey)!
let b = x25519.shared(&bob.secretKey, alice.publicKey)!
print("{a.reveal() == b.reveal()}")
}Вывод
true
pub(api) data x25519Потокобезопасность. pure functions apart from `generate`; safe from any task.
С версии. 1.0.0-beta
Методы
generate | () -> KeyPair randA new random X25519 key pair. |
shared | (secretKey: &secret<bytes>, peerPublic: bytes) -> secret<bytes> | CryptoErrorThe shared secret of your private key and the public key of the peer (32 bytes, kept in a secret). |
Определено в: std/crypto/crypto.oxl:683