JHUISI / charm

Charm: A Framework for Rapidly Prototyping Cryptosystems
http://charm-crypto.io
GNU Lesser General Public License v3.0
542 stars 166 forks source link

relic in Charm #235

Closed cryptoliu17 closed 4 years ago

cryptoliu17 commented 4 years ago

Hi all,

I 'm trying to use the Charm to call relic library. I successfully run my project with "BN254" curve but you can find this curve is implemented by PBC. I think relic tool kit provide more BN types of curves so I decide to add relic in charm and use it. I install the relic in Charm as the instruction in the website. https://jhuisi.github.io/charm/relic.html#charm-with-relic Everything looks fine, when I run "sudo make" command, it mentions many errors.

sudo make

Setup build/staging directories set -x set +x Building the Charm Framework /usr/bin/python3 setup.py build
Platform: Linux Config file: /home/cliu/charm/config.mk running build running build_py copying charm/config.py -> build/lib.linux-x86_64-3.5/charm package init file 'charm/schemes/prenc/init.py' not found (or not a regular file) running build_ext building 'charm.core.math.pairing' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBENCHMARK_ENABLED=1 -Icharm/core/utilities/ -Icharm/core/benchmark/ -I/usr/local/include/relic -I/usr/include/python3.5m -c charm/core/math/pairing/relic/pairingmodule3.c -o build/temp.linux-x86_64-3.5/charm/core/math/pairing/relic/pairingmodule3.o In file included from /usr/local/include/relic/relic_err.h:43:0, from /usr/local/include/relic/relic_core.h:44, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_pc.h:57:20: error: conflicting types for ‘ep_read_bin’

define G1LOWER ep

                ^

/usr/local/include/relic/relic_util.h:151:26: note: in definition of macro ‘_RLC_CAT’

define _RLC_CAT(A, B) A ## B

                      ^

/usr/local/include/relic/relic_pc.h:432:31: note: in expansion of macro ‘RLC_CAT’

define g1_read_bin(P, B, L) RLC_CAT(G1_LOWER, read_bin)(P, B, L)

                           ^

/usr/local/include/relic/relic_pc.h:432:39: note: in expansion of macro ‘G1_LOWER’

define g1_read_bin(P, B, L) RLC_CAT(G1_LOWER, read_bin)(P, B, L)

                                   ^

charm/core/math/pairing/relic/relic_interface.h:161:10: note: in expansion of macro ‘g1_read_bin’ status_t g1_read_bin(g1_t g, uint8_t data, int data_len); ^ In file included from /usr/local/include/relic/relic_epx.h:41:0, from /usr/local/include/relic/relic_core.h:47, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_ep.h:717:6: note: previous declaration of ‘ep_read_bin’ was here void ep_read_bin(ep_t a, const uint8_t bin, int len); ^ In file included from charm/core/math/pairing/relic/pairingmodule3.h:42:0, from charm/core/math/pairing/relic/pairingmodule3.c:30: charm/core/math/pairing/relic/relic_interface.h:162:58: error: macro "g1_write_bin" requires 4 arguments, but only 3 given status_t g1_write_bin(g1_t g, uint8_t *data, int data_len); ^ In file included from /usr/local/include/relic/relic_err.h:43:0, from /usr/local/include/relic/relic_core.h:44, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_pc.h:59:20: error: conflicting types for ‘ep2_read_bin’

define G2LOWER ep2

                ^

/usr/local/include/relic/relic_util.h:151:26: note: in definition of macro ‘_RLC_CAT’

define _RLC_CAT(A, B) A ## B

                      ^

/usr/local/include/relic/relic_pc.h:442:31: note: in expansion of macro ‘RLC_CAT’

define g2_read_bin(P, B, L) RLC_CAT(G2_LOWER, read_bin)(P, B, L)

                           ^

/usr/local/include/relic/relic_pc.h:442:39: note: in expansion of macro ‘G2_LOWER’

define g2_read_bin(P, B, L) RLC_CAT(G2_LOWER, read_bin)(P, B, L)

                                   ^

