Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Sep 2, 2024
2 parents fe5a143 + ddde52f commit 7ee34b6
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 96 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ foreach(bit IN ITEMS 256 384 384_256)
target_include_directories(bls${bit} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_DIR}/include>)
target_link_libraries(bls${bit} PUBLIC mcl::mclbn${bit})
target_link_libraries(bls${bit} PUBLIC mcl::mcl mcl::mcl_st mcl::mclbn${bit})
set_target_properties(bls${bit} PROPERTIES
POSITION_INDEPENDENT_CODE ON
VERSION ${bls_VERSION}
Expand All @@ -81,8 +81,7 @@ set(CMAKE_EXPORT_PACKAGE_REGISTERY ON)
export(PACKAGE bls)

# Tests
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR BLS_BUILD_TESTING)
AND BUILD_TESTING)
if(BLS_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
19 changes: 18 additions & 1 deletion Makefile.onelib
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ BINT_OBJ=$(MCL_DIR)/$(OBJ_DIR)/bint$(BIT).o

ifeq ($(CPU),x86-64)
_ARCH=amd64
MSM=msm_avx
MCL_MSM?=1
endif
ifeq ($(CPU),aarch64)
_ARCH=arm64
Expand Down Expand Up @@ -70,6 +72,11 @@ ifeq ($(MCL_USE_LLVM),1)
MIN_CFLAGS+=-DMCL_USE_LLVM=1
OBJS+=$(BASE_OBJ)
endif
ifeq ($(MCL_MSM),1)
MIN_CFLAGS+=-DMCL_MSM=1
MSM_OBJ=$(MCL_DIR)/$(OBJ_DIR)/$(MSM).o
OBJS+=$(MSM_OBJ)
endif

LIB_DIR?=$(OUT_DIR)/bls/lib/$(_OS)/$(_ARCH)
STATIC_LIB=$(LIB_DIR)/libbls384_256.a
Expand Down Expand Up @@ -120,6 +127,9 @@ $(BINT_OBJ):
$(BASE_OBJ):
$(MAKE) -C $(MCL_DIR) obj/base$(BIT).o CPU=$(CPU) OS=$(OS) BIT=$(BIT)

$(MSM_OBJ): $(MCL_DIR)/src/$(MSM).cpp
$(CXX) -c $< -o $@ $(MIN_CFLAGS) -mavx512f -mavx512ifma -std=c++11

ANDROID_TARGET=armeabi-v7a arm64-v8a x86_64
NDK_BUILD?=ndk-build
android: $(BASE_LL)
Expand Down Expand Up @@ -182,14 +192,21 @@ endif
ranlib $(IOS_OUTDIR)/$(IOS_LIB)

# cross compile
# e.g. make -f Makefile.onelib CXX=clang++ AS=clang++ build_aarch64 LLVM_VER=-12
#Try a compiler option `-isystem <include directory>` if you have trouble with including standard heder file.
# make -f Makefile.onelib build_aarch64 CXX=clang++ LLVM_VER=-18 build_aarch64
# aarch64-linux-gnu-gcc-13 sample/minsample.c bls/lib/linux/arm64/libbls384_256.a -I include/ -I mcl/include/
# env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ ./a.out
build_aarch64:
$(MAKE) -f $(THIS_FILE) ARCH=aarch64 CLANG_TARGET=aarch64
# $(CXX) -target aarch64 test/bls_c384_256_test.cpp -I ./include -I mcl/include bls/lib/linux/arm64/libbls384_256.a
build_i686:
$(MAKE) -f $(THIS_FILE) ARCH=x86 CLANG_TARGET=i686
# g++ -m32 test/bls_c384_256_test.cpp -I ./include -I mcl/include bls/lib/linux/libbls384_256.a

#make -f Makefile.onelib ARCH=mipsisa32r6el CLANG_TARGET=mipsisa32r6el BIT=32 CXX=clang++-17
#mipsisa32r6el-linux-gnu-gcc-13 sample/minsample.c -I include/ -I mcl/include/ bls/lib/linux/libbls384_256.a
#env QEMU_LD_PREFIX=/usr/mipsisa32r6el-linux-gnu/ ./a.out

clean:
$(MAKE) -C $(MCL_DIR) clean
$(MAKE) -C $(BLS_DIR) clean
Expand Down
46 changes: 38 additions & 8 deletions bls.sln
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
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}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mcllib", "mcl\src\proj\mcllib\mcllib.vcxproj", "{E95F067C-F6CE-48D5-B6AB-E469211D5B43}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blslib", "src\proj\blslib\blslib.vcxproj", "{1DBB979A-C212-45CD-9563-446A96F87F71}"
ProjectSection(ProjectDependencies) = postProject
{E95F067C-F6CE-48D5-B6AB-E469211D5B43} = {E95F067C-F6CE-48D5-B6AB-E469211D5B43}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blsethlib", "src\proj\blsethlib\blsethlib.vcxproj", "{1DBB979A-C212-45CD-9463-446A96F87F72}"
ProjectSection(ProjectDependencies) = postProject
{E95F067C-F6CE-48D5-B6AB-E469211D5B43} = {E95F067C-F6CE-48D5-B6AB-E469211D5B43}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls_test", "test\proj\bls_test\bls_test.vcxproj", "{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}"
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}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls_eth_test", "test\proj\bls_eth_test\bls_eth_test.vcxproj", "{9F935350-2F4C-45FA-A1C2-1D5AA0EADC97}"
ProjectSection(ProjectDependencies) = postProject
{1DBB979A-C212-45CD-9463-446A96F87F72} = {1DBB979A-C212-45CD-9463-446A96F87F72}
EndProjectSection
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
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}.Debug|x64.ActiveCfg = Debug|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}.Debug|x64.Build.0 = Debug|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}.Release|x64.ActiveCfg = Release|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}.Release|x64.Build.0 = Release|x64
{1DBB979A-C212-45CD-9463-446A96F87F72}.Debug|x64.ActiveCfg = Debug|x64
{1DBB979A-C212-45CD-9463-446A96F87F72}.Debug|x64.Build.0 = Debug|x64
{1DBB979A-C212-45CD-9463-446A96F87F72}.Release|x64.ActiveCfg = Release|x64
{1DBB979A-C212-45CD-9463-446A96F87F72}.Release|x64.Build.0 = Release|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC97}.Debug|x64.ActiveCfg = Debug|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC97}.Debug|x64.Build.0 = Debug|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC97}.Release|x64.ActiveCfg = Release|x64
{9F935350-2F4C-45FA-A1C2-1D5AA0EADC97}.Release|x64.Build.0 = Release|x64
{E95F067C-F6CE-48D5-B6AB-E469211D5B43}.Debug|x64.ActiveCfg = Debug|x64
{E95F067C-F6CE-48D5-B6AB-E469211D5B43}.Debug|x64.Build.0 = Debug|x64
{E95F067C-F6CE-48D5-B6AB-E469211D5B43}.Release|x64.ActiveCfg = Release|x64
{E95F067C-F6CE-48D5-B6AB-E469211D5B43}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {681C56BF-C724-4464-94A1-EAF22B6E7510}
EndGlobalSection
EndGlobal
13 changes: 3 additions & 10 deletions common.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)../cybozulib/include;$(SolutionDir)../cybozulib_ext/include;$(SolutionDir)include;$(SolutionDir)../mcl/include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>include;mcl/include;$(SolutionDir)\mcl\include;$(SolutionDir)\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>
<AdditionalLibraryDirectories>$(SolutionDir)lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
</Project>
14 changes: 0 additions & 14 deletions debug.props

