I am looking for a dart package in order to implement key exchange protocol (Elliptic-curve Diffie–Hellman) in a Flutter application.
- app generates a key pair during login and sends the public key to server (so a new key pair is generated for every login)
- server sends back its public key that it just generated
- app generates a secret key from its private key and server's public key
- app includes the hmac of all subsequent messages sent to the server
I took a look at pointycastle, which has supported Diffie–Hellman. But I don't find any method where to generate a secret key. This is what java does to generate:
KeyAgreement a = KeyAgreement.getInstance("ECDH", "SC");
a.init(mProvisionerPrivaetKey);
a.doPhase(publicKey, true);
Wonder if there's some clue you found to generate a secret key from its private key and server's public key in dart.