charm/core/math/pairing/relic/relic_interface.h:165:10: note: in expansion of macro ‘g2_read_bin’ status_t g2_read_bin(g2_t g, uint8_t data, int data_len); ^ In file included from /usr/local/include/relic/relic_core.h:47:0, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_epx.h:529:6: note: previous declaration of ‘ep2_read_bin’ was here void ep2_read_bin(ep2_t a, const uint8_t bin, int len); ^ In file included from charm/core/math/pairing/relic/pairingmodule3.h:42:0, from charm/core/math/pairing/relic/pairingmodule3.c:30: charm/core/math/pairing/relic/relic_interface.h:166:58: error: macro "g2_write_bin" requires 4 arguments, but only 3 given status_t g2_write_bin(g2_t g, uint8_t *data, int data_len); ^ In file included from /usr/local/include/relic/relic_err.h:43:0, from /usr/local/include/relic/relic_core.h:44, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_pc.h:61:20: error: conflicting types for ‘fp12_read_bin’

define GTLOWER fp12

                ^

/usr/local/include/relic/relic_util.h:151:26: note: in definition of macro ‘_RLC_CAT’

define _RLC_CAT(A, B) A ## B

                      ^

/usr/local/include/relic/relic_pc.h:452:31: note: in expansion of macro ‘RLC_CAT’

define gt_read_bin(A, B, L) RLC_CAT(GT_LOWER, read_bin)(A, B, L)

                           ^

/usr/local/include/relic/relic_pc.h:452:39: note: in expansion of macro ‘GT_LOWER’

define gt_read_bin(A, B, L) RLC_CAT(GT_LOWER, read_bin)(A, B, L)

                                   ^

charm/core/math/pairing/relic/relic_interface.h:169:10: note: in expansion of macro ‘gt_read_bin’ status_t gt_read_bin(gt_t g, uint8_t data, int data_len); ^ In file included from /usr/local/include/relic/relic_epx.h:40:0, from /usr/local/include/relic/relic_core.h:47, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_fpx.h:2900:6: note: previous declaration of ‘fp12_read_bin’ was here void fp12_read_bin(fp12_t a, const uint8_t bin, int len); ^ In file included from charm/core/math/pairing/relic/pairingmodule3.h:42:0, from charm/core/math/pairing/relic/pairingmodule3.c:30: charm/core/math/pairing/relic/relic_interface.h:170:58: error: macro "gt_write_bin" requires 4 arguments, but only 3 given status_t gt_write_bin(gt_t g, uint8_t data, int data_len); ^ charm/core/math/pairing/relic/pairingmodule3.c: In function ‘intToLongObj’: charm/core/math/pairing/relic/pairingmodule3.c:114:35: error: ‘BN_NEG’ undeclared (first use in this function) int size, isNeg = (bn_sign(x) == BN_NEG) ? TRUE : FALSE; ^ charm/core/math/pairing/relic/pairingmodule3.c:114:35: note: each undeclared identifier is reported only once for each function it appears in charm/core/math/pairing/relic/pairingmodule3.c:115:14: warning: passing argument 1 of ‘bn_size_str’ from incompatible pointer type [-Wincompatible-pointer-types] bn_size_str(&size, x, 2); ^ In file included from /usr/local/include/relic/relic_core.h:45:0, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_bn.h:565:5: note: expected ‘bn_t {aka struct const}’ but argument is of type ‘int ’ int bn_size_str(const bn_t a, int radix); ^ charm/core/math/pairing/relic/pairingmodule3.c:115:21: warning: passing argument 2 of ‘bn_size_str’ makes integer from pointer without a cast [-Wint-conversion] bn_size_str(&size, x, 2); ^ In file included from /usr/local/include/relic/relic_core.h:45:0, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_bn.h:565:5: note: expected ‘int’ but argument is of type ‘integer_t {aka struct }’ int bn_size_str(const bn_t a, int radix); ^ charm/core/math/pairing/relic/pairingmodule3.c:115:2: error: too many arguments to function ‘bn_size_str’ bn_size_str(&size, x, 2); ^ In file included from /usr/local/include/relic/relic_core.h:45:0, from /usr/local/include/relic/relic.h:83, from charm/core/math/pairing/relic/relic_interface.h:35, from charm/core/math/pairing/relic/pairingmodule3.h:42, from charm/core/math/pairing/relic/pairingmodule3.c:30: /usr/local/include/relic/relic_bn.h:565:5: note: declared here int bn_size_str(const bn_t a, int radix); ^ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 Makefile:28: recipe for target 'all' failed make: *** [all] Error 1


I don't know if anyone has once added relic in Charm and used "BN256" , "BN158" and so on to implement a scheme? I don't know if the relic version in current Charm is the correct one, or the relic is updated? Thanks for your time and attention!!

cryptoliu17 commented 4 years ago

I think Charm0.5 and relic0.3.4 can work fine together.