Ecdsa class abstract
ECDSA with P-256 / P-384 / P-521 elliptic curve.
For more information about ECDSA, read RFC 6090 ("Fundamental Elliptic Curve Cryptography Algorithms").
Secret keys can be instances of EcSecretKey
or implementation-specific
subclasses of SecretKey.
Example
import 'package:better_cryptography/better_cryptography.dart';
Future<void> main() async {
// In this example, we use ECDSA-P256-SHA256
final algorithm = Ecdsa.p256(Sha256());
// Generate a random key pair
final secretKey = await algorithm.newSecretKey();
final publicKey = await algorithm.publicKey(secretKey);
// Sign a message
final message = <int>[1,2,3];
final signature = await algorithm.sign(
[1,2,3],
secretKey: secretKey,
);
// Anyone can verify the signature
final isVerified = await algorithm.verify(
message: message,
signature: signature,
);
}
- Inheritance
-
- Object
- SignatureAlgorithm
- Ecdsa
- Implementers
Constructors
- Ecdsa.constructor()
-
Constructor for classes that extend this class.
const
- Ecdsa.p256(HashAlgorithm hashAlgorithm)
-
ECDSA using P-256 (secp256r1 / prime256v1) elliptic curve.
factory
- Ecdsa.p384(HashAlgorithm hashAlgorithm)
-
ECDSA using P-384 (secp384r1 / prime384v1) elliptic curve.
factory
- Ecdsa.p521(HashAlgorithm hashAlgorithm)
-
ECDSA using P-521 (secp521r1 / prime521v1) elliptic curve.
factory
Properties
- hashAlgorithm → HashAlgorithm
-
Used hash algorithm.
no setter
- 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
-
newKeyPair(
) → Future< EcKeyPair> -
Generates a new KeyPair for this algorithm.
override
-
newKeyPairFromSeed(
List< int> seed) → Future<EcKeyPair> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sign(
List< int> message, {required KeyPair keyPair}) → Future<Signature> -
Calculates signature for the message.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
verify(
List< int> message, {required Signature signature}) → Future<bool> -
Verifies the signature.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited