aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/tangerine-network/bls
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/tangerine-network/bls')
-rw-r--r--vendor/github.com/tangerine-network/bls/.gitignore7
-rw-r--r--vendor/github.com/tangerine-network/bls/.travis.yml39
-rw-r--r--vendor/github.com/tangerine-network/bls/CMakeLists.txt33
-rw-r--r--vendor/github.com/tangerine-network/bls/Makefile164
-rw-r--r--vendor/github.com/tangerine-network/bls/bin/.emptydir0
-rw-r--r--vendor/github.com/tangerine-network/bls/bls.sln30
-rw-r--r--vendor/github.com/tangerine-network/bls/bls_smpl.py40
-rw-r--r--vendor/github.com/tangerine-network/bls/common.props26
-rw-r--r--vendor/github.com/tangerine-network/bls/debug.props14
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/App.config6
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/Properties/AssemblyInfo.cs36
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls.cs351
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls.csproj97
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls.sln25
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls256.cs298
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls256.csproj62
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls256.sln22
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls256_test.cs126
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/bls_test.cs176
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/readme-ja.md188
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/cs/readme.md185
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/go/bls/bls.go539
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/go/bls/callback.go12
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/go/bls/dummy.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/ffi/go/bls/mcl.go646
-rw-r--r--vendor/github.com/tangerine-network/bls/images/bls-go-alpine/Dockerfile12
-rw-r--r--vendor/github.com/tangerine-network/bls/include/bls/bls.h275
-rw-r--r--vendor/github.com/tangerine-network/bls/include/bls/bls.hpp534
-rw-r--r--vendor/github.com/tangerine-network/bls/lib/.emptydir0
-rw-r--r--vendor/github.com/tangerine-network/bls/mk.bat20
-rwxr-xr-xvendor/github.com/tangerine-network/bls/mkdll.bat8
-rw-r--r--vendor/github.com/tangerine-network/bls/mklib.bat26
-rw-r--r--vendor/github.com/tangerine-network/bls/obj/.emptydir0
-rw-r--r--vendor/github.com/tangerine-network/bls/readme.md187
-rw-r--r--vendor/github.com/tangerine-network/bls/release.props12
-rw-r--r--vendor/github.com/tangerine-network/bls/sample/bls_smpl.cpp168
-rwxr-xr-xvendor/github.com/tangerine-network/bls/setvar.bat6
-rw-r--r--vendor/github.com/tangerine-network/bls/src/bls_c256.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/src/bls_c384.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/src/bls_c384_256.cpp4
-rw-r--r--vendor/github.com/tangerine-network/bls/src/bls_c_impl.hpp614
-rw-r--r--vendor/github.com/tangerine-network/bls/src/proj/bls.vcxproj92
-rw-r--r--vendor/github.com/tangerine-network/bls/src/qcoeff-bn254.hpp564
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls256_test.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls384_256_test.cpp4
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls384_test.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls_c256_test.cpp2
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls_c384_256_test.cpp3
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls_c384_test.cpp2
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls_c_test.hpp437
-rw-r--r--vendor/github.com/tangerine-network/bls/test/bls_test.hpp545
-rw-r--r--vendor/github.com/tangerine-network/bls/test/proj/bls_test/bls_test.vcxproj88
52 files changed, 6740 insertions, 0 deletions
diff --git a/vendor/github.com/tangerine-network/bls/.gitignore b/vendor/github.com/tangerine-network/bls/.gitignore
new file mode 100644
index 000000000..dacdfc906
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/.gitignore
@@ -0,0 +1,7 @@
+CVS
+bin/*.exe
+lib/*.a
+lib/*.so
+lib/*.dylib
+obj/*.d
+obj/*.o
diff --git a/vendor/github.com/tangerine-network/bls/.travis.yml b/vendor/github.com/tangerine-network/bls/.travis.yml
new file mode 100644
index 000000000..71a667a2e
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/.travis.yml
@@ -0,0 +1,39 @@
+sudo: true
+dist: xenial
+services:
+- docker
+env:
+ global:
+ - IMAGE_TAG=dexonfoundation/bls-go-alpine
+ - DOCKER_USER=spiderpowadeploy
+ - secure: mqNCngWukyjE3UARxaPjqS0xgC1dsnWfmPhpH2mq7nR6S2cGfJ3xBfyiTS//Clz//7sAL+Tp62r3fxyMjDogrSHZUUssCAwf17RM6vnALqaVbc3wXcTNudiDB5cVKe9C9gZqn1Ivd+qbmtuCezSrOG5Xih1gh4bPTyiFvU1sp9C2icMHkJZkjsP0QqCbHlQrMeECSIPlEGIOXUUSp+WmrZAdi2rHezKeZxuaT73RX1+N/+1RfWXo2MR4ydQU3eALl5s5UA9JweQO+MYIVr8EEpGNqJRYUyURx/5G/Sy2v6Z3imUvXZv1J5aplW/UDls92Olla1JHuvFW6ptRO+PHITNwvEkhxPFj+HcOpqEuSISsdk9rkHUrM0wEYPv6A4vQPUjMHrLQs2tQShVCelM1HtNvDDjttKMmVyRLusFP9eS7uvmmXu2l6efJjsMSFkY5WKbu2U0MQ1j708KH9k2WunU6sjJ+b74PkkZVtkQMIqgTokC0IOqbbrnwh4I9PpVpHAQrewRimMH+lDHk+HlMUCWk7/IcIFUl+mh6RzW2vkZTTr2ctSBI6QzK5smdPmqQpp2lqkGv/hQCBp5ICzFSkU6Djqe3hG8ta3+/Zhi10fPU2HcHDi+gR79CG8dvy+iOeTS2csXZx+YoN2BVkfu9AnrjZ9Kjkf9BMay4CehBUWE=
+language: cpp
+compiler:
+- gcc
+- clang
+addons:
+ apt:
+ packages:
+ - libgmp-dev
+install:
+- git clone --depth 1 https://github.com/dexon-foundation/mcl.git $TRAVIS_BUILD_DIR/../mcl
+script:
+- make -j3
+- make test_ci DISABLE_THREAD_TEST=1
+- make test_go
+- env LD_LIBRARY_PATH=../mcl/lib bin/bls_c384_test.exe
+- make clean && make -C ../mcl clean
+- make -j3 MCL_USE_OPENSSL=0
+- make test_ci DISABLE_THREAD_TEST=1 MCL_USE_OPENSSL=0
+- docker build --tag "$IMAGE_TAG" . -f images/bls-go-alpine/Dockerfile --no-cache
+before_deploy:
+- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
+- git_commit="$(git rev-parse --short HEAD)"
+- docker tag "$IMAGE_TAG" "${IMAGE_TAG}:${git_commit}"
+- docker tag "$IMAGE_TAG" "${IMAGE_TAG}:latest"
+deploy:
+ provider: script
+ script: docker push "${IMAGE_TAG}:latest" && docker push "${IMAGE_TAG}:${git_commit}"
+ on:
+ branch: dev
+ condition: "$CC = gcc"
diff --git a/vendor/github.com/tangerine-network/bls/CMakeLists.txt b/vendor/github.com/tangerine-network/bls/CMakeLists.txt
new file mode 100644
index 000000000..30fb90fd5
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required (VERSION 2.6)
+project(bls CXX ASM)
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+
+set(LIBS mcl gmp)
+
+include_directories(include/)
+
+add_library(bls_c256 SHARED src/bls_c256.cpp)
+add_library(bls_c384 SHARED src/bls_c384.cpp)
+add_library(bls_c384_256 SHARED src/bls_c384_256.cpp)
+target_link_libraries(bls_c256 ${LIBS})
+target_link_libraries(bls_c384 ${LIBS})
+target_link_libraries(bls_c384_256 ${LIBS})
+
+file(GLOB BLS_HEADERS include/bls/bls.h include/bls/bls.hpp)
+
+install(TARGETS bls_c256 DESTINATION lib)
+install(TARGETS bls_c384 DESTINATION lib)
+install(TARGETS bls_c384_256 DESTINATION lib)
+install(FILES ${BLS_HEADERS} DESTINATION include/bls)
+
+set(TEST_LIBS pthread gmpxx)
+
+add_executable(bls_c256_test test/bls_c256_test.cpp)
+target_link_libraries(bls_c256_test bls_c256 ${TEST_LIBS})
+add_executable(bls_c384_test test/bls_c384_test.cpp)
+target_link_libraries(bls_c384_test bls_c384 ${TEST_LIBS})
+add_executable(bls_c384_256_test test/bls_c384_256_test.cpp)
+target_link_libraries(bls_c384_256_test bls_c384_256 ${TEST_LIBS})
diff --git a/vendor/github.com/tangerine-network/bls/Makefile b/vendor/github.com/tangerine-network/bls/Makefile
new file mode 100644
index 000000000..efea22274
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/Makefile
@@ -0,0 +1,164 @@
+ifeq ($(findstring MINGW64,$(shell uname -s)),MINGW64)
+ # cgo accepts not '/c/path' but 'c:/path'
+ PWD=$(shell pwd|sed s'@^/\([a-z]\)@\1:@')
+else
+ PWD=$(shell pwd)
+endif
+MCL_DIR?=$(PWD)/../mcl
+include $(MCL_DIR)/common.mk
+LIB_DIR=lib
+OBJ_DIR=obj
+EXE_DIR=bin
+CFLAGS += -std=c++11
+LDFLAGS += -lpthread
+
+SRC_SRC=bls_c256.cpp bls_c384.cpp bls_c384_256.cpp
+TEST_SRC=bls256_test.cpp bls384_test.cpp bls384_256_test.cpp bls_c256_test.cpp bls_c384_test.cpp bls_c384_256_test.cpp
+SAMPLE_SRC=bls256_smpl.cpp bls384_smpl.cpp
+
+CFLAGS+=-I$(MCL_DIR)/include
+ifneq ($(MCL_MAX_BIT_SIZE),)
+ CFLAGS+=-DMCL_MAX_BIT_SIZE=$(MCL_MAX_BIT_SIZE)
+endif
+ifeq ($(DISABLE_THREAD_TEST),1)
+ CFLAGS+=-DDISABLE_THREAD_TEST
+endif
+ifeq ($(BLS_SWAP_G),1)
+ CFLAGS+=-DBLS_SWAP_G
+endif
+
+BLS256_LIB=$(LIB_DIR)/libbls256.a
+BLS384_LIB=$(LIB_DIR)/libbls384.a
+BLS384_256_LIB=$(LIB_DIR)/libbls384_256.a
+BLS256_SNAME=bls256
+BLS384_SNAME=bls384
+BLS384_256_SNAME=bls384_256
+BLS256_SLIB=$(LIB_DIR)/lib$(BLS256_SNAME).$(LIB_SUF)
+BLS384_SLIB=$(LIB_DIR)/lib$(BLS384_SNAME).$(LIB_SUF)
+BLS384_256_SLIB=$(LIB_DIR)/lib$(BLS384_256_SNAME).$(LIB_SUF)
+all: $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB) $(BLS384_256_LIB) $(BLS384_256_SLIB)
+
+MCL_LIB=$(MCL_DIR)/lib/libmcl.a
+
+$(MCL_LIB):
+ $(MAKE) -C $(MCL_DIR)
+
+$(BLS256_LIB): $(OBJ_DIR)/bls_c256.o $(MCL_LIB)
+ $(AR) $@ $<
+$(BLS384_LIB): $(OBJ_DIR)/bls_c384.o $(MCL_LIB)
+ $(AR) $@ $<
+$(BLS384_256_LIB): $(OBJ_DIR)/bls_c384_256.o $(MCL_LIB)
+ $(AR) $@ $<
+
+ifneq ($(findstring $(OS),mac/mingw64),)
+ COMMON_LIB=$(GMP_LIB) $(OPENSSL_LIB) -lstdc++
+ BLS256_SLIB_LDFLAGS+=$(COMMON_LIB)
+ BLS384_SLIB_LDFLAGS+=$(COMMON_LIB)
+ BLS384_256_SLIB_LDFLAGS+=$(COMMON_LIB)
+endif
+ifeq ($(OS),mingw64)
+ CFLAGS+=-I$(MCL_DIR)
+ BLS256_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS256_SNAME).a
+ BLS384_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS384_SNAME).a
+ BLS384_256_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS384_256_SNAME).a
+endif
+$(BLS256_SLIB): $(OBJ_DIR)/bls_c256.o $(MCL_LIB)
+ $(PRE)$(CXX) -shared -o $@ $< -L$(MCL_DIR)/lib -lmcl $(BLS256_SLIB_LDFLAGS) $(LDFLAGS)
+$(BLS384_SLIB): $(OBJ_DIR)/bls_c384.o $(MCL_LIB)
+ $(PRE)$(CXX) -shared -o $@ $< -L$(MCL_DIR)/lib -lmcl $(BLS384_SLIB_LDFLAGS) $(LDFLAGS)
+$(BLS384_256_SLIB): $(OBJ_DIR)/bls_c384_256.o $(MCL_LIB)
+ $(PRE)$(CXX) -shared -o $@ $< -L$(MCL_DIR)/lib -lmcl $(BLS384_256_SLIB_LDFLAGS) $(LDFLAGS)
+
+VPATH=test sample src
+
+.SUFFIXES: .cpp .d .exe
+
+$(OBJ_DIR)/%.o: %.cpp
+ $(PRE)$(CXX) $(CFLAGS) -c $< -o $@ -MMD -MP -MF $(@:.o=.d)
+
+$(EXE_DIR)/%384_256_test.exe: $(OBJ_DIR)/%384_256_test.o $(BLS384_256_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(BLS384_256_LIB) -L$(MCL_DIR)/lib -lmcl $(LDFLAGS)
+
+$(EXE_DIR)/%384_test.exe: $(OBJ_DIR)/%384_test.o $(BLS384_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(BLS384_LIB) -L$(MCL_DIR)/lib -lmcl $(LDFLAGS)
+
+$(EXE_DIR)/%256_test.exe: $(OBJ_DIR)/%256_test.o $(BLS256_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(BLS256_LIB) -L$(MCL_DIR)/lib -lmcl $(LDFLAGS)
+
+# sample exe links libbls256.a
+$(EXE_DIR)/%.exe: $(OBJ_DIR)/%.o $(BLS256_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(BLS256_LIB) -L$(MCL_DIR)/lib -lmcl $(LDFLAGS)
+ifeq ($(OS),mac)
+ install_name_tool bin/bls_smpl.exe -change lib/libmcl.dylib $(MCL_DIR)/lib/libmcl.dylib
+endif
+
+SAMPLE_EXE=$(addprefix $(EXE_DIR)/,$(SAMPLE_SRC:.cpp=.exe))
+sample: $(SAMPLE_EXE)
+
+TEST_EXE=$(addprefix $(EXE_DIR)/,$(TEST_SRC:.cpp=.exe))
+ifeq ($(OS),mac)
+ LIBPATH_KEY=DYLD_LIBRARY_PATH
+else
+ LIBPATH_KEY=LD_LIBRARY_PATH
+endif
+test_ci: $(TEST_EXE)
+ @sh -ec 'for i in $(TEST_EXE); do echo $$i; env PATH=$$PATH:../mcl/lib $(LIBPATH_KEY)=../mcl/lib LSAN_OPTIONS=verbosity=1 log_threads=1 $$i; done'
+ $(MAKE) sample_test
+
+test: $(TEST_EXE)
+ @echo test $(TEST_EXE)
+ @sh -ec 'for i in $(TEST_EXE); do env PATH=$$PATH:../mcl/lib $(LIBPATH_KEY)=../mcl/lib $$i|grep "ctest:name"; done' > result.txt
+ @grep -v "ng=0, exception=0" result.txt; if [ $$? -eq 1 ]; then echo "all unit tests succeed"; else exit 1; fi
+ $(MAKE) sample_test
+
+sample_test: $(EXE_DIR)/bls_smpl.exe
+ env PATH=$$PATH:../mcl/lib $(LIBPATH_KEY)=../mcl/lib python bls_smpl.py
+
+# PATH is for mingw, LD_LIBRARY_PATH is for linux, DYLD_LIBRARY_PATH is for mac
+COMMON_LIB_PATH="../../../lib:../../../../mcl/lib"
+PATH_VAL=$$PATH:$(COMMON_LIB_PATH) LD_LIBRARY_PATH=$(COMMON_LIB_PATH) DYLD_LIBRARY_PATH=$(COMMON_LIB_PATH)
+test_go256: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS256_LIB)
+ cd ffi/go/bls && env PATH=$(PATH_VAL) go test -tags bn256 .
+test_go384: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS384_LIB)
+ cd ffi/go/bls && env PATH=$(PATH_VAL) go test -tags bn384 .
+test_go384_256: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS384_256_LIB)
+ cd ffi/go/bls && env PATH=$(PATH_VAL) go test -tags bn384_256 .
+
+test_go:
+ $(MAKE) test_go256
+ $(MAKE) test_go384
+ $(MAKE) test_go384_256
+
+EMCC_OPT=-I./include -I./src -I../mcl/include -I./ -Wall -Wextra
+EMCC_OPT+=-O3 -DNDEBUG
+EMCC_OPT+=-s WASM=1 -s NO_EXIT_RUNTIME=1 -s MODULARIZE=1 #-s ASSERTIONS=1
+EMCC_OPT+=-DCYBOZU_MINIMUM_EXCEPTION
+EMCC_OPT+=-s ABORTING_MALLOC=0
+EMCC_OPT+=-DMCLBN_FP_UNIT_SIZE=6
+JS_DEP=src/bls_c384.cpp ../mcl/src/fp.cpp Makefile
+
+../bls-wasm/bls_c.js: $(JS_DEP)
+ emcc -o $@ src/bls_c384.cpp ../mcl/src/fp.cpp $(EMCC_OPT) -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_WEB_CRYPTO_API -s DISABLE_EXCEPTION_CATCHING=1 -DCYBOZU_DONT_USE_EXCEPTION -DCYBOZU_DONT_USE_STRING -DMCL_DONT_USE_CSPRNG -fno-exceptions -MD -MP -MF obj/bls_c384.d
+
+bls-wasm:
+ $(MAKE) ../bls-wasm/bls_c.js
+
+clean:
+ $(RM) $(OBJ_DIR)/*.d $(OBJ_DIR)/*.o $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_SRC) $(ASM_OBJ) $(LLVM_SRC) $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB) $(BLS384_256_LIB) $(BLS384_256_SLIB)
+
+ALL_SRC=$(SRC_SRC) $(TEST_SRC) $(SAMPLE_SRC)
+DEPEND_FILE=$(addprefix $(OBJ_DIR)/, $(ALL_SRC:.cpp=.d))
+-include $(DEPEND_FILE)
+
+PREFIX?=/usr/local
+install: lib/libbls256.a lib/libbls256.$(LIB_SUF) lib/libbls384.a lib/libbls384.$(LIB_SUF) lib/libbls384_256.a lib/libbls384_256.$(LIB_SUF)
+ $(MKDIR) $(PREFIX)/include/bls
+ cp -a include/bls/ $(PREFIX)/include/
+ $(MKDIR) $(PREFIX)/lib
+ cp -a lib/libbls256.a lib/libbls256.$(LIB_SUF) lib/libbls384.a lib/libbls384.$(LIB_SUF) lib/libbls384_256.a lib/libbls384_256.$(LIB_SUF) $(PREFIX)/lib/
+
+.PHONY: test bls-wasm
+
+# don't remove these files automatically
+.SECONDARY: $(addprefix $(OBJ_DIR)/, $(ALL_SRC:.cpp=.o))
+
diff --git a/vendor/github.com/tangerine-network/bls/bin/.emptydir b/vendor/github.com/tangerine-network/bls/bin/.emptydir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/bin/.emptydir
diff --git a/vendor/github.com/tangerine-network/bls/bls.sln b/vendor/github.com/tangerine-network/bls/bls.sln
new file mode 100644
index 000000000..4889ec601
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/bls.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls_test", "test\proj\bls_test\bls_test.vcxproj", "{51266DE6-B57B-4AE3-B85C-282F170E1728}"
+ ProjectSection(ProjectDependencies) = postProject
+ {1DBB979A-C212-45CD-9563-446A96F87F71} = {1DBB979A-C212-45CD-9563-446A96F87F71}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls", "src\proj\bls.vcxproj", "{1DBB979A-C212-45CD-9563-446A96F87F71}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {51266DE6-B57B-4AE3-B85C-282F170E1728}.Debug|x64.ActiveCfg = Debug|x64
+ {51266DE6-B57B-4AE3-B85C-282F170E1728}.Debug|x64.Build.0 = Debug|x64
+ {51266DE6-B57B-4AE3-B85C-282F170E1728}.Release|x64.ActiveCfg = Release|x64
+ {51266DE6-B57B-4AE3-B85C-282F170E1728}.Release|x64.Build.0 = Release|x64
+ {1DBB979A-C212-45CD-9563-446A96F87F71}.Debug|x64.ActiveCfg = Debug|x64
+ {1DBB979A-C212-45CD-9563-446A96F87F71}.Debug|x64.Build.0 = Debug|x64
+ {1DBB979A-C212-45CD-9563-446A96F87F71}.Release|x64.ActiveCfg = Release|x64
+ {1DBB979A-C212-45CD-9563-446A96F87F71}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vendor/github.com/tangerine-network/bls/bls_smpl.py b/vendor/github.com/tangerine-network/bls/bls_smpl.py
new file mode 100644
index 000000000..f834d80aa
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/bls_smpl.py
@@ -0,0 +1,40 @@
+import os, sys, subprocess
+
+EXE='bin/bls_smpl.exe'
+
+def init():
+ subprocess.check_call([EXE, "init"])
+
+def sign(m, i=0):
+ subprocess.check_call([EXE, "sign", "-m", m, "-id", str(i)])
+
+def verify(m, i=0):
+ subprocess.check_call([EXE, "verify", "-m", m, "-id", str(i)])
+
+def share(n, k):
+ subprocess.check_call([EXE, "share", "-n", str(n), "-k", str(k)])
+
+def recover(ids):
+ cmd = [EXE, "recover", "-ids"]
+ for i in ids:
+ cmd.append(str(i))
+ subprocess.check_call(cmd)
+
+def main():
+ m = "hello bls threshold signature"
+ n = 10
+ ids = [1, 5, 3, 7]
+ k = len(ids)
+ init()
+ sign(m)
+ verify(m)
+ share(n, k)
+ for i in ids:
+ sign(m, i)
+ verify(m, i)
+ subprocess.check_call(["rm", "sample/sign.txt"])
+ recover(ids)
+ verify(m)
+
+if __name__ == '__main__':
+ main()
diff --git a/vendor/github.com/tangerine-network/bls/common.props b/vendor/github.com/tangerine-network/bls/common.props
new file mode 100644
index 000000000..d6fdbb902
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/common.props
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <OutDir>$(SolutionDir)bin\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>$(SolutionDir)../cybozulib/include;$(SolutionDir)../cybozulib_ext/include;$(SolutionDir)include;$(SolutionDir)../mcl/include</AdditionalIncludeDirectories>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <PrecompiledHeaderFile />
+ <PrecompiledHeaderOutputFile />
+ <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);NOMINMAX;BLS_MAX_OP_UNIT_SIZE=6</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>$(SolutionDir)../cybozulib_ext/lib;$(SolutionDir)../mcl/lib;$(SolutionDir)lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup />
+</Project>
diff --git a/vendor/github.com/tangerine-network/bls/debug.props b/vendor/github.com/tangerine-network/bls/debug.props
new file mode 100644
index 000000000..1553ae0dc
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/debug.props
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <TargetName>$(ProjectName)d</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup />
+</Project> \ No newline at end of file
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/App.config b/vendor/github.com/tangerine-network/bls/ffi/cs/App.config
new file mode 100644
index 000000000..8d234373a
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
+ </startup>
+</configuration>
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/Properties/AssemblyInfo.cs b/vendor/github.com/tangerine-network/bls/ffi/cs/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..201222c55
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
+// アセンブリに関連付けられている情報を変更するには、
+// これらの属性値を変更してください。
+[assembly: AssemblyTitle("bls256")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("bls256")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
+// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
+// その型の ComVisible 属性を true に設定してください。
+[assembly: ComVisible(false)]
+
+// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
+[assembly: Guid("e9d06b1b-ea22-4ef4-ba4b-422f7625966c")]
+
+// アセンブリのバージョン情報は次の 4 つの値で構成されています:
+//
+// メジャー バージョン
+// マイナー バージョン
+// ビルド番号
+// Revision
+//
+// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
+// 既定値にすることができます:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls.cs b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.cs
new file mode 100644
index 000000000..6bcaf07fb
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.cs
@@ -0,0 +1,351 @@
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace mcl
+{
+ class BLS
+ {
+ public const int BN254 = 0;
+ public const int BLS12_381 = 5;
+
+ const int IoEcComp = 512; // fixed byte representation
+ public const int FR_UNIT_SIZE = 4;
+ public const int FP_UNIT_SIZE = 6; // 4 if bls256.dll is used
+ public const int COMPILED_TIME_VAR = FR_UNIT_SIZE * 10 + FP_UNIT_SIZE;
+
+ public const int ID_UNIT_SIZE = FR_UNIT_SIZE;
+ public const int SECRETKEY_UNIT_SIZE = FR_UNIT_SIZE;
+ public const int PUBLICKEY_UNIT_SIZE = FP_UNIT_SIZE * 3 * 2;
+ public const int SIGNATURE_UNIT_SIZE = FP_UNIT_SIZE * 3;
+
+ public const int ID_SERIALIZE_SIZE = FR_UNIT_SIZE * 8;
+ public const int SECRETKEY_SERIALIZE_SIZE = FR_UNIT_SIZE * 8;
+ public const int PUBLICKEY_SERIALIZE_SIZE = FP_UNIT_SIZE * 8 * 2;
+ public const int SIGNATURE_SERIALIZE_SIZE = FP_UNIT_SIZE * 8;
+
+ public const string dllName = FP_UNIT_SIZE == 4 ? "bls256.dll" : "bls384_256.dll";
+ [DllImport(dllName)]
+ public static extern int blsInit(int curveType, int compiledTimeVar);
+
+ [DllImport(dllName)] public static extern void blsIdSetInt(ref Id id, int x);
+ [DllImport(dllName)] public static extern int blsIdSetDecStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport(dllName)] public static extern int blsIdSetHexStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsIdGetDecStr([Out]StringBuilder buf, ulong maxBufSize, in Id id);
+ [DllImport(dllName)] public static extern ulong blsIdGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in Id id);
+
+ [DllImport(dllName)] public static extern ulong blsIdSerialize([Out]byte[] buf, ulong maxBufSize, in Id id);
+ [DllImport(dllName)] public static extern ulong blsSecretKeySerialize([Out]byte[] buf, ulong maxBufSize, in SecretKey sec);
+ [DllImport(dllName)] public static extern ulong blsPublicKeySerialize([Out]byte[] buf, ulong maxBufSize, in PublicKey pub);
+ [DllImport(dllName)] public static extern ulong blsSignatureSerialize([Out]byte[] buf, ulong maxBufSize, in Signature sig);
+ [DllImport(dllName)] public static extern ulong blsIdDeserialize(ref Id id, [In]byte[] buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsSecretKeyDeserialize(ref SecretKey sec, [In]byte[] buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsPublicKeyDeserialize(ref PublicKey pub, [In]byte[] buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsSignatureDeserialize(ref Signature sig, [In]byte[] buf, ulong bufSize);
+
+ [DllImport(dllName)] public static extern int blsIdIsEqual(in Id lhs, in Id rhs);
+ [DllImport(dllName)] public static extern int blsSecretKeyIsEqual(in SecretKey lhs, in SecretKey rhs);
+ [DllImport(dllName)] public static extern int blsPublicKeyIsEqual(in PublicKey lhs, in PublicKey rhs);
+ [DllImport(dllName)] public static extern int blsSignatureIsEqual(in Signature lhs, in Signature rhs);
+ // add
+ [DllImport(dllName)] public static extern void blsSecretKeyAdd(ref SecretKey sec, in SecretKey rhs);
+ [DllImport(dllName)] public static extern void blsPublicKeyAdd(ref PublicKey pub, in PublicKey rhs);
+ [DllImport(dllName)] public static extern void blsSignatureAdd(ref Signature sig, in Signature rhs);
+ // hash buf and set
+ [DllImport(dllName)] public static extern int blsHashToSecretKey(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ set secretKey if system has /dev/urandom or CryptGenRandom
+ return 0 if success else -1
+ */
+ [DllImport(dllName)] public static extern int blsSecretKeySetByCSPRNG(ref SecretKey sec);
+
+ [DllImport(dllName)] public static extern void blsGetPublicKey(ref PublicKey pub, in SecretKey sec);
+ [DllImport(dllName)] public static extern void blsGetPop(ref Signature sig, in SecretKey sec);
+
+ // return 0 if success
+ [DllImport(dllName)] public static extern int blsSecretKeyShare(ref SecretKey sec, in SecretKey msk, ulong k, in Id id);
+ [DllImport(dllName)] public static extern int blsPublicKeyShare(ref PublicKey pub, in PublicKey mpk, ulong k, in Id id);
+
+
+ [DllImport(dllName)] public static extern int blsSecretKeyRecover(ref SecretKey sec, in SecretKey secVec, in Id idVec, ulong n);
+ [DllImport(dllName)] public static extern int blsPublicKeyRecover(ref PublicKey pub, in PublicKey pubVec, in Id idVec, ulong n);
+ [DllImport(dllName)] public static extern int blsSignatureRecover(ref Signature sig, in Signature sigVec, in Id idVec, ulong n);
+
+ [DllImport(dllName)] public static extern void blsSign(ref Signature sig, in SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
+
+ // return 1 if valid
+ [DllImport(dllName)] public static extern int blsVerify(in Signature sig, in PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
+ [DllImport(dllName)] public static extern int blsVerifyPop(in Signature sig, in PublicKey pub);
+
+ //////////////////////////////////////////////////////////////////////////
+ // the following apis will be removed
+
+ // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
+ [DllImport(dllName)] public static extern int blsIdSetLittleEndian(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ return written byte size if success else 0
+ */
+ [DllImport(dllName)] public static extern ulong blsIdGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, in Id id);
+
+ // return 0 if success
+ // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
+ [DllImport(dllName)] public static extern int blsSecretKeySetLittleEndian(ref SecretKey sec, [In]byte[] buf, ulong bufSize);
+ [DllImport(dllName)] public static extern int blsSecretKeySetDecStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport(dllName)] public static extern int blsSecretKeySetHexStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ return written byte size if success else 0
+ */
+ [DllImport(dllName)] public static extern ulong blsSecretKeyGetLittleEndian([Out]byte[] buf, ulong maxBufSize, in SecretKey sec);
+ /*
+ return strlen(buf) if success else 0
+ buf is '\0' terminated
+ */
+ [DllImport(dllName)] public static extern ulong blsSecretKeyGetDecStr([Out]StringBuilder buf, ulong maxBufSize, in SecretKey sec);
+ [DllImport(dllName)] public static extern ulong blsSecretKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in SecretKey sec);
+ [DllImport(dllName)] public static extern int blsPublicKeySetHexStr(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsPublicKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in PublicKey pub);
+ [DllImport(dllName)] public static extern int blsSignatureSetHexStr(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport(dllName)] public static extern ulong blsSignatureGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in Signature sig);
+
+ public static void Init(int curveType = BN254) {
+ if (!System.Environment.Is64BitProcess) {
+ throw new PlatformNotSupportedException("not 64-bit system");
+ }
+ int err = blsInit(curveType, COMPILED_TIME_VAR);
+ if (err != 0) {
+ throw new ArgumentException("blsInit");
+ }
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct Id
+ {
+ private fixed ulong v[ID_UNIT_SIZE];
+ public byte[] Serialize() {
+ byte[] buf = new byte[ID_SERIALIZE_SIZE];
+ ulong n = blsIdSerialize(buf, (ulong)buf.Length, this);
+ if (n == 0) {
+ throw new ArithmeticException("blsIdSerialize");
+ }
+ return buf;
+ }
+ public void Deserialize(byte[] buf) {
+ ulong n = blsIdDeserialize(ref this, buf, (ulong)buf.Length);
+ if (n == 0) {
+ throw new ArithmeticException("blsIdDeserialize");
+ }
+ }
+ public bool IsEqual(in Id rhs) {
+ return blsIdIsEqual(this, rhs) != 0;
+ }
+ public void SetDecStr(string s) {
+ if (blsIdSetDecStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsIdSetDecSt:" + s);
+ }
+ }
+ public void SetHexStr(string s) {
+ if (blsIdSetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsIdSetHexStr:" + s);
+ }
+ }
+ public void SetInt(int x) {
+ blsIdSetInt(ref this, x);
+ }
+ public string GetDecStr() {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsIdGetDecStr(sb, (ulong)sb.Capacity, this);
+ if (size == 0) {
+ throw new ArgumentException("blsIdGetDecStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public string GetHexStr() {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsIdGetHexStr(sb, (ulong)sb.Capacity, this);
+ if (size == 0) {
+ throw new ArgumentException("blsIdGetHexStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct SecretKey
+ {
+ private fixed ulong v[SECRETKEY_UNIT_SIZE];
+ public byte[] Serialize() {
+ byte[] buf = new byte[SECRETKEY_SERIALIZE_SIZE];
+ ulong n = blsSecretKeySerialize(buf, (ulong)buf.Length, this);
+ if (n == 0) {
+ throw new ArithmeticException("blsSecretKeySerialize");
+ }
+ return buf;
+ }
+ public void Deserialize(byte[] buf) {
+ ulong n = blsSecretKeyDeserialize(ref this, buf, (ulong)buf.Length);
+ if (n == 0) {
+ throw new ArithmeticException("blsSecretKeyDeserialize");
+ }
+ }
+ public bool IsEqual(in SecretKey rhs) {
+ return blsSecretKeyIsEqual(this, rhs) != 0;
+ }
+ public void SetHexStr(string s) {
+ if (blsSecretKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsSecretKeySetHexStr:" + s);
+ }
+ }
+ public string GetHexStr() {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsSecretKeyGetHexStr(sb, (ulong)sb.Capacity, this);
+ if (size == 0) {
+ throw new ArgumentException("mclBnFr_getStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(in SecretKey rhs) {
+ blsSecretKeyAdd(ref this, rhs);
+ }
+ public void SetByCSPRNG() {
+ blsSecretKeySetByCSPRNG(ref this);
+ }
+ public void SetHashOf(string s) {
+ if (blsHashToSecretKey(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsHashToSecretKey");
+ }
+ }
+ public PublicKey GetPublicKey() {
+ PublicKey pub;
+ blsGetPublicKey(ref pub, this);
+ return pub;
+ }
+ public Signature Sign(string m) {
+ Signature sig;
+ blsSign(ref sig, this, m, (ulong)m.Length);
+ return sig;
+ }
+ public Signature GetPop() {
+ Signature sig;
+ blsGetPop(ref sig, this);
+ return sig;
+ }
+ }
+ // secretKey = sum_{i=0}^{msk.Length - 1} msk[i] * id^i
+ public static SecretKey ShareSecretKey(in SecretKey[] msk, in Id id) {
+ SecretKey sec;
+ if (blsSecretKeyShare(ref sec, msk[0], (ulong)msk.Length, id) != 0) {
+ throw new ArgumentException("GetSecretKeyForId:" + id.ToString());
+ }
+ return sec;
+ }
+ public static SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec) {
+ SecretKey sec;
+ if (blsSecretKeyRecover(ref sec, secVec[0], idVec[0], (ulong)secVec.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return sec;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct PublicKey
+ {
+ private fixed ulong v[PUBLICKEY_UNIT_SIZE];
+ public byte[] Serialize() {
+ byte[] buf = new byte[PUBLICKEY_SERIALIZE_SIZE];
+ ulong n = blsPublicKeySerialize(buf, (ulong)buf.Length, this);
+ if (n == 0) {
+ throw new ArithmeticException("blsPublicKeySerialize");
+ }
+ return buf;
+ }
+ public void Deserialize(byte[] buf) {
+ ulong n = blsPublicKeyDeserialize(ref this, buf, (ulong)buf.Length);
+ if (n == 0) {
+ throw new ArithmeticException("blsPublicKeyDeserialize");
+ }
+ }
+ public bool IsEqual(in PublicKey rhs) {
+ return blsPublicKeyIsEqual(this, rhs) != 0;
+ }
+ public void SetStr(string s) {
+ if (blsPublicKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsPublicKeySetStr:" + s);
+ }
+ }
+ public string GetHexStr() {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsPublicKeyGetHexStr(sb, (ulong)sb.Capacity, this);
+ if (size == 0) {
+ throw new ArgumentException("blsPublicKeyGetStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(in PublicKey rhs) {
+ blsPublicKeyAdd(ref this, rhs);
+ }
+ public bool Verify(in Signature sig, string m) {
+ return blsVerify(sig, this, m, (ulong)m.Length) == 1;
+ }
+ public bool VerifyPop(in Signature pop) {
+ return blsVerifyPop(pop, this) == 1;
+ }
+ }
+ // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i
+ public static PublicKey SharePublicKey(in PublicKey[] mpk, in Id id) {
+ PublicKey pub;
+ if (blsPublicKeyShare(ref pub, mpk[0], (ulong)mpk.Length, id) != 0) {
+ throw new ArgumentException("GetPublicKeyForId:" + id.ToString());
+ }
+ return pub;
+ }
+ public static PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec) {
+ PublicKey pub;
+ if (blsPublicKeyRecover(ref pub, pubVec[0], idVec[0], (ulong)pubVec.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return pub;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct Signature
+ {
+ private fixed ulong v[SIGNATURE_UNIT_SIZE];
+ public byte[] Serialize() {
+ byte[] buf = new byte[SIGNATURE_SERIALIZE_SIZE];
+ ulong n = blsSignatureSerialize(buf, (ulong)buf.Length, this);
+ if (n == 0) {
+ throw new ArithmeticException("blsSignatureSerialize");
+ }
+ return buf;
+ }
+ public void Deserialize(byte[] buf) {
+ ulong n = blsSignatureDeserialize(ref this, buf, (ulong)buf.Length);
+ if (n == 0) {
+ throw new ArithmeticException("blsSignatureDeserialize");
+ }
+ }
+ public bool IsEqual(in Signature rhs) {
+ return blsSignatureIsEqual(this, rhs) != 0;
+ }
+ public void SetStr(string s) {
+ if (blsSignatureSetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsSignatureSetStr:" + s);
+ }
+ }
+ public string GetHexStr() {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsSignatureGetHexStr(sb, (ulong)sb.Capacity, this);
+ if (size == 0) {
+ throw new ArgumentException("blsSignatureGetStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(in Signature rhs) {
+ blsSignatureAdd(ref this, rhs);
+ }
+ }
+ public static Signature RecoverSign(in Signature[] sigVec, in Id[] idVec) {
+ Signature sig;
+ if (blsSignatureRecover(ref sig, sigVec[0], idVec[0], (ulong)sigVec.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return sig;
+ }
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls.csproj b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.csproj
new file mode 100644
index 000000000..c03afa436
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.csproj
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{E9D06B1B-EA22-4EF4-BA4B-422F7625966D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>bls</RootNamespace>
+ <AssemblyName>bls</AssemblyName>
+ <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>..\..\bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <LangVersion>7.2</LangVersion>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <OutputPath>..\..\bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <Prefer32Bit>false</Prefer32Bit>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <LangVersion>7.2</LangVersion>
+ </PropertyGroup>
+ <PropertyGroup>
+ <NoWin32Manifest>true</NoWin32Manifest>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="bls.cs" />
+ <Compile Include="bls_test.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.5.2 %28x86 および x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls.sln b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.sln
new file mode 100644
index 000000000..7c3dfba7b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.539
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bls", "bls.csproj", "{E9D06B1B-EA22-4EF4-BA4B-422F7625966D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Debug|x64.ActiveCfg = Debug|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Debug|x64.Build.0 = Debug|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Release|x64.ActiveCfg = Release|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1935C301-6478-4F82-9587-6A66B531E327}
+ EndGlobalSection
+EndGlobal
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.cs b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.cs
new file mode 100644
index 000000000..3ef5fab9a
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.cs
@@ -0,0 +1,298 @@
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace mcl {
+ class BLS256 {
+ const int IoEcComp = 512; // fixed byte representation
+ public const int MCLBN_FR_UNIT_SIZE = 4;
+ public const int MCLBN_FP_UNIT_SIZE = 4;
+ public const int MCLBN_COMPILED_TIME_VAR = MCLBN_FR_UNIT_SIZE * 10 + MCLBN_FP_UNIT_SIZE;
+ [DllImport("bls256.dll")]
+ public static extern int blsInit(int curve, int compiledTimeVar);
+
+ [DllImport("bls256.dll")] public static extern void blsIdSetInt(ref Id id, int x);
+ [DllImport("bls256.dll")] public static extern int blsIdSetDecStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsIdSetHexStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern ulong blsIdGetDecStr([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
+ [DllImport("bls256.dll")] public static extern ulong blsIdGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
+
+
+ [DllImport("bls256.dll")] public static extern ulong blsIdSerialize([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
+ [DllImport("bls256.dll")] public static extern ulong blsSecretKeySerialize([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
+ [DllImport("bls256.dll")] public static extern ulong blsPublicKeySerialize([Out]StringBuilder buf, ulong maxBufSize, ref PublicKey pub);
+ [DllImport("bls256.dll")] public static extern ulong blsSignatureSerialize([Out]StringBuilder buf, ulong maxBufSize, ref Signature sig);
+
+ [DllImport("bls256.dll")] public static extern int blsIdDeserialize(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsSecretKeyDeserialize(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsPublicKeyDeserialize(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsSignatureDeserialize(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+
+ [DllImport("bls256.dll")] public static extern int blsIdIsEqual(ref Id lhs, ref Id rhs);
+ [DllImport("bls256.dll")] public static extern int blsSecretKeyIsEqual(ref SecretKey lhs, ref SecretKey rhs);
+ [DllImport("bls256.dll")] public static extern int blsPublicKeyIsEqual(ref PublicKey lhs, ref PublicKey rhs);
+ [DllImport("bls256.dll")] public static extern int blsSignatureIsEqual(ref Signature lhs, ref Signature rhs);
+
+ // add
+ [DllImport("bls256.dll")] public static extern void blsSecretKeyAdd(ref SecretKey sec, ref SecretKey rhs);
+ [DllImport("bls256.dll")] public static extern void blsPublicKeyAdd(ref PublicKey pub, ref PublicKey rhs);
+ [DllImport("bls256.dll")] public static extern void blsSignatureAdd(ref Signature sig, ref Signature rhs);
+
+ // hash buf and set
+ [DllImport("bls256.dll")] public static extern int blsHashToSecretKey(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ set secretKey if system has /dev/urandom or CryptGenRandom
+ return 0 if success else -1
+ */
+ [DllImport("bls256.dll")] public static extern int blsSecretKeySetByCSPRNG(ref SecretKey sec);
+
+ [DllImport("bls256.dll")] public static extern void blsGetPublicKey(ref PublicKey pub, ref SecretKey sec);
+ [DllImport("bls256.dll")] public static extern void blsGetPop(ref Signature sig, ref SecretKey sec);
+
+ // return 0 if success
+ [DllImport("bls256.dll")] public static extern int blsSecretKeyShare(ref SecretKey sec, ref SecretKey msk, ulong k, ref Id id);
+ [DllImport("bls256.dll")] public static extern int blsPublicKeyShare(ref PublicKey pub, ref PublicKey mpk, ulong k, ref Id id);
+
+
+ [DllImport("bls256.dll")] public static extern int blsSecretKeyRecover(ref SecretKey sec, ref SecretKey secVec, ref Id idVec, ulong n);
+ [DllImport("bls256.dll")] public static extern int blsPublicKeyRecover(ref PublicKey pub, ref PublicKey pubVec, ref Id idVec, ulong n);
+ [DllImport("bls256.dll")] public static extern int blsSignatureRecover(ref Signature sig, ref Signature sigVec, ref Id idVec, ulong n);
+
+ [DllImport("bls256.dll")] public static extern void blsSign(ref Signature sig, ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
+
+ // return 1 if valid
+ [DllImport("bls256.dll")] public static extern int blsVerify(ref Signature sig, ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
+ [DllImport("bls256.dll")] public static extern int blsVerifyPop(ref Signature sig, ref PublicKey pub);
+
+ //////////////////////////////////////////////////////////////////////////
+ // the following apis will be removed
+
+ // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
+ [DllImport("bls256.dll")] public static extern int blsIdSetLittleEndian(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ return written byte size if success else 0
+ */
+ [DllImport("bls256.dll")] public static extern ulong blsIdGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
+
+ // return 0 if success
+ // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
+ [DllImport("bls256.dll")] public static extern int blsSecretKeySetLittleEndian(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsSecretKeySetDecStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern int blsSecretKeySetHexStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ /*
+ return written byte size if success else 0
+ */
+ [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
+ /*
+ return strlen(buf) if success else 0
+ buf is '\0' terminated
+ */
+ [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetDecStr([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
+ [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
+ [DllImport("bls256.dll")] public static extern int blsPublicKeySetHexStr(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern ulong blsPublicKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref PublicKey pub);
+ [DllImport("bls256.dll")] public static extern int blsSignatureSetHexStr(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
+ [DllImport("bls256.dll")] public static extern ulong blsSignatureGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref Signature sig);
+
+ public static void Init()
+ {
+ const int CurveFp254BNb = 0;
+ if (!System.Environment.Is64BitProcess) {
+ throw new PlatformNotSupportedException("not 64-bit system");
+ }
+ int err = blsInit(CurveFp254BNb, MCLBN_COMPILED_TIME_VAR);
+ if (err != 0) {
+ throw new ArgumentException("blsInit");
+ }
+ }
+
+ public struct Id {
+ private ulong v0, v1, v2, v3;
+ public bool IsEqual(Id rhs)
+ {
+ return blsIdIsEqual(ref this, ref rhs) != 0;
+ }
+ public void SetDecStr(String s)
+ {
+ if (blsIdSetDecStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsIdSetDecSt:" + s);
+ }
+ }
+ public void SetHexStr(String s)
+ {
+ if (blsIdSetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsIdSetHexStr:" + s);
+ }
+ }
+ public void SetInt(int x)
+ {
+ blsIdSetInt(ref this, x);
+ }
+ public string GetDecStr()
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsIdGetDecStr(sb, (ulong)sb.Capacity, ref this);
+ if (size == 0) {
+ throw new ArgumentException("blsIdGetDecStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public string GetHexStr()
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsIdGetHexStr(sb, (ulong)sb.Capacity, ref this);
+ if (size == 0) {
+ throw new ArgumentException("blsIdGetHexStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ }
+ public struct SecretKey {
+ private ulong v0, v1, v2, v3;
+ public bool IsEqual(SecretKey rhs)
+ {
+ return blsSecretKeyIsEqual(ref this, ref rhs) != 0;
+ }
+ public void SetHexStr(String s)
+ {
+ if (blsSecretKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsSecretKeySetHexStr:" + s);
+ }
+ }
+ public string GetHexStr()
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsSecretKeyGetHexStr(sb, (ulong)sb.Capacity, ref this);
+ if (size == 0) {
+ throw new ArgumentException("mclBnFr_getStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(SecretKey rhs)
+ {
+ blsSecretKeyAdd(ref this, ref rhs);
+ }
+ public void SetByCSPRNG()
+ {
+ blsSecretKeySetByCSPRNG(ref this);
+ }
+ public void SetHashOf(string s)
+ {
+ if (blsHashToSecretKey(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsHashToSecretKey");
+ }
+ }
+ public PublicKey GetPublicKey()
+ {
+ PublicKey pub = new PublicKey();
+ blsGetPublicKey(ref pub, ref this);
+ return pub;
+ }
+ public Signature Signature(String m)
+ {
+ Signature Signature = new Signature();
+ blsSign(ref Signature, ref this, m, (ulong)m.Length);
+ return Signature;
+ }
+ }
+ // secretKey = sum_{i=0}^{msk.Length - 1} msk[i] * id^i
+ public static SecretKey ShareSecretKey(SecretKey[] msk, Id id)
+ {
+ SecretKey sec = new SecretKey();
+ if (blsSecretKeyShare(ref sec, ref msk[0], (ulong)msk.Length, ref id) != 0) {
+ throw new ArgumentException("GetSecretKeyForId:" + id.ToString());
+ }
+ return sec;
+ }
+ public static SecretKey RecoverSecretKey(SecretKey[] secs, Id[] ids)
+ {
+ SecretKey sec = new SecretKey();
+ if (blsSecretKeyRecover(ref sec, ref secs[0], ref ids[0], (ulong)secs.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return sec;
+ }
+ public struct PublicKey {
+ private ulong v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11;
+ private ulong v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23;
+ public bool IsEqual(PublicKey rhs)
+ {
+ return blsPublicKeyIsEqual(ref this, ref rhs) != 0;
+ }
+ public void SetStr(String s)
+ {
+ if (blsPublicKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsPublicKeySetStr:" + s);
+ }
+ }
+ public string GetHexStr()
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsPublicKeyGetHexStr(sb, (ulong)sb.Capacity, ref this);
+ if (size == 0) {
+ throw new ArgumentException("blsPublicKeyGetStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(PublicKey rhs)
+ {
+ blsPublicKeyAdd(ref this, ref rhs);
+ }
+ public bool Verify(Signature Signature, string m)
+ {
+ return blsVerify(ref Signature, ref this, m, (ulong)m.Length) == 1;
+ }
+ }
+ // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i
+ public static PublicKey SharePublicKey(PublicKey[] mpk, Id id)
+ {
+ PublicKey pub = new PublicKey();
+ if (blsPublicKeyShare(ref pub, ref mpk[0], (ulong)mpk.Length, ref id) != 0) {
+ throw new ArgumentException("GetPublicKeyForId:" + id.ToString());
+ }
+ return pub;
+ }
+ public static PublicKey RecoverPublicKey(PublicKey[] pubs, Id[] ids)
+ {
+ PublicKey pub = new PublicKey();
+ if (blsPublicKeyRecover(ref pub, ref pubs[0], ref ids[0], (ulong)pubs.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return pub;
+ }
+ public struct Signature {
+ private ulong v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11;
+ public bool IsEqual(Signature rhs)
+ {
+ return blsSignatureIsEqual(ref this, ref rhs) != 0;
+ }
+ public void SetStr(String s)
+ {
+ if (blsSignatureSetHexStr(ref this, s, (ulong)s.Length) != 0) {
+ throw new ArgumentException("blsSignatureSetStr:" + s);
+ }
+ }
+ public string GetHexStr()
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ ulong size = blsSignatureGetHexStr(sb, (ulong)sb.Capacity, ref this);
+ if (size == 0) {
+ throw new ArgumentException("blsSignatureGetStr");
+ }
+ return sb.ToString(0, (int)size);
+ }
+ public void Add(Signature rhs)
+ {
+ blsSignatureAdd(ref this, ref rhs);
+ }
+ }
+ public static Signature RecoverSign(Signature[] signs, Id[] ids)
+ {
+ Signature Signature = new Signature();
+ if (blsSignatureRecover(ref Signature, ref signs[0], ref ids[0], (ulong)signs.Length) != 0) {
+ throw new ArgumentException("Recover");
+ }
+ return Signature;
+ }
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.csproj b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.csproj
new file mode 100644
index 000000000..032a1d347
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.csproj
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{E9D06B1B-EA22-4EF4-BA4B-422F7625966C}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>bls256</RootNamespace>
+ <AssemblyName>bls256</AssemblyName>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>..\..\bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <OutputPath>..\..\bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="bls256.cs" />
+ <Compile Include="bls256_test.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.sln b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.sln
new file mode 100644
index 000000000..eb29af97b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBD}") = "bls256", "bls256.csproj", "{E9D06B1B-EA22-4EF4-BA4B-422F7625966C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Debug|x64.ActiveCfg = Debug|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Debug|x64.Build.0 = Debug|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Release|x64.ActiveCfg = Release|x64
+ {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls256_test.cs b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256_test.cs
new file mode 100644
index 000000000..989993e0f
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls256_test.cs
@@ -0,0 +1,126 @@
+using System;
+
+namespace mcl {
+ using static BLS256;
+ class BLS256Test {
+ static int err = 0;
+ static void assert(string msg, bool b)
+ {
+ if (b) return;
+ Console.WriteLine("ERR {0}", msg);
+ err++;
+ }
+ static void TestId()
+ {
+ Console.WriteLine("TestId");
+ Id id = new Id();
+ id.SetDecStr("255");
+ assert("GetStr(10)", id.GetDecStr() == "255");
+ assert("GetStr(16)", id.GetHexStr() == "ff");
+ }
+ static void TestSecretKey()
+ {
+ Console.WriteLine("TestSecretKey");
+ SecretKey sec = new SecretKey();
+ sec.SetHexStr("ff");
+ assert("GetHexStr()", sec.GetHexStr() == "ff");
+ {
+ SecretKey sec2 = new SecretKey();
+ sec.SetHexStr("321");
+ sec2.SetHexStr("4000");
+ sec.Add(sec2);
+ assert("sec.Add", sec.GetHexStr() == "4321");
+ sec.SetByCSPRNG();
+ Console.WriteLine("sec.Init={0}", sec.GetHexStr());
+ }
+ }
+ static void TestPublicKey()
+ {
+ Console.WriteLine("TestPublicKey");
+ SecretKey sec = new SecretKey();
+ sec.SetByCSPRNG();
+ PublicKey pub = sec.GetPublicKey();
+ String s = pub.GetHexStr();
+ Console.WriteLine("pub={0}", s);
+ PublicKey pub2 = new PublicKey();
+ pub2.SetStr(s);
+ assert("pub.SetStr", pub.IsEqual(pub2));
+ }
+ static void TestSign()
+ {
+ Console.WriteLine("TestSign");
+ SecretKey sec = new SecretKey();
+ sec.SetByCSPRNG();
+ PublicKey pub = sec.GetPublicKey();
+ String m = "abc";
+ Signature sig = sec.Signature(m);
+ assert("verify", pub.Verify(sig, m));
+ assert("not verify", !pub.Verify(sig, m + "a"));
+ }
+ static void TestSharing()
+ {
+ Console.WriteLine("TestSharing");
+ int k = 5;
+ SecretKey[] msk = new SecretKey[k];
+ PublicKey[] mpk = new PublicKey[k];
+ // make master secretkey
+ for (int i = 0; i < k; i++) {
+ msk[i].SetByCSPRNG();
+ mpk[i] = msk[i].GetPublicKey();
+ }
+ int n = 30;
+ Id[] ids = new Id[n];
+ SecretKey[] secs = new SecretKey[n];
+ PublicKey[] pubs = new PublicKey[n];
+ for (int i = 0; i < n; i++) {
+ ids[i].SetInt(i * i + 123);
+ secs[i] = ShareSecretKey(msk, ids[i]);
+ pubs[i] = SharePublicKey(mpk, ids[i]);
+ assert("share publicKey", secs[i].GetPublicKey().IsEqual(pubs[i]));
+ }
+ string m = "doremi";
+ for (int i = 0; i < n; i++) {
+ Signature Signature = secs[i].Signature(m);
+ assert("Signature.Verify", pubs[i].Verify(Signature, m));
+ }
+ {
+ int[] idxTbl = { 0, 2, 5, 8, 10 };
+ assert("idxTbl.Length=k", idxTbl.Length == k);
+ Id[] subIds = new Id[k];
+ SecretKey[] subSecs = new SecretKey[k];
+ PublicKey[] subPubs = new PublicKey[k];
+ Signature[] subSigns = new Signature[k];
+ for (int i = 0; i < k; i++) {
+ int idx = idxTbl[i];
+ subIds[i] = ids[idx];
+ subSecs[i] = secs[idx];
+ subPubs[i] = pubs[idx];
+ subSigns[i] = secs[idx].Signature(m);
+ }
+ SecretKey sec = RecoverSecretKey(subSecs, subIds);
+ PublicKey pub = RecoverPublicKey(subPubs, subIds);
+ assert("check pub", pub.IsEqual(sec.GetPublicKey()));
+ Signature Signature = RecoverSign(subSigns, subIds);
+ assert("Signature.verify", pub.Verify(Signature, m));
+ }
+ }
+ static void Main(string[] args)
+ {
+ try {
+ Init();
+ TestId();
+ TestSecretKey();
+ TestPublicKey();
+ TestSign();
+ TestSharing();
+ if (err == 0) {
+ Console.WriteLine("all tests succeed");
+ } else {
+ Console.WriteLine("err={0}", err);
+ }
+ } catch (Exception e) {
+ Console.WriteLine("ERR={0}", e);
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/bls_test.cs b/vendor/github.com/tangerine-network/bls/ffi/cs/bls_test.cs
new file mode 100644
index 000000000..2eb451ba9
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/bls_test.cs
@@ -0,0 +1,176 @@
+using System;
+
+namespace mcl
+{
+ using static BLS;
+ class BLSTest
+ {
+ static int err = 0;
+ static void assert(string msg, bool b) {
+ if (b) return;
+ Console.WriteLine("ERR {0}", msg);
+ err++;
+ }
+ static void TestId() {
+ Console.WriteLine("TestId");
+ Id id1;
+ id1.SetDecStr("255");
+ assert("GetStr(10)", id1.GetDecStr() == "255");
+ assert("GetStr(16)", id1.GetHexStr() == "ff");
+ Id id2;
+ id2.SetInt(255);
+ assert("IsEqual", id1.IsEqual(id2));
+ }
+ static void TestSecretKey() {
+ Console.WriteLine("TestSecretKey");
+ SecretKey sec;
+ sec.SetHexStr("ff");
+ assert("GetHexStr()", sec.GetHexStr() == "ff");
+ {
+ SecretKey sec2;
+ sec.SetHexStr("321");
+ sec2.SetHexStr("4000");
+ sec.Add(sec2);
+ assert("sec.Add", sec.GetHexStr() == "4321");
+ sec.SetByCSPRNG();
+ Console.WriteLine("sec.Init={0}", sec.GetHexStr());
+ }
+ {
+ SecretKey sec2;
+ byte[] buf = sec.Serialize();
+ sec2.Deserialize(buf);
+ assert("serialize", sec2.IsEqual(sec));
+ }
+ }
+ static void TestPublicKey() {
+ Console.WriteLine("TestPublicKey");
+ SecretKey sec;
+ sec.SetByCSPRNG();
+ PublicKey pub = sec.GetPublicKey();
+ string s = pub.GetHexStr();
+ Console.WriteLine("pub={0}", s);
+ {
+ PublicKey pub2;
+ pub2.SetStr(s);
+ assert("pub.SetStr", pub.IsEqual(pub2));
+ }
+ {
+ PublicKey pub2;
+ byte[] buf = pub.Serialize();
+ pub2.Deserialize(buf);
+ assert("serialize", pub2.IsEqual(pub));
+ }
+ }
+ static void TestSign() {
+ Console.WriteLine("TestSign");
+ SecretKey sec;
+ sec.SetByCSPRNG();
+ PublicKey pub = sec.GetPublicKey();
+ string m = "abc";
+ Signature sig = sec.Sign(m);
+ Console.WriteLine("sig={0}", sig.GetHexStr());
+ assert("verify", pub.Verify(sig, m));
+ assert("not verify", !pub.Verify(sig, m + "a"));
+ {
+ Signature sig2;
+ byte[] buf = sig.Serialize();
+ sig2.Deserialize(buf);
+ assert("serialize", sig2.IsEqual(sig));
+ }
+ }
+ static void TestSharing() {
+ Console.WriteLine("TestSharing");
+ int k = 5;
+ SecretKey[] msk = new SecretKey[k];
+ PublicKey[] mpk = new PublicKey[k];
+ // make master secretkey
+ for (int i = 0; i < k; i++) {
+ msk[i].SetByCSPRNG();
+ mpk[i] = msk[i].GetPublicKey();
+ }
+ int n = 30;
+ Id[] ids = new Id[n];
+ SecretKey[] secs = new SecretKey[n];
+ PublicKey[] pubs = new PublicKey[n];
+ for (int i = 0; i < n; i++) {
+ ids[i].SetInt(i * i + 123);
+ secs[i] = ShareSecretKey(msk, ids[i]);
+ pubs[i] = SharePublicKey(mpk, ids[i]);
+ assert("share publicKey", secs[i].GetPublicKey().IsEqual(pubs[i]));
+ }
+ string m = "doremi";
+ for (int i = 0; i < n; i++) {
+ Signature Signature = secs[i].Sign(m);
+ assert("Signature.Verify", pubs[i].Verify(Signature, m));
+ }
+ {
+ int[] idxTbl = { 0, 2, 5, 8, 10 };
+ assert("idxTbl.Length=k", idxTbl.Length == k);
+ Id[] subIds = new Id[k];
+ SecretKey[] subSecs = new SecretKey[k];
+ PublicKey[] subPubs = new PublicKey[k];
+ Signature[] subSigns = new Signature[k];
+ for (int i = 0; i < k; i++) {
+ int idx = idxTbl[i];
+ subIds[i] = ids[idx];
+ subSecs[i] = secs[idx];
+ subPubs[i] = pubs[idx];
+ subSigns[i] = secs[idx].Sign(m);
+ }
+ SecretKey sec = RecoverSecretKey(subSecs, subIds);
+ PublicKey pub = RecoverPublicKey(subPubs, subIds);
+ assert("check pub", pub.IsEqual(sec.GetPublicKey()));
+ Signature Signature = RecoverSign(subSigns, subIds);
+ assert("Signature.verify", pub.Verify(Signature, m));
+ }
+ }
+ static void TestAggregate() {
+ Console.WriteLine("TestAggregate");
+ const int n = 10;
+ const string m = "abc";
+ SecretKey[] secVec = new SecretKey[n];
+ PublicKey[] pubVec = new PublicKey[n];
+ Signature[] popVec = new Signature[n];
+ Signature[] sigVec = new Signature[n];
+ for (int i = 0; i < n; i++) {
+ secVec[i].SetByCSPRNG();
+ pubVec[i] = secVec[i].GetPublicKey();
+ popVec[i] = secVec[i].GetPop();
+ sigVec[i] = secVec[i].Sign(m);
+ }
+ SecretKey secAgg;
+ PublicKey pubAgg;
+ Signature sigAgg;
+ for (int i = 0; i < n; i++) {
+ secAgg.Add(secVec[i]);
+ assert("verify pop", pubVec[i].VerifyPop(popVec[i]));
+ pubAgg.Add(pubVec[i]);
+ sigAgg.Add(sigVec[i]);
+ }
+ assert("aggregate sec", secAgg.Sign(m).IsEqual(sigAgg));
+ assert("aggregate", pubAgg.Verify(sigAgg, m));
+ }
+ static void Main(string[] args) {
+ try {
+ int[] curveTypeTbl = { BN254, BLS12_381 };
+ foreach (int curveType in curveTypeTbl) {
+ Console.WriteLine("curveType={0}", curveType);
+ Init(curveType);
+ TestId();
+ TestSecretKey();
+ TestPublicKey();
+ TestSign();
+ TestSharing();
+ TestAggregate();
+ if (err == 0) {
+ Console.WriteLine("all tests succeed");
+ } else {
+ Console.WriteLine("err={0}", err);
+ }
+ }
+ } catch (Exception e) {
+ Console.WriteLine("ERR={0}", e);
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/readme-ja.md b/vendor/github.com/tangerine-network/bls/ffi/cs/readme-ja.md
new file mode 100644
index 000000000..199135725
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/readme-ja.md
@@ -0,0 +1,188 @@
+# BLS署名のC#バインディング
+
+# 必要環境
+
+* Visual Studio 2017(x64) or later
+* C# 7.2 or later
+* .NET Framework 4.5.2 or later
+
+# DLLのビルド方法
+
+Visual Studio 2017の64bit用コマンドプロンプトを開いて
+```
+md work
+cd work
+git clone https://github.com/herumi/cybozulib_ext
+git clone https://github.com/herumi/mcl
+git clone https://github.com/herumi/bls
+cd bls
+mklib dll
+```
+`bls/bin/*.dll`が作成される。
+
+# サンプルのビルド方法
+
+bls/ffi/cs/bls.slnを開いて実行する。
+
+* 注意 bls256.slnは古いため使わないでください。
+
+# クラスとAPI
+
+## API
+
+* `Init(int curveType = BN254);`
+ * ライブラリを曲線curveTypeで初期化する。
+ * curveType = BN254 or BLS12_381
+* `SecretKey ShareSecretKey(in SecretKey[] msk, in Id id);`
+ * マスター秘密鍵の列mskに対するidの秘密鍵を生成(共有)する。
+* `SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec);`
+ * 秘密鍵secVecとID idVecのペアから秘密鍵を復元する。
+* `PublicKey SharePublicKey(in PublicKey[] mpk, in Id id);`
+ * マスター公開鍵の列mpkに対するidの公開鍵を生成(共有)する。
+* `PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec);`
+ * 公開鍵pubVecとID idVecのペアから公開鍵を復元する。
+* `Signature RecoverSign(in Signature[] sigVec, in Id[] idVec);`
+ * 署名sigVecとID idVecのペアから署名を復元する。
+
+## Id
+
+識別子クラス
+
+* `byte[] Serialize();`
+ * Idをシリアライズする。
+* `void Deserialize(byte[] buf);`
+ * バイト列bufからIdをデシリアライズする。
+* `bool IsEqual(in Id rhs);`
+ * 同値判定。
+* `void SetDecStr(string s);`
+ * 10進数文字列を設定する。
+* `void SetHexStr(string s);`
+ * 16進数文字列を設定する。
+* `void SetInt(int x);`
+ * 整数xを設定する。
+* `string GetDecStr();`
+ * 10進数表記を取得する。
+* `string GetHexStr();`
+ * 16進数表記を取得する。
+
+## SecretKey
+
+* `byte[] Serialize();`
+ * Idをシリアライズする。
+* `void Deserialize(byte[] buf);`
+ * バイト列bufからSecretKeyをデシリアライズする。
+* `bool IsEqual(in SecretKey rhs);`
+ * 同値判定。
+* `void SetHexStr(string s);`
+ * 16進数文字列を設定する。
+* `string GetHexStr();`
+ * 16進数表記を取得する。
+* `void Add(in SecretKey rhs);`
+ * 秘密鍵rhsを加算する。
+* `void SetByCSPRNG();`
+ * 暗号学的乱数で設定する。
+* `void SetHashOf(string s);`
+ * 文字列sのハッシュ値を設定する。
+* `PublicKey GetPublicKey();`
+ * 対応する公開鍵を取得する。
+* `Signature Sign(string m);`
+ * 文字列mの署名を生成する。
+* `Signature GetPop();`
+ * 自身の秘密鍵による署名(Proof Of Posession)を生成する。
+
+## PublicKey
+
+* `byte[] Serialize();`
+ * PublicKeyをシリアライズする。
+* `void Deserialize(byte[] buf);`
+ * バイト列bufからPublicKeyをデシリアライズする。
+* `bool IsEqual(in PublicKey rhs);`
+ * 同値判定。
+* `void Add(in PublicKey rhs);`
+ * 公開鍵rhsを加算する。
+* `void SetHexStr(string s);`
+ * 16進数文字列を設定する。
+* `string GetHexStr();`
+ * 16進数表記を取得する。
+* `bool Verify(in Signature sig, string m);`
+ * 文字列mに対する署名sigの正当性を確認する。
+* `bool VerifyPop(in Signature pop);`
+ * PoPの正当性を確認する。
+
+## Signature
+
+* `byte[] Serialize();`
+ * Signatureをシリアライズする。
+* `void Deserialize(byte[] buf);`
+ * バイト列bufからSignatureをデシリアライズする。
+* `bool IsEqual(in Signature rhs);`
+ * 同値判定。
+* `void Add(in Signature rhs);`
+ * 署名rhsを加算する。
+* `void SetHexStr(string s);`
+ * 16進数文字列を設定する。
+* `string GetHexStr();`
+ * 16進数表記を取得する。
+
+## 使い方
+
+### 最小サンプル
+
+```
+using static BLS;
+
+Init(BN254); // ライブラリ初期化
+SecretKey sec;
+sec.SetByCSPRNG(); // 秘密鍵の初期化
+PublicKey pub = sec.GetPublicKey(); // 公開鍵の取得
+string m = "abc";
+Signature sig = sec.Sign(m); // 署名の作成
+if (pub.Verify(sig, m))) {
+ // 署名の確認
+}
+```
+
+### 集約署名
+```
+Init(BN254); // ライブラリ初期化
+const int n = 10;
+const string m = "abc";
+SecretKey[] secVec = new SecretKey[n];
+PublicKey[] pubVec = new PublicKey[n];
+Signature[] popVec = new Signature[n];
+Signature[] sigVec = new Signature[n];
+
+for (int i = 0; i < n; i++) {
+ secVec[i].SetByCSPRNG(); // 秘密鍵の初期化
+ pubVec[i] = secVec[i].GetPublicKey(); // 公開鍵の取得
+ popVec[i] = secVec[i].GetPop(); // 所有(PoP)の証明
+ sigVec[i] = secVec[i].Sign(m); // 署名
+}
+
+SecretKey secAgg;
+PublicKey pubAgg;
+Signature sigAgg;
+for (int i = 0; i < n; i++) {
+ // PoPの確認
+ if (pubVec[i].VerifyPop(popVec[i]))) {
+ // エラー
+ return;
+ }
+ pubAgg.Add(pubVec[i]); // 公開鍵の集約
+ sigAgg.Add(sigVec[i]); // 署名の集約
+}
+if (pubAgg.Verify(sigAgg, m)) {
+ // 署名の確認
+}
+```
+
+# ライセンス
+
+modified new BSD License
+http://opensource.org/licenses/BSD-3-Clause
+
+# 著者
+
+(C)2019 光成滋生 MITSUNARI Shigeo(herumi@nifty.com) All rights reserved.
+本コンテンツの著作権、および本コンテンツ中に出てくる商標権、団体名、ロゴ、製品、
+サービスなどはそれぞれ、各権利保有者に帰属します
diff --git a/vendor/github.com/tangerine-network/bls/ffi/cs/readme.md b/vendor/github.com/tangerine-network/bls/ffi/cs/readme.md
new file mode 100644
index 000000000..2b7191871
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/cs/readme.md
@@ -0,0 +1,185 @@
+# C# binding of BLS threshold signature library
+
+# Installation Requirements
+
+* Visual Studio 2017 or later
+* C# 7.2 or later
+* .NET Framework 4.5.2 or later
+
+# How to build
+
+```
+md work
+cd work
+git clone https://github.com/herumi/cybozulib_ext
+git clone https://github.com/herumi/mcl
+git clone https://github.com/herumi/bls
+cd bls
+mklib dll
+```
+bls/bin/*.dll are created
+
+# How to build a sample
+
+Open bls/ffi/cs/bls.sln and exec it.
+
+* Remark. bls256 is obsolete. Please use bls.sln.
+
+# class and API
+
+## API
+
+* `Init(int curveType = BN254);`
+ * initialize this library with a curve `curveType`.
+ * curveType = BN254 or BLS12_381
+* `SecretKey ShareSecretKey(in SecretKey[] msk, in Id id);`
+ * generate the shared secret key from a sequence of master secret keys msk and Id.
+* `SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec);`
+ * recover the secret key from a sequence of secret keys secVec and idVec.
+* `PublicKey SharePublicKey(in PublicKey[] mpk, in Id id);`
+ * generate the shared public key from a sequence of master public keys mpk and Id.
+* `PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec);`
+ * recover the public key from a sequence of public keys pubVec and idVec.
+* `Signature RecoverSign(in Signature[] sigVec, in Id[] idVec);`
+ * recover the signature from a sequence of signatures siVec and idVec.
+
+## Id
+
+Identifier class
+
+* `byte[] Serialize();`
+ * serialize Id
+* `void Deserialize(byte[] buf);`
+ * deserialize from byte[] buf
+* `bool IsEqual(in Id rhs);`
+ * equality
+* `void SetDecStr(string s);`
+ * set by a decimal string s
+* `void SetHexStr(string s);`
+ * set by a hexadecimal string s
+* `void SetInt(int x);`
+ * set an integer x
+* `string GetDecStr();`
+ * get a decimal string
+* `string GetHexStr();`
+ * get a hexadecimal string
+
+## SecretKey
+
+* `byte[] Serialize();`
+ * serialize SecretKey
+* `void Deserialize(byte[] buf);`
+ * deserialize from byte[] buf
+* `bool IsEqual(in SecretKey rhs);`
+ * equality
+* `string GetDecStr();`
+ * get a decimal string
+* `string GetHexStr();`
+ * get a hexadecimal string
+* `void Add(in SecretKey rhs);`
+ * add a secret key rhs
+* `void SetByCSPRNG();`
+ * set a secret key by cryptographically secure pseudo random number generator
+* `void SetHashOf(string s);`
+ * set a secret key by a hash of string s
+* `PublicKey GetPublicKey();`
+ * get the corresponding public key to a secret key
+* `Signature Sign(string m);`
+ * sign a string m
+* `Signature GetPop();`
+ * get a PoP (Proof Of Posession) for a secret key
+
+## PublicKey
+
+* `byte[] Serialize();`
+ * serialize PublicKey
+* `void Deserialize(byte[] buf);`
+ * deserialize from byte[] buf
+* `bool IsEqual(in PublicKey rhs);`
+ * equality
+* `void Add(in PublicKey rhs);`
+ * add a public key rhs
+* `string GetDecStr();`
+ * get a decimal string
+* `string GetHexStr();`
+ * get a hexadecimal string
+* `bool Verify(in Signature sig, string m);`
+ * verify the validness of the sig with m
+* `bool VerifyPop(in Signature pop);`
+ * verify the validness of PoP
+
+## Signature
+
+* `byte[] Serialize();`
+ * serialize Signature
+* `void Deserialize(byte[] buf);`
+ * deserialize from byte[] buf
+* `bool IsEqual(in Signature rhs);`
+ * equality
+* `void Add(in Signature rhs);`
+ * add a signature key rhs
+* `string GetDecStr();`
+ * get a decimal string
+* `string GetHexStr();`
+ * get a hexadecimal string
+
+## How to use
+
+### A minimum sample
+
+```
+using static BLS;
+
+Init(BN254); // init library
+SecretKey sec;
+sec.SetByCSPRNG(); // init secret key
+PublicKey pub = sec.GetPublicKey(); // get public key
+string m = "abc";
+Signature sig = sec.Sign(m); // create signature
+if (pub.Verify(sig, m))) {
+ // signature is verified
+}
+```
+
+### Aggregate signature
+```
+Init(BN254); // init library
+const int n = 10;
+const string m = "abc";
+SecretKey[] secVec = new SecretKey[n];
+PublicKey[] pubVec = new PublicKey[n];
+Signature[] popVec = new Signature[n];
+Signature[] sigVec = new Signature[n];
+
+for (int i = 0; i < n; i++) {
+ secVec[i].SetByCSPRNG(); // init secret key
+ pubVec[i] = secVec[i].GetPublicKey(); // get public key
+ popVec[i] = secVec[i].GetPop(); // get a proof of Possesion (PoP)
+ sigVec[i] = secVec[i].Sign(m); // create signature
+}
+
+SecretKey secAgg;
+PublicKey pubAgg;
+Signature sigAgg;
+for (int i = 0; i < n; i++) {
+ // verify PoP
+ if (pubVec[i].VerifyPop(popVec[i]))) {
+ // error
+ return;
+ }
+ pubAgg.Add(pubVec[i]); // aggregate public key
+ sigAgg.Add(sigVec[i]); // aggregate signature
+}
+if (pubAgg.Verify(sigAgg, m)) {
+ // aggregated signature is verified
+}
+```
+
+# License
+
+modified new BSD License
+http://opensource.org/licenses/BSD-3-Clause
+
+# Author
+
+(C)2019 MITSUNARI Shigeo(herumi@nifty.com) All rights reserved.
diff --git a/vendor/github.com/tangerine-network/bls/ffi/go/bls/bls.go b/vendor/github.com/tangerine-network/bls/ffi/go/bls/bls.go
new file mode 100644
index 000000000..56bf08039
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/go/bls/bls.go
@@ -0,0 +1,539 @@
+package bls
+
+/*
+#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4
+#cgo bn256 LDFLAGS:${SRCDIR}/../../../lib/libbls256.a
+#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
+#cgo bn384 LDFLAGS:${SRCDIR}/../../../lib/libbls384.a
+#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4
+#cgo bn384_256 LDFLAGS:${SRCDIR}/../../../lib/libbls384_256.a
+#cgo !bn256,!bn384,!bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
+#cgo !bn256,!bn384,!bn384_256 LDFLAGS:${SRCDIR}/../../../lib/libbls384.a
+#cgo CFLAGS:-I${SRCDIR}/../../../include -I${SRCDIR}/../../../../mcl/include
+#cgo LDFLAGS:${SRCDIR}/../../../../mcl/lib/libmcl.a -lgmpxx -lgmp
+#cgo static LDFLAGS:-static
+typedef unsigned int (*ReadRandFunc)(void *, void *, unsigned int);
+int wrapReadRandCgo(void *self, void *buf, unsigned int n);
+#include <bls/bls.h>
+*/
+import "C"
+import "fmt"
+import "unsafe"
+import "io"
+import "encoding/json"
+
+// Init --
+// call this function before calling all the other operations
+// this function is not thread safe
+func Init(curve int) error {
+ err := C.blsInit(C.int(curve), C.MCLBN_COMPILED_TIME_VAR)
+ if err != 0 {
+ return fmt.Errorf("ERR Init curve=%d", curve)
+ }
+ return nil
+}
+
+// ID --
+type ID struct {
+ v Fr
+}
+
+// getPointer --
+func (id *ID) getPointer() (p *C.blsId) {
+ // #nosec
+ return (*C.blsId)(unsafe.Pointer(id))
+}
+
+// GetLittleEndian --
+func (id *ID) GetLittleEndian() []byte {
+ return id.v.Serialize()
+}
+
+// SetLittleEndian --
+func (id *ID) SetLittleEndian(buf []byte) error {
+ return id.v.SetLittleEndian(buf)
+}
+
+// GetHexString --
+func (id *ID) GetHexString() string {
+ return id.v.GetString(16)
+}
+
+// GetDecString --
+func (id *ID) GetDecString() string {
+ return id.v.GetString(10)
+}
+
+// SetHexString --
+func (id *ID) SetHexString(s string) error {
+ return id.v.SetString(s, 16)
+}
+
+// SetDecString --
+func (id *ID) SetDecString(s string) error {
+ return id.v.SetString(s, 10)
+}
+
+// IsEqual --
+func (id *ID) IsEqual(rhs *ID) bool {
+ if id == nil || rhs == nil {
+ return false
+ }
+ return id.v.IsEqual(&rhs.v)
+}
+
+// MarshalJSON implements json.Marshaller.
+func (id *ID) MarshalJSON() ([]byte, error) {
+ return json.Marshal(&struct {
+ ID []byte `json:"id"`
+ }{
+ id.GetLittleEndian(),
+ })
+}
+
+// UnmarshalJSON implements json.Unmarshaller.
+func (id *ID) UnmarshalJSON(data []byte) error {
+ aux := &struct {
+ ID []byte `json:"id"`
+ }{}
+ if err := json.Unmarshal(data, &aux); err != nil {
+ return err
+ }
+ if err := id.SetLittleEndian(aux.ID); err != nil {
+ return err
+ }
+ return nil
+}
+
+// SecretKey --
+type SecretKey struct {
+ v Fr
+}
+
+// getPointer --
+func (sec *SecretKey) getPointer() (p *C.blsSecretKey) {
+ // #nosec
+ return (*C.blsSecretKey)(unsafe.Pointer(sec))
+}
+
+// GetLittleEndian --
+func (sec *SecretKey) GetLittleEndian() []byte {
+ return sec.v.Serialize()
+}
+
+// SetLittleEndian --
+func (sec *SecretKey) SetLittleEndian(buf []byte) error {
+ return sec.v.SetLittleEndian(buf)
+}
+
+// SerializeToHexStr --
+func (sec *SecretKey) SerializeToHexStr() string {
+ return sec.v.GetString(IoSerializeHexStr)
+}
+
+// DeserializeHexStr --
+func (sec *SecretKey) DeserializeHexStr(s string) error {
+ return sec.v.SetString(s, IoSerializeHexStr)
+}
+
+// GetHexString --
+func (sec *SecretKey) GetHexString() string {
+ return sec.v.GetString(16)
+}
+
+// GetDecString --
+func (sec *SecretKey) GetDecString() string {
+ return sec.v.GetString(10)
+}
+
+// SetHexString --
+func (sec *SecretKey) SetHexString(s string) error {
+ return sec.v.SetString(s, 16)
+}
+
+// SetDecString --
+func (sec *SecretKey) SetDecString(s string) error {
+ return sec.v.SetString(s, 10)
+}
+
+// IsEqual --
+func (sec *SecretKey) IsEqual(rhs *SecretKey) bool {
+ if sec == nil || rhs == nil {
+ return false
+ }
+ return sec.v.IsEqual(&rhs.v)
+}
+
+// SetByCSPRNG --
+func (sec *SecretKey) SetByCSPRNG() {
+ sec.v.SetByCSPRNG()
+}
+
+// Add --
+func (sec *SecretKey) Add(rhs *SecretKey) {
+ FrAdd(&sec.v, &sec.v, &rhs.v)
+}
+
+// GetMasterSecretKey --
+func (sec *SecretKey) GetMasterSecretKey(k int) (msk []SecretKey) {
+ msk = make([]SecretKey, k)
+ msk[0] = *sec
+ for i := 1; i < k; i++ {
+ msk[i].SetByCSPRNG()
+ }
+ return msk
+}
+
+// MarshalJSON implements json.Marshaller.
+func (sec *SecretKey) MarshalJSON() ([]byte, error) {
+ return json.Marshal(&struct {
+ SecretKey []byte `json:"secret_key"`
+ }{
+ sec.GetLittleEndian(),
+ })
+}
+
+// UnmarshalJSON implements json.Unmarshaller.
+func (sec *SecretKey) UnmarshalJSON(data []byte) error {
+ aux := &struct {
+ SecretKey []byte `json:"secret_key"`
+ }{}
+ if err := json.Unmarshal(data, &aux); err != nil {
+ return err
+ }
+ if err := sec.SetLittleEndian(aux.SecretKey); err != nil {
+ return err
+ }
+ return nil
+}
+
+// GetMasterPublicKey --
+func GetMasterPublicKey(msk []SecretKey) (mpk []PublicKey) {
+ n := len(msk)
+ mpk = make([]PublicKey, n)
+ for i := 0; i < n; i++ {
+ mpk[i] = *msk[i].GetPublicKey()
+ }
+ return mpk
+}
+
+// Set --
+func (sec *SecretKey) Set(msk []SecretKey, id *ID) error {
+ // #nosec
+ return FrEvaluatePolynomial(&sec.v, *(*[]Fr)(unsafe.Pointer(&msk)), &id.v)
+}
+
+// Recover --
+func (sec *SecretKey) Recover(secVec []SecretKey, idVec []ID) error {
+ // #nosec
+ return FrLagrangeInterpolation(&sec.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]Fr)(unsafe.Pointer(&secVec)))
+}
+
+// GetPop --
+func (sec *SecretKey) GetPop() (sign *Sign) {
+ sign = new(Sign)
+ C.blsGetPop(sign.getPointer(), sec.getPointer())
+ return sign
+}
+
+// PublicKey --
+type PublicKey struct {
+ v G2
+}
+
+// getPointer --
+func (pub *PublicKey) getPointer() (p *C.blsPublicKey) {
+ // #nosec
+ return (*C.blsPublicKey)(unsafe.Pointer(pub))
+}
+
+// Serialize --
+func (pub *PublicKey) Serialize() []byte {
+ return pub.v.Serialize()
+}
+
+// Deserialize --
+func (pub *PublicKey) Deserialize(buf []byte) error {
+ return pub.v.Deserialize(buf)
+}
+
+// SerializeToHexStr --
+func (pub *PublicKey) SerializeToHexStr() string {
+ return pub.v.GetString(IoSerializeHexStr)
+}
+
+// DeserializeHexStr --
+func (pub *PublicKey) DeserializeHexStr(s string) error {
+ return pub.v.SetString(s, IoSerializeHexStr)
+}
+
+// GetHexString --
+func (pub *PublicKey) GetHexString() string {
+ return pub.v.GetString(16)
+}
+
+// SetHexString --
+func (pub *PublicKey) SetHexString(s string) error {
+ return pub.v.SetString(s, 16)
+}
+
+// IsEqual --
+func (pub *PublicKey) IsEqual(rhs *PublicKey) bool {
+ if pub == nil || rhs == nil {
+ return false
+ }
+ return pub.v.IsEqual(&rhs.v)
+}
+
+// Add --
+func (pub *PublicKey) Add(rhs *PublicKey) {
+ G2Add(&pub.v, &pub.v, &rhs.v)
+}
+
+// Set --
+func (pub *PublicKey) Set(mpk []PublicKey, id *ID) error {
+ // #nosec
+ return G2EvaluatePolynomial(&pub.v, *(*[]G2)(unsafe.Pointer(&mpk)), &id.v)
+}
+
+// Recover --
+func (pub *PublicKey) Recover(pubVec []PublicKey, idVec []ID) error {
+ // #nosec
+ return G2LagrangeInterpolation(&pub.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]G2)(unsafe.Pointer(&pubVec)))
+}
+
+// MarshalJSON implements json.Marshaller.
+func (pub *PublicKey) MarshalJSON() ([]byte, error) {
+ return json.Marshal(&struct {
+ PublicKey []byte `json:"public_key"`
+ }{
+ pub.Serialize(),
+ })
+}
+
+// UnmarshalJSON implements json.Unmarshaller.
+func (pub *PublicKey) UnmarshalJSON(data []byte) error {
+ aux := &struct {
+ PublicKey []byte `json:"public_key"`
+ }{}
+ if err := json.Unmarshal(data, &aux); err != nil {
+ return err
+ }
+ if err := pub.Deserialize(aux.PublicKey); err != nil {
+ return err
+ }
+ return nil
+}
+
+// Sign --
+type Sign struct {
+ v G1
+}
+
+// getPointer --
+func (sign *Sign) getPointer() (p *C.blsSignature) {
+ // #nosec
+ return (*C.blsSignature)(unsafe.Pointer(sign))
+}
+
+// Serialize --
+func (sign *Sign) Serialize() []byte {
+ return sign.v.Serialize()
+}
+
+// Deserialize --
+func (sign *Sign) Deserialize(buf []byte) error {
+ return sign.v.Deserialize(buf)
+}
+
+// SerializeToHexStr --
+func (sign *Sign) SerializeToHexStr() string {
+ return sign.v.GetString(IoSerializeHexStr)
+}
+
+// DeserializeHexStr --
+func (sign *Sign) DeserializeHexStr(s string) error {
+ return sign.v.SetString(s, IoSerializeHexStr)
+}
+
+// GetHexString --
+func (sign *Sign) GetHexString() string {
+ return sign.v.GetString(16)
+}
+
+// SetHexString --
+func (sign *Sign) SetHexString(s string) error {
+ return sign.v.SetString(s, 16)
+}
+
+// IsEqual --
+func (sign *Sign) IsEqual(rhs *Sign) bool {
+ if sign == nil || rhs == nil {
+ return false
+ }
+ return sign.v.IsEqual(&rhs.v)
+}
+
+// GetPublicKey --
+func (sec *SecretKey) GetPublicKey() (pub *PublicKey) {
+ pub = new(PublicKey)
+ C.blsGetPublicKey(pub.getPointer(), sec.getPointer())
+ return pub
+}
+
+// Sign -- Constant Time version
+func (sec *SecretKey) Sign(m string) (sign *Sign) {
+ sign = new(Sign)
+ buf := []byte(m)
+ // #nosec
+ C.blsSign(sign.getPointer(), sec.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ return sign
+}
+
+// Add --
+func (sign *Sign) Add(rhs *Sign) {
+ C.blsSignatureAdd(sign.getPointer(), rhs.getPointer())
+}
+
+// Recover --
+func (sign *Sign) Recover(signVec []Sign, idVec []ID) error {
+ // #nosec
+ return G1LagrangeInterpolation(&sign.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]G1)(unsafe.Pointer(&signVec)))
+}
+
+// Verify --
+func (sign *Sign) Verify(pub *PublicKey, m string) bool {
+ buf := []byte(m)
+ // #nosec
+ return C.blsVerify(sign.getPointer(), pub.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 1
+}
+
+// VerifyPop --
+func (sign *Sign) VerifyPop(pub *PublicKey) bool {
+ if pub.getPointer() == nil {
+ return false
+ }
+ return C.blsVerifyPop(sign.getPointer(), pub.getPointer()) == 1
+}
+
+// MarshalJSON implements json.Marshaller.
+func (sign *Sign) MarshalJSON() ([]byte, error) {
+ return json.Marshal(&struct {
+ Sign []byte `json:"sign"`
+ }{
+ sign.Serialize(),
+ })
+}
+
+// UnmarshalJSON implements json.Unmarshaller.
+func (sign *Sign) UnmarshalJSON(data []byte) error {
+ aux := &struct {
+ Sign []byte `json:"sign"`
+ }{}
+ if err := json.Unmarshal(data, &aux); err != nil {
+ return err
+ }
+ if err := sign.Deserialize(aux.Sign); err != nil {
+ return err
+ }
+ return nil
+}
+
+// DHKeyExchange --
+func DHKeyExchange(sec *SecretKey, pub *PublicKey) (out PublicKey) {
+ C.blsDHKeyExchange(out.getPointer(), sec.getPointer(), pub.getPointer())
+ return out
+}
+
+// HashAndMapToSignature --
+func HashAndMapToSignature(buf []byte) *Sign {
+ sig := new(Sign)
+ err := sig.v.HashAndMapTo(buf)
+ if err == nil {
+ return sig
+ } else {
+ return nil
+ }
+}
+
+// VerifyPairing --
+func VerifyPairing(X *Sign, Y *Sign, pub *PublicKey) bool {
+ if X.getPointer() == nil || Y.getPointer() == nil || pub.getPointer() == nil {
+ return false
+ }
+ return C.blsVerifyPairing(X.getPointer(), Y.getPointer(), pub.getPointer()) == 1
+}
+
+// SignHash --
+func (sec *SecretKey) SignHash(hash []byte) (sign *Sign) {
+ sign = new(Sign)
+ // #nosec
+ err := C.blsSignHash(sign.getPointer(), sec.getPointer(), unsafe.Pointer(&hash[0]), C.size_t(len(hash)))
+ if err == 0 {
+ return sign
+ } else {
+ return nil
+ }
+}
+
+// VerifyHash --
+func (sign *Sign) VerifyHash(pub *PublicKey, hash []byte) bool {
+ if pub.getPointer() == nil {
+ return false
+ }
+ // #nosec
+ return C.blsVerifyHash(sign.getPointer(), pub.getPointer(), unsafe.Pointer(&hash[0]), C.size_t(len(hash))) == 1
+}
+
+func Min(x, y int) int {
+ if x < y {
+ return x
+ }
+ return y
+}
+
+// VerifyAggregateHashes --
+func (sign *Sign) VerifyAggregateHashes(pubVec []PublicKey, hash [][]byte) bool {
+ hashByte := GetOpUnitSize() * 8
+ n := len(hash)
+ h := make([]byte, n*hashByte)
+ for i := 0; i < n; i++ {
+ hn := len(hash[i])
+ copy(h[i*hashByte:(i+1)*hashByte], hash[i][0:Min(hn, hashByte)])
+ }
+ if pubVec[0].getPointer() == nil {
+ return false
+ }
+ return C.blsVerifyAggregatedHashes(sign.getPointer(), pubVec[0].getPointer(), unsafe.Pointer(&h[0]), C.size_t(hashByte), C.size_t(n)) == 1
+}
+
+///
+
+var s_randReader io.Reader
+
+func createSlice(buf *C.char, n C.uint) []byte {
+ size := int(n)
+ return (*[1 << 30]byte)(unsafe.Pointer(buf))[:size:size]
+}
+
+// this function can't be put in callback.go
+//export wrapReadRandGo
+func wrapReadRandGo(buf *C.char, n C.uint) C.uint {
+ slice := createSlice(buf, n)
+ ret, err := s_randReader.Read(slice)
+ if ret == int(n) && err == nil {
+ return n
+ }
+ return 0
+}
+
+// SetRandFunc --
+func SetRandFunc(randReader io.Reader) {
+ s_randReader = randReader
+ if randReader != nil {
+ C.blsSetRandFunc(nil, C.ReadRandFunc(unsafe.Pointer(C.wrapReadRandCgo)))
+ } else {
+ // use default random generator
+ C.blsSetRandFunc(nil, C.ReadRandFunc(unsafe.Pointer(nil)))
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/ffi/go/bls/callback.go b/vendor/github.com/tangerine-network/bls/ffi/go/bls/callback.go
new file mode 100644
index 000000000..ba73a5e15
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/go/bls/callback.go
@@ -0,0 +1,12 @@
+package bls
+
+/*
+// exported from bls.go
+unsigned int wrapReadRandGo(void *buf, unsigned int n);
+int wrapReadRandCgo(void *self, void *buf, unsigned int n)
+{
+ (void)self;
+ return wrapReadRandGo(buf, n);
+}
+*/
+import "C"
diff --git a/vendor/github.com/tangerine-network/bls/ffi/go/bls/dummy.cpp b/vendor/github.com/tangerine-network/bls/ffi/go/bls/dummy.cpp
new file mode 100644
index 000000000..a5103a1c5
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/go/bls/dummy.cpp
@@ -0,0 +1,3 @@
+// This is a dummy source file which forces cgo to use the C++ linker instead
+// of the default C linker. We can therefore eliminate non-portable linker
+// flags such as -lstdc++, which is likely to break on FreeBSD and OpenBSD.
diff --git a/vendor/github.com/tangerine-network/bls/ffi/go/bls/mcl.go b/vendor/github.com/tangerine-network/bls/ffi/go/bls/mcl.go
new file mode 100644
index 000000000..ca8d7f02b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/ffi/go/bls/mcl.go
@@ -0,0 +1,646 @@
+package bls
+
+/*
+#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4
+#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
+#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4
+#cgo !bn256,!bn384,!bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
+#include <mcl/bn.h>
+*/
+import "C"
+import "fmt"
+import "unsafe"
+
+// CurveFp254BNb -- 254 bit curve
+const CurveFp254BNb = C.mclBn_CurveFp254BNb
+
+// CurveFp382_1 -- 382 bit curve 1
+const CurveFp382_1 = C.mclBn_CurveFp382_1
+
+// CurveFp382_2 -- 382 bit curve 2
+const CurveFp382_2 = C.mclBn_CurveFp382_2
+
+// BLS12_381
+const BLS12_381 = C.MCL_BLS12_381
+
+// IoSerializeHexStr
+const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR
+
+// GetFrUnitSize() --
+func GetFrUnitSize() int {
+ return int(C.MCLBN_FR_UNIT_SIZE)
+}
+
+// GetFpUnitSize() --
+// same as GetMaxOpUnitSize()
+func GetFpUnitSize() int {
+ return int(C.MCLBN_FP_UNIT_SIZE)
+}
+
+// GetMaxOpUnitSize --
+func GetMaxOpUnitSize() int {
+ return int(C.MCLBN_FP_UNIT_SIZE)
+}
+
+// GetOpUnitSize --
+// the length of Fr is GetOpUnitSize() * 8 bytes
+func GetOpUnitSize() int {
+ return int(C.mclBn_getOpUnitSize())
+}
+
+// GetCurveOrder --
+// return the order of G1
+func GetCurveOrder() string {
+ buf := make([]byte, 1024)
+ // #nosec
+ n := C.mclBn_getCurveOrder((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if n == 0 {
+ panic("implementation err. size of buf is small")
+ }
+ return string(buf[:n])
+}
+
+// GetFieldOrder --
+// return the characteristic of the field where a curve is defined
+func GetFieldOrder() string {
+ buf := make([]byte, 1024)
+ // #nosec
+ n := C.mclBn_getFieldOrder((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if n == 0 {
+ panic("implementation err. size of buf is small")
+ }
+ return string(buf[:n])
+}
+
+// Fr --
+type Fr struct {
+ v C.mclBnFr
+}
+
+// getPointer --
+func (x *Fr) getPointer() (p *C.mclBnFr) {
+ // #nosec
+ return (*C.mclBnFr)(unsafe.Pointer(x))
+}
+
+// Clear --
+func (x *Fr) Clear() {
+ // #nosec
+ C.mclBnFr_clear(x.getPointer())
+}
+
+// SetInt64 --
+func (x *Fr) SetInt64(v int64) {
+ // #nosec
+ C.mclBnFr_setInt(x.getPointer(), C.int64_t(v))
+}
+
+// SetString --
+func (x *Fr) SetString(s string, base int) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.mclBnFr_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
+ if err != 0 {
+ return fmt.Errorf("err mclBnFr_setStr %x", err)
+ }
+ return nil
+}
+
+// Deserialize --
+func (x *Fr) Deserialize(buf []byte) error {
+ // #nosec
+ err := C.mclBnFr_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err == 0 {
+ return fmt.Errorf("err mclBnFr_deserialize %x", buf)
+ }
+ return nil
+}
+
+// SetLittleEndian --
+func (x *Fr) SetLittleEndian(buf []byte) error {
+ // #nosec
+ err := C.mclBnFr_setLittleEndian(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err != 0 {
+ return fmt.Errorf("err mclBnFr_setLittleEndian %x", err)
+ }
+ return nil
+}
+
+// IsEqual --
+func (x *Fr) IsEqual(rhs *Fr) bool {
+ return C.mclBnFr_isEqual(x.getPointer(), rhs.getPointer()) == 1
+}
+
+// IsZero --
+func (x *Fr) IsZero() bool {
+ return C.mclBnFr_isZero(x.getPointer()) == 1
+}
+
+// IsOne --
+func (x *Fr) IsOne() bool {
+ return C.mclBnFr_isOne(x.getPointer()) == 1
+}
+
+// SetByCSPRNG --
+func (x *Fr) SetByCSPRNG() {
+ err := C.mclBnFr_setByCSPRNG(x.getPointer())
+ if err != 0 {
+ panic("err mclBnFr_setByCSPRNG")
+ }
+}
+
+// SetHashOf --
+func (x *Fr) SetHashOf(buf []byte) bool {
+ // #nosec
+ return C.mclBnFr_setHashOf(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 0
+}
+
+// GetString --
+func (x *Fr) GetString(base int) string {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnFr_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
+ if n == 0 {
+ panic("err mclBnFr_getStr")
+ }
+ return string(buf[:n])
+}
+
+// Serialize --
+func (x *Fr) Serialize() []byte {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnFr_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
+ if n == 0 {
+ panic("err mclBnFr_serialize")
+ }
+ return buf[:n]
+}
+
+// FrNeg --
+func FrNeg(out *Fr, x *Fr) {
+ C.mclBnFr_neg(out.getPointer(), x.getPointer())
+}
+
+// FrInv --
+func FrInv(out *Fr, x *Fr) {
+ C.mclBnFr_inv(out.getPointer(), x.getPointer())
+}
+
+// FrAdd --
+func FrAdd(out *Fr, x *Fr, y *Fr) {
+ C.mclBnFr_add(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// FrSub --
+func FrSub(out *Fr, x *Fr, y *Fr) {
+ C.mclBnFr_sub(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// FrMul --
+func FrMul(out *Fr, x *Fr, y *Fr) {
+ C.mclBnFr_mul(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// FrDiv --
+func FrDiv(out *Fr, x *Fr, y *Fr) {
+ C.mclBnFr_div(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G1 --
+type G1 struct {
+ v C.mclBnG1
+}
+
+// getPointer --
+func (x *G1) getPointer() (p *C.mclBnG1) {
+ // #nosec
+ return (*C.mclBnG1)(unsafe.Pointer(x))
+}
+
+// Clear --
+func (x *G1) Clear() {
+ // #nosec
+ C.mclBnG1_clear(x.getPointer())
+}
+
+// SetString --
+func (x *G1) SetString(s string, base int) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.mclBnG1_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
+ if err != 0 {
+ return fmt.Errorf("err mclBnG1_setStr %x", err)
+ }
+ return nil
+}
+
+// Deserialize --
+func (x *G1) Deserialize(buf []byte) error {
+ // #nosec
+ err := C.mclBnG1_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err == 0 {
+ return fmt.Errorf("err mclBnG1_deserialize %x", buf)
+ }
+ return nil
+}
+
+// IsEqual --
+func (x *G1) IsEqual(rhs *G1) bool {
+ return C.mclBnG1_isEqual(x.getPointer(), rhs.getPointer()) == 1
+}
+
+// IsZero --
+func (x *G1) IsZero() bool {
+ return C.mclBnG1_isZero(x.getPointer()) == 1
+}
+
+// HashAndMapTo --
+func (x *G1) HashAndMapTo(buf []byte) error {
+ // #nosec
+ err := C.mclBnG1_hashAndMapTo(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err != 0 {
+ return fmt.Errorf("err mclBnG1_hashAndMapTo %x", err)
+ }
+ return nil
+}
+
+// GetString --
+func (x *G1) GetString(base int) string {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnG1_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
+ if n == 0 {
+ panic("err mclBnG1_getStr")
+ }
+ return string(buf[:n])
+}
+
+// Serialize --
+func (x *G1) Serialize() []byte {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnG1_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
+ if n == 0 {
+ panic("err mclBnG1_serialize")
+ }
+ return buf[:n]
+}
+
+// G1Neg --
+func G1Neg(out *G1, x *G1) {
+ C.mclBnG1_neg(out.getPointer(), x.getPointer())
+}
+
+// G1Dbl --
+func G1Dbl(out *G1, x *G1) {
+ C.mclBnG1_dbl(out.getPointer(), x.getPointer())
+}
+
+// G1Add --
+func G1Add(out *G1, x *G1, y *G1) {
+ C.mclBnG1_add(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G1Sub --
+func G1Sub(out *G1, x *G1, y *G1) {
+ C.mclBnG1_sub(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G1Mul --
+func G1Mul(out *G1, x *G1, y *Fr) {
+ C.mclBnG1_mul(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G1MulCT -- constant time (depending on bit lengh of y)
+func G1MulCT(out *G1, x *G1, y *Fr) {
+ C.mclBnG1_mulCT(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G2 --
+type G2 struct {
+ v C.mclBnG2
+}
+
+// getPointer --
+func (x *G2) getPointer() (p *C.mclBnG2) {
+ // #nosec
+ return (*C.mclBnG2)(unsafe.Pointer(x))
+}
+
+// Clear --
+func (x *G2) Clear() {
+ // #nosec
+ C.mclBnG2_clear(x.getPointer())
+}
+
+// SetString --
+func (x *G2) SetString(s string, base int) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.mclBnG2_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
+ if err != 0 {
+ return fmt.Errorf("err mclBnG2_setStr %x", err)
+ }
+ return nil
+}
+
+// Deserialize --
+func (x *G2) Deserialize(buf []byte) error {
+ // #nosec
+ err := C.mclBnG2_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err == 0 {
+ return fmt.Errorf("err mclBnG2_deserialize %x", buf)
+ }
+ return nil
+}
+
+// IsEqual --
+func (x *G2) IsEqual(rhs *G2) bool {
+ return C.mclBnG2_isEqual(x.getPointer(), rhs.getPointer()) == 1
+}
+
+// IsZero --
+func (x *G2) IsZero() bool {
+ return C.mclBnG2_isZero(x.getPointer()) == 1
+}
+
+// HashAndMapTo --
+func (x *G2) HashAndMapTo(buf []byte) error {
+ // #nosec
+ err := C.mclBnG2_hashAndMapTo(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err != 0 {
+ return fmt.Errorf("err mclBnG2_hashAndMapTo %x", err)
+ }
+ return nil
+}
+
+// GetString --
+func (x *G2) GetString(base int) string {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnG2_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
+ if n == 0 {
+ panic("err mclBnG2_getStr")
+ }
+ return string(buf[:n])
+}
+
+// Serialize --
+func (x *G2) Serialize() []byte {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnG2_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
+ if n == 0 {
+ panic("err mclBnG2_serialize")
+ }
+ return buf[:n]
+}
+
+// G2Neg --
+func G2Neg(out *G2, x *G2) {
+ C.mclBnG2_neg(out.getPointer(), x.getPointer())
+}
+
+// G2Dbl --
+func G2Dbl(out *G2, x *G2) {
+ C.mclBnG2_dbl(out.getPointer(), x.getPointer())
+}
+
+// G2Add --
+func G2Add(out *G2, x *G2, y *G2) {
+ C.mclBnG2_add(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G2Sub --
+func G2Sub(out *G2, x *G2, y *G2) {
+ C.mclBnG2_sub(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// G2Mul --
+func G2Mul(out *G2, x *G2, y *Fr) {
+ C.mclBnG2_mul(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GT --
+type GT struct {
+ v C.mclBnGT
+}
+
+// getPointer --
+func (x *GT) getPointer() (p *C.mclBnGT) {
+ // #nosec
+ return (*C.mclBnGT)(unsafe.Pointer(x))
+}
+
+// Clear --
+func (x *GT) Clear() {
+ // #nosec
+ C.mclBnGT_clear(x.getPointer())
+}
+
+// SetInt64 --
+func (x *GT) SetInt64(v int64) {
+ // #nosec
+ C.mclBnGT_setInt(x.getPointer(), C.int64_t(v))
+}
+
+// SetString --
+func (x *GT) SetString(s string, base int) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.mclBnGT_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
+ if err != 0 {
+ return fmt.Errorf("err mclBnGT_setStr %x", err)
+ }
+ return nil
+}
+
+// Deserialize --
+func (x *GT) Deserialize(buf []byte) error {
+ // #nosec
+ err := C.mclBnGT_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
+ if err == 0 {
+ return fmt.Errorf("err mclBnGT_deserialize %x", buf)
+ }
+ return nil
+}
+
+// IsEqual --
+func (x *GT) IsEqual(rhs *GT) bool {
+ return C.mclBnGT_isEqual(x.getPointer(), rhs.getPointer()) == 1
+}
+
+// IsZero --
+func (x *GT) IsZero() bool {
+ return C.mclBnGT_isZero(x.getPointer()) == 1
+}
+
+// IsOne --
+func (x *GT) IsOne() bool {
+ return C.mclBnGT_isOne(x.getPointer()) == 1
+}
+
+// GetString --
+func (x *GT) GetString(base int) string {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnGT_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
+ if n == 0 {
+ panic("err mclBnGT_getStr")
+ }
+ return string(buf[:n])
+}
+
+// Serialize --
+func (x *GT) Serialize() []byte {
+ buf := make([]byte, 2048)
+ // #nosec
+ n := C.mclBnGT_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
+ if n == 0 {
+ panic("err mclBnGT_serialize")
+ }
+ return buf[:n]
+}
+
+// GTNeg --
+func GTNeg(out *GT, x *GT) {
+ C.mclBnGT_neg(out.getPointer(), x.getPointer())
+}
+
+// GTInv --
+func GTInv(out *GT, x *GT) {
+ C.mclBnGT_inv(out.getPointer(), x.getPointer())
+}
+
+// GTAdd --
+func GTAdd(out *GT, x *GT, y *GT) {
+ C.mclBnGT_add(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GTSub --
+func GTSub(out *GT, x *GT, y *GT) {
+ C.mclBnGT_sub(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GTMul --
+func GTMul(out *GT, x *GT, y *GT) {
+ C.mclBnGT_mul(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GTDiv --
+func GTDiv(out *GT, x *GT, y *GT) {
+ C.mclBnGT_div(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GTPow --
+func GTPow(out *GT, x *GT, y *Fr) {
+ C.mclBnGT_pow(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// Pairing --
+func Pairing(out *GT, x *G1, y *G2) {
+ C.mclBn_pairing(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// FinalExp --
+func FinalExp(out *GT, x *GT) {
+ C.mclBn_finalExp(out.getPointer(), x.getPointer())
+}
+
+// MillerLoop --
+func MillerLoop(out *GT, x *G1, y *G2) {
+ C.mclBn_millerLoop(out.getPointer(), x.getPointer(), y.getPointer())
+}
+
+// GetUint64NumToPrecompute --
+func GetUint64NumToPrecompute() int {
+ return int(C.mclBn_getUint64NumToPrecompute())
+}
+
+// PrecomputeG2 --
+func PrecomputeG2(Qbuf []uint64, Q *G2) {
+ // #nosec
+ C.mclBn_precomputeG2((*C.uint64_t)(unsafe.Pointer(&Qbuf[0])), Q.getPointer())
+}
+
+// PrecomputedMillerLoop --
+func PrecomputedMillerLoop(out *GT, P *G1, Qbuf []uint64) {
+ // #nosec
+ C.mclBn_precomputedMillerLoop(out.getPointer(), P.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Qbuf[0])))
+}
+
+// PrecomputedMillerLoop2 --
+func PrecomputedMillerLoop2(out *GT, P1 *G1, Q1buf []uint64, P2 *G1, Q2buf []uint64) {
+ // #nosec
+ C.mclBn_precomputedMillerLoop2(out.getPointer(), P1.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Q1buf[0])), P1.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Q1buf[0])))
+}
+
+// FrEvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
+func FrEvaluatePolynomial(y *Fr, c []Fr, x *Fr) error {
+ // #nosec
+ err := C.mclBn_FrEvaluatePolynomial(y.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
+ if err != 0 {
+ return fmt.Errorf("err mclBn_FrEvaluatePolynomial")
+ }
+ return nil
+}
+
+// G1EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
+func G1EvaluatePolynomial(y *G1, c []G1, x *Fr) error {
+ // #nosec
+ err := C.mclBn_G1EvaluatePolynomial(y.getPointer(), (*C.mclBnG1)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
+ if err != 0 {
+ return fmt.Errorf("err mclBn_G1EvaluatePolynomial")
+ }
+ return nil
+}
+
+// G2EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
+func G2EvaluatePolynomial(y *G2, c []G2, x *Fr) error {
+ // #nosec
+ err := C.mclBn_G2EvaluatePolynomial(y.getPointer(), (*C.mclBnG2)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
+ if err != 0 {
+ return fmt.Errorf("err mclBn_G2EvaluatePolynomial")
+ }
+ return nil
+}
+
+// FrLagrangeInterpolation --
+func FrLagrangeInterpolation(out *Fr, xVec []Fr, yVec []Fr) error {
+ if len(xVec) != len(yVec) {
+ return fmt.Errorf("err FrLagrangeInterpolation:bad size")
+ }
+ // #nosec
+ err := C.mclBn_FrLagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnFr)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
+ if err != 0 {
+ return fmt.Errorf("err FrLagrangeInterpolation")
+ }
+ return nil
+}
+
+// G1LagrangeInterpolation --
+func G1LagrangeInterpolation(out *G1, xVec []Fr, yVec []G1) error {
+ if len(xVec) != len(yVec) {
+ return fmt.Errorf("err G1LagrangeInterpolation:bad size")
+ }
+ // #nosec
+ err := C.mclBn_G1LagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnG1)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
+ if err != 0 {
+ return fmt.Errorf("err G1LagrangeInterpolation")
+ }
+ return nil
+}
+
+// G2LagrangeInterpolation --
+func G2LagrangeInterpolation(out *G2, xVec []Fr, yVec []G2) error {
+ if len(xVec) != len(yVec) {
+ return fmt.Errorf("err G2LagrangeInterpolation:bad size")
+ }
+ // #nosec
+ err := C.mclBn_G2LagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnG2)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
+ if err != 0 {
+ return fmt.Errorf("err G2LagrangeInterpolation")
+ }
+ return nil
+}
diff --git a/vendor/github.com/tangerine-network/bls/images/bls-go-alpine/Dockerfile b/vendor/github.com/tangerine-network/bls/images/bls-go-alpine/Dockerfile
new file mode 100644
index 000000000..edd49eb4b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/images/bls-go-alpine/Dockerfile
@@ -0,0 +1,12 @@
+FROM golang:alpine
+MAINTAINER Jimmy Hu <jimmy.hu@dexon.org>
+
+# Install dependencies
+RUN apk add --update-cache build-base gmp-dev openssl-dev git
+
+# Build bls library
+RUN mkdir work ; cd work
+RUN git clone --depth 1 git://github.com/dexon-foundation/mcl.git
+RUN mkdir bls
+COPY . bls/
+RUN cd bls ; make clean && make test_go DOCKER=alpine -j && cp lib/* /usr/lib/
diff --git a/vendor/github.com/tangerine-network/bls/include/bls/bls.h b/vendor/github.com/tangerine-network/bls/include/bls/bls.h
new file mode 100644
index 000000000..cb300bc49
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/include/bls/bls.h
@@ -0,0 +1,275 @@
+#pragma once
+/**
+ @file
+ @brief C interface of bls.hpp
+ @author MITSUNARI Shigeo(@herumi)
+ @license modified new BSD license
+ http://opensource.org/licenses/BSD-3-Clause
+*/
+#include <mcl/bn.h>
+
+#ifdef BLS_SWAP_G
+ /*
+ error if BLS_SWAP_G is inconsistently used between library and exe
+ */
+ #undef MCLBN_COMPILED_TIME_VAR
+ #define MCLBN_COMPILED_TIME_VAR ((MCLBN_FR_UNIT_SIZE) * 10 + (MCLBN_FP_UNIT_SIZE) + 100)
+#endif
+
+#ifdef _MSC_VER
+ #ifdef BLS_DONT_EXPORT
+ #define BLS_DLL_API
+ #else
+ #ifdef BLS_DLL_EXPORT
+ #define BLS_DLL_API __declspec(dllexport)
+ #else
+ #define BLS_DLL_API __declspec(dllimport)
+ #endif
+ #endif
+ #ifndef BLS_NO_AUTOLINK
+ #if MCLBN_FP_UNIT_SIZE == 4
+ #pragma comment(lib, "bls256.lib")
+ #elif (MCLBN_FP_UNIT_SIZE == 6) && (MCLBN_FR_UNIT_SIZE == 4)
+ #pragma comment(lib, "bls384_256.lib")
+ #elif (MCLBN_FP_UNIT_SIZE == 6) && (MCLBN_FR_UNIT_SIZE == 6)
+ #pragma comment(lib, "bls384.lib")
+ #endif
+ #endif
+#elif defined(__EMSCRIPTEN__) && !defined(BLS_DONT_EXPORT)
+ #define BLS_DLL_API __attribute__((used))
+#elif defined(__wasm__) && !defined(BLS_DONT_EXPORT)
+ #define BLS_DLL_API __attribute__((visibility("default")))
+#else
+ #define BLS_DLL_API
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ mclBnFr v;
+} blsId;
+
+typedef struct {
+ mclBnFr v;
+} blsSecretKey;
+
+typedef struct {
+#ifdef BLS_SWAP_G
+ mclBnG1 v;
+#else
+ mclBnG2 v;
+#endif
+} blsPublicKey;
+
+typedef struct {
+#ifdef BLS_SWAP_G
+ mclBnG2 v;
+#else
+ mclBnG1 v;
+#endif
+} blsSignature;
+
+/*
+ initialize this library
+ call this once before using the other functions
+ @param curve [in] enum value defined in mcl/bn.h
+ @param compiledTimeVar [in] specify MCLBN_COMPILED_TIME_VAR,
+ which macro is used to make sure that the values
+ are the same when the library is built and used
+ @return 0 if success
+ @note blsInit() is thread safe and serialized if it is called simultaneously
+ but don't call it while using other functions.
+*/
+BLS_DLL_API int blsInit(int curve, int compiledTimeVar);
+
+BLS_DLL_API void blsIdSetInt(blsId *id, int x);
+
+// sec = buf & (1 << bitLen(r)) - 1
+// if (sec >= r) sec &= (1 << (bitLen(r) - 1)) - 1
+// always return 0
+BLS_DLL_API int blsSecretKeySetLittleEndian(blsSecretKey *sec, const void *buf, mclSize bufSize);
+// return 0 if success (bufSize <= 64) else -1
+// set (buf mod r) to sec
+BLS_DLL_API int blsSecretKeySetLittleEndianMod(blsSecretKey *sec, const void *buf, mclSize bufSize);
+
+BLS_DLL_API void blsGetPublicKey(blsPublicKey *pub, const blsSecretKey *sec);
+
+// calculate the has of m and sign the hash
+BLS_DLL_API void blsSign(blsSignature *sig, const blsSecretKey *sec, const void *m, mclSize size);
+
+// return 1 if valid
+BLS_DLL_API int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const void *m, mclSize size);
+
+// return written byte size if success else 0
+BLS_DLL_API mclSize blsIdSerialize(void *buf, mclSize maxBufSize, const blsId *id);
+BLS_DLL_API mclSize blsSecretKeySerialize(void *buf, mclSize maxBufSize, const blsSecretKey *sec);
+BLS_DLL_API mclSize blsPublicKeySerialize(void *buf, mclSize maxBufSize, const blsPublicKey *pub);
+BLS_DLL_API mclSize blsSignatureSerialize(void *buf, mclSize maxBufSize, const blsSignature *sig);
+
+// return read byte size if success else 0
+BLS_DLL_API mclSize blsIdDeserialize(blsId *id, const void *buf, mclSize bufSize);
+BLS_DLL_API mclSize blsSecretKeyDeserialize(blsSecretKey *sec, const void *buf, mclSize bufSize);
+BLS_DLL_API mclSize blsPublicKeyDeserialize(blsPublicKey *pub, const void *buf, mclSize bufSize);
+BLS_DLL_API mclSize blsSignatureDeserialize(blsSignature *sig, const void *buf, mclSize bufSize);
+
+// return 1 if same else 0
+BLS_DLL_API int blsIdIsEqual(const blsId *lhs, const blsId *rhs);
+BLS_DLL_API int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs);
+BLS_DLL_API int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs);
+BLS_DLL_API int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs);
+
+// return 0 if success
+BLS_DLL_API int blsSecretKeyShare(blsSecretKey *sec, const blsSecretKey* msk, mclSize k, const blsId *id);
+BLS_DLL_API int blsPublicKeyShare(blsPublicKey *pub, const blsPublicKey *mpk, mclSize k, const blsId *id);
+
+BLS_DLL_API int blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, mclSize n);
+BLS_DLL_API int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, mclSize n);
+BLS_DLL_API int blsSignatureRecover(blsSignature *sig, const blsSignature *sigVec, const blsId *idVec, mclSize n);
+
+// add
+BLS_DLL_API void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs);
+BLS_DLL_API void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs);
+BLS_DLL_API void blsSignatureAdd(blsSignature *sig, const blsSignature *rhs);
+
+/*
+ verify whether a point of an elliptic curve has order r
+ This api affetcs setStr(), deserialize() for G2 on BN or G1/G2 on BLS12
+ @param doVerify [in] does not verify if zero(default 1)
+ Signature = G1, PublicKey = G2
+*/
+BLS_DLL_API void blsSignatureVerifyOrder(int doVerify);
+BLS_DLL_API void blsPublicKeyVerifyOrder(int doVerify);
+// deserialize under VerifyOrder(true) = deserialize under VerifyOrder(false) + IsValidOrder
+BLS_DLL_API int blsSignatureIsValidOrder(const blsSignature *sig);
+BLS_DLL_API int blsPublicKeyIsValidOrder(const blsPublicKey *pub);
+
+#ifndef BLS_MINIMUM_API
+
+/*
+ verify X == sY by checking e(X, sQ) = e(Y, Q)
+ @param X [in]
+ @param Y [in]
+ @param pub [in] pub = sQ
+ @return 1 if e(X, pub) = e(Y, Q) else 0
+*/
+BLS_DLL_API int blsVerifyPairing(const blsSignature *X, const blsSignature *Y, const blsPublicKey *pub);
+
+/*
+ sign the hash
+ use the low (bitSize of r) - 1 bit of h
+ return 0 if success else -1
+ NOTE : return false if h is zero or c1 or -c1 value for BN254. see hashTest() in test/bls_test.hpp
+*/
+BLS_DLL_API int blsSignHash(blsSignature *sig, const blsSecretKey *sec, const void *h, mclSize size);
+// return 1 if valid
+BLS_DLL_API int blsVerifyHash(const blsSignature *sig, const blsPublicKey *pub, const void *h, mclSize size);
+
+/*
+ verify aggSig with pubVec[0, n) and hVec[0, n)
+ e(aggSig, Q) = prod_i e(hVec[i], pubVec[i])
+ return 1 if valid
+ @note do not check duplication of hVec
+*/
+BLS_DLL_API int blsVerifyAggregatedHashes(const blsSignature *aggSig, const blsPublicKey *pubVec, const void *hVec, size_t sizeofHash, mclSize n);
+
+// sub
+BLS_DLL_API void blsSecretKeySub(blsSecretKey *sec, const blsSecretKey *rhs);
+BLS_DLL_API void blsPublicKeySub(blsPublicKey *pub, const blsPublicKey *rhs);
+BLS_DLL_API void blsSignatureSub(blsSignature *sig, const blsSignature *rhs);
+
+// not thread safe version (old blsInit)
+BLS_DLL_API int blsInitNotThreadSafe(int curve, int compiledTimeVar);
+
+BLS_DLL_API mclSize blsGetOpUnitSize(void);
+// return strlen(buf) if success else 0
+BLS_DLL_API int blsGetCurveOrder(char *buf, mclSize maxBufSize);
+BLS_DLL_API int blsGetFieldOrder(char *buf, mclSize maxBufSize);
+
+// return bytes for serialized G1(=Fp)
+BLS_DLL_API int blsGetG1ByteSize(void);
+
+// return bytes for serialized Fr
+BLS_DLL_API int blsGetFrByteSize(void);
+
+#ifdef BLS_SWAP_G
+// get a generator of G1
+BLS_DLL_API void blsGetGeneratorOfG1(blsPublicKey *pub);
+#else
+// get a generator of G2
+BLS_DLL_API void blsGetGeneratorOfG2(blsPublicKey *pub);
+#endif
+
+// return 0 if success
+BLS_DLL_API int blsIdSetDecStr(blsId *id, const char *buf, mclSize bufSize);
+BLS_DLL_API int blsIdSetHexStr(blsId *id, const char *buf, mclSize bufSize);
+
+/*
+ return strlen(buf) if success else 0
+ buf is '\0' terminated
+*/
+BLS_DLL_API mclSize blsIdGetDecStr(char *buf, mclSize maxBufSize, const blsId *id);
+BLS_DLL_API mclSize blsIdGetHexStr(char *buf, mclSize maxBufSize, const blsId *id);
+
+// hash buf and set
+BLS_DLL_API int blsHashToSecretKey(blsSecretKey *sec, const void *buf, mclSize bufSize);
+#ifndef MCL_DONT_USE_CSPRNG
+/*
+ set secretKey if system has /dev/urandom or CryptGenRandom
+ return 0 if success else -1
+*/
+BLS_DLL_API int blsSecretKeySetByCSPRNG(blsSecretKey *sec);
+/*
+ set user-defined random function for setByCSPRNG
+ @param self [in] user-defined pointer
+ @param readFunc [in] user-defined function,
+ which writes random bufSize bytes to buf and returns bufSize if success else returns 0
+ @note if self == 0 and readFunc == 0 then set default random function
+ @note not threadsafe
+*/
+BLS_DLL_API void blsSetRandFunc(void *self, unsigned int (*readFunc)(void *self, void *buf, unsigned int bufSize));
+#endif
+
+BLS_DLL_API void blsGetPop(blsSignature *sig, const blsSecretKey *sec);
+
+BLS_DLL_API int blsVerifyPop(const blsSignature *sig, const blsPublicKey *pub);
+//////////////////////////////////////////////////////////////////////////
+// the following apis will be removed
+
+// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
+BLS_DLL_API int blsIdSetLittleEndian(blsId *id, const void *buf, mclSize bufSize);
+/*
+ return written byte size if success else 0
+*/
+BLS_DLL_API mclSize blsIdGetLittleEndian(void *buf, mclSize maxBufSize, const blsId *id);
+
+// return 0 if success
+BLS_DLL_API int blsSecretKeySetDecStr(blsSecretKey *sec, const char *buf, mclSize bufSize);
+BLS_DLL_API int blsSecretKeySetHexStr(blsSecretKey *sec, const char *buf, mclSize bufSize);
+/*
+ return written byte size if success else 0
+*/
+BLS_DLL_API mclSize blsSecretKeyGetLittleEndian(void *buf, mclSize maxBufSize, const blsSecretKey *sec);
+/*
+ return strlen(buf) if success else 0
+ buf is '\0' terminated
+*/
+BLS_DLL_API mclSize blsSecretKeyGetDecStr(char *buf, mclSize maxBufSize, const blsSecretKey *sec);
+BLS_DLL_API mclSize blsSecretKeyGetHexStr(char *buf, mclSize maxBufSize, const blsSecretKey *sec);
+BLS_DLL_API int blsPublicKeySetHexStr(blsPublicKey *pub, const char *buf, mclSize bufSize);
+BLS_DLL_API mclSize blsPublicKeyGetHexStr(char *buf, mclSize maxBufSize, const blsPublicKey *pub);
+BLS_DLL_API int blsSignatureSetHexStr(blsSignature *sig, const char *buf, mclSize bufSize);
+BLS_DLL_API mclSize blsSignatureGetHexStr(char *buf, mclSize maxBufSize, const blsSignature *sig);
+
+/*
+ Diffie Hellman key exchange
+ out = sec * pub
+*/
+BLS_DLL_API void blsDHKeyExchange(blsPublicKey *out, const blsSecretKey *sec, const blsPublicKey *pub);
+
+#endif // BLS_MINIMUM_API
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/vendor/github.com/tangerine-network/bls/include/bls/bls.hpp b/vendor/github.com/tangerine-network/bls/include/bls/bls.hpp
new file mode 100644
index 000000000..741334555
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/include/bls/bls.hpp
@@ -0,0 +1,534 @@
+#pragma once
+/**
+ @file
+ @brief BLS threshold signature on BN curve
+ @author MITSUNARI Shigeo(@herumi)
+ @license modified new BSD license
+ http://opensource.org/licenses/BSD-3-Clause
+*/
+#include <bls/bls.h>
+#include <stdexcept>
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <stdint.h>
+
+namespace bls {
+
+// same value with IoMode of mcl/op.hpp
+enum {
+ IoBin = 2, // binary number
+ IoDec = 10, // decimal number
+ IoHex = 16, // hexadecimal number
+ IoPrefix = 128, // append '0b'(bin) or '0x'(hex)
+ IoSerialize = 512,
+ IoFixedByteSeq = IoSerialize // fixed byte representation
+};
+
+/*
+ BLS signature
+ e : G2 x G1 -> Fp12
+ Q in G2 ; fixed global parameter
+ H : {str} -> G1
+ s : secret key
+ sQ ; public key
+ s H(m) ; signature of m
+ verify ; e(sQ, H(m)) = e(Q, s H(m))
+*/
+
+/*
+ initialize this library
+ call this once before using the other method
+ @param curve [in] type of curve
+ @param compiledTimevar [in] use the default value
+ @note init() is not thread safe
+*/
+inline void init(int curve = mclBn_CurveFp254BNb, int compiledTimeVar = MCLBN_COMPILED_TIME_VAR)
+{
+ if (blsInit(curve, compiledTimeVar) != 0) throw std::invalid_argument("blsInit");
+}
+inline size_t getOpUnitSize() { return blsGetOpUnitSize(); }
+
+inline void getCurveOrder(std::string& str)
+{
+ str.resize(1024);
+ mclSize n = blsGetCurveOrder(&str[0], str.size());
+ if (n == 0) throw std::runtime_error("blsGetCurveOrder");
+ str.resize(n);
+}
+inline void getFieldOrder(std::string& str)
+{
+ str.resize(1024);
+ mclSize n = blsGetFieldOrder(&str[0], str.size());
+ if (n == 0) throw std::runtime_error("blsGetFieldOrder");
+ str.resize(n);
+}
+inline int getG1ByteSize() { return blsGetG1ByteSize(); }
+inline int getFrByteSize() { return blsGetFrByteSize(); }
+
+namespace local {
+/*
+ the value of secretKey and Id must be less than
+ r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d
+ sizeof(uint64_t) * keySize byte
+*/
+const size_t keySize = MCLBN_FP_UNIT_SIZE;
+}
+
+class SecretKey;
+class PublicKey;
+class Signature;
+class Id;
+
+typedef std::vector<SecretKey> SecretKeyVec;
+typedef std::vector<PublicKey> PublicKeyVec;
+typedef std::vector<Signature> SignatureVec;
+typedef std::vector<Id> IdVec;
+
+class Id {
+ blsId self_;
+ friend class PublicKey;
+ friend class SecretKey;
+ friend class Signature;
+public:
+ Id(unsigned int id = 0)
+ {
+ blsIdSetInt(&self_, id);
+ }
+ bool operator==(const Id& rhs) const
+ {
+ return blsIdIsEqual(&self_, &rhs.self_) == 1;
+ }
+ bool operator!=(const Id& rhs) const { return !(*this == rhs); }
+ friend std::ostream& operator<<(std::ostream& os, const Id& id)
+ {
+ std::string str;
+ id.getStr(str, 16|IoPrefix);
+ return os << str;
+ }
+ friend std::istream& operator>>(std::istream& is, Id& id)
+ {
+ std::string str;
+ is >> str;
+ id.setStr(str, 16);
+ return is;
+ }
+ void getStr(std::string& str, int ioMode = 0) const
+ {
+ str.resize(1024);
+ size_t n = mclBnFr_getStr(&str[0], str.size(), &self_.v, ioMode);
+ if (n == 0) throw std::runtime_error("mclBnFr_getStr");
+ str.resize(n);
+ }
+ void setStr(const std::string& str, int ioMode = 0)
+ {
+ int ret = mclBnFr_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+ if (ret != 0) throw std::runtime_error("mclBnFr_setStr");
+ }
+ bool isZero() const
+ {
+ return mclBnFr_isZero(&self_.v) == 1;
+ }
+ /*
+ set p[0, .., keySize)
+ @note the value must be less than r
+ */
+ void set(const uint64_t *p)
+ {
+ setLittleEndian(p, local::keySize * sizeof(uint64_t));
+ }
+ // bufSize is truncted/zero extended to keySize
+ void setLittleEndian(const void *buf, size_t bufSize)
+ {
+ mclBnFr_setLittleEndian(&self_.v, buf, bufSize);
+ }
+};
+
+/*
+ s ; secret key
+*/
+class SecretKey {
+ blsSecretKey self_;
+public:
+ bool operator==(const SecretKey& rhs) const
+ {
+ return blsSecretKeyIsEqual(&self_, &rhs.self_) == 1;
+ }
+ bool operator!=(const SecretKey& rhs) const { return !(*this == rhs); }
+ friend std::ostream& operator<<(std::ostream& os, const SecretKey& sec)
+ {
+ std::string str;
+ sec.getStr(str, 16|IoPrefix);
+ return os << str;
+ }
+ friend std::istream& operator>>(std::istream& is, SecretKey& sec)
+ {
+ std::string str;
+ is >> str;
+ sec.setStr(str);
+ return is;
+ }
+ void getStr(std::string& str, int ioMode = 0) const
+ {
+ str.resize(1024);
+ size_t n = mclBnFr_getStr(&str[0], str.size(), &self_.v, ioMode);
+ if (n == 0) throw std::runtime_error("mclBnFr_getStr");
+ str.resize(n);
+ }
+ void setStr(const std::string& str, int ioMode = 0)
+ {
+ int ret = mclBnFr_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+ if (ret != 0) throw std::runtime_error("mclBnFr_setStr");
+ }
+ /*
+ initialize secretKey with random number
+ */
+ void init()
+ {
+ int ret = blsSecretKeySetByCSPRNG(&self_);
+ if (ret != 0) throw std::runtime_error("blsSecretKeySetByCSPRNG");
+ }
+ /*
+ set secretKey with p[0, .., keySize) and set id = 0
+ @note the value must be less than r
+ */
+ void set(const uint64_t *p)
+ {
+ setLittleEndian(p, local::keySize * sizeof(uint64_t));
+ }
+ // bufSize is truncted/zero extended to keySize
+ void setLittleEndian(const void *buf, size_t bufSize)
+ {
+ mclBnFr_setLittleEndian(&self_.v, buf, bufSize);
+ }
+ // set hash of buf
+ void setHashOf(const void *buf, size_t bufSize)
+ {
+ int ret = mclBnFr_setHashOf(&self_.v, buf, bufSize);
+ if (ret != 0) throw std::runtime_error("mclBnFr_setHashOf");
+ }
+ void getPublicKey(PublicKey& pub) const;
+ // constant time sign
+ // sign hash(m)
+ void sign(Signature& sig, const void *m, size_t size) const;
+ void sign(Signature& sig, const std::string& m) const
+ {
+ sign(sig, m.c_str(), m.size());
+ }
+ // sign hashed value
+ void signHash(Signature& sig, const void *h, size_t size) const;
+ void signHash(Signature& sig, const std::string& h) const
+ {
+ signHash(sig, h.c_str(), h.size());
+ }
+ /*
+ make Pop(Proof of Possesion)
+ pop = prv.sign(pub)
+ */
+ void getPop(Signature& pop) const;
+ /*
+ make [s_0, ..., s_{k-1}] to prepare k-out-of-n secret sharing
+ */
+ void getMasterSecretKey(SecretKeyVec& msk, size_t k) const
+ {
+ if (k <= 1) throw std::invalid_argument("getMasterSecretKey");
+ msk.resize(k);
+ msk[0] = *this;
+ for (size_t i = 1; i < k; i++) {
+ msk[i].init();
+ }
+ }
+ /*
+ set a secret key for id > 0 from msk
+ */
+ void set(const SecretKeyVec& msk, const Id& id)
+ {
+ set(msk.data(), msk.size(), id);
+ }
+ /*
+ recover secretKey from k secVec
+ */
+ void recover(const SecretKeyVec& secVec, const IdVec& idVec)
+ {
+ if (secVec.size() != idVec.size()) throw std::invalid_argument("SecretKey:recover");
+ recover(secVec.data(), idVec.data(), idVec.size());
+ }
+ /*
+ add secret key
+ */
+ void add(const SecretKey& rhs);
+
+ // the following methods are for C api
+ /*
+ the size of msk must be k
+ */
+ void set(const SecretKey *msk, size_t k, const Id& id)
+ {
+ int ret = blsSecretKeyShare(&self_, &msk->self_, k, &id.self_);
+ if (ret != 0) throw std::runtime_error("blsSecretKeyShare");
+ }
+ void recover(const SecretKey *secVec, const Id *idVec, size_t n)
+ {
+ int ret = blsSecretKeyRecover(&self_, &secVec->self_, &idVec->self_, n);
+ if (ret != 0) throw std::runtime_error("blsSecretKeyRecover:same id");
+ }
+};
+
+/*
+ sQ ; public key
+*/
+class PublicKey {
+ blsPublicKey self_;
+ friend class SecretKey;
+ friend class Signature;
+public:
+ bool operator==(const PublicKey& rhs) const
+ {
+ return blsPublicKeyIsEqual(&self_, &rhs.self_) == 1;
+ }
+ bool operator!=(const PublicKey& rhs) const { return !(*this == rhs); }
+ friend std::ostream& operator<<(std::ostream& os, const PublicKey& pub)
+ {
+ std::string str;
+ pub.getStr(str, 16|IoPrefix);
+ return os << str;
+ }
+ friend std::istream& operator>>(std::istream& is, PublicKey& pub)
+ {
+ std::string str;
+ is >> str;
+ if (str != "0") {
+ // 1 <x.a> <x.b> <y.a> <y.b>
+ std::string t;
+#ifdef BLS_SWAP_G
+ const int elemNum = 2;
+#else
+ const int elemNum = 4;
+#endif
+ for (int i = 0; i < elemNum; i++) {
+ is >> t;
+ str += ' ';
+ str += t;
+ }
+ }
+ pub.setStr(str, 16);
+ return is;
+ }
+ void getStr(std::string& str, int ioMode = 0) const
+ {
+ str.resize(1024);
+#ifdef BLS_SWAP_G
+ size_t n = mclBnG1_getStr(&str[0], str.size(), &self_.v, ioMode);
+#else
+ size_t n = mclBnG2_getStr(&str[0], str.size(), &self_.v, ioMode);
+#endif
+ if (n == 0) throw std::runtime_error("PublicKey:getStr");
+ str.resize(n);
+ }
+ void setStr(const std::string& str, int ioMode = 0)
+ {
+#ifdef BLS_SWAP_G
+ int ret = mclBnG1_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+#else
+ int ret = mclBnG2_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+#endif
+ if (ret != 0) throw std::runtime_error("PublicKey:setStr");
+ }
+ /*
+ set public for id from mpk
+ */
+ void set(const PublicKeyVec& mpk, const Id& id)
+ {
+ set(mpk.data(), mpk.size(), id);
+ }
+ /*
+ recover publicKey from k pubVec
+ */
+ void recover(const PublicKeyVec& pubVec, const IdVec& idVec)
+ {
+ if (pubVec.size() != idVec.size()) throw std::invalid_argument("PublicKey:recover");
+ recover(pubVec.data(), idVec.data(), idVec.size());
+ }
+ /*
+ add public key
+ */
+ void add(const PublicKey& rhs)
+ {
+ blsPublicKeyAdd(&self_, &rhs.self_);
+ }
+
+ // the following methods are for C api
+ void set(const PublicKey *mpk, size_t k, const Id& id)
+ {
+ int ret = blsPublicKeyShare(&self_, &mpk->self_, k, &id.self_);
+ if (ret != 0) throw std::runtime_error("blsPublicKeyShare");
+ }
+ void recover(const PublicKey *pubVec, const Id *idVec, size_t n)
+ {
+ int ret = blsPublicKeyRecover(&self_, &pubVec->self_, &idVec->self_, n);
+ if (ret != 0) throw std::runtime_error("blsPublicKeyRecover");
+ }
+};
+
+/*
+ s H(m) ; signature
+*/
+class Signature {
+ blsSignature self_;
+ friend class SecretKey;
+public:
+ bool operator==(const Signature& rhs) const
+ {
+ return blsSignatureIsEqual(&self_, &rhs.self_) == 1;
+ }
+ bool operator!=(const Signature& rhs) const { return !(*this == rhs); }
+ friend std::ostream& operator<<(std::ostream& os, const Signature& sig)
+ {
+ std::string str;
+ sig.getStr(str, 16|IoPrefix);
+ return os << str;
+ }
+ friend std::istream& operator>>(std::istream& is, Signature& sig)
+ {
+ std::string str;
+ is >> str;
+ if (str != "0") {
+ // 1 <x> <y>
+ std::string t;
+#ifdef BLS_SWAP_G
+ const int elemNum = 4;
+#else
+ const int elemNum = 2;
+#endif
+ for (int i = 0; i < elemNum; i++) {
+ is >> t;
+ str += ' ';
+ str += t;
+ }
+ }
+ sig.setStr(str, 16);
+ return is;
+ }
+ void getStr(std::string& str, int ioMode = 0) const
+ {
+ str.resize(1024);
+#ifdef BLS_SWAP_G
+ size_t n = mclBnG2_getStr(&str[0], str.size(), &self_.v, ioMode);
+#else
+ size_t n = mclBnG1_getStr(&str[0], str.size(), &self_.v, ioMode);
+#endif
+ if (n == 0) throw std::runtime_error("Signature:tgetStr");
+ str.resize(n);
+ }
+ void setStr(const std::string& str, int ioMode = 0)
+ {
+#ifdef BLS_SWAP_G
+ int ret = mclBnG2_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+#else
+ int ret = mclBnG1_setStr(&self_.v, str.c_str(), str.size(), ioMode);
+#endif
+ if (ret != 0) throw std::runtime_error("Signature:setStr");
+ }
+ bool verify(const PublicKey& pub, const void *m, size_t size) const
+ {
+ return blsVerify(&self_, &pub.self_, m, size) == 1;
+ }
+ bool verify(const PublicKey& pub, const std::string& m) const
+ {
+ return verify(pub, m.c_str(), m.size());
+ }
+ bool verifyHash(const PublicKey& pub, const void *h, size_t size) const
+ {
+ return blsVerifyHash(&self_, &pub.self_, h, size) == 1;
+ }
+ bool verifyHash(const PublicKey& pub, const std::string& h) const
+ {
+ return verifyHash(pub, h.c_str(), h.size());
+ }
+ bool verifyAggregatedHashes(const PublicKey *pubVec, const void *hVec, size_t sizeofHash, size_t n) const
+ {
+ return blsVerifyAggregatedHashes(&self_, &pubVec[0].self_, hVec, sizeofHash, n) == 1;
+ }
+ /*
+ verify self(pop) with pub
+ */
+ bool verify(const PublicKey& pub) const
+ {
+ std::string str;
+ pub.getStr(str);
+ return verify(pub, str);
+ }
+ /*
+ recover sig from k sigVec
+ */
+ void recover(const SignatureVec& sigVec, const IdVec& idVec)
+ {
+ if (sigVec.size() != idVec.size()) throw std::invalid_argument("Signature:recover");
+ recover(sigVec.data(), idVec.data(), idVec.size());
+ }
+ /*
+ add signature
+ */
+ void add(const Signature& rhs)
+ {
+ blsSignatureAdd(&self_, &rhs.self_);
+ }
+
+ // the following methods are for C api
+ void recover(const Signature* sigVec, const Id *idVec, size_t n)
+ {
+ int ret = blsSignatureRecover(&self_, &sigVec->self_, &idVec->self_, n);
+ if (ret != 0) throw std::runtime_error("blsSignatureRecover:same id");
+ }
+};
+
+/*
+ make master public key [s_0 Q, ..., s_{k-1} Q] from msk
+*/
+inline void getMasterPublicKey(PublicKeyVec& mpk, const SecretKeyVec& msk)
+{
+ const size_t n = msk.size();
+ mpk.resize(n);
+ for (size_t i = 0; i < n; i++) {
+ msk[i].getPublicKey(mpk[i]);
+ }
+}
+
+inline void SecretKey::getPublicKey(PublicKey& pub) const
+{
+ blsGetPublicKey(&pub.self_, &self_);
+}
+inline void SecretKey::sign(Signature& sig, const void *m, size_t size) const
+{
+ blsSign(&sig.self_, &self_, m, size);
+}
+inline void SecretKey::signHash(Signature& sig, const void *h, size_t size) const
+{
+ if (blsSignHash(&sig.self_, &self_, h, size) != 0) throw std::runtime_error("bad h");
+}
+inline void SecretKey::getPop(Signature& pop) const
+{
+ PublicKey pub;
+ getPublicKey(pub);
+ std::string m;
+ pub.getStr(m);
+ sign(pop, m);
+}
+
+/*
+ make pop from msk and mpk
+*/
+inline void getPopVec(SignatureVec& popVec, const SecretKeyVec& msk)
+{
+ const size_t n = msk.size();
+ popVec.resize(n);
+ for (size_t i = 0; i < n; i++) {
+ msk[i].getPop(popVec[i]);
+ }
+}
+
+inline Signature operator+(const Signature& a, const Signature& b) { Signature r(a); r.add(b); return r; }
+inline PublicKey operator+(const PublicKey& a, const PublicKey& b) { PublicKey r(a); r.add(b); return r; }
+inline SecretKey operator+(const SecretKey& a, const SecretKey& b) { SecretKey r(a); r.add(b); return r; }
+
+} //bls
diff --git a/vendor/github.com/tangerine-network/bls/lib/.emptydir b/vendor/github.com/tangerine-network/bls/lib/.emptydir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/lib/.emptydir
diff --git a/vendor/github.com/tangerine-network/bls/mk.bat b/vendor/github.com/tangerine-network/bls/mk.bat
new file mode 100644
index 000000000..9bf8dd9e6
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/mk.bat
@@ -0,0 +1,20 @@
+@echo off
+if "%1"=="-s" (
+ echo use static lib
+ set CFLAGS=%CFLAGS% /DMCLBN_NO_AUTOLINK /DBLS_DONT_EXPORT
+) else if "%1"=="-d" (
+ echo use dynamic lib
+) else (
+ echo "mk (-s|-d) <source file>"
+ goto exit
+)
+set CFLAGS=%CFLAGS% -I../mcl/include
+set SRC=%2
+set EXE=%SRC:.cpp=.exe%
+set EXE=%EXE:.c=.exe%
+set EXE=%EXE:test\=bin\%
+set EXE=%EXE:sample\=bin\%
+echo cl %CFLAGS% %2 /Fe:%EXE% /link %LDFLAGS%
+cl %CFLAGS% %2 /Fe:%EXE% /link %LDFLAGS%
+
+:exit
diff --git a/vendor/github.com/tangerine-network/bls/mkdll.bat b/vendor/github.com/tangerine-network/bls/mkdll.bat
new file mode 100755
index 000000000..17e934f92
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/mkdll.bat
@@ -0,0 +1,8 @@
+rem @echo off
+
+call setvar.bat dll
+echo make bls384.dll
+cl /c %CFLAGS% /DBLS_NO_AUTOLINK /Foobj/bls_c.obj src/bls_c.cpp
+cl /c %CFLAGS% /DBLS_NO_AUTOLINK /Foobj/fp.obj ../mcl/src/fp.cpp
+lib /OUT:lib/bls384.lib /nodefaultlib obj/bls_c.obj obj/fp.obj %LDFLAGS%
+cl /LD /MT obj/bls_c.obj obj/fp.obj %CFLAGS% /link /out:bin/bls384.dll %LDFLAGS%
diff --git a/vendor/github.com/tangerine-network/bls/mklib.bat b/vendor/github.com/tangerine-network/bls/mklib.bat
new file mode 100644
index 000000000..4a60d7196
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/mklib.bat
@@ -0,0 +1,26 @@
+@echo off
+call ..\mcl\setvar.bat
+if "%1"=="dll" (
+ echo make dynamic library DLL
+) else (
+ echo make static library LIB
+)
+call setvar.bat
+
+if "%1"=="dll" (
+ cl /c %CFLAGS% /Foobj/bls_c256.obj src/bls_c256.cpp /DBLS_NO_AUTOLINK
+ cl /c %CFLAGS% /Foobj/bls_c384.obj src/bls_c384.cpp /DBLS_NO_AUTOLINK
+ cl /c %CFLAGS% /Foobj/bls_c384_256.obj src/bls_c384_256.cpp /DBLS_NO_AUTOLINK
+ cl /c %CFLAGS% /Foobj/fp.obj ../mcl/src/fp.cpp
+ link /nologo /DLL /OUT:bin\bls256.dll obj\bls_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\bls256.lib
+ link /nologo /DLL /OUT:bin\bls384.dll obj\bls_c384.obj obj\fp.obj %LDFLAGS% /implib:lib\bls384.lib
+ link /nologo /DLL /OUT:bin\bls384_256.dll obj\bls_c384_256.obj obj\fp.obj %LDFLAGS% /implib:lib\bls384_256.lib
+) else (
+ cl /c %CFLAGS% /Foobj/bls_c256.obj src/bls_c256.cpp
+ cl /c %CFLAGS% /Foobj/bls_c384.obj src/bls_c384.cpp
+ cl /c %CFLAGS% /Foobj/bls_c384_256.obj src/bls_c384_256.cpp
+ cl /c %CFLAGS% /Foobj/fp.obj ../mcl/src/fp.cpp /DMCLBN_DONT_EXPORT
+ lib /OUT:lib/bls256.lib /nodefaultlib obj/bls_c256.obj obj/fp.obj %LDFLAGS%
+ lib /OUT:lib/bls384.lib /nodefaultlib obj/bls_c384.obj obj/fp.obj %LDFLAGS%
+ lib /OUT:lib/bls384_256.lib /nodefaultlib obj/bls_c384_256.obj obj/fp.obj %LDFLAGS%
+)
diff --git a/vendor/github.com/tangerine-network/bls/obj/.emptydir b/vendor/github.com/tangerine-network/bls/obj/.emptydir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/obj/.emptydir
diff --git a/vendor/github.com/tangerine-network/bls/readme.md b/vendor/github.com/tangerine-network/bls/readme.md
new file mode 100644
index 000000000..b1efb3f36
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/readme.md
@@ -0,0 +1,187 @@
+[![Build Status](https://travis-ci.com/dexon-foundation/bls.png?branch=dev)](https://travis-ci.com/dexon-foundation/bls)
+
+# BLS threshold signature
+
+An implementation of BLS threshold signature
+
+# Installation Requirements
+
+Create a working directory (e.g., work) and clone the following repositories.
+```
+mkdir work
+cd work
+git clone git://github.com/dexon-foundation/mcl.git
+git clone git://github.com/dexon-foundation/bls.git
+git clone git://github.com/herumi/cybozulib_ext ; for only Windows
+```
+
+# News
+* (Break backward compatibility) The suffix `_dy` of library name is removed and bls\*.a requires libmcl.so set LD_LIBRARY_PATH to the directory.
+* -tags option for Go bindings
+ * -tags bn256
+ * -tags bn384\_256
+ * -tags bn384 ; default mode
+* Support swap of G1 and G2
+ * `make BLS_SWAP_G=1` then G1 is assigned to PublicKey and G2 is assigned to Signature.
+ * golang binding does not support this feature yet.
+* Build option without GMP
+ * `make MCL_USE_GMP=0`
+* Build option without OpenSSL
+ * `make MCL_USE_OPENSSL=0`
+* Build option to specify `mcl` directory
+ * `make MCL_DIR=<mcl directory>`
+
+* (old) libbls.a for C++ interface(bls/bls.hpp) is removed
+Link `lib/libbls256.a` or `lib/libbls384.a` to use `bls/bls.hpp` according to MCLBN_FP_UNIT_SIZE = 4 or 6.
+
+# Build and test for Linux
+To make and test, run
+```
+cd bls
+make test
+```
+To make sample programs, run
+```
+make sample_test
+```
+
+# Build and test for Windows
+1) make static library and use it
+```
+mklib
+mk -s test\bls_c384_test.cpp
+bin\bls_c384_test.exe
+```
+
+2) make dynamic library and use it
+```
+mklib dll
+mk -d test\bls_c384_test.cpp
+bin\bls_c384_test.exe
+```
+
+# Library
+* libbls256.a/libbls256.so ; for BN254 compiled with MCLBN_FP_UNIT_SIZE=4
+* libbls384.a/libbls384.so ; for BN254/BN381_1/BLS12_381 compiled with MCLBN_FP_UNIT_SIZE=6
+* libbls384_256.a/libbls384_256.so ; for BN254/BLS12_381 compiled with MCLBN_FP_UNIT_SIZE=6 and MCLBN_FR_UNIT_SIZE=4
+
+See `mcl/include/curve_type.h` for curve parameter
+
+# API
+
+## Basic API
+
+BLS signature
+```
+e : G2 x G1 -> Fp12 ; optimal ate pairing over BN curve
+Q in G2 ; fixed global parameter
+H : {str} -> G1
+s in Fr: secret key
+sQ in G2; public key
+s H(m) in G1; signature of m
+verify ; e(sQ, H(m)) = e(Q, s H(m))
+```
+
+```
+void bls::init();
+```
+
+Initialize this library. Call this once to use the other api.
+
+```
+void SecretKey::init();
+```
+
+Initialize the instance of SecretKey. `s` is a random number.
+
+```
+void SecretKey::getPublicKey(PublicKey& pub) const;
+```
+
+Get public key `sQ` for the secret key `s`.
+
+```
+void SecretKey::sign(Sign& sign, const std::string& m) const;
+```
+
+Make sign `s H(m)` from message m.
+
+```
+bool Sign::verify(const PublicKey& pub, const std::string& m) const;
+```
+
+Verify sign with pub and m and return true if it is valid.
+
+```
+e(sQ, H(m)) == e(Q, s H(m))
+```
+
+### Secret Sharing API
+
+```
+void SecretKey::getMasterSecretKey(SecretKeyVec& msk, size_t k) const;
+```
+
+Prepare k-out-of-n secret sharing for the secret key.
+`msk[0]` is the original secret key `s` and `msk[i]` for i > 0 are random secret key.
+
+```
+void SecretKey::set(const SecretKeyVec& msk, const Id& id);
+```
+
+Make secret key f(id) from msk and id where f(x) = msk[0] + msk[1] x + ... + msk[k-1] x^{k-1}.
+
+You can make a public key `f(id)Q` from each secret key f(id) for id != 0 and sign a message.
+
+```
+void Sign::recover(const SignVec& signVec, const IdVec& idVec);
+```
+
+Collect k pair of sign `f(id) H(m)` and `id` for a message m and recover the original signature `s H(m)` for the secret key `s`.
+
+### PoP (Proof of Possesion)
+
+```
+void SecretKey::getPop(Sign& pop) const;
+```
+
+Sign pub and make a pop `s H(sQ)`
+
+```
+bool Sign::verify(const PublicKey& pub) const;
+```
+
+Verify a public key by pop.
+
+# Check the order of a point
+
+deserializer functions check whether a point has correct order and
+the cost is heavy for especially G2.
+If you do not want to check it, then call
+```
+void blsSignatureVerifyOrder(false);
+void blsPublicKeyVerifyOrder(false);
+```
+
+cf. subgroup attack
+
+# Go
+```
+make test_go
+```
+
+# WASM(WebAssembly)
+```
+mkdir ../bls-wasm
+make bls-wasm
+```
+see [BLS signature demo on browser](https://herumi.github.io/bls-wasm/bls-demo.html)
+
+# License
+
+modified new BSD License
+http://opensource.org/licenses/BSD-3-Clause
+
+# Author
+
+MITSUNARI Shigeo(herumi@nifty.com)
diff --git a/vendor/github.com/tangerine-network/bls/release.props b/vendor/github.com/tangerine-network/bls/release.props
new file mode 100644
index 000000000..886ce6890
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/release.props
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup />
+</Project> \ No newline at end of file
diff --git a/vendor/github.com/tangerine-network/bls/sample/bls_smpl.cpp b/vendor/github.com/tangerine-network/bls/sample/bls_smpl.cpp
new file mode 100644
index 000000000..e812cd500
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/sample/bls_smpl.cpp
@@ -0,0 +1,168 @@
+#define MCLBN_FP_UNIT_SIZE 4
+#include <bls/bls.hpp>
+#include <cybozu/option.hpp>
+#include <cybozu/itoa.hpp>
+#include <fstream>
+
+const std::string pubFile = "sample/publickey";
+const std::string secFile = "sample/secretkey";
+const std::string signFile = "sample/sign";
+
+std::string makeName(const std::string& name, const bls::Id& id)
+{
+ const std::string suf = ".txt";
+ if (id.isZero()) return name + suf;
+ std::ostringstream os;
+ os << name << '.' << id << suf;
+ return os.str();
+}
+
+template<class T>
+void save(const std::string& file, const T& t, const bls::Id& id = 0)
+{
+ const std::string name = makeName(file, id);
+ std::ofstream ofs(name.c_str(), std::ios::binary);
+ if (!(ofs << t)) {
+ throw cybozu::Exception("can't save") << name;
+ }
+}
+
+template<class T>
+void load(T& t, const std::string& file, const bls::Id& id = 0)
+{
+ const std::string name = makeName(file, id);
+ std::ifstream ifs(name.c_str(), std::ios::binary);
+ if (!(ifs >> t)) {
+ throw cybozu::Exception("can't load") << name;
+ }
+}
+
+int init()
+{
+ printf("make %s and %s files\n", secFile.c_str(), pubFile.c_str());
+ bls::SecretKey sec;
+ sec.init();
+ save(secFile, sec);
+ bls::PublicKey pub;
+ sec.getPublicKey(pub);
+ save(pubFile, pub);
+ return 0;
+}
+
+int sign(const std::string& m, int id)
+{
+ printf("sign message `%s` by id=%d\n", m.c_str(), id);
+ bls::SecretKey sec;
+ load(sec, secFile, id);
+ bls::Signature s;
+ sec.sign(s, m);
+ save(signFile, s, id);
+ return 0;
+}
+
+int verify(const std::string& m, int id)
+{
+ printf("verify message `%s` by id=%d\n", m.c_str(), id);
+ bls::PublicKey pub;
+ load(pub, pubFile, id);
+ bls::Signature s;
+ load(s, signFile, id);
+ if (s.verify(pub, m)) {
+ puts("verify ok");
+ return 0;
+ } else {
+ puts("verify err");
+ return 1;
+ }
+}
+
+int share(size_t n, size_t k)
+{
+ printf("%d-out-of-%d threshold sharing\n", (int)k, (int)n);
+ bls::SecretKey sec;
+ load(sec, secFile);
+ bls::SecretKeyVec msk;
+ sec.getMasterSecretKey(msk, k);
+ bls::SecretKeyVec secVec(n);
+ bls::IdVec ids(n);
+ for (size_t i = 0; i < n; i++) {
+ int id = i + 1;
+ ids[i] = id;
+ secVec[i].set(msk, id);
+ }
+ for (size_t i = 0; i < n; i++) {
+ save(secFile, secVec[i], ids[i]);
+ bls::PublicKey pub;
+ secVec[i].getPublicKey(pub);
+ save(pubFile, pub, ids[i]);
+ }
+ return 0;
+}
+
+int recover(const bls::IdVec& ids)
+{
+ printf("recover from");
+ for (size_t i = 0; i < ids.size(); i++) {
+ std::cout << ' ' << ids[i];
+ }
+ printf("\n");
+ bls::SignatureVec sigVec(ids.size());
+ for (size_t i = 0; i < sigVec.size(); i++) {
+ load(sigVec[i], signFile, ids[i]);
+ }
+ bls::Signature s;
+ s.recover(sigVec, ids);
+ save(signFile, s);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+ try
+{
+ bls::init(); // use BN254
+
+ std::string mode;
+ std::string m;
+ size_t n;
+ size_t k;
+ int id;
+ bls::IdVec ids;
+
+ cybozu::Option opt;
+ opt.appendParam(&mode, "init|sign|verify|share|recover");
+ opt.appendOpt(&n, 10, "n", ": k-out-of-n threshold");
+ opt.appendOpt(&k, 3, "k", ": k-out-of-n threshold");
+ opt.appendOpt(&m, "", "m", ": message to be signed");
+ opt.appendOpt(&id, 0, "id", ": id of secretKey");
+ opt.appendVec(&ids, "ids", ": select k id in [0, n). this option should be last");
+ opt.appendHelp("h");
+ if (!opt.parse(argc, argv)) {
+ goto ERR_EXIT;
+ }
+
+ if (mode == "init") {
+ return init();
+ } else if (mode == "sign") {
+ if (m.empty()) goto ERR_EXIT;
+ return sign(m, id);
+ } else if (mode == "verify") {
+ if (m.empty()) goto ERR_EXIT;
+ return verify(m, id);
+ } else if (mode == "share") {
+ return share(n, k);
+ } else if (mode == "recover") {
+ if (ids.empty()) {
+ fprintf(stderr, "use -ids option. ex. share -ids 1 3 5\n");
+ goto ERR_EXIT;
+ }
+ return recover(ids);
+ } else {
+ fprintf(stderr, "bad mode %s\n", mode.c_str());
+ }
+ERR_EXIT:
+ opt.usage();
+ return 1;
+} catch (std::exception& e) {
+ fprintf(stderr, "ERR %s\n", e.what());
+ return 1;
+}
diff --git a/vendor/github.com/tangerine-network/bls/setvar.bat b/vendor/github.com/tangerine-network/bls/setvar.bat
new file mode 100755
index 000000000..0ff286ab8
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/setvar.bat
@@ -0,0 +1,6 @@
+@echo off
+call ..\mcl\setvar.bat
+set CFLAGS=%CFLAGS% /I ..\mcl\include /I ./
+set LDFLAGS=%LDFLAGS% /LIBPATH:..\mcl\lib
+echo CFLAGS=%CFLAGS%
+echo LDFLAGS=%LDFLAGS%
diff --git a/vendor/github.com/tangerine-network/bls/src/bls_c256.cpp b/vendor/github.com/tangerine-network/bls/src/bls_c256.cpp
new file mode 100644
index 000000000..a9f3412ea
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/bls_c256.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 4
+#include "bls_c_impl.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/src/bls_c384.cpp b/vendor/github.com/tangerine-network/bls/src/bls_c384.cpp
new file mode 100644
index 000000000..d28f8547b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/bls_c384.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#include "bls_c_impl.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/src/bls_c384_256.cpp b/vendor/github.com/tangerine-network/bls/src/bls_c384_256.cpp
new file mode 100644
index 000000000..3dcb3e7d7
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/bls_c384_256.cpp
@@ -0,0 +1,4 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#define MCLBN_FR_UNIT_SIZE 4
+#include "bls_c_impl.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/src/bls_c_impl.hpp b/vendor/github.com/tangerine-network/bls/src/bls_c_impl.hpp
new file mode 100644
index 000000000..b38c1ad06
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/bls_c_impl.hpp
@@ -0,0 +1,614 @@
+#define MCLBN_DONT_EXPORT
+#define BLS_DLL_EXPORT
+
+#include <bls/bls.h>
+
+#if 1
+#include "mcl/impl/bn_c_impl.hpp"
+#else
+#if MCLBN_FP_UNIT_SIZE == 4 && MCLBN_FR_UNIT_SIZE == 4
+#include <mcl/bn256.hpp>
+#elif MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
+#include <mcl/bn384.hpp>
+#elif MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4
+#include <mcl/bls12_381.hpp>
+#elif MCLBN_FP_UNIT_SIZE == 8 && MCLBN_FR_UNIT_SIZE == 8
+#include <mcl/bn512.hpp>
+#else
+ #error "not supported size"
+#endif
+#include <mcl/lagrange.hpp>
+using namespace mcl::bn;
+inline Fr *cast(mclBnFr *p) { return reinterpret_cast<Fr*>(p); }
+inline const Fr *cast(const mclBnFr *p) { return reinterpret_cast<const Fr*>(p); }
+
+inline G1 *cast(mclBnG1 *p) { return reinterpret_cast<G1*>(p); }
+inline const G1 *cast(const mclBnG1 *p) { return reinterpret_cast<const G1*>(p); }
+
+inline G2 *cast(mclBnG2 *p) { return reinterpret_cast<G2*>(p); }
+inline const G2 *cast(const mclBnG2 *p) { return reinterpret_cast<const G2*>(p); }
+
+inline Fp12 *cast(mclBnGT *p) { return reinterpret_cast<Fp12*>(p); }
+inline const Fp12 *cast(const mclBnGT *p) { return reinterpret_cast<const Fp12*>(p); }
+
+inline Fp6 *cast(uint64_t *p) { return reinterpret_cast<Fp6*>(p); }
+inline const Fp6 *cast(const uint64_t *p) { return reinterpret_cast<const Fp6*>(p); }
+#endif
+
+void Gmul(G1& z, const G1& x, const Fr& y) { G1::mul(z, x, y); }
+void Gmul(G2& z, const G2& x, const Fr& y) { G2::mul(z, x, y); }
+void GmulCT(G1& z, const G1& x, const Fr& y) { G1::mulCT(z, x, y); }
+void GmulCT(G2& z, const G2& x, const Fr& y) { G2::mulCT(z, x, y); }
+
+/*
+ BLS signature
+ e : G1 x G2 -> GT
+ Q in G2 ; fixed global parameter
+ H : {str} -> G1
+ s : secret key
+ sQ ; public key
+ s H(m) ; signature of m
+ verify ; e(sQ, H(m)) = e(Q, s H(m))
+
+ swap G1 and G2 if BLS_SWAP_G is defined
+ @note the current implementation does not support precomputed miller loop
+*/
+
+#ifdef BLS_SWAP_G
+static G1 g_P;
+inline const G1& getBasePoint() { return g_P; }
+#else
+static G2 g_Q;
+const size_t maxQcoeffN = 128;
+static mcl::FixedArray<Fp6, maxQcoeffN> g_Qcoeff; // precomputed Q
+inline const G2& getBasePoint() { return g_Q; }
+inline const mcl::FixedArray<Fp6, maxQcoeffN>& getQcoeff() { return g_Qcoeff; }
+#endif
+
+int blsInitNotThreadSafe(int curve, int compiledTimeVar)
+{
+ if (compiledTimeVar != MCLBN_COMPILED_TIME_VAR) {
+ return -(compiledTimeVar | (MCLBN_COMPILED_TIME_VAR * 100));
+ }
+ const mcl::CurveParam& cp = mcl::getCurveParam(curve);
+ bool b;
+ initPairing(&b, cp);
+ if (!b) return -1;
+
+#ifdef BLS_SWAP_G
+ mapToG1(&b, g_P, 1);
+#else
+
+ if (curve == MCL_BN254) {
+ const char *Qx_BN254 = "11ccb44e77ac2c5dc32a6009594dbe331ec85a61290d6bbac8cc7ebb2dceb128 f204a14bbdac4a05be9a25176de827f2e60085668becdd4fc5fa914c9ee0d9a";
+ const char *Qy_BN254 = "7c13d8487903ee3c1c5ea327a3a52b6cc74796b1760d5ba20ed802624ed19c8 8f9642bbaacb73d8c89492528f58932f2de9ac3e80c7b0e41f1a84f1c40182";
+ g_Q.x.setStr(&b, Qx_BN254, 16);
+ g_Q.y.setStr(&b, Qy_BN254, 16);
+ g_Q.z = 1;
+ } else {
+ mapToG2(&b, g_Q, 1);
+ }
+ if (!b) return -100;
+ if (curve == MCL_BN254) {
+ #include "./qcoeff-bn254.hpp"
+ g_Qcoeff.resize(BN::param.precomputedQcoeffSize);
+ assert(g_Qcoeff.size() == CYBOZU_NUM_OF_ARRAY(QcoeffTblBN254));
+ for (size_t i = 0; i < g_Qcoeff.size(); i++) {
+ Fp6& x6 = g_Qcoeff[i];
+ for (size_t j = 0; j < 6; j++) {
+ Fp& x = x6.getFp0()[j];
+ mcl::fp::Unit *p = const_cast<mcl::fp::Unit*>(x.getUnit());
+ for (size_t k = 0; k < 4; k++) {
+ p[k] = QcoeffTblBN254[i][j][k];
+ }
+ }
+ }
+ } else {
+ precomputeG2(&b, g_Qcoeff, getBasePoint());
+ }
+#endif
+ if (!b) return -101;
+ return 0;
+}
+
+#ifdef __EMSCRIPTEN__
+extern "C" BLS_DLL_API void *blsMalloc(size_t n)
+{
+ return malloc(n);
+}
+extern "C" BLS_DLL_API void blsFree(void *p)
+{
+ free(p);
+}
+#endif
+
+#if !defined(__EMSCRIPTEN__) && !defined(__wasm__)
+ #if defined(CYBOZU_CPP_VERSION) && CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
+ #include <mutex>
+ #define USE_STD_MUTEX
+ #else
+ #include <cybozu/mutex.hpp>
+ #define USE_CYBOZU_MUTEX
+ #endif
+#endif
+
+int blsInit(int curve, int compiledTimeVar)
+{
+ int ret = 0;
+#ifdef USE_STD_MUTEX
+ static std::mutex m;
+ std::lock_guard<std::mutex> lock(m);
+#elif defined(USE_CYBOZU_MUTEX)
+ static cybozu::Mutex m;
+ cybozu::AutoLock lock(m);
+#endif
+ static int g_curve = -1;
+ if (g_curve != curve) {
+ ret = blsInitNotThreadSafe(curve, compiledTimeVar);
+ g_curve = curve;
+ }
+ return ret;
+}
+
+static inline const mclBnG1 *cast(const G1* x) { return (const mclBnG1*)x; }
+static inline const mclBnG2 *cast(const G2* x) { return (const mclBnG2*)x; }
+
+void blsIdSetInt(blsId *id, int x)
+{
+ *cast(&id->v) = x;
+}
+
+int blsSecretKeySetLittleEndian(blsSecretKey *sec, const void *buf, mclSize bufSize)
+{
+ cast(&sec->v)->setArrayMask((const char *)buf, bufSize);
+ return 0;
+}
+int blsSecretKeySetLittleEndianMod(blsSecretKey *sec, const void *buf, mclSize bufSize)
+{
+ bool b;
+ cast(&sec->v)->setArray(&b, (const char *)buf, bufSize, mcl::fp::Mod);
+ return b ? 0 : -1;
+}
+
+void blsGetPublicKey(blsPublicKey *pub, const blsSecretKey *sec)
+{
+ Gmul(*cast(&pub->v), getBasePoint(), *cast(&sec->v));
+}
+
+void blsSign(blsSignature *sig, const blsSecretKey *sec, const void *m, mclSize size)
+{
+#ifdef BLS_SWAP_G
+ G2 Hm;
+ hashAndMapToG2(Hm, m, size);
+#else
+ G1 Hm;
+ hashAndMapToG1(Hm, m, size);
+#endif
+ GmulCT(*cast(&sig->v), Hm, *cast(&sec->v));
+}
+
+#ifdef BLS_SWAP_G
+/*
+ e(P, sHm) == e(sP, Hm)
+ <=> finalExp(ML(P, sHm) * e(-sP, Hm)) == 1
+*/
+bool isEqualTwoPairings(const G2& sHm, const G1& sP, const G2& Hm)
+{
+ GT e1, e2;
+ millerLoop(e1, getBasePoint(), sHm);
+ G1 neg_sP;
+ G1::neg(neg_sP, sP);
+ millerLoop(e2, neg_sP, Hm);
+ e1 *= e2;
+ finalExp(e1, e1);
+ return e1.isOne();
+}
+#else
+/*
+ e(P1, Q1) == e(P2, Q2)
+ <=> finalExp(ML(P1, Q1)) == finalExp(ML(P2, Q2))
+ <=> finalExp(ML(P1, Q1) / ML(P2, Q2)) == 1
+ <=> finalExp(ML(P1, Q1) * ML(-P2, Q2)) == 1
+ Q1 is precomputed
+*/
+bool isEqualTwoPairings(const G1& P1, const Fp6* Q1coeff, const G1& P2, const G2& Q2)
+{
+ GT e;
+ precomputedMillerLoop2mixed(e, P2, Q2, -P1, Q1coeff);
+ finalExp(e, e);
+ return e.isOne();
+}
+#endif
+
+int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const void *m, mclSize size)
+{
+#ifdef BLS_SWAP_G
+ G2 Hm;
+ hashAndMapToG2(Hm, m, size);
+ return isEqualTwoPairings(*cast(&sig->v), *cast(&pub->v), Hm);
+#else
+ G1 Hm;
+ hashAndMapToG1(Hm, m, size);
+ /*
+ e(sHm, Q) = e(Hm, sQ)
+ e(sig, Q) = e(Hm, pub)
+ */
+ return isEqualTwoPairings(*cast(&sig->v), getQcoeff().data(), Hm, *cast(&pub->v));
+#endif
+}
+
+mclSize blsIdSerialize(void *buf, mclSize maxBufSize, const blsId *id)
+{
+ return cast(&id->v)->serialize(buf, maxBufSize);
+}
+
+mclSize blsSecretKeySerialize(void *buf, mclSize maxBufSize, const blsSecretKey *sec)
+{
+ return cast(&sec->v)->serialize(buf, maxBufSize);
+}
+
+mclSize blsPublicKeySerialize(void *buf, mclSize maxBufSize, const blsPublicKey *pub)
+{
+ return cast(&pub->v)->serialize(buf, maxBufSize);
+}
+
+mclSize blsSignatureSerialize(void *buf, mclSize maxBufSize, const blsSignature *sig)
+{
+ return cast(&sig->v)->serialize(buf, maxBufSize);
+}
+
+mclSize blsIdDeserialize(blsId *id, const void *buf, mclSize bufSize)
+{
+ return cast(&id->v)->deserialize(buf, bufSize);
+}
+
+mclSize blsSecretKeyDeserialize(blsSecretKey *sec, const void *buf, mclSize bufSize)
+{
+ return cast(&sec->v)->deserialize(buf, bufSize);
+}
+
+mclSize blsPublicKeyDeserialize(blsPublicKey *pub, const void *buf, mclSize bufSize)
+{
+ return cast(&pub->v)->deserialize(buf, bufSize);
+}
+
+mclSize blsSignatureDeserialize(blsSignature *sig, const void *buf, mclSize bufSize)
+{
+ return cast(&sig->v)->deserialize(buf, bufSize);
+}
+
+int blsIdIsEqual(const blsId *lhs, const blsId *rhs)
+{
+ return *cast(&lhs->v) == *cast(&rhs->v);
+}
+
+int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs)
+{
+ return *cast(&lhs->v) == *cast(&rhs->v);
+}
+
+int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs)
+{
+ return *cast(&lhs->v) == *cast(&rhs->v);
+}
+
+int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs)
+{
+ return *cast(&lhs->v) == *cast(&rhs->v);
+}
+
+int blsSecretKeyShare(blsSecretKey *sec, const blsSecretKey* msk, mclSize k, const blsId *id)
+{
+ bool b;
+ mcl::evaluatePolynomial(&b, *cast(&sec->v), cast(&msk->v), k, *cast(&id->v));
+ return b ? 0 : -1;
+}
+
+int blsPublicKeyShare(blsPublicKey *pub, const blsPublicKey *mpk, mclSize k, const blsId *id)
+{
+ bool b;
+ mcl::evaluatePolynomial(&b, *cast(&pub->v), cast(&mpk->v), k, *cast(&id->v));
+ return b ? 0 : -1;
+}
+
+int blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, mclSize n)
+{
+ bool b;
+ mcl::LagrangeInterpolation(&b, *cast(&sec->v), cast(&idVec->v), cast(&secVec->v), n);
+ return b ? 0 : -1;
+}
+
+int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, mclSize n)
+{
+ bool b;
+ mcl::LagrangeInterpolation(&b, *cast(&pub->v), cast(&idVec->v), cast(&pubVec->v), n);
+ return b ? 0 : -1;
+}
+
+int blsSignatureRecover(blsSignature *sig, const blsSignature *sigVec, const blsId *idVec, mclSize n)
+{
+ bool b;
+ mcl::LagrangeInterpolation(&b, *cast(&sig->v), cast(&idVec->v), cast(&sigVec->v), n);
+ return b ? 0 : -1;
+}
+
+void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs)
+{
+ *cast(&sec->v) += *cast(&rhs->v);
+}
+
+void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs)
+{
+ *cast(&pub->v) += *cast(&rhs->v);
+}
+
+void blsSignatureAdd(blsSignature *sig, const blsSignature *rhs)
+{
+ *cast(&sig->v) += *cast(&rhs->v);
+}
+
+void blsSignatureVerifyOrder(int doVerify)
+{
+#ifdef BLS_SWAP_G
+ verifyOrderG2(doVerify != 0);
+#else
+ verifyOrderG1(doVerify != 0);
+#endif
+}
+void blsPublicKeyVerifyOrder(int doVerify)
+{
+#ifdef BLS_SWAP_G
+ verifyOrderG1(doVerify != 0);
+#else
+ verifyOrderG2(doVerify != 0);
+#endif
+}
+int blsSignatureIsValidOrder(const blsSignature *sig)
+{
+ return cast(&sig->v)->isValidOrder();
+}
+int blsPublicKeyIsValidOrder(const blsPublicKey *pub)
+{
+ return cast(&pub->v)->isValidOrder();
+}
+
+#ifndef BLS_MINIMUM_API
+template<class G>
+inline bool toG(G& Hm, const void *h, mclSize size)
+{
+ Fp t;
+ t.setArrayMask((const char *)h, size);
+ bool b;
+#ifdef BLS_SWAP_G
+ BN::mapToG2(&b, Hm, Fp2(t, 0));
+#else
+ BN::mapToG1(&b, Hm, t);
+#endif
+ return b;
+}
+
+int blsVerifyAggregatedHashes(const blsSignature *aggSig, const blsPublicKey *pubVec, const void *hVec, size_t sizeofHash, mclSize n)
+{
+ if (n == 0) return 0;
+ GT e1, e2;
+ const char *ph = (const char*)hVec;
+#ifdef BLS_SWAP_G
+ millerLoop(e1, getBasePoint(), -*cast(&aggSig->v));
+ G2 h;
+ if (!toG(h, &ph[0], sizeofHash)) return 0;
+ BN::millerLoop(e2, *cast(&pubVec[0].v), h);
+ e1 *= e2;
+ for (size_t i = 1; i < n; i++) {
+ if (!toG(h, &ph[i * sizeofHash], sizeofHash)) return 0;
+ millerLoop(e2, *cast(&pubVec[i].v), h);
+ e1 *= e2;
+ }
+#else
+ /*
+ e(aggSig, Q) = prod_i e(hVec[i], pubVec[i])
+ <=> finalExp(ML(-aggSig, Q) * prod_i ML(hVec[i], pubVec[i])) == 1
+ */
+ BN::precomputedMillerLoop(e1, -*cast(&aggSig->v), g_Qcoeff.data());
+ G1 h;
+ if (!toG(h, &ph[0], sizeofHash)) return 0;
+ BN::millerLoop(e2, h, *cast(&pubVec[0].v));
+ e1 *= e2;
+ for (size_t i = 1; i < n; i++) {
+ if (!toG(h, &ph[i * sizeofHash], sizeofHash)) return 0;
+ BN::millerLoop(e2, h, *cast(&pubVec[i].v));
+ e1 *= e2;
+ }
+#endif
+ BN::finalExp(e1, e1);
+ return e1.isOne();
+}
+
+int blsSignHash(blsSignature *sig, const blsSecretKey *sec, const void *h, mclSize size)
+{
+#ifdef BLS_SWAP_G
+ G2 Hm;
+#else
+ G1 Hm;
+#endif
+ if (!toG(Hm, h, size)) return -1;
+ GmulCT(*cast(&sig->v), Hm, *cast(&sec->v));
+ return 0;
+}
+
+int blsVerifyPairing(const blsSignature *X, const blsSignature *Y, const blsPublicKey *pub)
+{
+#ifdef BLS_SWAP_G
+ return isEqualTwoPairings(*cast(&X->v), *cast(&pub->v), *cast(&Y->v));
+#else
+ return isEqualTwoPairings(*cast(&X->v), getQcoeff().data(), *cast(&Y->v), *cast(&pub->v));
+#endif
+}
+
+int blsVerifyHash(const blsSignature *sig, const blsPublicKey *pub, const void *h, mclSize size)
+{
+ blsSignature Hm;
+ if (!toG(*cast(&Hm.v), h, size)) return 0;
+ return blsVerifyPairing(sig, &Hm, pub);
+}
+
+void blsSecretKeySub(blsSecretKey *sec, const blsSecretKey *rhs)
+{
+ *cast(&sec->v) -= *cast(&rhs->v);
+}
+
+void blsPublicKeySub(blsPublicKey *pub, const blsPublicKey *rhs)
+{
+ *cast(&pub->v) -= *cast(&rhs->v);
+}
+
+void blsSignatureSub(blsSignature *sig, const blsSignature *rhs)
+{
+ *cast(&sig->v) -= *cast(&rhs->v);
+}
+
+mclSize blsGetOpUnitSize() // FpUint64Size
+{
+ return Fp::getUnitSize() * sizeof(mcl::fp::Unit) / sizeof(uint64_t);
+}
+
+int blsGetCurveOrder(char *buf, mclSize maxBufSize)
+{
+ return (int)Fr::getModulo(buf, maxBufSize);
+}
+
+int blsGetFieldOrder(char *buf, mclSize maxBufSize)
+{
+ return (int)Fp::getModulo(buf, maxBufSize);
+}
+
+int blsGetG1ByteSize()
+{
+ return (int)Fp::getByteSize();
+}
+
+int blsGetFrByteSize()
+{
+ return (int)Fr::getByteSize();
+}
+
+#ifdef BLS_SWAP_G
+void blsGetGeneratorOfG1(blsPublicKey *pub)
+{
+ *cast(&pub->v) = getBasePoint();
+}
+#else
+void blsGetGeneratorOfG2(blsPublicKey *pub)
+{
+ *cast(&pub->v) = getBasePoint();
+}
+#endif
+
+int blsIdSetDecStr(blsId *id, const char *buf, mclSize bufSize)
+{
+ return cast(&id->v)->deserialize(buf, bufSize, 10) > 0 ? 0 : -1;
+}
+int blsIdSetHexStr(blsId *id, const char *buf, mclSize bufSize)
+{
+ return cast(&id->v)->deserialize(buf, bufSize, 16) > 0 ? 0 : -1;
+}
+
+int blsIdSetLittleEndian(blsId *id, const void *buf, mclSize bufSize)
+{
+ cast(&id->v)->setArrayMask((const char *)buf, bufSize);
+ return 0;
+}
+
+mclSize blsIdGetDecStr(char *buf, mclSize maxBufSize, const blsId *id)
+{
+ return cast(&id->v)->getStr(buf, maxBufSize, 10);
+}
+
+mclSize blsIdGetHexStr(char *buf, mclSize maxBufSize, const blsId *id)
+{
+ return cast(&id->v)->getStr(buf, maxBufSize, 16);
+}
+
+int blsHashToSecretKey(blsSecretKey *sec, const void *buf, mclSize bufSize)
+{
+ cast(&sec->v)->setHashOf(buf, bufSize);
+ return 0;
+}
+
+#ifndef MCL_DONT_USE_CSPRNG
+int blsSecretKeySetByCSPRNG(blsSecretKey *sec)
+{
+ bool b;
+ cast(&sec->v)->setByCSPRNG(&b);
+ return b ? 0 : -1;
+}
+void blsSetRandFunc(void *self, unsigned int (*readFunc)(void *self, void *buf, unsigned int bufSize))
+{
+ mcl::fp::RandGen::setRandFunc(self, readFunc);
+}
+#endif
+
+void blsGetPop(blsSignature *sig, const blsSecretKey *sec)
+{
+ blsPublicKey pub;
+ blsGetPublicKey(&pub, sec);
+ char buf[1024];
+ mclSize n = cast(&pub.v)->serialize(buf, sizeof(buf));
+ assert(n);
+ blsSign(sig, sec, buf, n);
+}
+
+int blsVerifyPop(const blsSignature *sig, const blsPublicKey *pub)
+{
+ char buf[1024];
+ mclSize n = cast(&pub->v)->serialize(buf, sizeof(buf));
+ if (n == 0) return 0;
+ return blsVerify(sig, pub, buf, n);
+}
+
+mclSize blsIdGetLittleEndian(void *buf, mclSize maxBufSize, const blsId *id)
+{
+ return cast(&id->v)->serialize(buf, maxBufSize);
+}
+int blsSecretKeySetDecStr(blsSecretKey *sec, const char *buf, mclSize bufSize)
+{
+ return cast(&sec->v)->deserialize(buf, bufSize, 10) > 0 ? 0 : -1;
+}
+int blsSecretKeySetHexStr(blsSecretKey *sec, const char *buf, mclSize bufSize)
+{
+ return cast(&sec->v)->deserialize(buf, bufSize, 16) > 0 ? 0 : -1;
+}
+mclSize blsSecretKeyGetLittleEndian(void *buf, mclSize maxBufSize, const blsSecretKey *sec)
+{
+ return cast(&sec->v)->serialize(buf, maxBufSize);
+}
+mclSize blsSecretKeyGetDecStr(char *buf, mclSize maxBufSize, const blsSecretKey *sec)
+{
+ return cast(&sec->v)->getStr(buf, maxBufSize, 10);
+}
+mclSize blsSecretKeyGetHexStr(char *buf, mclSize maxBufSize, const blsSecretKey *sec)
+{
+ return cast(&sec->v)->getStr(buf, maxBufSize, 16);
+}
+int blsPublicKeySetHexStr(blsPublicKey *pub, const char *buf, mclSize bufSize)
+{
+ return cast(&pub->v)->deserialize(buf, bufSize, 16) > 0 ? 0 : -1;
+}
+mclSize blsPublicKeyGetHexStr(char *buf, mclSize maxBufSize, const blsPublicKey *pub)
+{
+ return cast(&pub->v)->getStr(buf, maxBufSize, 16);
+}
+int blsSignatureSetHexStr(blsSignature *sig, const char *buf, mclSize bufSize)
+{
+ return cast(&sig->v)->deserialize(buf, bufSize, 16) > 0 ? 0 : -1;
+}
+mclSize blsSignatureGetHexStr(char *buf, mclSize maxBufSize, const blsSignature *sig)
+{
+ return cast(&sig->v)->getStr(buf, maxBufSize, 16);
+}
+void blsDHKeyExchange(blsPublicKey *out, const blsSecretKey *sec, const blsPublicKey *pub)
+{
+ GmulCT(*cast(&out->v), *cast(&pub->v), *cast(&sec->v));
+}
+
+#endif
+
diff --git a/vendor/github.com/tangerine-network/bls/src/proj/bls.vcxproj b/vendor/github.com/tangerine-network/bls/src/proj/bls.vcxproj
new file mode 100644
index 000000000..b78c97919
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/proj/bls.vcxproj
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{1DBB979A-C212-45CD-9563-446A96F87F71}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>ec_test</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(SolutionDir)common.props" />
+ <Import Project="$(SolutionDir)debug.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(SolutionDir)common.props" />
+ <Import Project="$(SolutionDir)release.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <TargetExt>.lib</TargetExt>
+ <OutDir>$(SolutionDir)lib\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <TargetExt>.lib</TargetExt>
+ <OutDir>$(SolutionDir)lib\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="$(SolutionDir)src\bls.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/vendor/github.com/tangerine-network/bls/src/qcoeff-bn254.hpp b/vendor/github.com/tangerine-network/bls/src/qcoeff-bn254.hpp
new file mode 100644
index 000000000..18d169568
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/src/qcoeff-bn254.hpp
@@ -0,0 +1,564 @@
+#if MCL_SIZEOF_UNIT == 8
+static const uint64_t QcoeffTblBN254[][6][4] = {
+ {
+ {0x8c5c1b842e501310ull,0x6a418cdaced77710ull,0xf5ad725dd0d9a5ffull,0x012d501f32362f48ull,},
+ {0xb8a8a8c11e51dc62ull,0xeaeb87e0f25a8611ull,0x9ba8738e4483d511ull,0x0664a4e36d64379eull,},
+ {0x4a5af38c0aa5930aull,0x189fef61a74c388dull,0x83cc3225c7748527ull,0x2107491582310dc6ull,},
+ {0x43aef621120a524aull,0x359d06a56e339486ull,0xdf5ab35e2222d9b1ull,0x20968bac939743acull,},
+ {0xe8e4c0bb65cd67b8ull,0x255a0859bc55ff2cull,0xf1c57d1da3c060c6ull,0x138d83468f42cc0eull,},
+ {0xdf985e5f768c149cull,0xa059c65c4b5da3ffull,0xed3d38d9f77bb968ull,0x02281f01255a850cull,},
+ },
+ {
+ {0xe3f53d8cfb4866a0ull,0xa0f9a16a21c159aaull,0x647fc210c7edf3a9ull,0x0db92f588c73caf9ull,},
+ {0x6e9349b777bc2cf1ull,0x4fd987eb22e2469cull,0x666644a8e61b0a0eull,0x02f5bf9aae96c0deull,},
+ {0xd5fd6288342479ebull,0x74022b671c6c8d8eull,0xda32d1b497cac7b2ull,0x0abecf35a19b5c7eull,},
+ {0x1500891565b5f9aaull,0x4b7ce141cd7f4361ull,0xadf3447c534846c1ull,0x078b36a30d45de5full,},
+ {0x37f172cff76e4b77ull,0x696d093b3ee37e4aull,0x2193797b7da56c6eull,0x1f5fc9efcbbb93e7ull,},
+ {0x4c7d799b765b8f44ull,0x7adfd285e906edd8ull,0x79d68eaaf88a0885ull,0x20707d672be892cbull,},
+ },
+ {
+ {0x84bbf3849c691e74ull,0xeeb90e1efc3e3436ull,0xd9d9bb6257bf19e4ull,0x1b37ef04ea7d6f85ull,},
+ {0xa6bdbbe0895ba12aull,0x58cade2ad0f1aa84ull,0xe0bb325678a2c748ull,0x23d1992e977c788cull,},
+ {0x44559f0b0f4bb2ccull,0xe61b479bc88980eeull,0x2a70aa9df3e28c92ull,0x18039bee97722b74ull,},
+ {0x9e5667da3db8e9e6ull,0x826ba07eb28c31f8ull,0x3f8b4eeb463d6923ull,0x1af85c2b10d3a2f0ull,},
+ {0x8783f372684ea930ull,0x1aa0d9e436f41ea7ull,0xc84a3fc56af9f624ull,0x0d02698756cd5a2cull,},
+ {0xe47407ede7b7c2afull,0x7d665c59e37ee7a7ull,0x542b91f12e0fa2a7ull,0x2084e73dc21f415eull,},
+ },
+ {
+ {0x2aebe318f3d167c6ull,0x5a2b2364b3abc614ull,0x31b2cdfd847e0053ull,0x04f0f63eed2a2f8cull,},
+ {0x0573d320ee14ecf4ull,0x4e0dc9d92e543ddeull,0x58a280570cac8d36ull,0x16226935e8e9f9bdull,},
+ {0x2d51a89174717a26ull,0x7341be7f883d0806ull,0xc9b4ee66364066ceull,0x018c79b95f127b49ull,},
+ {0xe5420d2f4210dbd7ull,0x179c22d607a5c801ull,0xe3aae016e739bcc8ull,0x20c554233ddd50caull,},
+ {0x6c5c4b29c77bb152ull,0xc30df398c85f0f2cull,0x5d5096a07ed6a257ull,0x0790d485c22a3639ull,},
+ {0x8aadc7bbf2cb348eull,0xc339d87c2118c2cfull,0x8f49e0eb46961ca9ull,0x24740f0ee2134c2cull,},
+ },
+ {
+ {0x3b80354a061dbf06ull,0x961e0dfd74b84147ull,0xeb4b27dbde455fc1ull,0x100da22e6baf58b5ull,},
+ {0xb156ffc78a60a8acull,0xc873bf776b8daaeeull,0x5a702f5446bf83fdull,0x1fce59e50222949bull,},
+ {0x32d7640c0f717812ull,0xc58d05abdc19ceedull,0x1e63c2a492849373ull,0x23443ce8fb2d6feaull,},
+ {0x870f2d1a2e39f52eull,0x7aa53cb06541429aull,0xee7b80b7031f23beull,0x0a8a095b3fdf2cf6ull,},
+ {0x4e489bd278487a58ull,0xa914d93e5ed31065ull,0x6720c32ae140db7aull,0x0c22020e6a97031full,},
+ {0x7535115a15420cceull,0x2cd019bac6256080ull,0x8234c3b61757e461ull,0x24d65e78c88298b2ull,},
+ },
+ {
+ {0x1f0bdc2cae53aa21ull,0x263506a6526641afull,0xacd41097fab7f62full,0x0b2c92453d474a86ull,},
+ {0x2d23a58a46d63e3aull,0xa65ff6f1f716fe37ull,0xb86dc831f970fb2dull,0x0bc3cf38a191e63aull,},
+ {0xeb0ca4fdeba41bbaull,0x969cf610e1a3a009ull,0x93c5d1bad6c7240bull,0x20ad29c9a9f1d6d6ull,},
+ {0x006a12a187464b7aull,0xe354d9be0ec65202ull,0x9dff5c227947f5b7ull,0x24e3dc2833ba4d2full,},
+ {0x9350693ebfdfb4c6ull,0x07d8abf27abb8fc3ull,0x58f5ab0b518e5113ull,0x125f2d7d40ed8650ull,},
+ {0xc9fd435af6e86f34ull,0x04dc07374f373455ull,0xd040d286d71db00dull,0x141a1253f3bc2a50ull,},
+ },
+ {
+ {0xbcfee5dad6ad33b7ull,0x8cd72df36c5b56daull,0xc2949399ad52da69ull,0x0f6ffe6d68a398d6ull,},
+ {0x777dc689b038aaf4ull,0xf7a8f41c7c04e9f1ull,0xcdab24ebcea39892ull,0x0178d69b1b935d81ull,},
+ {0x65a001a22be563c6ull,0xfc1b2634dc76eafeull,0xed4f6ea19949392full,0x0e4e9127957d60e7ull,},
+ {0x919a1c91a123e003ull,0x23f8ec239ef8a15dull,0x0470cb40e520d6f5ull,0x0be9b58098cd0f01ull,},
+ {0x735e236220cf1152ull,0x82e68710903f65b1ull,0x6c932338d29169ccull,0x0e204d6a8c7d5034ull,},
+ {0xac47692ec8245f1full,0x125db7c68d7e7a9bull,0x6ead9899d3150beaull,0x1957068d4a3da4b8ull,},
+ },
+ {
+ {0x45c168b2bce7b4daull,0x63afa3b276f9f910ull,0x60af02b6be9889a6ull,0x1adad7fa35385ae7ull,},
+ {0x8d35cd7e7df59aa6ull,0x13cf29589f4b84b1ull,0xec6ecff2e1540013ull,0x0ecbf75abda6eb1dull,},
+ {0xf6ce05fc3becfc23ull,0xe4ac8d257a7bf44eull,0x4c12510765eeaa43ull,0x06c870a377df50e4ull,},
+ {0x2f6871bdc1d62dd7ull,0x80591505c1279cb7ull,0x1322088b2719ecd2ull,0x222e71f8f5995a2bull,},
+ {0x2d1a1ab198363dfbull,0x35635c96cfa670ceull,0x7d5034dd7a26c656ull,0x003bf0608625abedull,},
+ {0x98ca35cf5ed8716cull,0x2265e1237bc6df23ull,0x403b67933e14f23bull,0x17bd2dadc39729fdull,},
+ },
+ {
+ {0x73eaf26576b3ee71ull,0x1e385de29d896044ull,0x25a0f40f08a59317ull,0x19849935bfbebeeaull,},
+ {0xc124cb642102cadcull,0x15bc408ad6ca7826ull,0x2d7fb7c9392b5314ull,0x191fe8471669f053ull,},
+ {0x4519ddbccb6a7c26ull,0xf93bd195baec8228ull,0xacd754a721948defull,0x12f17b60c7e426bdull,},
+ {0xcf447b92b04c15dbull,0xfcb7da793167f250ull,0xcbabb4ee570c4306ull,0x190ab94c6e5c81ceull,},
+ {0x66edbe6740930cfcull,0x00c8c644983a181full,0xfe9e80b984c44209ull,0x1dd6f530584a7ffaull,},
+ {0x14c61214aa1a9038ull,0xc34e5e23426cf8b6ull,0x89fca910ec46ae5full,0x04f1b9161a0f7c1dull,},
+ },
+ {
+ {0x60c3a79ac91ab4deull,0x541e051ca71a1a2bull,0x490abafd41a5d25cull,0x126275c8a46cf343ull,},
+ {0xe5da0fcfffccd2b6ull,0xe3820301b166bb43ull,0xc6599e01bed6085dull,0x226548dff57c5cfbull,},
+ {0x36428b1296882728ull,0xe08312e604299b9aull,0x5a15c889ce55478dull,0x172710198cd7c270ull,},
+ {0x2450f291477cc1ddull,0xcb0f85c9d92d1bc3ull,0x86325c11cfe0e296ull,0x13ff03a4bd5be082ull,},
+ {0x74298091e426bf55ull,0xbed700b48330ccdfull,0xb1ec45894f74fb11ull,0x1716d956bea958b0ull,},
+ {0x91b29e513e9a4114ull,0xcdb3b373910c02fdull,0x268e148f9431fa75ull,0x1288ec8fde3009bdull,},
+ },
+ {
+ {0x02ae4c95e0afb8caull,0x8e7aec631cf8f5dfull,0xdfd9373259eca3c3ull,0x1fed34fb88af7224ull,},
+ {0xc47e420205b5c88full,0x7207ef7451d1c567ull,0x53262358433f5294ull,0x193248ecf07ad085ull,},
+ {0x49de15f9bb694200ull,0xc35f531086b5c242ull,0x95a1903858cd5140ull,0x032a4992511b1f97ull,},
+ {0x42ee2c4def1faaa7ull,0xf6ca28bc9d99cd60ull,0x83c60d620a1e004cull,0x024ccf0ba1568759ull,},
+ {0x6122291bf42e7d82ull,0x0866090d368a8205ull,0x11f04812ad6ec708ull,0x14cdebecb4ec13edull,},
+ {0x535e8fd1ac15390dull,0xb37b579abb1773daull,0xbace0a295cd4b579ull,0x215e20d42270bcb0ull,},
+ },
+ {
+ {0x400bdbc644ac1d92ull,0x6d856667d971f595ull,0x03343816a1bd40f7ull,0x0361ad7534821a43ull,},
+ {0x824222acf8437091ull,0x79141c3205b1032full,0x6b4d331fc9974530ull,0x1bf965a7ba2bade5ull,},
+ {0x0bf66d1afdad6063ull,0xfe6571464fe71527ull,0x3ec25815cc90ab9bull,0x132ca2d9d51c3b56ull,},
+ {0x37e3ae17fb5ac815ull,0x2dfedb4efe3f37c0ull,0x4b086ea5032745a4ull,0x0f966cabdd479e9full,},
+ {0xb5266c229b7ebe0dull,0xc6717a5442929826ull,0xad22a19d8892adf1ull,0x172da87fcc14d4f9ull,},
+ {0xae0d9866d891bb59ull,0xc500c36e3fe7d354ull,0xc2b582f2929b23abull,0x11428eb730dd4e8full,},
+ },
+ {
+ {0x81538fef8e07dae0ull,0x3c05274665489b39ull,0x36e4401350ceb55bull,0x23822f2029f31339ull,},
+ {0x9a946e7c30090ad9ull,0x5bbc4c8c656ea3fdull,0x3cc2cecb7ec7227full,0x075a6fe87014899full,},
+ {0x504b2ff7fbb0366bull,0xdbf315791bc3d5e8ull,0x34b16de185c8c4faull,0x0c722a3dffe0761cull,},
+ {0xe1b2c1fc3b33c383ull,0xce84d3e5182665f5ull,0xbcedf2f72de4d795ull,0x1a84c62c0c4a6f6full,},
+ {0x85ebabd309ae9553ull,0x1330ec03b0ac91f7ull,0x8f42ba9c8c1ae123ull,0x24c230fae89db4b9ull,},
+ {0x63ba534e151566b6ull,0x7e44c5bd39e6334full,0x06921595325d11dfull,0x217f3a4e9d6413deull,},
+ },
+ {
+ {0x25ac71f16a82e592ull,0x47846dfdcc378ef2ull,0x75c53c75b38260a2ull,0x039b9da33bf9b997ull,},
+ {0x53d30cb619b09dfeull,0x566d6a55a184cd91ull,0xa589c53ae28a8e0full,0x13c05b500d5f285eull,},
+ {0xd22faf3af0a087b6ull,0xd5e538653ca52380ull,0x42c893b42092e080ull,0x18f7a1bdd3badfbbull,},
+ {0xdba4e6c94bb0a0b2ull,0x323d4769578ee4deull,0xbaedb0f8e01fdb15ull,0x21ca037715dcfe00ull,},
+ {0xe6ccc0bc06afac14ull,0xfb943c10916b581cull,0x2d5694a4c968aff2ull,0x054a1b209a812e31ull,},
+ {0x1983e59a45dcb02cull,0x71dcb184a30af740ull,0xb75b69bd5ae155acull,0x13c7fc9ace199224ull,},
+ },
+ {
+ {0xddbd6b95067516b5ull,0x29ca0360372d54e8ull,0x3e2955c1d6748678ull,0x1f8b276aafcd2c7dull,},
+ {0x893187796c272ab6ull,0xc843325fc53fa37eull,0xbe658fac833007a3ull,0x04bdf08356fbd83full,},
+ {0xa0863d3fd012aa1cull,0xb1b2c2c3c2fa879eull,0x4cd718b80433407dull,0x1e1ff82d0a23f609ull,},
+ {0x0c72fdbda5da70b5ull,0xfa2ad5a7dafb202bull,0xa63ce1e889feffefull,0x030b328f5fa93e0full,},
+ {0xc4a01585dc609f7eull,0xade61ef3353eda34ull,0xfa884e9a73d65e8eull,0x24750424a4543a02ull,},
+ {0x54f07e883bbe27b6ull,0xfb41ed1660623383ull,0xe112647feeae3cabull,0x055cf71a930304b0ull,},
+ },
+ {
+ {0xcc5f813b041ba372ull,0x1b892909c069bfd9ull,0xdfac1a47d46ba3dcull,0x1bc553fdedaa97e3ull,},
+ {0x623da812c8d71640ull,0x59b3b84486ab96c5ull,0xd77a7d970676d563ull,0x09473f20b0087846ull,},
+ {0x9214acc8a6ad6f76ull,0x53e9b1713dffaa0aull,0xe66631ab33f6477cull,0x16792dc3fd2138d9ull,},
+ {0x612c9ffc45facb86ull,0xd43cb433555b3da3ull,0xb0ca697731e8202dull,0x141ac2b6bfa546e5ull,},
+ {0x51b480946640c6a2ull,0xc71f677b6d96bb2bull,0x7e0377527663c0beull,0x036b2f551e8c7db8ull,},
+ {0x09610b7524482b53ull,0x65196312af7438ccull,0x7050f94a8a70305eull,0x06fde0d46e6c059eull,},
+ },
+ {
+ {0x707927b8fc061859ull,0xd9e38cc9ebbd94ddull,0x96eba99c855f975full,0x0c12d088d263d28aull,},
+ {0xfa236e22ee58216aull,0x470b1efa73ec6699ull,0x4c5457a04dbf7553ull,0x1a1dc4cbd3ccec1aull,},
+ {0x9a327665f6db6d31ull,0x6443a4f683536914ull,0x58eff845741ae1d6ull,0x0b784f2a8c259646ull,},
+ {0x08cfd913a263ce94ull,0xe58aab8c6b488744ull,0x335fa717116557daull,0x137bf0016a4e4c17ull,},
+ {0x0c14566b7ca1106full,0xb5fac75743cf44ddull,0xe87d1d95b95cba63ull,0x1d2823802dac3d01ull,},
+ {0x445099d6807bd76cull,0x41b66837529eb51bull,0x84267670e2264913ull,0x0ed84664bb37032eull,},
+ },
+ {
+ {0x938964e622d307e8ull,0x2edeb24656039ea6ull,0x642dd6f7e2144be3ull,0x1d31590cb07cb098ull,},
+ {0xe57bf1b8729263c1ull,0x48f9b371fd250d79ull,0x670ce0ee36513b90ull,0x1b908986cbfec7f1ull,},
+ {0x9fc8ffb876636effull,0xd57385d67c117698ull,0x4813753691eeba7full,0x0e36785e030209eaull,},
+ {0xeef1935cb4c5e8f1ull,0x1b8726a75ab06681ull,0xee973c5cd718bf31ull,0x026910b1fafe0208ull,},
+ {0x8c1826b08792fd9bull,0x00325e83cb419665ull,0x9cf44c5b81265badull,0x2462a8c0fc4f85f9ull,},
+ {0xa4068de0bcf85b4cull,0x5292433f89646bedull,0x05b4bdd364d3bc53ull,0x1e25be7fab47bf9aull,},
+ },
+ {
+ {0x51c27ca3424bdf72ull,0x167926750fe4d445ull,0x41985a737513c6e8ull,0x070056ab60d56287ull,},
+ {0x0a23d1344dfd91a0ull,0x6c518fef27a24e64ull,0x059a8c49360f8730ull,0x0f1d38b2c12772f2ull,},
+ {0xaa2a1e60b126566eull,0x1ed2add1bb218007ull,0x71385f0a8fabe78eull,0x024c0880d7c0fd5aull,},
+ {0xeef5704923a38ff1ull,0x34506a9872581fa9ull,0x78152bc691cbac5dull,0x0c41086d97a7fccaull,},
+ {0xb0c0d854ad72b6b6ull,0xb38455c3e3e5f457ull,0xfe665f1f4ddafb6dull,0x10373cbf9ca2add9ull,},
+ {0x8a306e7799aa2605ull,0x5dbca515ad2f9733ull,0x9b8b80da928edeb0ull,0x0052a2d2f8f7b1e2ull,},
+ },
+ {
+ {0x13e3e3df198f8864ull,0xc80f05cd02b931f3ull,0x8826debe7162b2f6ull,0x1d319ece62ae45e7ull,},
+ {0x313e17d4fa80fd67ull,0x82c5f606bfe97eabull,0x66f092bfa6b46100ull,0x16fde5bd28d86353ull,},
+ {0xcd4e7dfcd19cfb45ull,0x026d1e42ed44630bull,0x8d6b54119bc07918ull,0x1eff361145a4818bull,},
+ {0xc80d511a9a448566ull,0x9df3e33a28a32065ull,0x5a5860db779cc4aaull,0x1c226a0a4bf8c193ull,},
+ {0xfe0fa440138c1ebcull,0xc32c16bd93c71daaull,0x5e053ef1a9d73a8eull,0x2105d2d85afe7c65ull,},
+ {0x553c6840e4d14fdfull,0x600506d781612ff5ull,0x3ab288079ba2da8full,0x19b8f14b3e9cefeaull,},
+ },
+ {
+ {0x101f9567b577f4ccull,0x9d7dfbbb95010b1eull,0x1801c3f5ef323a26ull,0x08066f8c302be6e0ull,},
+ {0x301f867187aa8cc4ull,0xdcb504ccd5deb64bull,0x7a19b8838cf066e1ull,0x1ce06a9c35aa0809ull,},
+ {0x010a732bda3f076eull,0xf36ad54eeb0df727ull,0xe7e3ba3699eb12eeull,0x1d65654037809723ull,},
+ {0xb8ff82aa0c8f9e89ull,0x39fd76e872772dd1ull,0xd0a9a0cf7b300237ull,0x21cdd8098a877d70ull,},
+ {0xfff1cbe2921532d7ull,0xe919f4cbb2b62082ull,0x43858e6488e4d9f3ull,0x227d32cd853e2a11ull,},
+ {0xdd7807401672de18ull,0x7e3167a195002069ull,0xef20051461812a1full,0x1ee6ee09899caca3ull,},
+ },
+ {
+ {0x18dcb2c8d68bcf3dull,0x55c30335c441d056ull,0xddcda87759df1c4cull,0x0bd72b9d00117407ull,},
+ {0x53759bf204dc6ee2ull,0x5a491198ccc07fb6ull,0x21023e765d4b082bull,0x052467582f570a64ull,},
+ {0xc71f8479e69bc9efull,0x1a8b07f3a7f9f4e4ull,0x4898f9336938503bull,0x210b416bb55f686dull,},
+ {0x2ea76a804a514216ull,0xaed1c043402cba72ull,0x8e96b191c8508968ull,0x0a6845487a544d0cull,},
+ {0x20f8a88abe36a0fbull,0xf7be80390c4df565ull,0xb4d6ae73ab0ac7b4ull,0x03dee2bd150d75caull,},
+ {0x31f41f54a9d5ba23ull,0x32d8a838645e8303ull,0x1ce68866725d4d63ull,0x16eff9d7d55f24a6ull,},
+ },
+ {
+ {0xc9ef98de3048fe85ull,0x91d247303ba2cc5dull,0xfeebf32febfe0c50ull,0x12193bd2dfc7cbaaull,},
+ {0x05545cc46d6e2f10ull,0x0c1885bd6a173fe0ull,0x19192206ce77ae4dull,0x21bc567dedda3bcaull,},
+ {0x0289985f4f8a3e0eull,0x46a6f360ff57d0beull,0x8ecf6d8914a57a28ull,0x16fad252e99a0f5dull,},
+ {0xa1ce7650862f87aaull,0x624601ad20a0a754ull,0x181fa95e1dceca7aull,0x04c7063bf6031512ull,},
+ {0x47221f77cb9dead6ull,0x0b0a1f41bf04b7daull,0x1285ec2ea904f669ull,0x05d815fd67d084b4ull,},
+ {0x2f4621c7c48ac6bfull,0x6c94a7fc7433ddc8ull,0xbfbc34ad00dc77bdull,0x0d420c22daa0e425ull,},
+ },
+ {
+ {0xa125bb06b8f5ae5cull,0xf130e54b42e247baull,0xa7d5d0e59b914ac6ull,0x071f28cba94510baull,},
+ {0x23781cfd40419519ull,0x2ea1f31e32e9865dull,0xb81d3422cdc1a049ull,0x09b4ecf31bed5dadull,},
+ {0x7cad0528d1f2ffbdull,0x4aac3a0629f7f4f7ull,0xffa90428bf6d62ffull,0x1e313094fa295c2eull,},
+ {0xac9d8af47d98869cull,0x8ecebc8bdf6c41e8ull,0x859d29cb97f9f264ull,0x0c9223c674634d76ull,},
+ {0x5adcabb24bf08460ull,0xbc91aaa43338b671ull,0x7abcd2f2031ec66dull,0x19b3dbaaf6fb5a1bull,},
+ {0x00b0c3d6c69380bbull,0x044a0a413e3aaea9ull,0x48d820b0f17d1ac2ull,0x1745bb82ed277652ull,},
+ },
+ {
+ {0xd921b459e78504aeull,0x79ef5733fecdb405ull,0x04020f6200148defull,0x1163b626e015e688ull,},
+ {0x0781fcc9b627e44bull,0x5d8c6c8944d557a6ull,0x5493d9920c1d32fcull,0x0ecdc7510a2f454aull,},
+ {0x7086854c556b47fdull,0x4ec3f6dd8ad274dbull,0x274e92925edf85deull,0x09e6aa987250022full,},
+ {0xa63453a7eb3a8fb5ull,0xbd83f1e026f71f82ull,0x1386ec55e6450e3full,0x00873f000047164eull,},
+ {0x179dbc93073fcb3aull,0x592c5c9b8baf6411ull,0x4b81a7b27b4d9070ull,0x1d26ead51df9a20eull,},
+ {0x6a244f14dc36671cull,0xd1e9d82e3c5bea31ull,0xbd883c1283d17771ull,0x1e09e59618c6163full,},
+ },
+ {
+ {0xc1b0578027cdeed9ull,0x7ad19ad5cb04d6e5ull,0xee6f7f36d5ed1465ull,0x01d616ac45e80f5full,},
+ {0x2c0c7df57e945feeull,0x9709cf12715b87afull,0xa6e99327a9e2f868ull,0x1dc75e316e45b2aeull,},
+ {0xa7bc3e0832276f4bull,0x36ed99677fa22ffaull,0x89da95557e5dd91eull,0x0c1f4bf5d672d3b9ull,},
+ {0x25624941c1047a5full,0x463ccb3bd3fce3b1ull,0xd115fc8570096682ull,0x17145e34ff1d0e9aull,},
+ {0x4a3a34676a6a378full,0xac89a12198b0ca1cull,0xb97a2d982319e20eull,0x0caf54593dcf42e9ull,},
+ {0x7a07a3d321faf4daull,0x6a062e2ec939fd56ull,0xfd7ac47f692009a9ull,0x1121561f1c332cd7ull,},
+ },
+ {
+ {0xcfb495c8f564f52cull,0x39665331e96c838bull,0x42c49998a1446b14ull,0x03cc4e294cff3ff7ull,},
+ {0xd41d69b42b557d10ull,0x98dab8bd722a39a0ull,0xd4e24c4add54c81aull,0x1344527908d19fa6ull,},
+ {0xe9648caa7c8da128ull,0x8497aa165fdee967ull,0xf437d75fab691b76ull,0x052cbd6eb6436a4bull,},
+ {0x389f7092e280920bull,0x9b8625c09555310bull,0xe91f49f9d9031898ull,0x1c95a9d881b18be8ull,},
+ {0xe8605b4d2212b1fbull,0xb1c4f57736dbf0c3ull,0x8a90c4bcc09cad9eull,0x12f03ba47d2620d4ull,},
+ {0xcbd4494a5830ba3cull,0xb5a5d7b6b635fb6dull,0x154076781060c57aull,0x14e27241d5bdbe5dull,},
+ },
+ {
+ {0x5545df3af64ec9c4ull,0xff2adbc37d224acdull,0xcf02fc8672ce69ffull,0x0a7fcfe0b85478f0ull,},
+ {0x402246e5d134054cull,0x0bd5980440304ad7ull,0x3df09979193914b6ull,0x22610927d3977e51ull,},
+ {0x08235659dbd58c8full,0xd159c4e705d2f6d9ull,0x3c5ae22b53836251ull,0x137039c4b43f1c9dull,},
+ {0x4ee6c2b196d188bbull,0x54ecda987459243eull,0xb3a9cfbf1aea2748ull,0x234243a4a87cf61eull,},
+ {0x248eec552d9a5ef7ull,0xc8a98bee264e9e26ull,0xf3bcd8c268d0c073ull,0x16e365499a23e913ull,},
+ {0xbb406c86a8f7f2d7ull,0x03426cc36d053972ull,0x047915ec9f472c4dull,0x2318c0030bfcee73ull,},
+ },
+ {
+ {0x3c783caa5308c82dull,0x81bcacdec8f45662ull,0xe169822ce2c0837cull,0x09c179836e05b980ull,},
+ {0xf5d882cd842d337full,0x861761db32052e52ull,0xd6721854e7e686f2ull,0x0d22ec35de13a291ull,},
+ {0xd9dd477876f2c6d0ull,0x5ef6dd9d6e4eb6b3ull,0xa22e8bf49d19a102ull,0x1fb12cb296762e6aull,},
+ {0x8372df5211227b55ull,0xc3994286779c5c02ull,0xa302f7b3be87ac5bull,0x22b842b9b918d821ull,},
+ {0x2cb75b8cb17911a1ull,0x5cd8f56c7f4dacf8ull,0x09874f95dd87d8d6ull,0x15b92554f1bdb068ull,},
+ {0x4786ec1f88a80264ull,0x91dc53364f6aec54ull,0xbd9bd414e46eb290ull,0x1b27b7fd99d5e212ull,},
+ },
+ {
+ {0xbb40271789b4bb9cull,0xddf3b8f645386314ull,0xce090cc4ffeabe23ull,0x0c3920ea76b361f4ull,},
+ {0x14c64e1eed2b5edeull,0x99c5289af2511b43ull,0x5de1d7b1dccb2575ull,0x0b5e4419ad2e1c52ull,},
+ {0x0c04995f7bb764c0ull,0xbd9eb56e1c742072ull,0x9009271bd281dfd1ull,0x2464821365b75205ull,},
+ {0x49724e13fe376d0cull,0x189fb55cbe1abfc2ull,0x80162bfa5b8980d5ull,0x1a96550a3916c5caull,},
+ {0xcd79e4d9633065d2ull,0x2b51887668a49a0aull,0x8785b375ac581035ull,0x10a5547822c082bfull,},
+ {0xb98da2585b65ccd3ull,0xa8015a03bee86a26ull,0x2eb6a1e1bd1cdf1bull,0x07bf364897d1c8b8ull,},
+ },
+ {
+ {0xb791c26545931abcull,0x9a1ad86e4fda79aeull,0x06855828328d0314ull,0x116650fafca899dcull,},
+ {0x28a52543d8cb599cull,0xbdd390c86fa4fb40ull,0x903fff92c56629c6ull,0x0b496e3e73b93100ull,},
+ {0x0f5622574884b369ull,0x48dc4ad8ee6e6c07ull,0x9bf8705b75932345ull,0x12fdae5ddc53fccbull,},
+ {0xffbab25f3f4dbcc5ull,0x2e29054e3b0c795bull,0x4e42d9554507c4a9ull,0x0100c6ddccafa66full,},
+ {0xd070c555e094dddeull,0xc33dd5eda3c03e59ull,0xaf83e343a270dd9aull,0x098aee3da1fa8162ull,},
+ {0xad02918dc6d1048aull,0xf04903a09f8c1e95ull,0x51622aaf4848d918ull,0x1ded54a06c3901a3ull,},
+ },
+ {
+ {0x407e49d022ba5897ull,0xdb8d26843eab7b0full,0xf976a1b95413e184ull,0x0aec3abccfa3f870ull,},
+ {0x5a796987e2623f7bull,0xf9ab67105d5e1b46ull,0x9d9d00cfaddf51aeull,0x1be8e30f8202ab70ull,},
+ {0x793be4982c00e681ull,0x903759a9286f8a57ull,0x16a3daf170f851afull,0x13cf0c29956077fdull,},
+ {0xfb5787f1092904dcull,0x9a7422c14149238aull,0xe8e61be7e9ad1fc9ull,0x10029d3e967eff2full,},
+ {0x4a4887f39a050b1bull,0x2b7f2e2d718b7fa5ull,0xdcf39f9d5e4ccc87ull,0x0e9ae22b93f3c46cull,},
+ {0xe2085144d647649full,0xbb22757ff04f1a8dull,0x39c323e34631d9f7ull,0x04865b0a1462c9b9ull,},
+ },
+ {
+ {0x684266fdd1482bdbull,0x49a7895fd6b87933ull,0x28476e848c17b925ull,0x19e95e89691c4ea5ull,},
+ {0xe9a6a6bccaf53a2dull,0x479cccded58ddaccull,0x16049a3fd6291256ull,0x07364abc39086c40ull,},
+ {0xf24da0fc6d7e4b82ull,0x29591202c08178e9ull,0xf9b5dff7dc07aae1ull,0x0ed06afda0a02f78ull,},
+ {0xcac1c41fcc1f702cull,0x52b029719b5224f2ull,0xc838b665539d0364ull,0x246b61674cf835aaull,},
+ {0x44068b26b9dce8e0ull,0x6b3a0b0e83a7c8b9ull,0x03feca47fb021110ull,0x10d9d6e7fbc944eaull,},
+ {0x3a39ad7da63fd6fcull,0xaf3e9dde8885823full,0x31511af0a15648cfull,0x19de25d493f0200aull,},
+ },
+ {
+ {0xd4fff38e62012c13ull,0xae59ef30122850ffull,0x9d23a0381a012cf6ull,0x120ae1d814828c1full,},
+ {0x42eb1c5dfbf07103ull,0xd254f031490046f0ull,0xb47882ae239b8ae8ull,0x11158120470a13baull,},
+ {0xd5144f9267a09051ull,0x66da90aae84bab57ull,0x586fcfe6e1dfc445ull,0x221e49ed2a16e941ull,},
+ {0xf467fe034d6cbdccull,0x7ac29c1d1e5e20feull,0xa110e6e05eb1585aull,0x23d954fcdf786a64ull,},
+ {0xc1ae9be330026938ull,0x874b19ab11339205ull,0x0964cbafa59f62aeull,0x1e6167f38349f253ull,},
+ {0x23efb445bd9ef627ull,0x897335bf70b7bcaeull,0xa00f86ae69e47650ull,0x2509e8fa87d5670bull,},
+ },
+ {
+ {0x22a00ec33abc6b8eull,0x09620addb21d394full,0xb965fdcb7ee143dfull,0x1febe6994e628a7bull,},
+ {0x1c710a901e98b013ull,0x2801fd688f4dddf6ull,0x0abcab0ebadf8343ull,0x10f0cfd199338d92ull,},
+ {0xd599e818b6e83ff6ull,0xb88539365c679f3eull,0x0313ce19b529a51dull,0x21f5f0b9f1cf3415ull,},
+ {0xb59034f3ef13e954ull,0x6883ab623a40da9dull,0x94faebf81576de70ull,0x14d2247af37a0cceull,},
+ {0x99757d5184162b77ull,0xf79b9dc74871c5dbull,0x608ad4501b03300bull,0x074149d915458798ull,},
+ {0xa3252b36c3eda717ull,0xc1ded9f245002540ull,0x14b5755b56dac7b3ull,0x19308239f6756bf4ull,},
+ },
+ {
+ {0x07f4f5a6f26b067eull,0x32d2eb865477dbdfull,0x6945cbc86ac200a0ull,0x1e6311fd6ef61d2bull,},
+ {0xa0d0920425c68e5cull,0x683d1987c8fe9e5aull,0xd7228b5e41a381faull,0x114a05f6a9f409b5ull,},
+ {0xf677d47e68eeea17ull,0x87f50243b30d3112ull,0x084cf054770d8dc4ull,0x0bc9fe9990a74fb5ull,},
+ {0xf22bdc5dc2eec0d2ull,0x3bae3de98c595ff4ull,0xc95e53073fd0b23bull,0x11a7e2b2d55a6ea2ull,},
+ {0x8ddcbdbb83b870baull,0x728950ad96866c71ull,0xd145c1d31fae9c5cull,0x0547d0e831e70104ull,},
+ {0xead79bef2b2433d9ull,0x0647d5966623bf56ull,0x4fb0056ba69d7958ull,0x1a0983813c5d2e9eull,},
+ },
+ {
+ {0x215a5a20e15d19d2ull,0xae9ceafe33084b69ull,0x80f85025ca380f77ull,0x1c19066c196d1a00ull,},
+ {0x359cfc6bc545de2full,0x7339f8704a758d60ull,0x64eca98cd5f2d7edull,0x248ba44255247839ull,},
+ {0xc2c6e70b389e8492ull,0xc9b97f7a19d874c9ull,0x87d7b9a332957727ull,0x0119950fe431afe3ull,},
+ {0x51eeee98aaf4581cull,0x081de6981f8512e1ull,0x4bb18cf097ac6997ull,0x21e465b23c21951bull,},
+ {0xe5bc584a9a1f5a1aull,0x1ccc4b14286b7ad9ull,0x435b382aeb470e64ull,0x1f9ae9143c5b987bull,},
+ {0x990eccb3248cd3d9ull,0xe6cfbcdbd8c8fd0bull,0xb48de18c5009802full,0x198d98c5412a6213ull,},
+ },
+ {
+ {0x43cd5d8c9073ea61ull,0x5174db54059acdffull,0x45e871c04aa7a2ddull,0x05e16d3199d840a0ull,},
+ {0x9ad1091f764df938ull,0x67637f20a74490b7ull,0xdbd73b8487d04861ull,0x15a139abaa8b478eull,},
+ {0x1b10547972b4d507ull,0xf641d3763db1a739ull,0x15597787c5b84ec3ull,0x0134b78ebf335c12ull,},
+ {0xf6b7a9d4052963daull,0x2d806855d9466783ull,0x623658a8a2d743dcull,0x00de0208fc0298b1ull,},
+ {0x1b67ee84e8c40714ull,0x620107f4c2393038ull,0x96441ca3a07baeeeull,0x0b27368271b0f683ull,},
+ {0xa65922c66ed876ebull,0xdc21179aa8971bdbull,0x9309a00b5206e041ull,0x088fc38497bf88ebull,},
+ },
+ {
+ {0xee8bf43d2fc34584ull,0x4ff6772e8da82b6bull,0xa7ae3c97dc955a78ull,0x09651f34f9ad7ab5ull,},
+ {0x103de2e1906f8fd3ull,0x046ca4e6b276642full,0x220398cd397af5fdull,0x07b984811b0df962ull,},
+ {0xd0519e42b872b7aaull,0x164acb4f7d9df94dull,0x54cd157448c94337ull,0x04c636efd3f59641ull,},
+ {0x7cf41f52f0acc90eull,0x54dff80755d46315ull,0x83a7e3f528daec19ull,0x0039b02577bb91e6ull,},
+ {0x828eb12b537a9732ull,0xd81ce0f79c6211ccull,0xcd2fd2f2e35379adull,0x1e84fa2068841dd3ull,},
+ {0x931aef70f9a3a06dull,0x71abc5af88fa12caull,0xa70ddb3102a75247ull,0x14a049c881169cceull,},
+ },
+ {
+ {0xa9975bec6d3f0412ull,0x72feab9fdc81092full,0x49f533cdb7ae9d66ull,0x18632a2c4c5b4d2dull,},
+ {0xaa9f81eeb706ca09ull,0xb1065065a3fe5198ull,0x3381765974ac94a8ull,0x0ec5d52c65b1f5e0ull,},
+ {0xfe465050a5cd7ab1ull,0x5059fae63d47120aull,0x49ad1fd731ef0aebull,0x1e018673e33f45e5ull,},
+ {0x6eebdeb52c24d248ull,0xa43988a55ccc8d10ull,0xe997fafe55d0ff64ull,0x233675abd5ad14e6ull,},
+ {0x8b5530b175fbeaadull,0x27ba08984164ed08ull,0x94a9507d0189809dull,0x12fb832d1d13901cull,},
+ {0x912ff6e6cf0c29f4ull,0x54d7a43121bcd1afull,0xcdf9fb448a1e2185ull,0x02aac1a8e253b8f9ull,},
+ },
+ {
+ {0x26a581d7ca270a84ull,0x989bddaaecea533cull,0xda7993327a4b8cddull,0x0c1637ca7d045160ull,},
+ {0x6213cd9db7a6d076ull,0xc03037d124aded7bull,0x32d9e1bd41523d2bull,0x008ea641abbe75edull,},
+ {0x7d3c23b227774f03ull,0x4a5e7805e6f9a14dull,0x1c24f1a43d487e79ull,0x18eafaffc703509bull,},
+ {0xe146113f559bd9efull,0xe56825b1a7fcf7f5ull,0xa93689399f819fceull,0x14fa96013c5a6638ull,},
+ {0x81c625bff8857fe7ull,0xc98edd68e7203a68ull,0xc88c3a681a3f1ac1ull,0x0bd4fa57e9b6d9f4ull,},
+ {0x2dd6eb21127b1fefull,0x91b039a57e0f6233ull,0xd02548bc3dc3c783ull,0x0e8a4d19a777a688ull,},
+ },
+ {
+ {0x025c54533652a519ull,0xb3bcbf01559e8920ull,0x5c53eb97c55f25fbull,0x22322b9402949dccull,},
+ {0x260ef92c70dd5c11ull,0x9e27626b6cd441acull,0xc6661507ed6f5d61ull,0x0fac1fb2f6bb53edull,},
+ {0x5511ab3bd7ea4c51ull,0x6562a46409240916ull,0x83a5e441731b870dull,0x205c0c853ef83501ull,},
+ {0x7c8ae57f4deec828ull,0x349dd08555bea497ull,0xcb5d3234c7b839bdull,0x153259da7d31993eull,},
+ {0x964b508f6fa5bb3full,0x82b5262f18242750ull,0x970156d1896d43c2ull,0x028fc28439e44783ull,},
+ {0xda5afd0f1a7d7fcaull,0xddb473f9a75a7a4cull,0x180c169ed34f6781ull,0x0cde138f3279be8bull,},
+ },
+ {
+ {0x63de6da225c321ddull,0x4832886b582d3833ull,0xb0dee708e55cb53bull,0x06c9e933c223ec30ull,},
+ {0xdab1fab5dd78e263ull,0x3e658d3d9ec3bb7full,0x3d0a56ca4a1b088cull,0x008ce74540e8386dull,},
+ {0x0b0ee452fc9bca4bull,0xfd0b0e032d16b266ull,0xfaeea7076b32cc91ull,0x1823f6048f88ea5cull,},
+ {0x3966dc6553a5ff08ull,0x85192338024e75e5ull,0xff2cc296f92beee4ull,0x229caca8d4f809ffull,},
+ {0x7702729e0d1f5157ull,0x1a3ac2432384d0bcull,0xd006954b39b11e9cull,0x118a5126dec2a2faull,},
+ {0x2e9bfe6eaf026413ull,0xc720a61aef11d653ull,0x6ea67c87c36691a3ull,0x18f925014f9c61d4ull,},
+ },
+ {
+ {0xd3b27621ad1dd1abull,0xf97b0f55f22f18c9ull,0xb6113e8be6db1114ull,0x1a8a1ae8f65ead1aull,},
+ {0x0007a32980115669ull,0x605196cb02f760a8ull,0xfbd2085c8671df43ull,0x0c381e59ea5960d2ull,},
+ {0x94116d83a9603b67ull,0x92b23f61ccedfbbcull,0x50e0fc7e78727f5eull,0x23fc01a1d8cc7e65ull,},
+ {0xd1b8a0d5024aff36ull,0x2b25d1cf4ab60e92ull,0x8dbbaf91e20c91fbull,0x185a985f30c061fcull,},
+ {0x06fe112b333faa7aull,0x9323dbd6f08549bfull,0xcf5e43f668844df0ull,0x10df0c27f29e1637ull,},
+ {0xf2afbd9928527e7dull,0xd856c6d7448b34ddull,0xc5e025621b375c86ull,0x01b0fe70c9b177dcull,},
+ },
+ {
+ {0xf09e65fdda5bf41cull,0x59ef2a8eb45985f0ull,0xfec4facae20ae75full,0x019f623d519953a8ull,},
+ {0xd5dc50c38c7e165eull,0x62fc39995a53fcf4ull,0x557a7e55f3ae1284ull,0x0fde40ac729d9ca2ull,},
+ {0x4b49ba1f5fcea25aull,0x631dbbd1d4e3cea5ull,0x7069fcd00919239full,0x09c559fb76aa0dbcull,},
+ {0xbb6348d2d3a8d733ull,0x460c7255ba85e5c1ull,0x42e7d9808787c01cull,0x22c0fd2eef2261e2ull,},
+ {0x19833887b93cc3abull,0x2cee6551569164daull,0x1c44fdcd7b0c79dbull,0x1807ed58575a7b33ull,},
+ {0x30713388923e3b7eull,0x6d541ffc75d914c7ull,0xbbb50245851f0f6eull,0x1df0abdb9048edc2ull,},
+ },
+ {
+ {0x62788c325d2b0f0bull,0x33744819eb512733ull,0x83ff060d6ff7309cull,0x18829912bda99968ull,},
+ {0xe09edb24cdbdfc6bull,0x099200c5850fc442ull,0x967790a56049a66bull,0x011cd382712b1d77ull,},
+ {0x8df4e975f64427d7ull,0x2e3901a3a7b0f55dull,0x641ec6f45805e402ull,0x06e1d0db4022cd43ull,},
+ {0x440dbd8590564164ull,0x6aa7d9c34c053da4ull,0xe0da2752be2f5aaaull,0x2264f00ad93d3d4aull,},
+ {0x716e5f9a7e68031full,0x1bcb15653094bebaull,0xf84ac39bc138e963ull,0x1d7a1fc06adf5b63ull,},
+ {0x8835962eb2e3079dull,0xc3d7c9d41261e319ull,0x30c0c53b9353bf58ull,0x03bf957dd1541c99ull,},
+ },
+ {
+ {0xe77e8891944694ccull,0x04efd57869ed85ceull,0xe9de08ffa6a88729ull,0x1d062265f1d299d3ull,},
+ {0x387dab533dc83cc8ull,0xf7fa09c0bbdf31b7ull,0x59b84e1a3762d3b9ull,0x01b32660eab7f6beull,},
+ {0xf7daf1d596d17df2ull,0xcd931e51341e0ebbull,0x51710bb172705525ull,0x244d6b81dbc7d273ull,},
+ {0xe7a144e6eefd2dc8ull,0xf5c76e992d995cabull,0x477afe1374a66f3cull,0x1aebe5717b54fe53ull,},
+ {0x541a0d7dc825c3b1ull,0x93a0cab475598133ull,0x096efa1eb12a99feull,0x17a85ece29f273fbull,},
+ {0xa36f4f86b5bc5c1bull,0x1b4a0fc57947e76bull,0xaf302e3f7838388eull,0x06aadb4991feff1full,},
+ },
+ {
+ {0xd6afd4710167605eull,0x1897263cb81c98e1ull,0x90e133c23eb0207eull,0x0718643da3a96ba2ull,},
+ {0x8344e521afad71f8ull,0x66af04f81ad9f156ull,0x5ecd25d48f404733ull,0x0234ffcdbb42d141ull,},
+ {0x8a50c65ef686166dull,0x34cdda95694e0cacull,0xa8add01d08d2dbaaull,0x1ce98a7c6ceb5696ull,},
+ {0xb1702710fa0af484ull,0xe30a4eb2f39aa3f1ull,0x7409d5afcd96441eull,0x1e0168166b2894d7ull,},
+ {0x8cfa29792abed76aull,0x75d7bfbcee2073efull,0x7c0372e7080fdaedull,0x1ee8cc19eb967336ull,},
+ {0x2a265f9eb8f2265eull,0x48f9b13b07b728f5ull,0x7b915e1225774e84ull,0x0d4eff23e23d5ae3ull,},
+ },
+ {
+ {0x13cc952b1ef56e58ull,0xeb3870335e75a7c9ull,0x2fe15087e3c0845bull,0x1011a2007bc71f04ull,},
+ {0x472e18f407707bbbull,0x053d1dd70cceea98ull,0xe200cdc8798603d2ull,0x0bddb233bffdfc1aull,},
+ {0xec920181b8484410ull,0xc6b9a9b74e18f513ull,0x84c1695c77cf9fc1ull,0x01005eda69cae7ceull,},
+ {0x7c668bd94e95d9f5ull,0xbaf12b0a06fcd749ull,0x674b2e2824d6029aull,0x23c9d63fdca6307aull,},
+ {0x92bd96dd3a545dceull,0xccb9355edd49cadcull,0xf49ca3d068b74eb3ull,0x1d9461936f823b86ull,},
+ {0x6a2fa39fa7e93bb3ull,0x468fac8c8f151f41ull,0xd12e0aec4bb21bbeull,0x2326bbeb4405b3ebull,},
+ },
+ {
+ {0x1e029295309f1347ull,0x6589babde3a80cdbull,0x74de96ccf73da639ull,0x125810442f8c9fbaull,},
+ {0x47d63700da3a6cefull,0x59c3fd0f2b9b6f35ull,0x66f1979c84873b7eull,0x02770c35ac617c99ull,},
+ {0xa757e064e4f9edb2ull,0x46eb13ddfbda28f5ull,0x519177520a694aabull,0x04f6097d775debf9ull,},
+ {0x072be9865dd6841dull,0x4d9d5c0fa6d6a7b1ull,0x1749ea911a952c21ull,0x15e98445e982607eull,},
+ {0x6fb1b6845ce93f6dull,0x52d5387b1a0f8405ull,0xd6a11cff22d72a42ull,0x2283db33f8496ec9ull,},
+ {0x77bae4ccdf2e5bf6ull,0x21812c170f736a30ull,0x5a8477a3203036fbull,0x1e667d8ca4a419f4ull,},
+ },
+ {
+ {0xfc925115198c93d4ull,0x0aebd45cf3b16db7ull,0x2f7c3d2ab0f16732ull,0x1c4b48273365c9bcull,},
+ {0x2a26617f1f00e47full,0x828f68381a20ae68ull,0x0221e65b7f01b6e8ull,0x19e45e14ca4e5650ull,},
+ {0x231de599fda4c7e2ull,0x55e6d0d3df2457abull,0x34f961f715fddd4aull,0x0e97e5f5fbfe6aecull,},
+ {0x8f1f1a8b1b687949ull,0xbcbdae7ed35524edull,0xd7c78090035aa0b8ull,0x19f2a0d7fb844166ull,},
+ {0xc397557bba8fe6a4ull,0x366daf415604f8f6ull,0xa9b99d86ac93e705ull,0x21fb72d548929de6ull,},
+ {0x6a2ff9d0392aedf0ull,0xb0a90a0d10fb8fb2ull,0x5ef8e1768350ba26ull,0x24aca64027557318ull,},
+ },
+ {
+ {0x18e3eeb6b8937690ull,0x7c87ee4ffda9eb41ull,0x59d0d9e9eb070efdull,0x10b64beb52f348f5ull,},
+ {0x60cb09b15da28d99ull,0xde4b5aaff3981423ull,0x7429b4169dfddfb9ull,0x199eb1a7a6de0f9full,},
+ {0x450661858d54325eull,0x338439f5a896f88cull,0x9d41086dd111bec0ull,0x146d0b19b0b567ddull,},
+ {0x93a470115d0544ceull,0xdbec88b263d6ba96ull,0x4162857e9d97ef77ull,0x07a4e45e194880aaull,},
+ {0x7279bdde87e7ecb8ull,0xbfcc34d54c72df15ull,0x57d3ff1a2476f6c9ull,0x0f0da2351d32d405ull,},
+ {0xffee1be1efc73104ull,0xb873a987a8076cb4ull,0xce026a94aa6b71f0ull,0x15d4bd558bf59554ull,},
+ },
+ {
+ {0xae631a8d76bd7f86ull,0x7e7d9176acbc845eull,0xea421fd87eb8808aull,0x20aaae552a029015ull,},
+ {0x5c1c015cfce07393ull,0xc678b97a85aea9b0ull,0x1eea5259304f0a23ull,0x1464e4d058ceb8caull,},
+ {0xc65d3f2d4e51915cull,0xeedd92d9fe368d68ull,0xc8df47e3a123fc9eull,0x0a40dfad54ccd6aaull,},
+ {0x09a262e9428a05f8ull,0xa0510048ec69ab80ull,0x335a295aecb01ddbull,0x05d9e955d5b1a89full,},
+ {0x5eb68ea11c52c37aull,0xe444556824dd8a88ull,0x8e380018a6aeef10ull,0x0442ce4eda39623dull,},
+ {0xa77e431b883ec5b0ull,0xac34fb82921e9c20ull,0xa8cfc2d08ef8cfc0ull,0x24ae732a4db3bb4full,},
+ },
+ {
+ {0xd5563857f984777bull,0x538e5c618a4be3c1ull,0x5f8eff3fbeab5a7eull,0x017bdafb790e0102ull,},
+ {0x6a62e076dc44c251ull,0xd4743cd8eb4cb3dfull,0x98f0d5617f07650full,0x0ef52eb4c0151010ull,},
+ {0x516284d618713c13ull,0xe651d8c5769b47dfull,0x27fb0f16b90bfbdaull,0x10e729bd4403fe24ull,},
+ {0x7770b670be42c842ull,0x6a9d9db10a3626b9ull,0x17676416c44a62ebull,0x2155a03fd59945caull,},
+ {0xcd58941a2ba1e208ull,0x2d5e3caf14827df1ull,0x6e8dbafadc4e1635ull,0x03bbd3e6d397465aull,},
+ {0x451703d643a411bbull,0xcca0c1d97355c175ull,0xc5074f56618aa2f1ull,0x04c8acdd37ef602full,},
+ },
+ {
+ {0x3f7e0caeff75a1d9ull,0x1b753ba68a2b8451ull,0xf46aeda408dbf4f5ull,0x11652b99c4365b3full,},
+ {0x3f8bf5f03132d146ull,0x0b527b11a12d2424ull,0xd587034aa3632352ull,0x13ffef8175d1a563ull,},
+ {0x2a30747e4ac8eeaaull,0x0aea36171552eed3ull,0x04e341313ec7b422ull,0x1fb62ea6d5e86357ull,},
+ {0x13c69094d2dcc5aaull,0x54573685ddc44032ull,0xd95abdd392375f10ull,0x13a501913c2f1d0full,},
+ {0x343cc1b0318577b8ull,0x98776ba96045eb10ull,0x5492dba5b5936d5dull,0x1d1bb567d6a602e6ull,},
+ {0xccf58e05f8b305bdull,0x3fee26e8419548ceull,0x62c64af67fc27dc8ull,0x08456a814b2fe18bull,},
+ },
+ {
+ {0x47f8ccf69457895aull,0x66d08f143ca062fdull,0x8f0df2e2a97b4518ull,0x0cac6d2b34b243d6ull,},
+ {0x758f56a94a45e6beull,0x63ed30c20cf6721cull,0x20e942550629c9ccull,0x167acfffb8203274ull,},
+ {0x8e727dabacc57eb3ull,0xa2f85144ebbe15f3ull,0x7fc17e7a0a6a4291ull,0x1793c43f349e48b8ull,},
+ {0xed2f91d056a5c2d3ull,0x30433d773122e8ddull,0x2c3fef6399c4f9deull,0x099b39a0e3e524f2ull,},
+ {0x4cddac568a4b563cull,0xdcd1c44d3983138dull,0x2f421d9f8d71a88aull,0x01a02cb6459cdb12ull,},
+ {0x68c09ced7ae8977dull,0x76cb2bf3a933cdaeull,0x6390cd95c4f85d40ull,0x1cad79870e6b2c2cull,},
+ },
+ {
+ {0xfd754584dcb80db2ull,0xb73ea36e2df2b8c0ull,0x3ca5645bffb60c04ull,0x1280d1e1f4dd4da6ull,},
+ {0x75a069b69ae4403aull,0xbbf6c5ded1f82c60ull,0x34919f2295d7b5b4ull,0x1f7bc94e3a96507bull,},
+ {0x9255ca27cb288f9dull,0x760719cfb400f56full,0x291bfbf807781368ull,0x15fa25b272fee67eull,},
+ {0x6054f038190f5f6cull,0xe0978a57792a09bdull,0x1ed22ba69556fe50ull,0x20ba270b20baf856ull,},
+ {0x55de530a1af249d0ull,0x249e57b2414ceb2cull,0xd98bdcde7f16edfcull,0x0ee1bfb7da744ae4ull,},
+ {0x01b24c4d0bb96ddfull,0x32239e98244d75f0ull,0x20dc68759c157d45ull,0x0120769b781bc14eull,},
+ },
+ {
+ {0x4f93886e58c4695full,0x85d6a1914aba1d04ull,0x65bb00f8cf495806ull,0x22a2413c698ae97aull,},
+ {0x5e7928222bb02f69ull,0x93a92c850ce1dfb0ull,0xab3eda670f968b1aull,0x1d80886e0fba63ffull,},
+ {0x672372572dbdeb59ull,0xba4cd6dd6cb11489ull,0xc74f1c6e3b714d1bull,0x1680ad98da380987ull,},
+ {0xbad24d644fd9ab88ull,0x5c817abf11d3ce46ull,0x50587e12664ad6ebull,0x13505c240ec7b092ull,},
+ {0x69ade81d2b6d1284ull,0xdd1d9aacd53d3f77ull,0x0888b2de31545a07ull,0x110788f6944c78e4ull,},
+ {0x81032f6ea72116caull,0xfcb0253b20bea779ull,0x3d0a38d424eba36eull,0x07bdfcb51526c1e5ull,},
+ },
+ {
+ {0xebb80cf2cf44bfbeull,0xb8d559e318097038ull,0x212ed4c3d148be8eull,0x07028dcc862fbbb7ull,},
+ {0x91e0a395d89f04d4ull,0xf777ae0142ff07c1ull,0x546b9b47f738fa6eull,0x01c284ef516920c6ull,},
+ {0x2042edb5a4eb2cdcull,0xc69cefe0a36a7068ull,0x54471d65b3238311ull,0x077562b3344b4304ull,},
+ {0xdb85089b11ece88dull,0x5c27780550f90569ull,0xb9607c12434a6b3dull,0x0d02a6324718f932ull,},
+ {0x22ef9b5c8b453c5dull,0x6fdc3875e9247830ull,0x20e375065f9e593aull,0x2351c044ce0d933aull,},
+ {0xfa0fcb482093eacbull,0xf8d695e8413f5acdull,0xc7020d8c84a2d773ull,0x11bf7584e5283fa1ull,},
+ },
+ {
+ {0xc6b304aa2adf2dfcull,0x19aac2d5544ee834ull,0xb7966f8cd629c330ull,0x1bc72a08a8bf8f9bull,},
+ {0x18a5f463799112c7ull,0x4f14db51e967ebc3ull,0xa5ddb48f64db5e8eull,0x15b4fdd8610f3a32ull,},
+ {0xe7b86b479d7e2293ull,0x931034487abf490dull,0x8c40ab7dfd28a196ull,0x1d981d3918fdc3b5ull,},
+ {0x00797000c2afd324ull,0xf2954f0f86622806ull,0x8464fe0995cd3a7dull,0x0f0a74df4ca00cc3ull,},
+ {0x639707b1839c8330ull,0x9c8d491ad7d779a9ull,0x576b7e0f24ce5f46ull,0x21fbdcc42ccd04c2ull,},
+ {0x4578db4bdfd55434ull,0x1126933c97e9f4dcull,0xe64529a8921d7415ull,0x12e48bab87ea1fe3ull,},
+ },
+ {
+ {0x3f6d2fd04bd5ed75ull,0x65e464cdac7d235bull,0x45903a63a3608961ull,0x1f60c825bccd55c9ull,},
+ {0x36b33d0fb8528047ull,0xc8d1f1ad82683baeull,0x78f4b80065c2e4c6ull,0x2066f32874bd1228ull,},
+ {0x8b6d6a4b986e8d4cull,0x58f6f275f1d020f4ull,0xe4f3c16209e87ad5ull,0x1cdc33d41ad30173ull,},
+ {0x9ec18a6cba3fb3ecull,0x31fc74b68ac834c6ull,0x256788ece76e37b0ull,0x13de6919841928e1ull,},
+ {0xae46aa08773971f6ull,0xacd04d9698d47643ull,0x3667178a594f2153ull,0x19a0cadfa3cb7fa0ull,},
+ {0x228420456325e079ull,0x3e4ec53c418fdae9ull,0xb9fee919e867c6f1ull,0x2272413f3e989842ull,},
+ },
+ {
+ {0x6420ee94e7c764dcull,0x87b3c986d488deecull,0x11dc3e6b59de7ffbull,0x14bb613bce5792e2ull,},
+ {0xcc0b60cd4e352976ull,0x794b585f70a5b463ull,0x415cb954036ba631ull,0x1e521f8201ca4258ull,},
+ {0xd707ac91ecd5dbdaull,0x08ffd44e5fd83cc6ull,0xa5f39e0f8dff5afcull,0x02315f6a55599212ull,},
+ {0x2cdbd9f11596e797ull,0x7c560adedcf2cb25ull,0xdc474409e5650d9dull,0x158bc955e7e492e2ull,},
+ {0xd6023b14352a1766ull,0xd5c271d942b6541dull,0x5dc4d1c72d25258full,0x0753f065a4cb028eull,},
+ {0x11b4229a4c62010aull,0x2949cb6b089b3aa9ull,0x01b8bdc50766366dull,0x1094dfda1e2e5e57ull,},
+ },
+ {
+ {0x773cc6e1ac12f73eull,0x77686f8d75a83e9eull,0x7ce94b7ef1bd53a0ull,0x005a7d3e75c16332ull,},
+ {0xafdc64df2ceca388ull,0x15be551bbca0e367ull,0x62d9b7608cf3b8a2ull,0x11ddfe7a0a96af25ull,},
+ {0x5d23851a77554f67ull,0xa0f51815094e8050ull,0x930af7569c7850d7ull,0x108eb034eeda1460ull,},
+ {0x28a80b277688cae3ull,0xd09ef5d30ec9b193ull,0xb6c554e32540d421ull,0x1da12923355fd2faull,},
+ {0x9db6509d0130494dull,0xe28936417c250459ull,0xde8b4491aa8d1dc1ull,0x194b8e7bfc005322ull,},
+ {0x7aaeb4f2f941741bull,0xf9d7b55b452158f8ull,0x17e172a187f68105ull,0x02f620bde277950aull,},
+ },
+ {
+ {0xf555a7766ac21481ull,0x82b12050c9449770ull,0x7bd16da27eff49fcull,0x06d1ad9a6cd69b71ull,},
+ {0xa059542aa0f64e9full,0x93671f16b269a351ull,0x795262fddcb7cc3eull,0x199f355d6263cf86ull,},
+ {0x0cbf707f1f8f73aeull,0xf483501e15982b44ull,0x2456aaa4d84d80c0ull,0x0d0ffb5393f7dd0aull,},
+ {0x62999996c09097e2ull,0x1b87e828f9fc66e4ull,0x6b17eb3166967f57ull,0x1603601303478f52ull,},
+ {0xfb776d4fd407d485ull,0xac03efdb746bf127ull,0x57bde58a5671a601ull,0x0cfbfa20d141f05cull,},
+ {0x625ac1161752cbe2ull,0xe3348570b6ad71bcull,0x155b3911f5335f75ull,0x1679ec68122edc64ull,},
+ },
+ {
+ {0x9334b4c82aee3ef8ull,0x7ea393af9d865ce4ull,0x0f4ee0906b864850ull,0x1d9e34461e27cc61ull,},
+ {0x921b1a6aa179a081ull,0xcca25db2d609388dull,0x816b69ad9a56a314ull,0x00eb3f6388c4d375ull,},
+ {0x04e25f4225e50e72ull,0x59a20b6edf897f2aull,0x0842d5f5823535b4ull,0x0dceaf5ae8e50885ull,},
+ {0xac6598257175aa0aull,0x1d5d21e8129f2efaull,0xe81dcc9497cb17fdull,0x11327c40c92dff80ull,},
+ {0x149e4b2c0a3bfd81ull,0xb8efe68c475436ebull,0x3a8bf06e9ca15cd8ull,0x152d72639c6e5308ull,},
+ {0x217e0e34f3f76b8bull,0x5c722d926b596985ull,0x45417905be08807bull,0x1e6132b54ad5595eull,},
+ },
+ {
+ {0xe5b541097726667dull,0x5583dfb4ade471adull,0x1840bff44a2faef2ull,0x093c23f8028fe3b9ull,},
+ {0xe1e3347370f6e6c7ull,0x8dd7352c4dcc2a17ull,0x3cade218210f9e29ull,0x190ff57eac6e8b87ull,},
+ {0x34905e72c173fdc3ull,0x59f8c6f4373c834eull,0x1bd9feabed806c99ull,0x1f209a7935a8ba38ull,},
+ {0xe44f080023c83b49ull,0xfd2006276058693cull,0x44b43b6e462a32cbull,0x0942a0ed8e4657ebull,},
+ {0xf7e53796340fd772ull,0xf8219ede4152370full,0x548b9b002c19940cull,0x1d0aaff93f50f52full,},
+ {0xb5987eb545462ddaull,0xe0f29867116336edull,0xcc75a11c3ff8374aull,0x144d0b8fda0a44a9ull,},
+ },
+ {
+ {0x676408d2ff1a7593ull,0xc96a8077d911776full,0x9efff30500904c63ull,0x100a6093df2ae343ull,},
+ {0xf1f92502b846cf30ull,0x57888806036aec6cull,0x310ceb0b04caaa7cull,0x1192819a3058307bull,},
+ {0xbbf882b39fec7883ull,0x4079d241f7e6e0efull,0xb3090a69b3c7261full,0x16440a02d7fb5d2dull,},
+ {0x70e9c8a88422df45ull,0x48fa15635ca49bd9ull,0x0430c461bfb96d16ull,0x0a29a4007c99f6d1ull,},
+ {0x643a2bdb308a297cull,0xe4a5bca158e65ff6ull,0xc8dd1579abdeb9e5ull,0x1ee4a94b3d6c775cull,},
+ {0xc085b2622b5c4480ull,0x8c69048c5fcded96ull,0x418ba7bd3260d85dull,0x0b22158bb6c29f9eull,},
+ },
+ {
+ {0xf661abe667e83f01ull,0x41068a7e95fd10c0ull,0xc9c4cc186cb3eb72ull,0x1a95a93a30592461ull,},
+ {0x78dfc65c7280895eull,0xb9f1514b98add459ull,0xc7d713fd92025a11ull,0x0dbe6c1ceabcf73full,},
+ {0xe35368a946428244ull,0x990da5e2783a2762ull,0x686b61b7775fb02cull,0x1a79e39b78922172ull,},
+ {0xbf8ca28c8d95600full,0x0f56487a909e51cbull,0xfa1da11e3018a2faull,0x07a32571b231773cull,},
+ {0x46c84d812bce56f5ull,0x84aa8d8bfe2b498cull,0x699ad1f34e22d74cull,0x0ad743bd99c458dbull,},
+ {0xa8d16c7e09aa59b0ull,0x59ba8cbe75f31d51ull,0x5c68705d7838ff4eull,0x1c863feb5090e87eull,},
+ },
+ {
+ {0x86af66313ed193baull,0xa0902147163778b5ull,0xa101fcdc6b2d6191ull,0x12fbff4713e6eb10ull,},
+ {0x9e1abdaf6e329c66ull,0xd8de2fb4db8e7554ull,0xb4374e1e93a0171bull,0x0ba2ecd00749208full,},
+ {0x0cad8f57c02ce090ull,0xcac04eddadd338ecull,0x7ee5c235934f9918ull,0x24db5a9b0ad7ed64ull,},
+ {0x46288ad8e01c5063ull,0x4b4c58654226c44aull,0xc4974aaf56ae42dfull,0x173e64cdd5661536ull,},
+ {0x58b3450781e7e080ull,0x14ab3a25a5e64bbcull,0x3f9f91743276d2f5ull,0x0e101d0b89b81cdcull,},
+ {0xa6bca5fbe99b2b7full,0x5fb8817e670ef40eull,0xb44cbcb05de76cb3ull,0x17110ed4912babb5ull,},
+ },
+ {
+ {0x6745e77f4e05d8edull,0xed278e7875ebb5fdull,0x3662f60864a8ccd2ull,0x028104ffc0a31868ull,},
+ {0x740b76d64f25c9f0ull,0xb519a415132160e7ull,0x550a38ed829c5f68ull,0x04ea27d6deefcfabull,},
+ {0x32d82ea897185651ull,0x04a8f5b63a90573aull,0x2c88fdfba241b62full,0x0285780fe0b77687ull,},
+ {0xfb6ebce4f4b20f13ull,0x8ce24ff3dad1a3c7ull,0x716f93b316af50c2ull,0x0a09e678713447efull,},
+ {0x6868a19728642ca6ull,0x4be5579c08e0a30cull,0xbd630b8f9c3d1552ull,0x0f277cf26c8e60f2ull,},
+ {0x1a105d54bc290b18ull,0xa7e1a7c716529370ull,0x6e5a6c5b44350fd0ull,0x1fd2ae638488fccbull,},
+ },
+};
+#endif
diff --git a/vendor/github.com/tangerine-network/bls/test/bls256_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls256_test.cpp
new file mode 100644
index 000000000..e53a87057
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls256_test.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 4
+#include "bls_test.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/test/bls384_256_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls384_256_test.cpp
new file mode 100644
index 000000000..ea8126567
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls384_256_test.cpp
@@ -0,0 +1,4 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#define MCLBN_FR_UNIT_SIZE 4
+#include "bls_test.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/test/bls384_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls384_test.cpp
new file mode 100644
index 000000000..2212f8e6b
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls384_test.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#include "bls_test.hpp"
+
diff --git a/vendor/github.com/tangerine-network/bls/test/bls_c256_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls_c256_test.cpp
new file mode 100644
index 000000000..8613720b4
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls_c256_test.cpp
@@ -0,0 +1,2 @@
+#define MCLBN_FP_UNIT_SIZE 4
+#include "bls_c_test.hpp"
diff --git a/vendor/github.com/tangerine-network/bls/test/bls_c384_256_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls_c384_256_test.cpp
new file mode 100644
index 000000000..6f153f9d8
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls_c384_256_test.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#define MCLBN_FR_UNIT_SIZE 4
+#include "bls_c_test.hpp"
diff --git a/vendor/github.com/tangerine-network/bls/test/bls_c384_test.cpp b/vendor/github.com/tangerine-network/bls/test/bls_c384_test.cpp
new file mode 100644
index 000000000..b6886dd04
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls_c384_test.cpp
@@ -0,0 +1,2 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#include "bls_c_test.hpp"
diff --git a/vendor/github.com/tangerine-network/bls/test/bls_c_test.hpp b/vendor/github.com/tangerine-network/bls/test/bls_c_test.hpp
new file mode 100644
index 000000000..e9b6e6302
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls_c_test.hpp
@@ -0,0 +1,437 @@
+#include <cybozu/test.hpp>
+#include <cybozu/inttype.hpp>
+#include <bls/bls.h>
+#include <string.h>
+#include <cybozu/benchmark.hpp>
+#include <mcl/gmp_util.hpp>
+
+size_t pubSize(size_t FrSize)
+{
+#ifdef BLS_SWAP_G
+ return FrSize;
+#else
+ return FrSize * 2;
+#endif
+}
+size_t sigSize(size_t FrSize)
+{
+#ifdef BLS_SWAP_G
+ return FrSize * 2;
+#else
+ return FrSize;
+#endif
+}
+
+void bls_use_stackTest()
+{
+ blsSecretKey sec;
+ blsPublicKey pub;
+ blsSignature sig;
+ const char *msg = "this is a pen";
+ const size_t msgSize = strlen(msg);
+
+ blsSecretKeySetByCSPRNG(&sec);
+
+ blsGetPublicKey(&pub, &sec);
+
+ blsSign(&sig, &sec, msg, msgSize);
+
+ CYBOZU_TEST_ASSERT(blsVerify(&sig, &pub, msg, msgSize));
+}
+
+void blsDataTest()
+{
+ const char *msg = "test test";
+ const size_t msgSize = strlen(msg);
+ const size_t FrSize = blsGetFrByteSize();
+ const size_t FpSize = blsGetG1ByteSize();
+ blsSecretKey sec1, sec2;
+ blsSecretKeySetByCSPRNG(&sec1);
+ char buf[1024];
+ size_t n;
+ size_t ret;
+ n = blsSecretKeyGetHexStr(buf, sizeof(buf), &sec1);
+ CYBOZU_TEST_ASSERT(0 < n && n <= FrSize * 2);
+ ret = blsSecretKeySetHexStr(&sec2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+
+ memset(&sec2, 0, sizeof(sec2));
+ n = blsSecretKeySerialize(buf, sizeof(buf), &sec1);
+ CYBOZU_TEST_EQUAL(n, FrSize);
+ ret = blsSecretKeyDeserialize(&sec2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+
+ blsPublicKey pub1, pub2;
+ blsGetPublicKey(&pub1, &sec1);
+ n = blsPublicKeySerialize(buf, sizeof(buf), &pub1);
+ CYBOZU_TEST_EQUAL(n, pubSize(FpSize));
+ ret = blsPublicKeyDeserialize(&pub2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
+ blsSignature sig1, sig2;
+ blsSign(&sig1, &sec1, msg, msgSize);
+ n = blsSignatureSerialize(buf, sizeof(buf), &sig1);
+ CYBOZU_TEST_EQUAL(n, sigSize(FpSize));
+ ret = blsSignatureDeserialize(&sig2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig1, &sig2));
+}
+
+void blsOrderTest(const char *curveOrder/*Fr*/, const char *fieldOrder/*Fp*/)
+{
+ char buf[1024];
+ size_t len;
+ len = blsGetCurveOrder(buf, sizeof(buf));
+ CYBOZU_TEST_ASSERT(len > 0);
+ CYBOZU_TEST_EQUAL(buf, curveOrder);
+ len = blsGetFieldOrder(buf, sizeof(buf));
+ CYBOZU_TEST_ASSERT(len > 0);
+ CYBOZU_TEST_EQUAL(buf, fieldOrder);
+}
+
+#if !defined(DISABLE_THREAD_TEST) || defined(__clang__)
+#if defined(CYBOZU_CPP_VERSION) && CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
+#include <thread>
+#include <vector>
+struct Thread {
+ std::unique_ptr<std::thread> t;
+ Thread() : t() {}
+ ~Thread()
+ {
+ if (t) {
+ t->join();
+ }
+ }
+ template<class F>
+ void run(F func, int p1, int p2)
+ {
+ t.reset(new std::thread(func, p1, p2));
+ }
+};
+
+CYBOZU_TEST_AUTO(multipleInit)
+{
+ const size_t n = 100;
+ {
+ std::vector<Thread> vt(n);
+ for (size_t i = 0; i < n; i++) {
+ vt[i].run(blsInit, MCL_BN254, MCLBN_COMPILED_TIME_VAR);
+ }
+ }
+ CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 4u);
+#if MCLBN_FP_UNIT_SIZE == 6
+ {
+ std::vector<Thread> vt(n);
+ for (size_t i = 0; i < n; i++) {
+ vt[i].run(blsInit, MCL_BLS12_381, MCLBN_COMPILED_TIME_VAR);
+ }
+ }
+ CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 6u);
+#endif
+}
+#endif
+#endif
+
+void blsSerializeTest()
+{
+ const size_t FrSize = blsGetFrByteSize();
+ const size_t FpSize = blsGetG1ByteSize();
+ printf("FrSize=%d, FpSize=%d\n", (int)FrSize, (int)FpSize);
+ blsId id1, id2;
+ blsSecretKey sec1, sec2;
+ blsPublicKey pub1, pub2;
+ blsSignature sig1, sig2;
+ char buf[1024];
+ size_t n;
+ size_t expectSize;
+ size_t ret;
+ const char dummyChar = '1';
+
+ // Id
+ expectSize = FrSize;
+ blsIdSetInt(&id1, -1);
+ n = blsIdSerialize(buf, sizeof(buf), &id1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+
+ ret = blsIdDeserialize(&id2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsIdIsEqual(&id1, &id2));
+
+ ret = blsIdDeserialize(&id2, buf, n - 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+
+ memset(&id2, 0, sizeof(id2));
+ buf[n] = dummyChar;
+ ret = blsIdDeserialize(&id2, buf, n + 1);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsIdIsEqual(&id1, &id2));
+
+ n = blsIdSerialize(buf, expectSize, &id1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+
+ // SecretKey
+ expectSize = FrSize;
+ blsSecretKeySetDecStr(&sec1, "-1", 2);
+ n = blsSecretKeySerialize(buf, sizeof(buf), &sec1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+
+ ret = blsSecretKeyDeserialize(&sec2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+
+ ret = blsSecretKeyDeserialize(&sec2, buf, n - 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+
+ memset(&sec2, 0, sizeof(sec2));
+ buf[n] = dummyChar;
+ ret = blsSecretKeyDeserialize(&sec2, buf, n + 1);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+
+ n = blsSecretKeySerialize(buf, expectSize, &sec1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+
+ // PublicKey
+ expectSize = pubSize(FpSize);
+ blsGetPublicKey(&pub1, &sec1);
+ n = blsPublicKeySerialize(buf, sizeof(buf), &pub1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsValidOrder(&pub1));
+
+ ret = blsPublicKeyDeserialize(&pub2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
+
+ ret = blsPublicKeyDeserialize(&pub2, buf, n - 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+
+ memset(&pub2, 0, sizeof(pub2));
+ buf[n] = dummyChar;
+ ret = blsPublicKeyDeserialize(&pub2, buf, n + 1);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
+
+ n = blsPublicKeySerialize(buf, expectSize, &pub1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+
+ // Signature
+#ifdef BLS_SWAP_G
+ expectSize = FpSize * 2;
+#else
+ expectSize = FpSize;
+#endif
+ blsSign(&sig1, &sec1, "abc", 3);
+ n = blsSignatureSerialize(buf, sizeof(buf), &sig1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+ CYBOZU_TEST_ASSERT(blsSignatureIsValidOrder(&sig1));
+
+ ret = blsSignatureDeserialize(&sig2, buf, n);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig1, &sig2));
+
+ ret = blsSignatureDeserialize(&sig2, buf, n - 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+
+ memset(&sig2, 0, sizeof(sig2));
+ buf[n] = dummyChar;
+ ret = blsSignatureDeserialize(&sig2, buf, n + 1);
+ CYBOZU_TEST_EQUAL(ret, n);
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig1, &sig2));
+
+ n = blsSignatureSerialize(buf, expectSize, &sig1);
+ CYBOZU_TEST_EQUAL(n, expectSize);
+}
+
+void blsVerifyOrderTest()
+{
+ puts("blsVerifyOrderTest");
+#ifdef BLS_SWAP_G
+ const uint8_t Qs[] =
+#else
+ const uint8_t Ps[] =
+#endif
+ {
+0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ };
+#ifdef BLS_SWAP_G
+ const uint8_t Ps[] =
+#else
+ const uint8_t Qs[] =
+#endif
+ {
+0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ };
+ size_t n;
+ blsPublicKey pub;
+ n = blsPublicKeyDeserialize(&pub, Ps, sizeof(Ps));
+ CYBOZU_TEST_EQUAL(n, 0);
+ blsPublicKeyVerifyOrder(0);
+ n = blsPublicKeyDeserialize(&pub, Ps, sizeof(Ps));
+ CYBOZU_TEST_ASSERT(n > 0);
+ CYBOZU_TEST_ASSERT(!blsPublicKeyIsValidOrder(&pub));
+ blsPublicKeyVerifyOrder(1);
+
+ blsSignature sig;
+ n = blsSignatureDeserialize(&sig, Qs, sizeof(Qs));
+ CYBOZU_TEST_EQUAL(n, 0);
+ blsSignatureVerifyOrder(0);
+ n = blsSignatureDeserialize(&sig, Qs, sizeof(Qs));
+ CYBOZU_TEST_ASSERT(n > 0);
+ CYBOZU_TEST_ASSERT(!blsSignatureIsValidOrder(&sig));
+ blsSignatureVerifyOrder(1);
+}
+
+void blsAddSubTest()
+{
+ blsSecretKey sec[3];
+ blsPublicKey pub[3];
+ blsSignature sig[3];
+ const char *msg = "this is a pen";
+ const size_t msgSize = strlen(msg);
+
+ const char *secHexStr[8] = { "12", "34" };
+ for (int i = 0; i < 2; i++) {
+ blsSecretKeySetHexStr(&sec[i], secHexStr[i], strlen(secHexStr[i]));
+ blsGetPublicKey(&pub[i], &sec[i]);
+ blsSign(&sig[i], &sec[i], msg, msgSize);
+ }
+ sec[2] = sec[0];
+ blsSecretKeyAdd(&sec[2], &sec[1]);
+ char buf[1024];
+ size_t n = blsSecretKeyGetHexStr(buf, sizeof(buf), &sec[2]);
+ CYBOZU_TEST_EQUAL(n, 2);
+ CYBOZU_TEST_EQUAL(buf, "46"); // "12" + "34"
+
+ pub[2] = pub[0];
+ blsPublicKeyAdd(&pub[2], &pub[1]);
+ sig[2] = sig[0];
+ blsSignatureAdd(&sig[2], &sig[1]); // sig[2] = sig[0] + sig[1]
+ blsSignature sig2;
+ blsSign(&sig2, &sec[2], msg, msgSize); // sig2 = signature by sec[2]
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig2, &sig[2]));
+ CYBOZU_TEST_ASSERT(blsVerify(&sig[2], &pub[2], msg, msgSize)); // verify by pub[2]
+
+ blsSecretKeySub(&sec[2], &sec[1]);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec[2], &sec[0]));
+ blsPublicKeySub(&pub[2], &pub[1]);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub[2], &pub[0]));
+ blsSignatureSub(&sig[2], &sig[1]);
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig[2], &sig[0]));
+}
+
+void blsTrivialShareTest()
+{
+ blsSecretKey sec1, sec2;
+ blsPublicKey pub1, pub2;
+ blsId id;
+ blsIdSetInt(&id, 123);
+
+ blsSecretKeySetByCSPRNG(&sec1);
+ blsGetPublicKey(&pub1, &sec1);
+ int ret;
+
+ memset(&sec2, 0, sizeof(sec2));
+ ret = blsSecretKeyShare(&sec2, &sec1, 1, &id);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+ memset(&sec2, 0, sizeof(sec2));
+ ret = blsSecretKeyRecover(&sec2, &sec1, &id, 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
+
+ memset(&pub2, 0, sizeof(pub2));
+ ret = blsPublicKeyShare(&pub2, &pub1, 1, &id);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
+ memset(&pub2, 0, sizeof(pub2));
+ ret = blsPublicKeyRecover(&pub2, &pub1, &id, 1);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
+}
+
+void modTest(const char *rStr)
+{
+ unsigned char buf[1024] = {};
+ int ret;
+ blsSecretKey sec;
+ const size_t maxByte = 64; // 512-bit
+ memset(buf, 0xff, maxByte);
+ ret = blsSecretKeySetLittleEndianMod(&sec, buf, maxByte);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ const mpz_class x = (mpz_class(1) << (maxByte * 8)) - 1; // 512-bit 0xff....ff
+ const mpz_class r(rStr);
+ size_t n = blsSecretKeySerialize(buf, sizeof(buf), &sec);
+ CYBOZU_TEST_ASSERT(n > 0);
+ // serialized data to mpz_class
+ mpz_class y = 0;
+ for (size_t i = 0; i < n; i++) {
+ y <<= 8;
+ y += buf[n - 1 - i];
+ }
+ CYBOZU_TEST_EQUAL(y, x % r);
+}
+
+void blsBench()
+{
+ blsSecretKey sec;
+ blsPublicKey pub;
+ blsSignature sig;
+ const char *msg = "this is a pen";
+ const size_t msgSize = strlen(msg);
+
+ blsSecretKeySetByCSPRNG(&sec);
+
+ blsGetPublicKey(&pub, &sec);
+
+ CYBOZU_BENCH_C("sign", 10000, blsSign, &sig, &sec, msg, msgSize);
+ CYBOZU_BENCH_C("verify", 1000, blsVerify, &sig, &pub, msg, msgSize);
+}
+
+CYBOZU_TEST_AUTO(all)
+{
+ const struct {
+ int curveType;
+ const char *r;
+ const char *p;
+ } tbl[] = {
+ {
+ MCL_BN254,
+ "16798108731015832284940804142231733909759579603404752749028378864165570215949",
+ "16798108731015832284940804142231733909889187121439069848933715426072753864723",
+ },
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
+ {
+ MCL_BN381_1,
+ "5540996953667913971058039301942914304734176495422447785042938606876043190415948413757785063597439175372845535461389",
+ "5540996953667913971058039301942914304734176495422447785045292539108217242186829586959562222833658991069414454984723",
+ },
+#endif
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE >= 4
+ {
+ MCL_BLS12_381,
+ "52435875175126190479447740508185965837690552500527637822603658699938581184513",
+ "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
+ },
+#endif
+ };
+ for (size_t i = 0; i < sizeof(tbl) / sizeof(tbl[0]); i++) {
+ printf("i=%d\n", (int)i);
+ int ret = blsInit(tbl[i].curveType, MCLBN_COMPILED_TIME_VAR);
+ CYBOZU_TEST_EQUAL(ret, 0);
+ if (ret) {
+ printf("ERR %d\n", ret);
+ exit(1);
+ }
+ bls_use_stackTest();
+ blsDataTest();
+ blsOrderTest(tbl[i].r, tbl[i].p);
+ blsSerializeTest();
+ if (tbl[i].curveType == MCL_BLS12_381) blsVerifyOrderTest();
+ blsAddSubTest();
+ blsTrivialShareTest();
+ modTest(tbl[i].r);
+ blsBench();
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/test/bls_test.hpp b/vendor/github.com/tangerine-network/bls/test/bls_test.hpp
new file mode 100644
index 000000000..346fafe15
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/bls_test.hpp
@@ -0,0 +1,545 @@
+#include <bls/bls.hpp>
+#include <cybozu/test.hpp>
+#include <cybozu/inttype.hpp>
+#include <iostream>
+#include <sstream>
+#include <cybozu/benchmark.hpp>
+#include <cybozu/sha2.hpp>
+
+template<class T>
+void streamTest(const T& t)
+{
+ std::ostringstream oss;
+ oss << t;
+ std::istringstream iss(oss.str());
+ T t2;
+ iss >> t2;
+ CYBOZU_TEST_EQUAL(t, t2);
+}
+
+template<class T>
+void testSetForBN254()
+{
+ /*
+ mask value to be less than r if the value >= (1 << (192 + 62))
+ */
+ const uint64_t fff = uint64_t(-1);
+ const uint64_t one = uint64_t(1);
+ const struct {
+ uint64_t in;
+ uint64_t expected;
+ } tbl[] = {
+ { fff, (one << 61) - 1 }, // masked with (1 << 61) - 1
+ { one << 62, 0 }, // masked
+ { (one << 62) | (one << 61), (one << 61) }, // masked
+ { (one << 61) - 1, (one << 61) - 1 }, // same
+ };
+ T t1, t2;
+ for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
+ uint64_t v1[] = { fff, fff, fff, tbl[i].in };
+ uint64_t v2[] = { fff, fff, fff, tbl[i].expected };
+ t1.set(v1);
+ t2.set(v2);
+ CYBOZU_TEST_EQUAL(t1, t2);
+ }
+}
+
+void testForBN254()
+{
+ CYBOZU_TEST_EQUAL(bls::getOpUnitSize(), 4);
+ bls::Id id;
+ CYBOZU_TEST_ASSERT(id.isZero());
+ id = 5;
+ CYBOZU_TEST_EQUAL(id, 5);
+ {
+ const uint64_t id1[] = { 1, 2, 3, 4 };
+ id.set(id1);
+ std::ostringstream os;
+ os << id;
+ CYBOZU_TEST_EQUAL(os.str(), "0x4000000000000000300000000000000020000000000000001");
+ }
+ testSetForBN254<bls::Id>();
+ testSetForBN254<bls::SecretKey>();
+}
+
+void hashTest(int type)
+{
+ bls::SecretKey sec;
+ sec.init();
+ bls::PublicKey pub;
+ sec.getPublicKey(pub);
+ const std::string h = "\x01\x02\x03";
+ bls::Signature sig;
+ sec.signHash(sig, h);
+ CYBOZU_TEST_ASSERT(sig.verifyHash(pub, h));
+ CYBOZU_TEST_ASSERT(!sig.verifyHash(pub, "\x01\x02\04"));
+ if (type == MCL_BN254) {
+ CYBOZU_TEST_EXCEPTION(sec.signHash(sig, "", 0), std::exception);
+ CYBOZU_TEST_EXCEPTION(sec.signHash(sig, "\x00", 1), std::exception);
+ CYBOZU_TEST_EXCEPTION(sec.signHash(sig, "\x00\x00", 2), std::exception);
+#ifndef BLS_SWAP_G
+ const uint64_t c1[] = { 0x0c00000000000004ull, 0xcf0f000000000006ull, 0x26cd890000000003ull, 0x2523648240000001ull };
+ const uint64_t mc1[] = { 0x9b0000000000000full, 0x921200000000000dull, 0x9366c48000000004ull };
+ CYBOZU_TEST_EXCEPTION(sec.signHash(sig, c1, 32), std::exception);
+ CYBOZU_TEST_EXCEPTION(sec.signHash(sig, mc1, 24), std::exception);
+#endif
+ }
+}
+
+void blsTest()
+{
+ bls::SecretKey sec;
+ sec.init();
+ streamTest(sec);
+ bls::PublicKey pub;
+ sec.getPublicKey(pub);
+ streamTest(pub);
+ for (int i = 0; i < 5; i++) {
+ std::string m = "hello";
+ m += char('0' + i);
+ bls::Signature sig;
+ sec.sign(sig, m);
+ CYBOZU_TEST_ASSERT(sig.verify(pub, m));
+ CYBOZU_TEST_ASSERT(!sig.verify(pub, m + "a"));
+ streamTest(sig);
+ CYBOZU_BENCH_C("sign", 10000, sec.sign, sig, m);
+ CYBOZU_BENCH_C("verify", 1000, sig.verify, pub, m);
+ }
+}
+
+void k_of_nTest()
+{
+ const std::string m = "abc";
+ const int n = 5;
+ const int k = 3;
+ bls::SecretKey sec0;
+ sec0.init();
+ bls::Signature sig0;
+ sec0.sign(sig0, m);
+ bls::PublicKey pub0;
+ sec0.getPublicKey(pub0);
+ CYBOZU_TEST_ASSERT(sig0.verify(pub0, m));
+
+ bls::SecretKeyVec msk;
+ sec0.getMasterSecretKey(msk, k);
+
+ bls::SecretKeyVec allPrvVec(n);
+ bls::IdVec allIdVec(n);
+ for (int i = 0; i < n; i++) {
+ int id = i + 1;
+ allPrvVec[i].set(msk, id);
+ allIdVec[i] = id;
+
+ bls::SecretKey p;
+ p.set(msk.data(), k, id);
+ CYBOZU_TEST_EQUAL(allPrvVec[i], p);
+ }
+
+ bls::SignatureVec allSigVec(n);
+ for (int i = 0; i < n; i++) {
+ CYBOZU_TEST_ASSERT(allPrvVec[i] != sec0);
+ allPrvVec[i].sign(allSigVec[i], m);
+ bls::PublicKey pub;
+ allPrvVec[i].getPublicKey(pub);
+ CYBOZU_TEST_ASSERT(pub != pub0);
+ CYBOZU_TEST_ASSERT(allSigVec[i].verify(pub, m));
+ }
+
+ /*
+ 3-out-of-n
+ can recover
+ */
+ bls::SecretKeyVec secVec(3);
+ bls::IdVec idVec(3);
+ for (int a = 0; a < n; a++) {
+ secVec[0] = allPrvVec[a];
+ idVec[0] = allIdVec[a];
+ for (int b = a + 1; b < n; b++) {
+ secVec[1] = allPrvVec[b];
+ idVec[1] = allIdVec[b];
+ for (int c = b + 1; c < n; c++) {
+ secVec[2] = allPrvVec[c];
+ idVec[2] = allIdVec[c];
+ bls::SecretKey sec;
+ sec.recover(secVec, idVec);
+ CYBOZU_TEST_EQUAL(sec, sec0);
+ bls::SecretKey sec2;
+ sec2.recover(secVec.data(), idVec.data(), secVec.size());
+ CYBOZU_TEST_EQUAL(sec, sec2);
+ }
+ }
+ }
+ {
+ secVec[0] = allPrvVec[0];
+ secVec[1] = allPrvVec[1];
+ secVec[2] = allPrvVec[0]; // same of secVec[0]
+ idVec[0] = allIdVec[0];
+ idVec[1] = allIdVec[1];
+ idVec[2] = allIdVec[0];
+ bls::SecretKey sec;
+ CYBOZU_TEST_EXCEPTION_MESSAGE(sec.recover(secVec, idVec), std::exception, "same id");
+ }
+ {
+ /*
+ n-out-of-n
+ can recover
+ */
+ bls::SecretKey sec;
+ sec.recover(allPrvVec, allIdVec);
+ CYBOZU_TEST_EQUAL(sec, sec0);
+ }
+ /*
+ 2-out-of-n
+ can't recover
+ */
+ secVec.resize(2);
+ idVec.resize(2);
+ for (int a = 0; a < n; a++) {
+ secVec[0] = allPrvVec[a];
+ idVec[0] = allIdVec[a];
+ for (int b = a + 1; b < n; b++) {
+ secVec[1] = allPrvVec[b];
+ idVec[1] = allIdVec[b];
+ bls::SecretKey sec;
+ sec.recover(secVec, idVec);
+ CYBOZU_TEST_ASSERT(sec != sec0);
+ }
+ }
+ /*
+ 3-out-of-n
+ can recover
+ */
+ bls::SignatureVec sigVec(3);
+ idVec.resize(3);
+ for (int a = 0; a < n; a++) {
+ sigVec[0] = allSigVec[a];
+ idVec[0] = allIdVec[a];
+ for (int b = a + 1; b < n; b++) {
+ sigVec[1] = allSigVec[b];
+ idVec[1] = allIdVec[b];
+ for (int c = b + 1; c < n; c++) {
+ sigVec[2] = allSigVec[c];
+ idVec[2] = allIdVec[c];
+ bls::Signature sig;
+ sig.recover(sigVec, idVec);
+ CYBOZU_TEST_EQUAL(sig, sig0);
+ }
+ }
+ }
+ {
+ sigVec[0] = allSigVec[1]; idVec[0] = allIdVec[1];
+ sigVec[1] = allSigVec[4]; idVec[1] = allIdVec[4];
+ sigVec[2] = allSigVec[3]; idVec[2] = allIdVec[3];
+ bls::Signature sig;
+ CYBOZU_BENCH_C("sig.recover", 100, sig.recover, sigVec, idVec);
+ }
+ {
+ /*
+ n-out-of-n
+ can recover
+ */
+ bls::Signature sig;
+ sig.recover(allSigVec, allIdVec);
+ CYBOZU_TEST_EQUAL(sig, sig0);
+ }
+ /*
+ 2-out-of-n
+ can't recover
+ */
+ sigVec.resize(2);
+ idVec.resize(2);
+ for (int a = 0; a < n; a++) {
+ sigVec[0] = allSigVec[a];
+ idVec[0] = allIdVec[a];
+ for (int b = a + 1; b < n; b++) {
+ sigVec[1] = allSigVec[b];
+ idVec[1] = allIdVec[b];
+ bls::Signature sig;
+ sig.recover(sigVec, idVec);
+ CYBOZU_TEST_ASSERT(sig != sig0);
+ }
+ }
+ // return same value if n = 1
+ sigVec.resize(1);
+ idVec.resize(1);
+ sigVec[0] = allSigVec[0];
+ idVec[0] = allIdVec[0];
+ {
+ bls::Signature sig;
+ sig.recover(sigVec, idVec);
+ CYBOZU_TEST_EQUAL(sig, sigVec[0]);
+ }
+ // share and recover publicKey
+ {
+ bls::PublicKeyVec pubVec(k);
+ idVec.resize(k);
+ // select [0, k) publicKey
+ for (int i = 0; i < k; i++) {
+ allPrvVec[i].getPublicKey(pubVec[i]);
+ idVec[i] = allIdVec[i];
+ }
+ bls::PublicKey pub;
+ pub.recover(pubVec, idVec);
+ CYBOZU_TEST_EQUAL(pub, pub0);
+ bls::PublicKey pub2;
+ pub2.recover(pubVec.data(), idVec.data(), pubVec.size());
+ CYBOZU_TEST_EQUAL(pub, pub2);
+ }
+}
+
+void popTest()
+{
+ const size_t k = 3;
+ const size_t n = 6;
+ const std::string m = "pop test";
+ bls::SecretKey sec0;
+ sec0.init();
+ bls::PublicKey pub0;
+ sec0.getPublicKey(pub0);
+ bls::Signature sig0;
+ sec0.sign(sig0, m);
+ CYBOZU_TEST_ASSERT(sig0.verify(pub0, m));
+
+ bls::SecretKeyVec msk;
+ sec0.getMasterSecretKey(msk, k);
+
+ bls::PublicKeyVec mpk;
+ bls::getMasterPublicKey(mpk, msk);
+ bls::SignatureVec popVec;
+ bls::getPopVec(popVec, msk);
+
+ for (size_t i = 0; i < popVec.size(); i++) {
+ CYBOZU_TEST_ASSERT(popVec[i].verify(mpk[i]));
+ }
+
+ const int idTbl[n] = {
+ 3, 5, 193, 22, 15
+ };
+ bls::SecretKeyVec secVec(n);
+ bls::PublicKeyVec pubVec(n);
+ bls::SignatureVec sVec(n);
+ for (size_t i = 0; i < n; i++) {
+ int id = idTbl[i];
+ secVec[i].set(msk, id);
+ secVec[i].getPublicKey(pubVec[i]);
+ bls::PublicKey pub;
+ pub.set(mpk, id);
+ CYBOZU_TEST_EQUAL(pubVec[i], pub);
+
+ bls::Signature pop;
+ secVec[i].getPop(pop);
+ CYBOZU_TEST_ASSERT(pop.verify(pubVec[i]));
+
+ secVec[i].sign(sVec[i], m);
+ CYBOZU_TEST_ASSERT(sVec[i].verify(pubVec[i], m));
+ }
+ secVec.resize(k);
+ sVec.resize(k);
+ bls::IdVec idVec(k);
+ for (size_t i = 0; i < k; i++) {
+ idVec[i] = idTbl[i];
+ }
+ bls::SecretKey sec;
+ sec.recover(secVec, idVec);
+ CYBOZU_TEST_EQUAL(sec, sec0);
+ bls::Signature sig;
+ sig.recover(sVec, idVec);
+ CYBOZU_TEST_EQUAL(sig, sig0);
+ bls::Signature sig2;
+ sig2.recover(sVec.data(), idVec.data(), sVec.size());
+ CYBOZU_TEST_EQUAL(sig, sig2);
+}
+
+void addTest()
+{
+ bls::SecretKey sec1, sec2;
+ sec1.init();
+ sec2.init();
+ CYBOZU_TEST_ASSERT(sec1 != sec2);
+
+ bls::PublicKey pub1, pub2;
+ sec1.getPublicKey(pub1);
+ sec2.getPublicKey(pub2);
+
+ const std::string m = "doremi";
+ bls::Signature sig1, sig2;
+ sec1.sign(sig1, m);
+ sec2.sign(sig2, m);
+ CYBOZU_TEST_ASSERT((sig1 + sig2).verify(pub1 + pub2, m));
+}
+
+void aggregateTest()
+{
+ const size_t n = 10;
+ bls::SecretKey secs[n];
+ bls::PublicKey pubs[n], pub;
+ bls::Signature sigs[n], sig;
+ const std::string m = "abc";
+ for (size_t i = 0; i < n; i++) {
+ secs[i].init();
+ secs[i].getPublicKey(pubs[i]);
+ secs[i].sign(sigs[i], m);
+ }
+ pub = pubs[0];
+ sig = sigs[0];
+ for (size_t i = 1; i < n; i++) {
+ pub.add(pubs[i]);
+ sig.add(sigs[i]);
+ }
+ CYBOZU_TEST_ASSERT(sig.verify(pub, m));
+}
+
+void dataTest()
+{
+ const size_t FrSize = bls::getFrByteSize();
+ const size_t FpSize = bls::getG1ByteSize();
+ bls::SecretKey sec;
+ sec.init();
+ std::string str;
+ sec.getStr(str, bls::IoFixedByteSeq);
+ {
+ CYBOZU_TEST_EQUAL(str.size(), FrSize);
+ bls::SecretKey sec2;
+ sec2.setStr(str, bls::IoFixedByteSeq);
+ CYBOZU_TEST_EQUAL(sec, sec2);
+ }
+ bls::PublicKey pub;
+ sec.getPublicKey(pub);
+ pub.getStr(str, bls::IoFixedByteSeq);
+ {
+#ifdef BLS_SWAP_G
+ CYBOZU_TEST_EQUAL(str.size(), FpSize);
+#else
+ CYBOZU_TEST_EQUAL(str.size(), FpSize * 2);
+#endif
+ bls::PublicKey pub2;
+ pub2.setStr(str, bls::IoFixedByteSeq);
+ CYBOZU_TEST_EQUAL(pub, pub2);
+ }
+ std::string m = "abc";
+ bls::Signature sign;
+ sec.sign(sign, m);
+ sign.getStr(str, bls::IoFixedByteSeq);
+ {
+#ifdef BLS_SWAP_G
+ CYBOZU_TEST_EQUAL(str.size(), FpSize * 2);
+#else
+ CYBOZU_TEST_EQUAL(str.size(), FpSize);
+#endif
+ bls::Signature sign2;
+ sign2.setStr(str, bls::IoFixedByteSeq);
+ CYBOZU_TEST_EQUAL(sign, sign2);
+ }
+ bls::Id id;
+ const uint64_t v[] = { 1, 2, 3, 4, 5, 6, };
+ id.set(v);
+ id.getStr(str, bls::IoFixedByteSeq);
+ {
+ CYBOZU_TEST_EQUAL(str.size(), FrSize);
+ bls::Id id2;
+ id2.setStr(str, bls::IoFixedByteSeq);
+ CYBOZU_TEST_EQUAL(id, id2);
+ }
+}
+
+void verifyAggregateTest()
+{
+ const size_t n = 10;
+ bls::SecretKey secs[n];
+ bls::PublicKey pubs[n];
+ bls::Signature sigs[n], sig;
+ const size_t sizeofHash = 32;
+ struct Hash { char data[sizeofHash]; };
+ std::vector<Hash> h(n);
+ for (size_t i = 0; i < n; i++) {
+ char msg[128];
+ CYBOZU_SNPRINTF(msg, sizeof(msg), "abc-%d", (int)i);
+ const size_t msgSize = strlen(msg);
+ cybozu::Sha256().digest(h[i].data, sizeofHash, msg, msgSize);
+ secs[i].init();
+ secs[i].getPublicKey(pubs[i]);
+ secs[i].signHash(sigs[i], h[i].data, sizeofHash);
+ }
+ sig = sigs[0];
+ for (size_t i = 1; i < n; i++) {
+ sig.add(sigs[i]);
+ }
+ CYBOZU_TEST_ASSERT(sig.verifyAggregatedHashes(pubs, h.data(), sizeofHash, n));
+ bls::Signature invalidSig = sigs[0] + sigs[1];
+ CYBOZU_TEST_ASSERT(!invalidSig.verifyAggregatedHashes(pubs, h.data(), sizeofHash, n));
+ h[0].data[0]++;
+ CYBOZU_TEST_ASSERT(!sig.verifyAggregatedHashes(pubs, h.data(), sizeofHash, n));
+}
+
+unsigned int writeSeq(void *self, void *buf, unsigned int bufSize)
+{
+ int& seq = *(int*)self;
+ char *p = (char *)buf;
+ for (unsigned int i = 0; i < bufSize; i++) {
+ p[i] = char(seq++);
+ }
+ return bufSize;
+}
+
+void setRandFuncTest()
+{
+ blsSecretKey sec;
+ const int seqInit1 = 5;
+ int seq = seqInit1;
+ blsSetRandFunc(&seq, writeSeq);
+ blsSecretKeySetByCSPRNG(&sec);
+ unsigned char buf[128];
+ size_t n = blsSecretKeySerialize(buf, sizeof(buf), &sec);
+ CYBOZU_TEST_ASSERT(n > 0);
+ for (size_t i = 0; i < n - 1; i++) {
+ // ommit buf[n - 1] because it may be masked
+ CYBOZU_TEST_EQUAL(buf[i], seqInit1 + i);
+ }
+ // use default CSPRNG
+ blsSetRandFunc(0, 0);
+ blsSecretKeySetByCSPRNG(&sec);
+ n = blsSecretKeySerialize(buf, sizeof(buf), &sec);
+ CYBOZU_TEST_ASSERT(n > 0);
+ printf("sec=");
+ for (size_t i = 0; i < n; i++) {
+ printf("%02x", buf[i]);
+ }
+ printf("\n");
+}
+
+void testAll()
+{
+ blsTest();
+ k_of_nTest();
+ popTest();
+ addTest();
+ dataTest();
+ aggregateTest();
+ verifyAggregateTest();
+ setRandFuncTest();
+}
+CYBOZU_TEST_AUTO(all)
+{
+ const struct {
+ int type;
+ const char *name;
+ } tbl[] = {
+ { MCL_BN254, "BN254" },
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
+ { MCL_BN381_1, "BN381_1" },
+#endif
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4
+ { MCL_BLS12_381, "BLS12_381" },
+#endif
+ };
+ for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
+ printf("curve=%s\n", tbl[i].name);
+ int type = tbl[i].type;
+ bls::init(type);
+ if (type == MCL_BN254) {
+ testForBN254();
+ }
+ testAll();
+ hashTest(type);
+ }
+}
diff --git a/vendor/github.com/tangerine-network/bls/test/proj/bls_test/bls_test.vcxproj b/vendor/github.com/tangerine-network/bls/test/proj/bls_test/bls_test.vcxproj
new file mode 100644
index 000000000..1755135fb
--- /dev/null
+++ b/vendor/github.com/tangerine-network/bls/test/proj/bls_test/bls_test.vcxproj
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{51266DE6-B57B-4AE3-B85C-282F170E1728}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>fp_test</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(SolutionDir)common.props" />
+ <Import Project="$(SolutionDir)debug.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(SolutionDir)common.props" />
+ <Import Project="$(SolutionDir)release.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="$(SolutionDir)test\\bls_test.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file