IPWorks Encrypt 2020 Android Edition

Questions / Feedback?

ComputeSecret Method

Computes a shared secret.


public void computeSecret();


This method computes a shared secret using Elliptic Curve Diffie Hellman (ECDH).

When this method is called the component will use the public key specified by RecipientKey and the private key specified by Key to compute a shared secret, or secret agreement. The ComputeSecretKDF property specifies the Hash or HMAC algorithm that is applied to the raw secret. The resulting value is held by SharedSecret. The following properties are applicable when calling this method:

See ComputeSecretKDF for details on advanced settings that may be applicable for the chosen algorithm.

Keys created with the ed25519 and ed448 algorithms are not supported when calling this method.

Compute Secret Example

//Create a key for Party 1
Ecc ecc1 = new Ecc();
string ecc1_priv = ecc1.Key.PrivateKey;
string ecc1_pub = ecc1.Key.PublicKey;

//Create a key for Party 2
Ecc ecc2 = new Ecc();
string ecc2_priv = ecc2.Key.PrivateKey;
string ecc2_pub = ecc2.Key.PublicKey;

//Note: the public keys must be exchanged between parties by some mechanism

//Create the shared secret on Party 1
ecc1.Key.PrivateKey = ecc1_priv; //Private key of this party
ecc1.RecipientKey.PublicKey = ecc2_pub; //Public key of other party
ecc1.UseHex = true; //Hex encodes the shared secret bytes for easier display/storage


//Create the shared secret on Party 2
ecc2.Key.PrivateKey = ecc2_priv; //Private key of this party
ecc2.RecipientKey.PublicKey = ecc1_pub; //Public key of other party
ecc2.UseHex = true; //Hex encodes the shared secret bytes for easier display/storage

Console.WriteLine(ecc2.SharedSecret); //This will match the shared secret created by ecc1.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 Android Edition - Version 20.0 [Build 8161]