示例#1
0
        /// <summary>
        ///     Creates a round 1 (zero-knowledge proof) DTO to send to the partner participant.
        /// </summary>
        public ECJpakeRound1 CreateRound1ToSend()
        {
            Contract.Requires(ProtocolState < State.Round1Created, "Round 1 payload already created.");

            BigInteger x1 = BigInteger.CreateRandomInRange(BigInteger.One, _domain.N.Subtract(BigInteger.One),
                                                           EntropySupply);

            _x2  = BigInteger.CreateRandomInRange(BigInteger.One, _domain.N.Subtract(BigInteger.One), EntropySupply);
            _gx1 = BasePointMultiplier.Multiply(_domain.G, x1);
            _gx2 = BasePointMultiplier.Multiply(_domain.G, _x2);

            ECPoint    V1, V2;
            BigInteger r1, r2;

            CreateZeroKnowledgeProof(_domain.G, x1, _gx1, ParticipantId, out V1, out r1);
            CreateZeroKnowledgeProof(_domain.G, _x2, _gx2, ParticipantId, out V2, out r2);

            var dto = new ECJpakeRound1 {
                ParticipantId = ParticipantId,
                GX1           = _gx1.GetEncoded(),
                X1V           = V1.GetEncoded(),
                X1R           = r1.ToByteArray(),
                GX2           = _gx2.GetEncoded(),
                X2V           = V2.GetEncoded(),
                X2R           = r2.ToByteArray()
            };

            ProtocolState = State.Round1Created;
            return(dto);
        }