update-fork
MITSUNARI Shigeo 5 years ago
parent b108b31c17
commit 402b825fc0
  1. 3
      ffi/go/mcl/init.go
  2. 8
      ffi/go/mcl/mcl.go
  3. 4
      ffi/go/mcl/mcl_test.go

@ -11,6 +11,7 @@ package mcl
*/
import "C"
import "fmt"
// Init --
// call this function before calling all the other operations
// this function is not thread safe
@ -21,5 +22,3 @@ func Init(curve int) error {
}
return nil
}

@ -313,7 +313,7 @@ func G1Mul(out *G1, x *G1, y *Fr) {
// G1MulVec -- multi scalar multiplication out = sum mul(xVec[i], yVec[i])
func G1MulVec(out *G1, xVec []G1, yVec []Fr) {
if len(xVec) != len (yVec) {
if len(xVec) != len(yVec) {
panic("xVec and yVec have the same size")
}
C.mclBnG1_mulVec(out.getPointer(), (*C.mclBnG1)(unsafe.Pointer(&xVec[0])), (*C.mclBnFr)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
@ -431,7 +431,7 @@ func G2Mul(out *G2, x *G2, y *Fr) {
// G2MulVec -- multi scalar multiplication out = sum mul(xVec[i], yVec[i])
func G2MulVec(out *G2, xVec []G2, yVec []Fr) {
if len(xVec) != len (yVec) {
if len(xVec) != len(yVec) {
panic("xVec and yVec have the same size")
}
C.mclBnG2_mulVec(out.getPointer(), (*C.mclBnG2)(unsafe.Pointer(&xVec[0])), (*C.mclBnFr)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
@ -568,9 +568,9 @@ func MillerLoop(out *GT, x *G1, y *G2) {
C.mclBn_millerLoop(out.getPointer(), x.getPointer(), y.getPointer())
}
// MillerLoopVec -- multi pairing
// MillerLoopVec -- multi pairings ; out = prod_i e(xVec[i], yVec[i])
func MillerLoopVec(out *GT, xVec []G1, yVec []G2) {
if len(xVec) != len (yVec) {
if len(xVec) != len(yVec) {
panic("xVec and yVec have the same size")
}
C.mclBn_millerLoopVec(out.getPointer(), (*C.mclBnG1)(unsafe.Pointer(&xVec[0])), (*C.mclBnG2)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))

@ -79,7 +79,7 @@ func testVecG1(t *testing.T) {
var R1, R2 G1
for i := 0; i < N; i++ {
if i > 0 {
G1Dbl(&xVec[i], &xVec[i - 1])
G1Dbl(&xVec[i], &xVec[i-1])
}
yVec[i].SetByCSPRNG()
G1Mul(&R1, &xVec[i], &yVec[i])
@ -99,7 +99,7 @@ func testVecG2(t *testing.T) {
var R1, R2 G2
for i := 0; i < N; i++ {
if i > 0 {
G2Dbl(&xVec[i], &xVec[i - 1])
G2Dbl(&xVec[i], &xVec[i-1])
}
yVec[i].SetByCSPRNG()
G2Mul(&R1, &xVec[i], &yVec[i])

Loading…
Cancel
Save