Exemplo n.º 1
0
        public static GT Pow(GT x, Fr y)
        {
            var g = new GT();

            g.SetPowOf(x, y);
            return(g);
        }
Exemplo n.º 2
0
 public void SetMultiplicationOf(G2 x, Fr y)
 {
     unsafe
     {
         fixed(G2 *ptr = &this)
         {
             MclBls12381.Imports.MclBnG2Mul.Value(ptr, &x, &y);
         }
     }
 }
Exemplo n.º 3
0
 private void SetPowOf(GT x, Fr y)
 {
     unsafe
     {
         fixed(GT *ptr = &this)
         {
             MclBls12381.Imports.MclBnGtPow.Value(ptr, &x, &y);
         }
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }