Beispiel #1
0
        //public override byte[] writeToByteArray()
        //{
        //    var bs = new BitStream();
        //    bs.writeMessageType(MessageType.MULT_STEP_VERIFY_POLY);
        //    writeToBitStreamNoHeader(bs);
        //    bs.close();
        //    return bs.ByteArray;
        //}

        //public override void loadFromByteArrayNoHeader(BitStream bs, int prime)
        //{
        //    if (bs.readBoolean())
        //        RxPolynomial_Renamed = bs.readList(prime);
        //}

        //public override void writeToBitStreamNoHeader(BitStream bs)
        //{
        //    bs.writeBoolean(RxPolynomial_Renamed != null);
        //    if (RxPolynomial_Renamed != null)
        //        bs.writeList(RxPolynomial_Renamed);
        //}

        public override bool Equals(object obj)
        {
            if (!(obj is MultStepVerificationPoly))
            {
                return(false);
            }
            MultStepVerificationPoly second = (MultStepVerificationPoly)obj;

            if (RxPolynomial_Renamed == null && second.RxPolynomial_Renamed != null || RxPolynomial_Renamed != null && second.RxPolynomial_Renamed == null)
            {
                return(false);
            }
            if (RxPolynomial_Renamed == null && second.RxPolynomial_Renamed == null)
            {
                return(true);
            }
            if (RxPolynomial_Renamed.Count != second.RxPolynomial_Renamed.Count)
            {
                return(false);
            }
            for (int i = 0; i < RxPolynomial_Renamed.Count; i++)
            {
                if (!(RxPolynomial_Renamed[i] == second.RxPolynomial_Renamed[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        private bool IsMultStepShareLegal(MultStepBCaseShare recvShareFromPlayer_i, MultStepVerificationPoly recvVerifcationPolynomial)
        {
            if (!IsRecvShareLegal(recvShareFromPlayer_i))
                return false;

            var RxPolynomial = recvVerifcationPolynomial.RxPolynomial;
            Zp Ratpoint0 = Zp.EvalutePolynomialAtPoint(RxPolynomial, new Zp(Prime, 0));
            if (!Ratpoint0.Equals(new Zp(Prime, 0)))
            {
                return false;
            }
            int w = NumTheoryUtils.GetFieldMinimumPrimitive(Prime);
            var w_InMyIndex = new Zp(Prime, NumTheoryUtils.ModPow(w, Party.Id, Prime));
            Zp RjFromPublicPolynomial = Zp.EvalutePolynomialAtPoint(RxPolynomial, w_InMyIndex);

            Zp temp = recvShareFromPlayer_i.AShare.ConstMul(recvShareFromPlayer_i.BShare).ConstSub(recvShareFromPlayer_i.AbShare);
            Zp RjFromRecvPrivateInfo = w_InMyIndex.ConstMul(recvShareFromPlayer_i.RShare).ConstAdd(temp);
            if (!RjFromPublicPolynomial.Equals(RjFromRecvPrivateInfo))
                return false;

            return true;
        }
Beispiel #3
0
 private bool IsMultStepPolynomialLegal(MultStepVerificationPoly recvVerifcationPolynomial)
 {
     if (recvVerifcationPolynomial != null)
     {
         var RxPolynomial = recvVerifcationPolynomial.RxPolynomial;
         if (!IsPolynomialLegal(RxPolynomial, 2 * PolynomialDeg + 1))
             return false;
     }
     else
         return false;
     return true;
 }