Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Jun 10, 2024
2 parents 07b7634 + 3092d13 commit 7af8ea7
Show file tree
Hide file tree
Showing 15 changed files with 394 additions and 526 deletions.
10 changes: 3 additions & 7 deletions common.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)../cybozulib/include;$(SolutionDir)../cybozulib_ext/include;$(SolutionDir)include;$(SolutionDir)../xbyak</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\include</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);NOMINMAX;MCL_MAX_BIT_SIZE=384;MCL_MSM=1</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)../cybozulib_ext/lib;$(SolutionDir)lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
</Project>
14 changes: 0 additions & 14 deletions debug.props

This file was deleted.

14 changes: 5 additions & 9 deletions include/cybozu/inttype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,12 @@
#endif
#endif
#ifndef CYBOZU_ASSUME
#ifdef NDEBUG
#if defined(__clang__)
#define CYBOZU_ASSUME(x) __builtin_assume(x)
#elif defined(_MSC_VER) || defined(__ICC)
#define CYBOZU_ASSUME(x) __assume(x)
#else
#define CYBOZU_ASSUME(x) if (!(x)) { __builtin_unreachable(); }
#endif
#if defined(__clang__)
#define CYBOZU_ASSUME(x) assert(x); __builtin_assume(x)
#elif defined(_MSC_VER) || defined(__ICC)
#define CYBOZU_ASSUME(x) assert(x); __assume(x)
#else
#define CYBOZU_ASSUME(x) assert(x)
#define CYBOZU_ASSUME(x) assert(x); if (!(x)) { __builtin_unreachable(); }
#endif
#endif

Expand Down
2 changes: 2 additions & 0 deletions include/mcl/gmp_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,10 @@ size_t getContinuousVal(const Vec& v, size_t pos, int val)
template<class Vec>
void convertToNAF(Vec& v, const Vec& in)
{
assert(in.size() > 0);
v.copy(in);
size_t pos = v.size() - 1;
if (pos == 0) return;
for (;;) {
size_t p = getContinuousVal(v, pos, 0);
if (p == 1) return;
Expand Down
2 changes: 1 addition & 1 deletion include/mcl/op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace mcl {

static const int version = 0x192; /* 0xABC = A.BC */
static const int version = 0x193; /* 0xABC = A.BC */

/*
specifies available string format mode for X::setIoMode()
Expand Down
48 changes: 12 additions & 36 deletions mcl.sln
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
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}") = "fp_test", "test\proj\fp_test\fp_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}") = "ec_test", "test\proj\ec_test\ec_test.vcxproj", "{46B6E88E-739A-406B-9F68-BC46C5950FA3}"
ProjectSection(ProjectDependencies) = postProject
{1DBB979A-C212-45CD-9563-446A96F87F71} = {1DBB979A-C212-45CD-9563-446A96F87F71}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib", "src\proj\mcllib\mcllib.vcxproj", "{E95F067C-F6CE-48D5-B6AB-E469211D5B43}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mcl", "src\proj\mcl.vcxproj", "{1DBB979A-C212-45CD-9563-446A96F87F71}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fp_tower_test", "test\proj\fp_tower_test\fp_tower_test.vcxproj", "{733B6250-D249-4A99-B2A6-C8FAF6A90E97}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls12_test", "test\proj\bls12_test\bls12_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}") = "bn_test", "test\proj\bn_test\bn_test.vcxproj", "{9F935350-2F4C-45FA-A1C2-1D5AA0EADC96}"
ProjectSection(ProjectDependencies) = postProject
{1DBB979A-C212-45CD-9563-446A96F87F71} = {1DBB979A-C212-45CD-9563-446A96F87F71}
{E95F067C-F6CE-48D5-B6AB-E469211D5B43} = {E95F067C-F6CE-48D5-B6AB-E469211D5B43}
EndProjectSection
EndProject
Global
Expand All @@ -30,22 +15,10 @@ Global
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
{46B6E88E-739A-406B-9F68-BC46C5950FA3}.Debug|x64.ActiveCfg = Debug|x64
{46B6E88E-739A-406B-9F68-BC46C5950FA3}.Debug|x64.Build.0 = Debug|x64
{46B6E88E-739A-406B-9F68-BC46C5950FA3}.Release|x64.ActiveCfg = Release|x64
{46B6E88E-739A-406B-9F68-BC46C5950FA3}.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
{733B6250-D249-4A99-B2A6-C8FAF6A90E97}.Debug|x64.ActiveCfg = Debug|x64
{733B6250-D249-4A99-B2A6-C8FAF6A90E97}.Debug|x64.Build.0 = Debug|x64
{733B6250-D249-4A99-B2A6-C8FAF6A90E97}.Release|x64.ActiveCfg = Release|x64
{733B6250-D249-4A99-B2A6-C8FAF6A90E97}.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
{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
Expand All @@ -54,4 +27,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A3433A9E-1985-4F82-86E1-2CC416510BA7}
EndGlobalSection
EndGlobal
39 changes: 31 additions & 8 deletions misc/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@ s = r.bit_length()
S = 1<<s
v = S // L
r0 = S % L
```

variables|z|L|r|S|v
-|-|-|-|-|-
bit_length|64|128|255|255|128


### Split function
```python
adj = False
def split(x):
b = (x * v) >> s
Expand All @@ -55,6 +47,11 @@ def split(x):
b += 1
return (a, b)
```

variables|z|L|r|S|v
-|-|-|-|-|-
bit_length|64|128|255|255|128

- x in [0, r-1]
- a + b L = x for (a, b) = split(x).

Expand Down Expand Up @@ -144,3 +141,29 @@ Otherwise, Q is bigger than L P, so Q != tbl1[j1].
-|-|-
Proj|12M+27A|8M+13A
Jacobi|16M+7A|7M+12A

## NAF (Non-Adjacent Form)

```
def naf(x, w=3):
tbl = []
H=2**(w-1)
W=H*2
mask = W-1
while x >= 1:
if x & 1:
t = x & mask
if t >= H:
t -= W
x = x - t
else:
t = 0
x = x >> 1
tbl.append(t)
tbl.reverse()
return tbl
```

Consider to apply `w=5` to `(a, b)=split(x)`.
The max value of `a` is `1.1 L = 0b101...` of 128-bit length.
`0b101` is less than `(1<<(w-1))-1` and so negativity and CF operation are unnecessary.
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,18 @@ cmake .. -DCMAKE_CXX_COMPILER=clang++
make
```

For Visual Studio,
For Visual Studio, (REMARK : It is not maintained; use the vcxproj file.)
```
mkdir build
cd build
cmake .. -A x64
msbuild mcl.sln /p:Configuration=Release /m
```

## How to build a static library with Visual Studio
Open `mcl.sln` and build it.
`src/proj/lib/lib.vcxproj` is to build a static library `lib/mcl.lib` which is defined `MCL_MAX_BIT_SIZE=384`.

## options

see `cmake .. -LA`.
Expand Down
12 changes: 0 additions & 12 deletions release.props

This file was deleted.

Loading

0 comments on commit 7af8ea7

Please sign in to comment.