KeyExchangeAlgorithm class abstract
Abstract superclass for key exchange algorithms.
A key exchange algorithm must support newKeyPair() and sharedSecretKey().
Available algorithms
Example
In this example, we use X25519:
import 'package:cryptography/cryptography.dart';
Future<void> main() async {
// Generate a key pair for Alice
final algorithm = X25519();
final aliceKeyPair = await algorithm.newKeyPair();
// Generate a key pair for Bob.
//
// In a real application, we will receive or know Bob's public key
// somehow.
final bobKeyPair = await algorithm.newKeyPair();
final bobPublicKey = await bobKeyPair.extractPublicKey();
// We can now calculate a shared secret.
final sharedSecret = await algorithm.sharedSecretKey(
keyPair: aliceKeyPair,
remotePublicKey: bobPublicKey,
);
final sharedSecretBytes = await sharedSecret.extractBytes();
print('Shared secret: $sharedSecretBytes');
}
Constructors
- KeyExchangeAlgorithm()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
keyPairType
→ KeyPairType<
KeyPairData, PublicKey> -
no setter
- 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.
-
newKeyExchangeWandFromKeyPair(
KeyPair keyPair) → Future< KeyExchangeWand> - Returns a new KeyExchangeWand that uses the given KeyPair.
-
newKeyPair(
) → Future< KeyPair> - Generates a new KeyPair that can be used with this algorithm.
-
newKeyPairFromSeed(
List< int> seed) → Future<KeyPair> - Generates a key pair from the seed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
- Calculates a shared SecretKey.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited