Sunday, July 17, 2022

[How To] Install Pyfhel in macOS

 


  • Tested on Intel-based (x86_64) MacBook, not tested on M1/M2 (ARM)
  • Apple Clang does not support -fopenmp and -libseal, use GCC or CLANG
  1. % git clone --recursive https://github.com/ibarrond/Pyfhel

2.a) create requirements.txt file

  "setuptools<=60.9",
  "wheel",
  "cython>=3.0.0a9",
  "numpy>=1.20",
  "cmake>=3.15",
  "toml>=0.10"

2.b) % pip install -r requirements.txt

  1. edit pyproject.toml

Line #111 [Afhel]

extra_compile_args

  • {Darwin = ["-std=c++17","-O3","-fopenmp"]},

extra_link_args

  • {Darwin = ["-fopenmp","-dynamiclib"]},

Repeat the above for [CYTHON EXTENSIONS]

Wednesday, July 13, 2022

[Solved] Jupyter notebook raises Module Not Found Error

I recently ran into issues on my MacBook with Jupyter notebooks, where it could not find any packages and was throwing "ModuleNotFoundError: No module named ****" for several libraries. I already had these packages installed but somehow Jupyter python kernel could not find it. I tried to install these packages in the notebook cells with the command !pip install **** but this did not help either. I also tried %brew reinstall jupyterlab and that did not work as well.

Finally, I found a fix.

Solution:

Step-1: Install/upgrade jupyter packages:

% pip3 install --upgrade jupyter notebook jupyterlab

Step-2: Run jupyter with this command:

% jupyter-lab

[Solved] ld: library not found for -lntl

NTL: A Library for doing Number Theory

NTL is a high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers and for vectors, matrices, and polynomials over the integers and over finite fields.

You might face a linking error with NTL in macOS using the Apple Clang compiler:

% make                               

Consolidate compiler generated dependencies of target degrees

[ 25%] Linking CXX executable degrees

ld: library not found for -lntl

clang: error: linker command failed with exit code 1 (use -v to see invocation)



Solution:

% brew install NTL
% export LIBRARY_PATH=/usr/local/lib
% make

[How To] Run MinimaxComp_degrees in macOS

MinimaxComp_degrees

This algorithm finds optimized degrees for comparison/max/ReLU algorithms using minimax composite polynomial on the RNS-CKKS scheme, which was proposed in https://ieeexplore.ieee.org/document/9517029 and https://eprint.iacr.org/2021/1215.

How to run on macOS using the Apple Clang compiler:

1. % brew install NTL
2. % export LIBRARY_PATH=/usr/local/lib
4. % cd MinimaxComp_degrees
5. % cmake -S . -B build
6. % cd build
7. % make
8. % ./degrees

Output:

------------------------------------

alpha: 20

epsilon: 0.2002716064453125e-4

mintime: 162

depth: 22

0.39825903512705770933e-4

7 13 15 15 59 


Friday, July 08, 2022

[How To] Install CRC RevEng on macOS

CRC RevEng

CRC RevEng is a portable, arbitrary-precision CRC calculator and algorithm finder. It calculates CRCs using any 111 preset algorithms or a user-specified algorithm to any width. It calculates reversed CRCs to give the bit pattern that produces a desired forward CRC. CRC RevEng also reverse-engineers any CRC algorithm from good, correctly formatted message-CRC pairs and optional known parameters. It comprises powerful input interpretation options.

Installation instructions for macOS:

1. Download reveng from SourceForge: https://sourceforge.net/projects/reveng/files/

2. Unzip the downloaded reveng zip file

3. % cd Downloads/reveng-3.0.3


4. % make


gcc -O3 -Wall -ansi -fomit-frame-pointer -DPRESETS -DBMPTST -o bmptst bmpbit.c

( ./bmptst && touch bmptst ) || ( rm bmptst bmptst.exe && false )

reveng: configuration fault.  Update config.h with these definitions and recompile:

#define BMP_BIT   64

#define BMP_SUB   32

rm: bmptst.exe: No such file or directory

make: *** [bmptst] Error 1