Пример #1
0
        public static GT Pow(GT x, Fr y)
        {
            var g = new GT();

            g.SetPowOf(x, y);
            return(g);
        }
Пример #2
0
 public void SetMultiplicationOf(G2 x, Fr y)
 {
     unsafe
     {
         fixed(G2 *ptr = &this)
         {
             MclBls12381.Imports.MclBnG2Mul.Value(ptr, &x, &y);
         }
     }
 }
Пример #3
0
 private void SetPowOf(GT x, Fr y)
 {
     unsafe
     {
         fixed(GT *ptr = &this)
         {
             MclBls12381.Imports.MclBnGtPow.Value(ptr, &x, &y);
         }
     }
 }
Пример #4
0
        public static Fr[] Powers(Fr x, int n)
        {
            var result = new Fr[n];

            result[0] = Fr.One;
            for (var i = 1; i < n; ++i)
            {
                result[i] = result[i - 1] * x;
            }
            return(result);
        }
Пример #5
0
        public static G2 EvaluatePolynomial(G2[] poly, Fr at)
        {
            unsafe
            {
                var res = new G2();

                fixed(G2 *cVec = poly)
                Imports.MclBnG2EvaluatePolynomial.Value(&res, cVec, (ulong)poly.Length, &at);

                return(res);
            }
        }
Пример #6
0
        public static Fr EvaluatePolynomial(Fr[] poly, Fr at)
        {
            unsafe
            {
                var res = new Fr();

                fixed(Fr *cVec = poly)
                Imports.MclBnFrEvaluatePolynomial.Value(&res, cVec, (ulong)poly.Length, &at);

                return(res);
            }
        }
Пример #7
0
        public static Fr LagrangeInterpolate(Fr[] xs, Fr[] ys)
        {
            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("arrays are unequal length");
            }
            unsafe
            {
                var res = new Fr();

                fixed(Fr *xVec = xs)
                fixed(Fr * yVec = ys)
                Imports.MclBnFrLagrangeInterpolation.Value(&res, xVec, yVec, (ulong)xs.Length);

                return(res);
            }
        }