/** * The Elliptic Curve Diffe-Hellman Key Agreement Scheme as specified in ANSI X9.63 and IEEE P1363 * In ECKAS-DH1 (the Elliptic Curve Key Agreement Scheme, Diffie-Hellman 1), each party combines * its own private key with the other party�fs public key to calculate a shared secret key which * can then be used as the key for a symmetric encryption algorithm such as AES. Other (public or * private) information known to both parties may be used as key derivation parameters to ensure * that a dierent secret key is generated every session. This key agreement scheme is described * in more detail in section 9.2 of the IEEEP1363 standard. This Calculates a 128 bit secret key * from EC domain parameters dp, private key s, public key Wi and key derivation parameter P (an * octet string). s belongs to one party, Wi belongs to the other and dp and P are common to both * of them. * * @param dp The EC domain parameters. * @param s The EC private key. * @param Wi The EC public key. * @param P The key derivation parameter. * @return */ public static BigInteger ECKAS_DH1(ECDomainParameters dp, BigInteger s, ECPoint Wi, int[] P) { Fq z = ECSVDP_DH(dp, s, Wi); int[] Z = Utils.FE2OSP(z); int[] k = KDF2(Z, 16, P); // 128 bits BigInteger K = Utils.OS2IP(k); return K; }