Exemple #1
0
        /// <summary>
        /// Creates and returns the payload to send to the other participant during round 2.
        ///
        /// ValidateRound1PayloadReceived(JPakeRound1Payload) must be called prior to this method.
        ///
        /// After execution, the State state will be  STATE_ROUND_2_CREATED.
        ///
        /// Throws InvalidOperationException if called prior to ValidateRound1PayloadReceived(JPakeRound1Payload), or multiple times
        /// </summary>
        public virtual JPakeRound2Payload CreateRound2PayloadToSend()
        {
            if (this.state >= STATE_ROUND_2_CREATED)
                throw new InvalidOperationException("Round 2 payload already created for " + this.participantId);
            if (this.state < STATE_ROUND_1_VALIDATED)
                throw new InvalidOperationException("Round 1 payload must be validated prior to creating round 2 payload for " + this.participantId);

            BigInteger gA = JPakeUtilities.CalculateGA(p, gx1, gx3, gx4);
            BigInteger s = JPakeUtilities.CalculateS(password);
            BigInteger x2s = JPakeUtilities.CalculateX2s(q, x2, s);
            BigInteger A = JPakeUtilities.CalculateA(p, q, gA, x2s);
            BigInteger[] knowledgeProofForX2s = JPakeUtilities.CalculateZeroKnowledgeProof(p, q, gA, A, x2s, participantId, digest, random);

            this.state = STATE_ROUND_2_CREATED;

            return new JPakeRound2Payload(participantId, A, knowledgeProofForX2s);
        }
        public virtual JPakeRound2Payload CreateRound2PayloadToSend()
        {
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0040: Unknown result type (might be due to invalid IL or missing references)
            if (state >= STATE_ROUND_2_CREATED)
            {
                throw new InvalidOperationException("Round 2 payload already created for " + participantId);
            }
            if (state < STATE_ROUND_1_VALIDATED)
            {
                throw new InvalidOperationException("Round 1 payload must be validated prior to creating round 2 payload for " + participantId);
            }
            BigInteger gA          = JPakeUtilities.CalculateGA(p, gx1, gx3, gx4);
            BigInteger s           = JPakeUtilities.CalculateS(password);
            BigInteger bigInteger  = JPakeUtilities.CalculateX2s(q, x2, s);
            BigInteger bigInteger2 = JPakeUtilities.CalculateA(p, q, gA, bigInteger);

            BigInteger[] knowledgeProofForX2s = JPakeUtilities.CalculateZeroKnowledgeProof(p, q, gA, bigInteger2, bigInteger, participantId, digest, random);
            state = STATE_ROUND_2_CREATED;
            return(new JPakeRound2Payload(participantId, bigInteger2, knowledgeProofForX2s));
        }