Skip to content
This repository has been archived by the owner on Apr 19, 2019. It is now read-only.

Latest commit

 

History

History
179 lines (144 loc) · 7.57 KB

windows-installation-guide.md

File metadata and controls

179 lines (144 loc) · 7.57 KB

Installing charm-crypto on Windows x64

Pre-built package

The easiest way to install charm-crypto is to use the pre-built (with Mingw64) package for Windows x64.

  1. Install Python 3.5 for Windows x86-64: Python3.5_win_x86_64. (or Python 3.5 for Windows x86: Python3.5_win_x86).

  2. Extract charm-crypto-win-x64.7z (or charm-crypto-win32.7z for Python 32-bit) and go to charm-crypto folder

  3. Copy all .dll files to C:\Windows\System32.

  4. Run the following to install Charm-crypto for Python 64-bit:

    easy_install Charm_Crypto-0.43-py3.5-win-amd64.egg
    

or for Python 32-bit:

easy_install Charm_Crypto-0.43-py3.5-win32.egg

Manual build and installation of charm-crypto using Mingw32 and Python 32-bit

If the pre-built packages (see above) doesn't work or not appropriate for some reasons, then please find detailed steps on how to build charm-crypto on Win32 using Mingw32:

  1. Install and prepare mingw32

    1. Install MSYS2 MSYS2_32_installer

    2. Open MSYS2 shell (C:\msys32\msys2.exe)

    3. Update packages (from MSYS2 shell):

      pacman -Sy pacman
      pacman -Syu
      pacman -Su
      
    4. Install a Mingw32 toolchain (from MSYS2 shell):

      pacman -S mingw-w64-i686-gcc
      pacman -S make
      
  2. Install charm-crypto dependencies (from MSYS2 shell):

    1. Open MSYS2 shell (C:\msys32\msys2.exe)
    2. Install bison pacman -S bison
    3. Install openssl-dev pacman -S openssl-devel
    4. Install gmp-dev pacman -S gmp-devel
  3. Build PBC lib (charm-crypto dependency)

    1. Get and extract pbc source PBC

    2. Open Mingw32 shell (C:\msys32\mingw32.exe)

    3. Go to extracted PBC location

    4. Build PBC:

       ./configure --prefix=/mingw32 --disable-static --enable-shared
       make
       make install
      
  4. Add mingw32/bin (C:\msys32\mingw32\bin) to PATH

  5. Install Python 3.5 for Windows 32 bit: Python3.5_win_x86. In what follows we assume that it was installed to C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35-32.

  6. Patch Python to be able to work with Mingw32

    1. Patch the cygwin compiler in distutils:
      1. Open C:\Users\indy\AppData\Local\Application Data\Programs\Python\Python35-32\Lib\distutils\cygwinccompiler.py
      2. Comment out all lines with get_msvcr() call.
  7. Build charm-crypto

    1. Get and extract charm-crypto source charm-crypto-0.43

    2. Go to extracted charm-crypto folder

    3. Add #include <stdint.h> at the top of the following files:

      Charm-Crypto-0.43\charm\core\math\integer\integermodule.h
      Charm-Crypto-0.43\charm\core\math\elliptic_curve\ecmodule.h
      Charm-Crypto-0.43\charm\core\math\pairing\pairingmodule.h
      
    4. Open Mingw32 shell (C:\msys32\mingw32.exe)

    5. Build charm-crypto (please note that we specify the path to python35.exe there)

       ./configure.sh --prefix=/mingw32 --python=/c/users/user/AppData/Local/Programs/Python/Python35-32/python.exe 
       make
       make install
      

Manual build and installation of charm-crypto using Mingw64 and Python 64-bit

If the pre-built packages (see above) doesn't work or not appropriate for some reasons, then please find detailed steps on how to build charm-crypto on Win_x64 using Mingw64:

  1. Install and prepare mingw64

    1. Install MSYS2 MSYS2_64_installer

    2. Open MSYS2 shell (C:\msys64\msys2.exe)

    3. Update packages (from MSYS2 shell):

      pacman -Sy pacman
      pacman -Syu
      pacman -Su
      
    4. Install a Mingw64 toolchain (from MSYS2 shell):

      pacman -S mingw-w64-x86_64-gcc
      pacman -S make
      
  2. Install charm-crypto dependencies (from MSYS2 shell):

    1. Open MSYS2 shell (C:\msys64\msys2.exe)
    2. Install bison pacman -S bison
    3. Install openssl-dev pacman -S openssl-devel
    4. Install gmp-dev pacman -S gmp-devel
  3. Build PBC lib (charm-crypto dependency)

    1. Get and extract pbc source PBC

    2. Open Mingw64 shell (C:\msys64\mingw64.exe)

    3. Go to extracted PBC location

    4. Build PBC:

       ./configure --prefix=/mingw64 --disable-static --enable-shared
       make
       make install
      
  4. Add mingw64/bin (C:\msys64\mingw64\bin) to PATH

  5. Install Python 3.5 for Windows x86-64: Python3.5_win_x86_64. In what follows we assume that it was installed to C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35.

  6. Patch Python to be able to build and use 64 bit binaries

    1. Download and extract gendef.exe from gendef

    2. Copy dendef.exe into mingw64/bin (C:\msys64\mingw64/bin)

    3. Copy python35.dll to libs folder:

      cd C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35
      cp python35.dll libs
      
    4. Patch libpython35.a

      cd C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35\libs
      rename python35.lib old_python35.lib
      gendef python35.dll
      dlltool --dllname python35.dll --def python35.def --output-lib libpython35.a
      
    5. Patch pyconfig.h:

      1. Open C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35\include\pyconfig.h

      2. In that file search for the text #ifdef _WIN64, and cut out the following three lines:

        #ifdef _WIN64
        #define MS_WIN64
        #endif
        
      3. Search for the text #ifdef _MSC_VER. Paste in the cut-out lines, ABOVE the #ifdef _MSC_VER.

    6. Patch the cygwin compiler in distutils:

      1. Open C:\Users\user\AppData\Local\Application Data\Programs\Python\Python35\Lib\distutils\cygwinccompiler.py
      2. Comment out all lines with get_msvcr() call.
  7. Build charm-crypto

    1. Get and extract charm-crypto source charm-crypto-0.43

    2. Go to extracted charm-crypto folder

    3. Add #include <stdint.h> at the top of the following files:

      Charm-Crypto-0.43\charm\core\math\integer\integermodule.h
      Charm-Crypto-0.43\charm\core\math\elliptic_curve\ecmodule.h
      Charm-Crypto-0.43\charm\core\math\pairing\pairingmodule.h
      
    4. Open Mingw64 shell (C:\msys64\mingw64.exe)

    5. Build charm-crypto (please note that we specify the path to python35.exe there)

       ./configure.sh --prefix=/mingw64 --python=/c/users/user/AppData/Local/Programs/Python/Python35/python.exe 
       make
       make install