relic-toolkit / relic

Code
Other
452 stars 179 forks source link

Unable to install presets on M1 chip arm64 #268

Closed DilanCaro closed 10 months ago

DilanCaro commented 1 year ago

Hello, I have tried installing the relic library with presets on an M1 ARM64 chip, running MacOS ventura 13.3.1 (a) , but I have not been able to. I tried the x64-pbc-bls12-381.sh preset., but after running the $make command , I get [ 0%] Built target arith_objs [ 0%] Building C object src/CMakeFiles/relic_s.dir/relic_err.c.o clang: warning: optimization flag '-finline-small-functions' is not supported [-Wignored-optimization-argument] // accompanied with a different type to pointers errors with the gmp library. Important to note , I was able to install the relic library with its defaults. I am trying to use the BLS12-P381 or any other curve with better security to run a bilinear pairing program . The default option is initialized with BN-P256 which is not secure enough for my purposes. Any help would be greatly appreciated.

dfaranha commented 1 year ago

Hi,

This preset includes Assembly for Intel machines, so it will not work on the M1 without writing dedicated ASM. You can try downgrading the arithmetic backend to GMP, but that's about it. :(

DilanCaro commented 1 year ago

Hi, thank you for your quick response and this great library. It is worth nothing that I was the library worked with default settings using x86_64 terminal using rosseta translation.

However, now I was able to get a macOS intel machine, the processes to install the presets seem to go further MacOS Big Sur, 2.7 GHz Dual-Core Intel Core i5 Running $../preset/x64-pbc-bls12-381.sh ../ $make [ 72%] Building C object src/CMakeFiles/relic_s_type3.dir/low/gmp/relic_bn_add_low.c.o clang: warning: optimization flag '-finline-small-functions' is not supported [-Wignored-optimization-argument] /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/gmp/relic_bn_add_low.c:43:19: warning: incompatible pointer types passing 'dig_t ' (aka 'unsigned long long ') to parameter of type 'mp_ptr' (aka 'unsigned long ') [-Wincompatible-pointer-types] return mpn_add_1(c, a, size, digit); More errors ... /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_inv_low.c:68:43: warning: incompatible pointer types passing 'const dig_t ' (aka 'const unsigned long long ') to parameter of type 'mp_srcptr' (aka 'const unsigned long ') [-Wincompatible-pointer-types] mpn_tdiv_qr(u, c, 0, t, 2 * RLC_FP_DIGS, fp_prime_get(), RLC_FP_DIGS); ^~~~~~ /Users/userbilinearity/Desktop/Bilinear Pairing/relic/include/relic_label.h:553:23: note: expanded from macro 'fp_prime_get'

define fp_prime_get RLC_PREFIX(fp_prime_get)

/Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:57:1: error: unknown directive .hidden p1 ^ /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:58:1: error: unknown directive .hidden p2

:1:10: error: expected register here movq 8*1((381/64+1)-1)(%rsi), %r10 ^ /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:88:2: note: while in macro instantiation ADD1 1 ((381/64 + 1) - 1) ^ :3:17: error: expected register here movq %r10, 8*1((381/64+1)-1)(%rdi) ^ /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:88:2: note: while in macro instantiation ADD1 1 ((381/64 + 1) - 1) ^ :4:7: error: unexpected token in '.if' directive .if 1((381/64+1)-1) - ^ /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:88:2: note: while in macro instantiation ADD1 1 ((381/64 + 1) - 1) ^ :1:10: error: expected ')' in parentheses expression movq 8*(1((381/64+1)-1) + 1)(%rsi), %r10 ^ :5:3: note: while in macro instantiation ADD1 "(1((381/64+1)-1) + 1)" /Users/userbilinearity/Desktop/Bilinear Pairing/relic/src/low/x64-asm-6l/relic_fp_add_low.s:88:2: note: while in macro instantiation ADD1 1 ((381/64 + 1) - 1) ^ :1:24: error: expected ')' in parentheses expression movq 8*(((((((((((((((1((381/64+1)-1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1)(%rsi), %r10 make[2]: *** [src/CMakeFiles/relic_s_type3.dir/low/x64-asm-6l/relic_fp_add_low.s.o] Error 1 make[1]: *** [src/CMakeFiles/relic_s_type3.dir/all] Error 2 make: *** [all] Error 2 // it seems to be the assembly code as well? Not sure, Also tried $../preset/gmp-pbc-bls381.sh ../ $make [ 81%] Linking C static library ../lib/librelic_s_type3.a /Library/Developer/CommandLineTools/usr/bin/ranlib: file: ../lib/librelic_s_type3.a(relic_dv_mem.c.o) has no symbols /Library/Developer/CommandLineTools/usr/bin/ranlib: file: ../lib/librelic_s_type3.a(relic_dv_mem.c.o) has no symbols [ 81%] Built target relic_s_type3 [ 82%] Building C object test/CMakeFiles/test_bn.dir/test_bn.c.o [ 82%] Linking C executable ../bin/test_bn clang: error: no such file or directory: 'Pairing/relic/src/low/gmp/' make[2]: *** [bin/test_bn] Error 1 make[1]: *** [test/CMakeFiles/test_bn.dir/all] Error 2 make: *** [all] Error 2 Any help or guidance will be greatly appreciated.
dfaranha commented 10 months ago

Sorry, but unfortunately I don't have an M1 machine to attempt to reproduce. It looks like the compiler toolchain does not support recursive Assembly macros, however.