예제 #1
0
        /// <summary>
        /// Compute shared key for the handshake communication.
        /// </summary>
        /// <param name="pseudonym"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public byte[] computeSharedKeyClient(string pseudonym, string role)
        {
            string  credential     = pseudonym + "-" + role;
            Element credentialHash = m_pairing.elementFromHash(new G1(), credential);
            Element sharedKey      = m_pairing.apply(credentialHash, m_secret);

            return(sharedKey.toBuffer());
        }
예제 #2
0
        public static void testPairings()
        {
            Debug.WriteLine("Running pairing test...");

            Pairing pairing = new Pairing();

            Debug.WriteLine("Pairing is " + (pairing.isSymmetric() ? "" : "not ") + "symmetric");

            Element g1 = pairing.elementFromHash(new G1(), "ABCDEF");

            byte[] buffer = g1.toBuffer();
            Debug.WriteLine(Convert.ToBase64String(buffer));

            Element g2 = pairing.elementFromHash(new G2(), "ADcsde");
            Element gt = pairing.apply(g1, g2);

            Debug.WriteLine("OK");
        }