OxL Справочник OxL
РусскийEnglish

method x25519.shared

The shared secret of your private key and the public key of the peer (32 bytes, kept in a secret). Both sides derive the same value.

Example:

oxl✓ проверяется в CI
use std.crypto { x25519 }

fn main() io, rand {
  let a = x25519.generate()
  let b = x25519.generate()
  let secret = x25519.shared(&a.secretKey, b.publicKey)!
  print("{secret}")
}
Вывод
***
pub(api) static fn shared(secretKey: &secret<bytes>, peerPublic: bytes) -> secret<bytes> | CryptoError

С версии. 1.0.0-beta

Параметры

ИмяТип
secretKey&secret<bytes>
peerPublicbytes

Возвращает

secret<bytes>

Ошибки

  • CryptoError @error
  • `CryptoError` for a key of the wrong size or a low-order peer key.

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/crypto/crypto.oxl:723

См. также