e-CryptIt Engine Xojo Plugin |
|
EinhugurEd25519.KeyExchange Method
Exchanges public keys to securely get shared secret.
KeyExchange(
otherPublicKey as String,
privateKey as String) as String
Parameters
- otherPublicKey
- The public key coming from the other person.
- privateKey
- Your private key.
Returns
- String
- Shared secret. (Note that shared secret is binary data, so not string with any encoding, you can use EncodeHex to represent it as Hex though if wanting to display it)
Shared secret is 32 character long.
Remarks
Key exchange goes as follows:
1. Person A gives their public key to Person B.
2. Person B gives their public key to Person A.
3. Person A uses KeyExchange method, using public Key from Person B, but their own private key.
4. Person B uses KeyExchange method, using public Key from Person A, but their own private key.
Now Person A and Person B will both have generated the same shared secret without having passed any Private key between them.
var message as String = "Some important message"
var keys as new EinhugurEd25519.KeyPair()
var signature as String = EinhugurEd25519.Sign(message,keys)
MessageBox("Signature: " + EndOfLine + EncodeHex(signature))
if EinhugurEd25519.Verify(message, signature, keys.PublicKey) then
MessageBox("Signature was valid")
else
MessageBox("Signature was not valid")
end if
var keys2 as new EinhugurEd25519.KeyPair()
var sharedSecret as String = EinhugurEd25519.KeyExchange(keys2.PublicKey, keys.PrivateKey)
var sharedSecret2 as String = EinhugurEd25519.KeyExchange(keys.PublicKey, keys2.PrivateKey)
if sharedSecret = sharedSecret2 then
MessageBox("Shared secret matches")
else
MessageBox("Shared secret does not match")
end if
This function can throw InvalidArgumentException if the keys are of incorrect size.
Supported Platforms:
macOS Intel 64 bitmacOS Apple SiliconWindows 32 bitWindows 64 bitWindows ARM 64 bitLinux 32 bitLinux 64 bitLinux ARM 32 bitLinux ARM 64 bitiOS
See Also
EinhugurEd25519 Module