This file was deleted.

2 changes: 1 addition & 1 deletion mcl
Submodule mcl updated 58 files
+32 −0 .github/CONTRIBUTING.md
+4 −1 .github/workflows/main.yml
+50 −8 CMakeLists.txt
+32 −5 Makefile
+17 −5 api.md
+7 −3 common.mk
+3 −7 common.props
+0 −14 debug.props
+6 −9 include/cybozu/inttype.hpp
+16 −8 include/cybozu/serializer.hpp
+129 −1 include/mcl/bint.hpp
+3 −0 include/mcl/bn.h
+69 −27 include/mcl/bn.hpp
+7 −1 include/mcl/config.hpp
+146 −30 include/mcl/ec.hpp
+11 −48 include/mcl/fp.hpp
+2 −2 include/mcl/fp_tower.hpp
+33 −81 include/mcl/gmp_util.hpp
+4 −0 include/mcl/impl/bn_c_impl.hpp
+56 −4 include/mcl/op.hpp
+4 −4 include/mcl/operator.hpp
+18 −8 include/mcl/util.hpp
+7 −5 include/mcl/vint.hpp
+12 −36 mcl.sln
+130 −15 misc/internal.md
+138 −0 misc/mul-approx.py
+9 −7 misc/mulvec_test.cpp
+2 −1 mklib.bat
+10 −2 readme.md
+0 −12 release.props
+1 −1 sample/CMakeLists.txt
+1 −0 sample/mt_test.cpp
+1 −1 setvar.bat
+1,266 −0 src/asm/bint-x64-amd64.S
+6,185 −0 src/asm/bint-x64-mingw.S
+1,394 −0 src/asm/bint-x64-win.asm
+464 −0 src/avx512.hpp
+3 −1 src/fp.cpp
+123 −122 src/gen_bint_header.py
+607 −0 src/gen_bint_x64.py
+96 −0 src/gen_msm_para.py
+99 −0 src/montgomery.py
+2,175 −0 src/msm_avx.cpp
+288 −0 src/msm_avx_bls12_381.h
+41 −30 src/proj/mcllib/mcllib.vcxproj
+1,348 −1,274 src/s_xbyak.py
+3 −0 test/bench.hpp
+92 −0 test/bint_test.cpp
+27 −1 test/bls12_test.cpp
+25 −1 test/bn_c_test.hpp
+14 −0 test/common_test.hpp
+15 −1 test/low_func_test.cpp
+38 −17 test/mont.hpp
+89 −87 test/proj/bls12_test/bls12_test.vcxproj
+0 −88 test/proj/ec_test/ec_test.vcxproj
+0 −88 test/proj/fp_test/fp_test.vcxproj
+0 −88 test/proj/fp_tower_test/fp_tower_test.vcxproj
+42 −0 test/smallmodp_test.cpp
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ make BLS_ETH=1 lib/libbls384_256.a
If the option `MCL_USE_GMP=0` (resp.`MCL_USE_OPENSSL=0`) is used then GMP (resp. OpenSSL) is not used.

### Build library for Windows
Open the x64 Native Tools for Visual Studio and type the following command.

static library
```
Expand All @@ -304,6 +305,9 @@ dynamic library
mklib dll eth
```

Or open `bls.sln` and build it.
*REMARK* CmakeLists.txt is not maintained for Visual Studio.

### Build static library for Android

See [bls-eth-go-binary](https://github.com/herumi/bls-eth-go-binary)
Expand Down
12 changes: 0 additions & 12 deletions release.props

This file was deleted.

85 changes: 85 additions & 0 deletions src/proj/blsethlib/blsethlib.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" 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>
<ItemGroup>
<ClCompile Include="..\..\bls_c384_256.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectGuid>{1DBB979A-C212-45CD-9463-446A96F87F72}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</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="$(ProjectDir)\..\..\..\common.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="$(ProjectDir)\..\..\..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\</OutDir>
<TargetName>bls384_256</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\</OutDir>
<TargetName>bls384_256</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NDEBUG;MCL_MAX_BIT_SIZE=384;BLS_ETH=1</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>NDEBUG;MCL_MAX_BIT_SIZE=384;BLS_ETH=1</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 7ee34b6

Please sign in to comment.