diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 06f8d3d..1af122d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -96,18 +96,6 @@ jobs: runs-on: windows-2019 steps: - uses: actions/checkout@v2 - # https://github.com/egor-tensin/setup-mingw/issues/17 - - name: Set up MinGW - uses: egor-tensin/setup-mingw@v2.2.0 - with: - version: 12.2.0 - - name: Set environment variables for compiler - env: - CC: x86_64-w64-mingw32-gcc - CXX: x86_64-w64-mingw32-g++ - run: | - echo "CC=${CC}" >> $GITHUB_ENV - echo "CXX=${CXX}" >> $GITHUB_ENV - name: set up python 3.8 uses: actions/setup-python@v2 with: diff --git a/cryptomite/__init__.py b/cryptomite/__init__.py index d20a286..b6acbad 100644 --- a/cryptomite/__init__.py +++ b/cryptomite/__init__.py @@ -16,4 +16,4 @@ from cryptomite.trevisan import Trevisan from cryptomite.utils import von_neumann -__version__ = '0.1.1' +__version__ = '0.1.2' diff --git a/src/bigntt.cpp b/src/bigntt.cpp index d22c8b2..02f6079 100644 --- a/src/bigntt.cpp +++ b/src/bigntt.cpp @@ -21,17 +21,21 @@ uint64_t add(uint64_t a, uint64_t b) { * @pre a,b < P */ static uint64_t sub(uint64_t a, uint64_t b) { - __int128_t c = a; - c -= b; - __int128_t d = c + P; - __int128_t e = c >> 64; - // return c if c >= 0 else d - return (c&~e) | (d&e); + uint64_t c = a - b; + if (a < b) { + c += P; + } + + return c; } uint64_t mul(uint64_t a, uint64_t b) { - __int128_t n = a; n*= b; - return n % P; + // correct if a,b,P < 2^57 + uint64_t c = (double)a * b / P; + int64_t ans = int64_t(a * b - c * P) % int64_t(P); + if (ans < 0) + ans += P; + return ans; } /**