This document describes examples of signing and verification with a key pair using the NosoDart library.
- Check for key pair matching
- Signing message or creating an ECSignature
- Verification of the signed message
This example demonstrates how to perform a key-pair matching check.
bool isMatching = NosoSigner().verifyKeysPair(KeyPair(publicKey: "examplePublic", privateKey: "examplePrivate"));
The verifyKeysPair() method will return true if the key match is confirmed, otherwise it will return false.
This example explains how to create an ECSignature signature and convert it to Base64. Or just sign the message for further verification.
ECSignature? ecSignature = NosoSigner().signMessage("exampleMessage", "examplePrivatKey");
The signMessage() method will return a valid ECSignature if no exceptions occurred in the process, otherwise null will be returned;
String signatureString = NosoSigner().encodeSignatureToBase64(ecSignature);
ECSignature decodeEcSignature = NosoSigner().decodeBase64ToSignature(signatureString);
This example demonstrates how to verify a signed message.
bool isVerified = NosoSigner().verifySignedString("exampleMessage", ecSignature, "examplePublickKey");
The verifySignedString() method will return true if the message signature is confirmed, otherwise it will return false;