Exemple #1
0
        /// <summary>
        ///     Creates a round 2 (zero-knowledge proof) DTO to send to the partner participant.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        ///     Prior round (1) has not been completed yet, or method may have been called more than once.
        /// </exception>
        public ECJpakeRound2 CreateRound2ToSend()
        {
            if (ProtocolState >= State.Round2Created)
            {
                throw new InvalidOperationException("Round 2 payload already created.");
            }
            if (ProtocolState < State.Round1Validated)
            {
                throw new InvalidOperationException("Round 1 payload must be validated prior to creating Round 2 payload.");
            }

            var s1 = new BigInteger(_passwordBytes);

            ECPoint    GA   = _gx1.Add(_gx3).Add(_gx4);
            BigInteger x2s1 = _x2.Multiply(s1).Mod(_domain.N);
            ECPoint    A    = BasePointMultiplier.Multiply(GA, x2s1);

            ECPoint    X2sV;
            BigInteger X2sR;

            CreateZeroKnowledgeProof(GA, x2s1, A, ParticipantId, out X2sV, out X2sR);

            var dto = new ECJpakeRound2 {
                ParticipantId = ParticipantId,
                A             = A.GetEncoded(),
                X2sV          = X2sV.GetEncoded(),
                X2sR          = X2sR.ToByteArray()
            };

            ProtocolState = State.Round2Created;
            return(dto);
        }
Exemple #2
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = ParticipantId.GetHashCode();
         hashCode = (hashCode * 397) ^ A.GetHashCode();
         hashCode = (hashCode * 397) ^ X2sV.GetHashCode();
         hashCode = (hashCode * 397) ^ X2sR.GetHashCode();
         return(hashCode);
     }
 }
Exemple #3
0
 /// <inheritdoc />
 public bool Equals(ECJpakeRound2 other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(String.Equals(ParticipantId, other.ParticipantId, StringComparison.Ordinal) &&
            A.SequenceEqualShortCircuiting(other.A) && X2sV.SequenceEqualShortCircuiting(other.X2sV) &&
            X2sR.SequenceEqualShortCircuiting(other.X2sR));
 }