-
Notifications
You must be signed in to change notification settings - Fork 178
Linking multiple builds
You might need to link different versions of the RELIC library using different configurations, for example when you need multiple curves simultaneously or support different security levels. RELIC includes a LABEL configuration that helps making this possible.
In the example below, RELIC will be built to support both symmetric and asymmetric pairings at two security levels, but the same procedure should work with different presets.
First, configure and build the different presets attached in three different folders.
mkdir target-type1; cd target-type1
cmake -DLABEL=type1 ..
../preset/gmp-pbc-ss1536.sh ../
make;
make install; cd ..
mkdir target-type3; cd target-type3
cmake -DLABEL=type3 .
../preset/x64-pbc-bls12-381.sh ../
make
make install; cd ..
Each configuration assigns a different LABEL, which serves as a prefix for renaming all library functions through macros in header relic_label.h, avoiding any symbol clashes. Note that the library can now also be installed, and different configurations should not overwrite each other. I'm using LABEL=type1
for supersingular curves, and LABEL=type3
for 381-bit BLS12 curves.
Test files can be found inside de demo/link-test
folder, together with a Makefile
. Now, compile each of the test files using a different configuration:
gcc -c test1.c -o test1.o -I /usr/local/include/relic_type1
gcc -c test2.c -o test2.o -I /usr/local/include/relic_type3
Note that the files are almost identical, abstracting an implementation of a simple protocol.
Compile the main program, linking with the three different libraries:
gcc -o test test.c test1.o test2.o /usr/local/lib/librelic_s_*.a -lgmp
Run the resulting binary and check if no problems appear. The output should print pairing results in two configurations:
-- Curve SS-P1536:
4F2F12A18FFA0DC2 D070A6099664FE73 BD730FA2BFD76790 C36214F891E41952 FBEA166B2700AA91 31C2EDCE7FC2877D CABD07BA6E7A6ABB 9179D9C763BD9BEF 4EC4DF7124D80707 5FCB88BA898A9F1B CDE35D42EFB8301D D518F7F1AD764C3F 12166DB5FF7F7A6B 0B1FFC89DF24D7AF 09F7D53A994E7C0D 660E80C45CFFE347 F6C1D8502A6E67A1 B4BCB4F20A746FF7 096671B2F13D9690 932AB976FE3F84F9 283FACC23EB546BB ED627841BA7DE849 FF15844B04B6327D FCD49DE7E8E49A1F
470C2C8929E839B3 ECAEB4A948EFB396 ADEE64290A712861 11A96DDEE9FF5858 ECF71E91E7CA70EA F9336D191CA35B66 CE3AED6DE27A15E4 02700C0A887F43B7 79595DBE4660A73F F5F67516C1E4987D 22209A9DD632D677 670C70ECB5C564C3 C834EA513E8E2C00 E1114642FA9DE5C3 29FA84BCA6B2F2A1 521C3D31AAD9F337 82DD26C21BE6B95B 56A4A48F5C364060 D1820B90A023EB9B 9406C50B7733DC29 912B5F9A5E48FAA3 1F70BB2122CB5429 3C17996C7C8BD495 9A1451B2BCE8C67B
Is pairing symmetric? 1
Is pairing asymmetric? 0
-- Curve B12-P381:
079A45A201B0B7DE FC7B4C322242349D 32F8DEC36878A702 386FF6CC8DA1BAEF 5268FD6E4F1AA810 725BA49B1C43438F
033E4B0FAD04F0ED E98AD6698DC579E0 9B0897D2BDD064D2 CEBE47BCEAB9BB5C A9943BBFA1C45BAA D7A2213E140EB5F8
17A2321655640288 6F47C61BA3991ED8 BAA7E4FE1AACB5F4 2E7B0189B5C7BDBE C9293FC2F872304C C929BCCDE36ECA82
0D150BB5242AB84C 0845624AFC33A6C1 9ED47F871FB235B1 20964BDC3954D665 41B6404788DBFC34 FC05DC6B51C7BC88
13670FC1F9CB0CA7 DA9819EA79EC7C10 1E327DD66866B186 99D48D883EB20FFE 3194A2290EB2F2F2 053D21E766F97CF6
04E62F95355FEE8C F36843955383D285 FA162684C003C1D2 6A38234469E4E9DA 9F9759A3BB2C8842 C1B1E010B1790C96
1740CBF55F6F04B1 D5BA06CD998B876D BE540A129CB1C430 93F8E375DD2C6306 FB543BD495F99559 74E8EF268F8A4DCC
0B73F3F8D58F946C 73395EAD320AA035 E1E23FB9B5EA1AAC 5E3C247F171DC7EF 8D2D192561CD696E 6E3C0F3467E9E51E
18FD99CB674D9673 0560A8B5170DFA48 8A7BF1F53B69F105 D4F543260567B7B3 844B64962113DE5D E39DE9DB3B6557F7
149B846157BFA02B 735367430E77C587 E8C73FD08CF22E38 F5921B4A1B2BF3BE 8E903C5BD69E8A0E D2C16FD1CFD93404
0D1D4AC7EF1D8823 5B7F7AD34744A840 FB1F2C5C8A36DBDF 918E7DCDC92F198D A2220DCFDFFF98B1 2CA9A5A8EC568BB5
18CF52CEB2019C92 EBD87AAA9455F55E 0CC50D7CA224EE0A E04C1FE6E1BF4F66 D14DD5B32405FF19 5914D8378EAFFCFD
Is pairing symmetric? 0
Is pairing asymmetric? 1