Beispiel #1
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 #2
0
        private IList <Zp> ConstructRxPolynomial(ShareDetails aSharesDetails,
                                                 ShareDetails bSharesDetails, ShareDetails abSharesDetails, ShareDetails rSharesDetails)
        {
            var fax = aSharesDetails.RandomPolynomial;
            var fbx = bSharesDetails.RandomPolynomial;
            var hx  = abSharesDetails.RandomPolynomial;
            var rx  = rSharesDetails.RandomPolynomial;

            var RxPolynomial = new Zp[2 * PolynomialDeg + 1];

            /* Initialize RxPolynomial coefs with zeros  */
            for (int i = 0; i < 2 * PolynomialDeg + 1; i++)
            {
                RxPolynomial[i] = new Zp(Prime, 0);
            }

            /* First calculate fax*fbx - hx */
            for (int i = 0; i < fax.Count; i++)
            {
                Zp temp = fax[i];
                for (int j = 0; j < fax.Count; j++)
                {
                    RxPolynomial[i + j].Add(temp.ConstMul(fbx[j]));
                }

                RxPolynomial[i].Sub(hx[i]);
            }
            /* Calculate x*rx+fax*fbx - hx*/
            for (int i = 0; i < rx.Count; i++)
            {
                RxPolynomial[i + 1].Add(rx[i]);
            }

            return(new List <Zp>(RxPolynomial));
        }
Beispiel #3
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;
        }