IPWorks Encrypt 2020 Python Edition

Questions / Feedback?

compute_secret Method

Computes a shared secret.

Syntax

def compute_secret() -> None: ...

Remarks

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

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

See compute_secret_kdf 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();
ecc1.CreateKey("x25519");
string ecc1_priv = ecc1.Key.PrivateKey;
string ecc1_pub = ecc1.Key.PublicKey;

//Create a key for Party 2
Ecc ecc2 = new Ecc();
ecc2.CreateKey("x25519");
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.Reset();
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
ecc1.ComputeSecret();

Console.WriteLine(ecc1.SharedSecret);

//Create the shared secret on Party 2
ecc2.Reset();
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
ecc2.ComputeSecret();

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 Python Edition - Version 20.0 [Build 8155]