X25519 class abstract

X25519 (RFC 7748) KeyExchangeAlgorithm.

X25519 is an elliptic curve Diffie-Hellman key exchange algorithm that uses Curve25519.

By default, DartX25519 will be used. If you use Flutter, you can enable cryptography_flutter. It can improve performance in many cases.

Things to know

Example

import 'package:cryptography/cryptography.dart';

Future<void> main() async {
  final algorithm = X25519();

  // We need the private key pair of Alice.
  final aliceKeyPair = await algorithm.newKeyPair();

  // We need only public key of Bob.
  final bobKeyPair = await algorithm.newKeyPair();
  final bobPublicKey = await bobKeyPair.extractPublicKey();

  // We can now calculate a 32-byte shared secret key.
  final sharedSecretKey = await algorithm.sharedSecretKey(
    keyPair: aliceKeyPair,
    remotePublicKey: bobPublicKey,
  );
}

## In need of synchronous APIs?

If you need to perform operations synchronously, use [DartX25519] in
_package:cryptography/dart.dart_.
Inheritance
Implementers

Constructors

X25519()
factory
X25519.constructor({Random? random})
Constructor for classes that extend this class.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
keyPairType KeyPairType<KeyPairData, PublicKey>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

newKeyExchangeWand() Future<KeyExchangeWand>
Returns a new KeyExchangeWand that has a random KeyPair.
inherited
newKeyExchangeWandFromKeyPair(KeyPair keyPair) Future<KeyExchangeWand>
Returns a new KeyExchangeWand that uses the given KeyPair.
inherited
newKeyPair() Future<SimpleKeyPair>
Generates a new KeyPair that can be used with this algorithm.
override
newKeyPairFromSeed(List<int> seed) Future<SimpleKeyPair>
Generates a key pair from the seed.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sharedSecretKey({required KeyPair keyPair, required PublicKey remotePublicKey}) Future<SecretKey>
Calculates a shared SecretKey.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited