From 2b897527a85a505a06ef932ab3e4f7c07b3f7732 Mon Sep 17 00:00:00 2001 From: Odysseas Gabrielides Date: Fri, 4 Oct 2024 18:27:51 +0300 Subject: [PATCH 1/3] Revert "build: stop tracking cmake dependency relic_conf.h.in" This reverts commit a891c78654538c477fba0d8918d81005cdcd9601. --- .../depends/relic/include/relic_conf.h.in | 717 ++++++++++++++++++ 1 file changed, 717 insertions(+) create mode 100644 src/dashbls/depends/relic/include/relic_conf.h.in diff --git a/src/dashbls/depends/relic/include/relic_conf.h.in b/src/dashbls/depends/relic/include/relic_conf.h.in new file mode 100644 index 0000000000000..7db6f5b509c45 --- /dev/null +++ b/src/dashbls/depends/relic/include/relic_conf.h.in @@ -0,0 +1,717 @@ +/* + * RELIC is an Efficient LIbrary for Cryptography + * Copyright (c) 2009 RELIC Authors + * + * This file is part of RELIC. RELIC is legal property of its developers, + * whose names are not listed here. Please refer to the COPYRIGHT file + * for contact information. + * + * RELIC is free software; you can redistribute it and/or modify it under the + * terms of the version 2.1 (or later) of the GNU Lesser General Public License + * as published by the Free Software Foundation; or version 2.0 of the Apache + * License as published by the Apache Software Foundation. See the LICENSE files + * for more details. + * + * RELIC is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the LICENSE files for more details. + * + * You should have received a copy of the GNU Lesser General Public or the + * Apache License along with RELIC. If not, see + * or . + */ + +/** + * @file + * + * Project configuration. + * + * @version $Id: relic_conf.h.in 45 2009-07-04 23:45:48Z dfaranha $ + * @ingroup relic + */ + +#ifndef RLC_CONF_H +#define RLC_CONF_H + +/** Project version. */ +#define RLC_VERSION "@VERSION@" + +/** Debugging support. */ +#cmakedefine DEBUG +/** Profiling support. */ +#cmakedefine PROFL +/** Error handling support. */ +#cmakedefine CHECK +/** Verbose error messages. */ +#cmakedefine VERBS +/** Build with overhead estimation. */ +#cmakedefine OVERH +/** Build documentation. */ +#cmakedefine DOCUM +/** Build only the selected algorithms. */ +#cmakedefine STRIP +/** Build with printing disabled. */ +#cmakedefine QUIET +/** Build with colored output. */ +#cmakedefine COLOR +/** Build with big-endian support. */ +#cmakedefine BIGED +/** Build shared library. */ +#cmakedefine SHLIB +/** Build static library. */ +#cmakedefine STLIB + +/** Number of times each test is ran. */ +#define TESTS @TESTS@ +/** Number of times each benchmark is ran. */ +#define BENCH @BENCH@ +/** Number of available cores. */ +#define CORES @CORES@ + +/** Atmel AVR ATMega128 8-bit architecture. */ +#define AVR 1 +/** MSP430 16-bit architecture. */ +#define MSP 2 +/** ARM 32-bit architecture. */ +#define ARM 3 +/** Intel x86-compatible 32-bit architecture. */ +#define X86 4 +/** AMD64-compatible 64-bit architecture. */ +#define X64 5 +/** Architecture. */ +#cmakedefine ARCH @ARCH@ + +/** Size of word in this architecture. */ +#define WSIZE @WSIZE@ + +/** Byte boundary to align digit vectors. */ +#define ALIGN @ALIGN@ + +/** Build multiple precision integer module. */ +#cmakedefine WITH_BN +/** Build prime field module. */ +#cmakedefine WITH_FP +/** Build prime field extension module. */ +#cmakedefine WITH_FPX +/** Build binary field module. */ +#cmakedefine WITH_FB +/** Build prime elliptic curve module. */ +#cmakedefine WITH_EP +/** Build prime field extension elliptic curve module. */ +#cmakedefine WITH_EPX +/** Build binary elliptic curve module. */ +#cmakedefine WITH_EB +/** Build elliptic Edwards curve module. */ +#cmakedefine WITH_ED +/** Build elliptic curve cryptography module. */ +#cmakedefine WITH_EC +/** Build pairings over prime curves module. */ +#cmakedefine WITH_PP +/** Build pairing-based cryptography module. */ +#cmakedefine WITH_PC +/** Build block ciphers. */ +#cmakedefine WITH_BC +/** Build hash functions. */ +#cmakedefine WITH_MD +/** Build cryptographic protocols. */ +#cmakedefine WITH_CP +/** Build Multi-party computation primitives. */ +#cmakedefine WITH_MPC + +/** Easy C-only backend. */ +#define EASY 1 +/** GMP backend. */ +#define GMP 2 +/** GMP constant-time backend. */ +#define GMP_SEC 3 +/** Arithmetic backend. */ +#define ARITH @ARITH@ + +/** Required precision in bits. */ +#define BN_PRECI @BN_PRECI@ +/** A multiple precision integer can store w words. */ +#define SINGLE 0 +/** A multiple precision integer can store the result of an addition. */ +#define CARRY 1 +/** A multiple precision integer can store the result of a multiplication. */ +#define DOUBLE 2 +/** Effective size of a multiple precision integer. */ +#define BN_MAGNI @BN_MAGNI@ +/** Number of Karatsuba steps. */ +#define BN_KARAT @BN_KARAT@ + +/** Schoolbook multiplication. */ +#define BASIC 1 +/** Comba multiplication. */ +#define COMBA 2 +/** Chosen multiple precision multiplication method. */ +#define BN_MUL @BN_MUL@ + +/** Schoolbook squaring. */ +#define BASIC 1 +/** Comba squaring. */ +#define COMBA 2 +/** Reuse multiplication for squaring. */ +#define MULTP 4 +/** Chosen multiple precision multiplication method. */ +#define BN_SQR @BN_SQR@ + +/** Division modular reduction. */ +#define BASIC 1 +/** Barrett modular reduction. */ +#define BARRT 2 +/** Montgomery modular reduction. */ +#define MONTY 3 +/** Pseudo-Mersenne modular reduction. */ +#define PMERS 4 +/** Chosen multiple precision modular reduction method. */ +#define BN_MOD @BN_MOD@ + +/** Binary modular exponentiation. */ +#define BASIC 1 +/** Sliding window modular exponentiation. */ +#define SLIDE 2 +/** Montgomery powering ladder. */ +#define MONTY 3 +/** Chosen multiple precision modular exponentiation method. */ +#define BN_MXP @BN_MXP@ + +/** Basic Euclidean GCD Algorithm. */ +#define BASIC 1 +/** Lehmer's fast GCD Algorithm. */ +#define LEHME 2 +/** Stein's binary GCD Algorithm. */ +#define STEIN 3 +/** Chosen multiple precision greatest common divisor method. */ +#define BN_GCD @BN_GCD@ + +/** Basic prime generation. */ +#define BASIC 1 +/** Safe prime generation. */ +#define SAFEP 2 +/** Strong prime generation. */ +#define STRON 3 +/** Chosen prime generation algorithm. */ +#define BN_GEN @BN_GEN@ + +/** Multiple precision arithmetic method */ +#define BN_METHD "@BN_METHD@" + +/** Prime field size in bits. */ +#define FP_PRIME @FP_PRIME@ +/** Number of Karatsuba steps. */ +#define FP_KARAT @FP_KARAT@ +/** Prefer Pseudo-Mersenne primes over random primes. */ +#cmakedefine FP_PMERS +/** Use -1 as quadratic non-residue. */ +#cmakedefine FP_QNRES +/** Width of window processing for exponentiation methods. */ +#define FP_WIDTH @FP_WIDTH@ + +/** Schoolbook addition. */ +#define BASIC 1 +/** Integrated modular addtion. */ +#define INTEG 3 +/** Chosen prime field multiplication method. */ +#define FP_ADD @FP_ADD@ + +/** Schoolbook multiplication. */ +#define BASIC 1 +/** Comba multiplication. */ +#define COMBA 2 +/** Integrated modular multiplication. */ +#define INTEG 3 +/** Chosen prime field multiplication method. */ +#define FP_MUL @FP_MUL@ + +/** Schoolbook squaring. */ +#define BASIC 1 +/** Comba squaring. */ +#define COMBA 2 +/** Integrated modular squaring. */ +#define INTEG 3 +/** Reuse multiplication for squaring. */ +#define MULTP 4 +/** Chosen prime field multiplication method. */ +#define FP_SQR @FP_SQR@ + +/** Division-based reduction. */ +#define BASIC 1 +/** Fast reduction modulo special form prime. */ +#define QUICK 2 +/** Montgomery modular reduction. */ +#define MONTY 3 +/** Chosen prime field reduction method. */ +#define FP_RDC @FP_RDC@ + +/** Inversion by Fermat's Little Theorem. */ +#define BASIC 1 +/** Binary inversion. */ +#define BINAR 2 +/** Integrated modular multiplication. */ +#define MONTY 3 +/** Extended Euclidean algorithm. */ +#define EXGCD 4 +/** Constant-time inversion by Bernstein-Yang division steps. */ +#define DIVST 5 +/** Use implementation provided by the lower layer. */ +#define LOWER 8 +/** Chosen prime field inversion method. */ +#define FP_INV @FP_INV@ + +/** Binary modular exponentiation. */ +#define BASIC 1 +/** Sliding window modular exponentiation. */ +#define SLIDE 2 +/** Constant-time Montgomery powering ladder. */ +#define MONTY 3 +/** Chosen multiple precision modular exponentiation method. */ +#define FP_EXP @FP_EXP@ + +/** Prime field arithmetic method */ +#define FP_METHD "@FP_METHD@" + +/** Basic quadratic extension field arithmetic. */ +#define BASIC 1 +/** Integrated extension field arithmetic. */ +#define INTEG 3 +/* Chosen extension field arithmetic method. */ +#define FPX_QDR @FPX_QDR@ + +/** Basic cubic extension field arithmetic. */ +#define BASIC 1 +/** Integrated extension field arithmetic. */ +#define INTEG 3 +/* Chosen extension field arithmetic method. */ +#define FPX_CBC @FPX_CBC@ + +/** Basic quadratic extension field arithmetic. */ +#define BASIC 1 +/** Lazy-reduced extension field arithmetic. */ +#define LAZYR 2 +/* Chosen extension field arithmetic method. */ +#define FPX_RDC @FPX_RDC@ + +/** Prime extension field arithmetic method */ +#define FPX_METHD "@FPX_METHD@" + +/** Irreducible polynomial size in bits. */ +#define FB_POLYN @FB_POLYN@ +/** Number of Karatsuba steps. */ +#define FB_KARAT @FB_KARAT@ +/** Prefer trinomials over pentanomials. */ +#cmakedefine FB_TRINO +/** Prefer square-root friendly polynomials. */ +#cmakedefine FB_SQRTF +/** Precompute multiplication table for sqrt(z). */ +#cmakedefine FB_PRECO +/** Width of window processing for exponentiation methods. */ +#define FB_WIDTH @FB_WIDTH@ + +/** Shift-and-add multiplication. */ +#define BASIC 1 +/** Lopez-Dahab multiplication. */ +#define LODAH 2 +/** Integrated modular multiplication. */ +#define INTEG 3 +/** Chosen binary field multiplication method. */ +#define FB_MUL @FB_MUL@ + +/** Basic squaring. */ +#define BASIC 1 +/** Table-based squaring. */ +#define QUICK 2 +/** Integrated modular squaring. */ +#define INTEG 3 +/** Chosen binary field squaring method. */ +#define FB_SQR @FB_SQR@ + +/** Shift-and-add modular reduction. */ +#define BASIC 1 +/** Fast reduction modulo a trinomial or pentanomial. */ +#define QUICK 2 +/** Chosen binary field modular reduction method. */ +#define FB_RDC @FB_RDC@ + +/** Square root by repeated squaring. */ +#define BASIC 1 +/** Fast square root extraction. */ +#define QUICK 2 +/** Chosen binary field modular reduction method. */ +#define FB_SRT @FB_SRT@ + +/** Trace by repeated squaring. */ +#define BASIC 1 +/** Fast trace computation. */ +#define QUICK 2 +/** Chosen trace computation method. */ +#define FB_TRC @FB_TRC@ + +/** Solve by half-trace computation. */ +#define BASIC 1 +/** Solve with precomputed half-traces. */ +#define QUICK 2 +/** Chosen method to solve a quadratic equation. */ +#define FB_SLV @FB_SLV@ + +/** Inversion by Fermat's Little Theorem. */ +#define BASIC 1 +/** Binary inversion. */ +#define BINAR 2 +/** Almost inverse algorithm. */ +#define ALMOS 3 +/** Extended Euclidean algorithm. */ +#define EXGCD 4 +/** Itoh-Tsuji inversion. */ +#define ITOHT 5 +/** Hardware-friendly inversion by Brunner-Curiger-Hofstetter.*/ +#define BRUCH 6 +/** Constant-time version of almost inverse. */ +#define CTAIA 7 +/** Use implementation provided by the lower layer. */ +#define LOWER 8 +/** Chosen binary field inversion method. */ +#define FB_INV @FB_INV@ + +/** Binary modular exponentiation. */ +#define BASIC 1 +/** Sliding window modular exponentiation. */ +#define SLIDE 2 +/** Constant-time Montgomery powering ladder. */ +#define MONTY 3 +/** Chosen multiple precision modular exponentiation method. */ +#define FB_EXP @FB_EXP@ + +/** Iterated squaring/square-root by consecutive squaring/square-root. */ +#define BASIC 1 +/** Iterated squaring/square-root by table-based method. */ +#define QUICK 2 +/** Chosen method to solve a quadratic equation. */ +#define FB_ITR @FB_ITR@ + +/** Binary field arithmetic method */ +#define FB_METHD "@FB_METHD@" + +/** Support for ordinary curves. */ +#cmakedefine EP_PLAIN +/** Support for supersingular curves. */ +#cmakedefine EP_SUPER +/** Support for prime curves with efficient endormorphisms. */ +#cmakedefine EP_ENDOM +/** Use mixed coordinates. */ +#cmakedefine EP_MIXED +/** Build precomputation table for generator. */ +#cmakedefine EP_PRECO +/** Enable isogeny map for SSWU map-to-curve. */ +#cmakedefine EP_CTMAP +/** Width of precomputation table for fixed point methods. */ +#define EP_DEPTH @EP_DEPTH@ +/** Width of window processing for unknown point methods. */ +#define EP_WIDTH @EP_WIDTH@ + +/** Affine coordinates. */ +#define BASIC 1 +/** Projective coordinates. */ +#define PROJC 2 +/** Jacobian coordinates. */ +#define JACOB 3 +/** Chosen prime elliptic curve coordinate method. */ +#define EP_ADD @EP_ADD@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** Sliding window. */ +#define SLIDE 2 +/** Montgomery powering ladder. */ +#define MONTY 3 +/** Left-to-right Width-w NAF. */ +#define LWNAF 4 +/** Left-to-right Width-w NAF. */ +#define LWREG 5 +/** Chosen prime elliptic curve point multiplication method. */ +#define EP_MUL @EP_MUL@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** Single-table comb method. */ +#define COMBS 2 +/** Double-table comb method. */ +#define COMBD 3 +/** Left-to-right Width-w NAF. */ +#define LWNAF 4 +/** Chosen prime elliptic curve point multiplication method. */ +#define EP_FIX @EP_FIX@ + +/** Basic simultaneouns point multiplication. */ +#define BASIC 1 +/** Shamir's trick. */ +#define TRICK 2 +/** Interleaving of w-(T)NAFs. */ +#define INTER 3 +/** Joint sparse form. */ +#define JOINT 4 +/** Chosen prime elliptic curve simulteanous point multiplication method. */ +#define EP_SIM @EP_SIM@ + +/** Prime elliptic curve arithmetic method. */ +#define EP_METHD "@EP_METHD@" + +/** Support for ordinary curves without endormorphisms. */ +#cmakedefine EB_PLAIN +/** Support for Koblitz anomalous binary curves. */ +#cmakedefine EB_KBLTZ +/** Use mixed coordinates. */ +#cmakedefine EB_MIXED +/** Build precomputation table for generator. */ +#cmakedefine EB_PRECO +/** Width of precomputation table for fixed point methods. */ +#define EB_DEPTH @EB_DEPTH@ +/** Width of window processing for unknown point methods. */ +#define EB_WIDTH @EB_WIDTH@ + +/** Binary elliptic curve arithmetic method. */ +#define EB_METHD "@EB_METHD@" + +/** Affine coordinates. */ +#define BASIC 1 +/** López-Dahab Projective coordinates. */ +#define PROJC 2 +/** Chosen binary elliptic curve coordinate method. */ +#define EB_ADD @EB_ADD@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** L�pez-Dahab point multiplication. */ +#define LODAH 2 +/** Halving. */ +#define HALVE 3 +/** Left-to-right width-w (T)NAF. */ +#define LWNAF 4 +/** Right-to-left width-w (T)NAF. */ +#define RWNAF 5 +/** Chosen binary elliptic curve point multiplication method. */ +#define EB_MUL @EB_MUL@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** Single-table comb method. */ +#define COMBS 2 +/** Double-table comb method. */ +#define COMBD 3 +/** Left-to-right Width-w NAF. */ +#define LWNAF 4 +/** Chosen binary elliptic curve point multiplication method. */ +#define EB_FIX @EB_FIX@ + +/** Basic simultaneouns point multiplication. */ +#define BASIC 1 +/** Shamir's trick. */ +#define TRICK 2 +/** Interleaving of w-(T)NAFs. */ +#define INTER 3 +/** Joint sparse form. */ +#define JOINT 4 +/** Chosen binary elliptic curve simulteanous point multiplication method. */ +#define EB_SIM @EB_SIM@ + +/** Build precomputation table for generator. */ +#cmakedefine ED_PRECO +/** Width of precomputation table for fixed point methods. */ +#define ED_DEPTH @ED_DEPTH@ +/** Width of window processing for unknown point methods. */ +#define ED_WIDTH @ED_WIDTH@ + +/** Edwards elliptic curve arithmetic method. */ +#define ED_METHD "@ED_METHD@" + +/** Affine coordinates. */ +#define BASIC 1 +/** Simple projective twisted Edwards coordinates */ +#define PROJC 2 +/** Extended projective twisted Edwards coordinates */ +#define EXTND 3 +/** Chosen binary elliptic curve coordinate method. */ +#define ED_ADD @ED_ADD@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** Sliding window. */ +#define SLIDE 2 +/** Montgomery powering ladder. */ +#define MONTY 3 +/** Left-to-right Width-w NAF. */ +#define LWNAF 4 +/** Left-to-right Width-w NAF. */ +#define LWREG 5 +/** Chosen prime elliptic twisted Edwards curve point multiplication method. */ +#define ED_MUL @ED_MUL@ + +/** Binary point multiplication. */ +#define BASIC 1 +/** Single-table comb method. */ +#define COMBS 2 +/** Double-table comb method. */ +#define COMBD 3 +/** Left-to-right Width-w NAF. */ +#define LWNAF 4 +/** Chosen prime elliptic twisted Edwards curve point multiplication method. */ +#define ED_FIX @ED_FIX@ + +/** Basic simultaneouns point multiplication. */ +#define BASIC 1 +/** Shamir's trick. */ +#define TRICK 2 +/** Interleaving of w-(T)NAFs. */ +#define INTER 3 +/** Joint sparse form. */ +#define JOINT 4 +/** Chosen prime elliptic curve simulteanous point multiplication method. */ +#define ED_SIM @ED_SIM@ + +/** Prime curves. */ +#define PRIME 1 +/** Binary curves. */ +#define CHAR2 2 +/** Edwards curves */ +#define EDDIE 3 +/** Chosen elliptic curve type. */ +#define EC_CUR @EC_CUR@ + +/** Chosen elliptic curve cryptography method. */ +#define EC_METHD "@EC_METHD@" +/** Prefer curves with efficient endomorphisms. */ +#cmakedefine EC_ENDOM + +/** Basic quadratic extension field arithmetic. */ +#define BASIC 1 +/** Lazy-reduced extension field arithmetic. */ +#define LAZYR 2 +/* Chosen extension field arithmetic method. */ +#define PP_EXT @PP_EXT@ + +/** Bilinear pairing method. */ +#define PP_METHD "@PP_METHD@" + +/** Tate pairing. */ +#define TATEP 1 +/** Weil pairing. */ +#define WEILP 2 +/** Optimal ate pairing. */ +#define OATEP 3 +/** Chosen pairing method over prime elliptic curves. */ +#define PP_MAP @PP_MAP@ + +/** SHA-224 hash function. */ +#define SH224 2 +/** SHA-256 hash function. */ +#define SH256 3 +/** SHA-384 hash function. */ +#define SH384 4 +/** SHA-512 hash function. */ +#define SH512 5 +/** BLAKE2s-160 hash function. */ +#define B2S160 6 +/** BLAKE2s-256 hash function. */ +#define B2S256 7 +/** Chosen hash function. */ +#define MD_MAP @MD_MAP@ + +/** Choice of hash function. */ +#define MD_METHD "@MD_METHD@" + +/** Chosen RSA method. */ +#cmakedefine CP_CRT +/** RSA without padding. */ +#define BASIC 1 +/** RSA PKCS#1 v1.5 padding. */ +#define PKCS1 2 +/** RSA PKCS#1 v2.1 padding. */ +#define PKCS2 3 +/** Chosen RSA padding method. */ +#define CP_RSAPD @CP_RSAPD@ + +/** Automatic memory allocation. */ +#define AUTO 1 +/** Dynamic memory allocation. */ +#define DYNAMIC 2 +/** Chosen memory allocation policy. */ +#define ALLOC @ALLOC@ + +/** NIST HASH-DRBG generator. */ +#define HASHD 1 +/** Intel RdRand instruction. */ +#define RDRND 2 +/** Operating system underlying generator. */ +#define UDEV 3 +/** Override library generator with the callback. */ +#define CALL 4 +/** Chosen random generator. */ +#define RAND @RAND@ + +/** Standard C library generator. */ +#define LIBC 1 +/** Intel RdRand instruction. */ +#define RDRND 2 +/** Device node generator. */ +#define UDEV 3 +/** Use Windows' CryptGenRandom. */ +#define WCGR 4 +/** Chosen random generator seeder. */ +#cmakedefine SEED @SEED@ + +/** GNU/Linux operating system. */ +#define LINUX 1 +/** FreeBSD operating system. */ +#define FREEBSD 2 +/** Windows operating system. */ +#define MACOSX 3 +/** Windows operating system. */ +#define WINDOWS 4 +/** Android operating system. */ +#define DROID 5 +/** Arduino platform. */ +#define DUINO 6 +/** OpenBSD operating system. */ +#define OPENBSD 7 +/** Detected operation system. */ +#cmakedefine OPSYS @OPSYS@ + +/** OpenMP multithreading support. */ +#define OPENMP 1 +/** POSIX multithreading support. */ +#define PTHREAD 2 +/** Chosen multithreading API. */ +#cmakedefine MULTI @MULTI@ + +/** Per-process high-resolution timer. */ +#define HREAL 1 +/** Per-process high-resolution timer. */ +#define HPROC 2 +/** Per-thread high-resolution timer. */ +#define HTHRD 3 +/** POSIX-compatible timer. */ +#define POSIX 4 +/** ANSI-compatible timer. */ +#define ANSI 5 +/** Cycle-counting timer. */ +#define CYCLE 6 +/** Performance monitoring framework. */ +#define PERF 7 +/** Chosen timer. */ +#cmakedefine TIMER @TIMER@ + +/** Prefix to identity this build of the library. */ +#cmakedefine LABEL @LABEL@ + +#ifndef ASM + +#include "relic_label.h" + +/** + * Prints the project options selected at build time. + */ +void conf_print(void); + +#endif /* ASM */ + +#endif /* !RLC_CONF_H */ From 3ae9f9d0cb65aff3a9cdb16a4845e3664189946f Mon Sep 17 00:00:00 2001 From: Odysseas Gabrielides Date: Fri, 4 Oct 2024 18:30:27 +0300 Subject: [PATCH 2/3] Squashed 'src/dashbls/' changes from 795660db76..3ffa7fa2b6 3ffa7fa2b6 chore: bump version to 1.3.2 (#94) 0f4efc9327 Merge pull request #88 from HashEngineering/feat/support-android a181889489 fix: rust bindings build for macos (#89) 69bdc1aac7 Merge pull request #85 from kwvg/debug 39791d4e31 build: print build options after configure 73106a0121 build: use `-mbranch-protection=bti` on supporting `aarch64` compilers 6a3c28f6ca build: use stricter `-Werror` when testing compile flags 7a1b227637 build: rename {`NO`}`WARN_CFLAGS` to {`NO`}`WARN_FLAGS`, use with C{++} 28bea63838 build: set {`NO`}`WARN_CFLAGS` flags if not overridden and uniformly 32c2f0f5f8 trivial: rename `CORE_CXXFLAGS` to `CORE_FLAGS`, use with C{++} b630c2c323 build: append `HARDENED_FLAGS` to `AM_CFLAGS` e6008148e4 trivial: rename `HARDENED_CXXFLAGS` to `HARDENED_FLAGS` af0e3daef5 build: subsume `PI{C,E}_FLAGS` into `HARDENED_CXXFLAGS` 9ff8618a1b build: expand `--disable-optimizations` to include `-O0` and `-fwrapv` 3036b83181 build: expand `--enable-debug` to include `-O0`, `-ftrapv` and dbg info c90d43d43b build: add check to see if `CFLAGS` has been overridden 2d77f7ae49 build: remove vestigial `LIBTOOL_{CXX,CPP,LD}FLAGS`, `HARDENED_CPPFLAGS` 883a098868 build: autodetect i?86 and arm as 32-bit deb3269820 build: don't specify exact `{CPU_}ARCH` if optimizations are disabled 720d49a44b trivial: fix indentation for `want_backend` check f9328320af build: use `easy` backend if optimizations are disabled unless specified 3687cd59e0 build: define new flag `--enable-optimizations` f82bfee5dd build: ensure help string format matches Autotool defaults d68920063e build: define arguments as `--enable-[term]` instead of `--disable-[term]` 7f41e7dd16 fix: support android 1c2fc79c19 feat(rust): allow to move G1 and G2 elements between threads (#87) 3540b8bbed feat: debug with data hex (#86) git-subtree-dir: src/dashbls git-subtree-split: 3ffa7fa2b62aecf3943c142508de4b7ec6005bb5 --- Makefile.am | 7 +- Makefile.relic.include | 2 +- apple.rust.deps.sh | 47 +- apple.rust.sh | 458 ------------------ apple.rust.single.sh | 404 --------------- configure.ac | 295 ++++++----- rust-bindings/bls-dash-sys/build.rs | 89 +++- rust-bindings/bls-signatures/Cargo.toml | 1 + rust-bindings/bls-signatures/src/elements.rs | 47 +- .../bls-signatures/src/legacy/elements.rs | 8 + rust-bindings/bls-signatures/src/lib.rs | 22 + .../bls-signatures/src/private_key.rs | 9 +- 12 files changed, 378 insertions(+), 1011 deletions(-) delete mode 100755 apple.rust.sh delete mode 100755 apple.rust.single.sh diff --git a/Makefile.am b/Makefile.am index 9ce6ff4f6c6a3..1c1e5d19d5941 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,9 +9,10 @@ print-%: FORCE ACLOCAL_AMFLAGS = -I build-aux/m4 .PHONY: deploy FORCE -AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(CORE_LDFLAGS) $(GMP_LDFLAGS) -AM_CXXFLAGS = $(LIBTOOL_CXXFLAGS) $(HARDENED_CXXFLAGS) $(CORE_CXXFLAGS) $(PIC_FLAGS) $(PIE_FLAGS) -AM_CPPFLAGS = $(LIBTOOL_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) $(PIC_FLAGS) $(GMP_CPPFLAGS) +AM_LDFLAGS = $(HARDENED_LDFLAGS) $(CORE_LDFLAGS) $(GMP_LDFLAGS) +AM_CFLAGS = $(DEBUG_FLAGS) $(HARDENED_FLAGS) $(CORE_FLAGS) $(WARN_FLAGS) $(NOWARN_FLAGS) +AM_CPPFLAGS = $(CORE_CPPFLAGS) $(GMP_CPPFLAGS) +AM_CXXFLAGS = $(DEBUG_FLAGS) $(HARDENED_FLAGS) $(CORE_FLAGS) $(WARN_FLAGS) $(NOWARN_FLAGS) PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = diff --git a/Makefile.relic.include b/Makefile.relic.include index 725e8ca4f233d..92bd7c7e8f5ba 100644 --- a/Makefile.relic.include +++ b/Makefile.relic.include @@ -464,7 +464,7 @@ librelic_la_SOURCES = \ librelic_la_CPPFLAGS = $(AM_CPPFLAGS) $(RELIC_CPPFLAGS) $(RELIC_INCLUDES) librelic_la_CXXFLAGS = $(AM_CXXFLAGS) -librelic_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS) $(NOWARN_CFLAGS) +librelic_la_CFLAGS = $(AM_CFLAGS) librelic_la_LDFLAGS = $(AM_LDFLAGS) noinst_LTLIBRARIES += $(LIBRELIC) diff --git a/apple.rust.deps.sh b/apple.rust.deps.sh index 7d3b8de22f4c6..8bd561c696872 100755 --- a/apple.rust.deps.sh +++ b/apple.rust.deps.sh @@ -1,5 +1,6 @@ #!/bin/sh set -x +set -e # "x86_64-apple-ios" # "aarch64-apple-ios" # "aarch64-apple-ios-sim" @@ -51,7 +52,7 @@ version_min_flag() { prepare() { download_gmp() { - GMP_VERSION="6.2.1" + GMP_VERSION="6.3.0" CURRENT_DIR=$(pwd) echo "$CURRENT_DIR" # shellcheck disable=SC2039,SC2164 @@ -65,8 +66,8 @@ prepare() { pushd contrib tar xfj "gmp-${GMP_VERSION}.tar.bz2" mv gmp-${GMP_VERSION} gmp - rm gmp/compat.c && cp ../../contrib/gmp-patch-6.2.1/compat.c gmp/compat.c - rm gmp/longlong.h && cp ../../contrib/gmp-patch-6.2.1/longlong.h gmp/longlong.h + #rm gmp/compat.c && cp ../../contrib/gmp-patch-6.2.1/compat.c gmp/compat.c + #rm gmp/longlong.h && cp ../../contrib/gmp-patch-6.2.1/longlong.h gmp/longlong.h # shellcheck disable=SC2039,SC2164 popd #contrib # shellcheck disable=SC2039,SC2164 @@ -88,10 +89,10 @@ prepare() { download_relic() { CURRENT_DIR=$(pwd) echo "$CURRENT_DIR" - mkdir -p "${CURRENT_DIR}/${BUILD}/contrib" - if [ ! -s "${CURRENT_DIR}/${BUILD}/contrib/relic" ]; then + mkdir -p "${CURRENT_DIR}/${BUILD}/depends" + if [ ! -s "${CURRENT_DIR}/${BUILD}/depends/relic" ]; then # shellcheck disable=SC2039,SC2164 - pushd "${CURRENT_DIR}/${BUILD}/contrib" + pushd "${CURRENT_DIR}/${BUILD}/depends" git clone --depth 1 --branch "feat/ios-support" https://github.com/pankcuf/relic # shellcheck disable=SC2039,SC2164 pushd relic @@ -100,7 +101,7 @@ prepare() { # shellcheck disable=SC2039,SC2164 popd #relic # shellcheck disable=SC2039,SC2164 - popd #contrib + popd #depends fi } rm -rf ${BUILD} @@ -115,7 +116,7 @@ build_gmp_arch() { ARCH=$2 PFX=${PLATFORM}-${ARCH} # why this works with this host only? - HOST=arm-apple-darwin + HOST=aarch64-apple-darwin # shellcheck disable=SC2039,SC2164 pushd ${BUILD} SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) @@ -143,7 +144,7 @@ CC="$CLANG" CFLAGS="$CFLAGS" CPPFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" \ --host=${HOST} --prefix="${CURRENT_DIR}/gmplib-${PFX}" \ --disable-shared --enable-static --disable-assembly -v EOF - + chmod a+x "$CONFIGURESCRIPT" sh "$CONFIGURESCRIPT" rm "$CONFIGURESCRIPT" @@ -154,6 +155,8 @@ EOF make -j "$LOGICALCPU_MAX" &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-build.log # shellcheck disable=SC2039 make install &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-install.log + #make check + #exit 1 # shellcheck disable=SC2039,SC2164 popd # gmp # shellcheck disable=SC2039,SC2164 @@ -258,15 +261,15 @@ build_relic_arch() { EXTRA_ARGS+=" -DARCH=X86" elif [[ $ARCH = "x86_64" ]]; then EXTRA_ARGS+=" -DARCH=X64" - else - EXTRA_ARGS+=" -DARCH=ARM" - if [[ $ARCH = "armv7s" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7s" - elif [[ $ARCH = "armv7k" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7k" - elif [[ $ARCH = "arm64_32" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=arm64_32" - fi + elif [[ $ARCH = "arm64" ]]; then + # Relic doesn't support aarch64 yet, "ARCH=ARM" is for ARM 32-bit architecture only + EXTRA_ARGS+=" -DIOS_ARCH=arm64 -DARCH=" + elif [[ $ARCH = "armv7s" ]]; then + EXTRA_ARGS+=" -DIOS_ARCH=armv7s -DARCH=ARM" + elif [[ $ARCH = "armv7k" ]]; then + EXTRA_ARGS+=" -DIOS_ARCH=armv7k -DARCH=ARM" + elif [[ $ARCH = "arm64_32" ]]; then + EXTRA_ARGS+=" -DIOS_ARCH=arm64_32 -DARCH=ARM" fi CURRENT_DIR=$(pwd) @@ -281,7 +284,7 @@ build_relic_arch() { # shellcheck disable=SC2039,SC2164 popd # "$BUILDDIR" # shellcheck disable=SC2039,SC2164 - popd # contrib/relic + popd # depends/relic } build_bls_arch() { @@ -311,7 +314,7 @@ build_bls_arch() { clang -I"../contrib/relic/include" \ -I"../../depends/relic/include" \ -I"../../include/dashbls" \ - -I"../relic-${PFX}/_deps/relic-build/include" \ + -I"../relic-${PFX}/depends/relic/include" \ -I"../../src/" \ -I"../gmplib-${PFX}/include" \ -x c++ -std=c++14 -stdlib=libc++ -fembed-bitcode -arch "${ARCH}" -isysroot "${SDK}" "${EXTRA_ARGS}" \ @@ -360,8 +363,8 @@ build_target() { rm -rf "build/artefacts/${BUILD_IN}" mkdir -p "build/artefacts/${BUILD_IN}" cp "build/gmplib-${PFX}/lib/libgmp.a" "build/artefacts/${BUILD_IN}" - cp "build/relic-${PFX}/_deps/relic-build/lib/librelic_s.a" "build/artefacts/${BUILD_IN}" - cp "build/relic-${PFX}/_deps/sodium-build/libsodium.a" "build/artefacts/${BUILD_IN}" + cp "build/relic-${PFX}/depends/relic/lib/librelic_s.a" "build/artefacts/${BUILD_IN}" +# cp "build/relic-${PFX}/depends/sodium/libsodium.a" "build/artefacts/${BUILD_IN}" cp "build/bls-${PFX}/libbls.a" "build/artefacts/${BUILD_IN}" # cp -rf build/bls-"${PFX}"/*.o build/artefacts/"${BUILD_IN}"/include # cp -rf src/*.hpp build/artefacts/"${BUILD_IN}"/include diff --git a/apple.rust.sh b/apple.rust.sh deleted file mode 100755 index e105c3ce6ce13..0000000000000 --- a/apple.rust.sh +++ /dev/null @@ -1,458 +0,0 @@ -#!/bin/sh -set -x - -git submodule update --init - -MIN_IOS="13.0" -MIN_WATCHOS="5.0" -MIN_TVOS=$MIN_IOS -MIN_MACOS="10.15" - -IPHONEOS=iphoneos -IPHONESIMULATOR=iphonesimulator -WATCHOS=watchos -WATCHSIMULATOR=watchsimulator -TVOS=appletvos -TVSIMULATOR=appletvsimulator -MACOS=macosx - -LOGICALCPU_MAX=$(sysctl -n hw.logicalcpu_max) -BUILD=build - -version_min_flag() { - PLATFORM=$1 - FLAG="" - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - FLAG="-miphoneos-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - FLAG="-mios-simulator-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $WATCHOS ]]; then - FLAG="-mwatchos-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - FLAG="-mwatchos-simulator-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $TVOS ]]; then - FLAG="-mtvos-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - FLAG="-mtvos-simulator-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $MACOS ]]; then - FLAG="-mmacosx-version-min=${MIN_MACOS}" - fi - echo $FLAG -} - - -prepare() { - download_gmp() { - GMP_VERSION="6.2.1" - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - mkdir -p "contrib" - if [ ! -s "contrib/gmp-${GMP_VERSION}.tar.bz2" ]; then - curl -L -o "contrib/gmp-${GMP_VERSION}.tar.bz2" https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2 - fi - rm -rf "contrib/gmp" - # shellcheck disable=SC2039,SC2164 - pushd contrib - tar xfj "gmp-${GMP_VERSION}.tar.bz2" - mv gmp-${GMP_VERSION} gmp - rm gmp/compat.c && cp ../../contrib/gmp-patch-6.2.1/compat.c gmp/compat.c - rm gmp/longlong.h && cp ../../contrib/gmp-patch-6.2.1/longlong.h gmp/longlong.h - # shellcheck disable=SC2039,SC2164 - popd #contrib - # shellcheck disable=SC2039,SC2164 - popd #build - } - - download_cmake_toolchain() { - if [ ! -s "${BUILD}/ios.toolchain.cmake" ]; then - SHA256_HASH="d02857ff6bd64f1d7109ca59c3e4f3b2f89d0663c412146e6977c679801b3243" - curl -o "${BUILD}/ios.toolchain.cmake" https://raw.githubusercontent.com/leetal/ios-cmake/c55677a4445b138c9ef2650d3c21f22cc78c2357/ios.toolchain.cmake - DOWNLOADED_HASH=$(shasum -a 256 ${BUILD}/ios.toolchain.cmake | cut -f 1 -d " ") - if [ $SHA256_HASH != "$DOWNLOADED_HASH" ]; then - echo "Error: sha256 checksum of ios.toolchain.cmake mismatch" >&2 - exit 1 - fi - fi - } - - download_relic() { - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - mkdir -p "${CURRENT_DIR}/${BUILD}/contrib" - if [ ! -s "${CURRENT_DIR}/${BUILD}/contrib/relic" ]; then - # shellcheck disable=SC2039,SC2164 - pushd "${CURRENT_DIR}/${BUILD}/contrib" - git clone --depth 1 --branch "feat/ios-support" https://github.com/pankcuf/relic - # shellcheck disable=SC2039,SC2164 - pushd relic - git fetch --depth 1 origin 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - git checkout 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - # shellcheck disable=SC2039,SC2164 - popd #relic - # shellcheck disable=SC2039,SC2164 - popd #contrib - fi - } - rm -rf ${BUILD} - mkdir -p ${BUILD} - download_relic - download_gmp - download_cmake_toolchain - mkdir -p ${BUILD}/artefacts/include -} - -build_gmp_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - # why this works with this host only? - HOST=arm-apple-darwin - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - PLATFORM_PATH=$(xcrun --sdk "$PLATFORM" --show-sdk-platform-path) - CLANG=$(xcrun --sdk "$PLATFORM" --find clang) - DEVELOPER=$(xcode-select --print-path) - CURRENT_DIR=$(pwd) - export PATH="${PLATFORM_PATH}/Developer/usr/bin:${DEVELOPER}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin" - mkdir gmplib-"${PLATFORM}"-"${ARCH}" - CFLAGS="-Wno-unused-value -fembed-bitcode -arch ${ARCH} --sysroot=${SDK} $(version_min_flag "$PLATFORM")" - CONFIGURESCRIPT="gmp_configure_script.sh" - # shellcheck disable=SC2039,SC2164 - pushd contrib - # shellcheck disable=SC2039,SC2164 - pushd gmp - make clean || true - make distclean || true - echo "HOST: $HOST" - echo "PREFIX: ${CURRENT_DIR}/gmplib-${PFX}" - - cat >"$CONFIGURESCRIPT" << EOF -#!/bin/sh -./configure \ -CC="$CLANG" CFLAGS="$CFLAGS" CPPFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" \ ---host=${HOST} --prefix="${CURRENT_DIR}/gmplib-${PFX}" \ ---disable-shared --enable-static --disable-assembly -v -EOF - - chmod a+x "$CONFIGURESCRIPT" - sh "$CONFIGURESCRIPT" - rm "$CONFIGURESCRIPT" - - # shellcheck disable=SC2039 - mkdir -p "${CURRENT_DIR}/log" - # shellcheck disable=SC2039 - make -j "$LOGICALCPU_MAX" &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-build.log - # shellcheck disable=SC2039 - make install &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-install.log - # shellcheck disable=SC2039,SC2164 - popd # gmp - # shellcheck disable=SC2039,SC2164 - popd # contrib - # shellcheck disable=SC2039,SC2164 - popd # build -} - -build_relic_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=relic-"${PFX}" - TOOLCHAIN=$(pwd)/ios.toolchain.cmake - GMP_PFX=$(pwd)/gmplib-${PFX} - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - unset CC - # shellcheck disable=SC2155 - export CC=$(xcrun --sdk "${PLATFORM}" --find clang) - - WSIZE=0 - IOS_PLATFORM="" - OPTIMIZATIONFLAGS="" - DEPLOYMENT_TARGET="" - - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - if [[ $ARCH = "arm64" ]] || [[ $ARCH = "arm64e" ]]; then - IOS_PLATFORM=OS64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - else - IOS_PLATFORM=OS - WSIZE=32 - fi - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - if [[ $ARCH = "x86_64" ]]; then - IOS_PLATFORM=SIMULATOR64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $ARCH = "arm64" ]]; then - IOS_PLATFORM=SIMULATORARM64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - else - IOS_PLATFORM=SIMULATOR - WSIZE=32 - fi - elif [[ $PLATFORM = $WATCHOS ]]; then - IOS_PLATFORM=WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $TVOS ]]; then - IOS_PLATFORM=TVOS - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_TVOS - #TODO - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=OS64 - fi - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $MACOS ]]; then - WSIZE=64 - IOS_PLATFORM=MAC - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=MAC_ARM64 - fi - DEPLOYMENT_TARGET=$MIN_MACOS - OPTIMIZATIONFLAGS=-fomit-frame-pointer - fi - - COMPILER_ARGS="$(version_min_flag "$PLATFORM") -Wno-unused-functions" - - EXTRA_ARGS="-DOPSYS=NONE -DPLATFORM=$IOS_PLATFORM -DDEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN" - - # shellcheck disable=SC2039 - if [[ $ARCH = "i386" ]]; then - EXTRA_ARGS+=" -DARCH=X86" - elif [[ $ARCH = "x86_64" ]]; then - EXTRA_ARGS+=" -DARCH=X64" - else - EXTRA_ARGS+=" -DARCH=ARM" - if [[ $ARCH = "armv7s" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7s" - elif [[ $ARCH = "armv7k" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7k" - elif [[ $ARCH = "arm64_32" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=arm64_32" - fi - fi - - CURRENT_DIR=$(pwd) - cmake -DCMAKE_PREFIX_PATH:PATH="${GMP_PFX}" -DTESTS=0 -DBENCH=0 -DBUILD_BLS_JS_BINDINGS=0 -DBUILD_BLS_PYTHON_BINDINGS=0 \ - -DBUILD_BLS_BENCHMARKS=0 -DBUILD_BLS_TESTS=0 -DCHECK=off -DARITH=gmp -DTIMER=HPROC -DFP_PRIME=381 -DMULTI=PTHREAD \ - -DFP_QNRES=on -DFP_METHD="INTEG;INTEG;INTEG;MONTY;EXGCD;SLIDE" -DFPX_METHD="INTEG;INTEG;LAZYR" -DPP_METHD="LAZYR;OATEP" \ - -DCOMP_FLAGS="-pipe -std=c99 -O3 -funroll-loops $OPTIMIZATIONFLAGS -isysroot $SDK -arch $ARCH -fembed-bitcode ${COMPILER_ARGS}" \ - -DWSIZE=$WSIZE -DVERBS=off -DSHLIB=off -DALLOC="AUTO" -DEP_PLAIN=off -DEP_SUPER=off -DPP_EXT="LAZYR" \ - -DWITH="DV;BN;MD;FP;EP;FPX;EPX;PP;PC;CP" -DBN_METHD="COMBA;COMBA;MONTY;SLIDE;STEIN;BASIC" ${EXTRA_ARGS} ../../ - - make -j "$LOGICALCPU_MAX" - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - popd # contrib/relic -} - -build_bls_arch() { - # shellcheck disable=SC2039 - BLS_FILES=( "bls" "chaincode" "elements" "extendedprivatekey" "extendedpublickey" "legacy" "privatekey" "schemes" "threshold" ) - # shellcheck disable=SC2039 - ALL_BLS_OBJ_FILES=$(printf "%s.o " "${BLS_FILES[@]}") - - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=${BUILD}/bls-"${PFX}" - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - EXTRA_ARGS="$(version_min_flag "$PLATFORM")" - - CURRENT_DIR=$(pwd) - - # shellcheck disable=SC2039 - for F in "${BLS_FILES[@]}" - do - clang -I"../contrib/relic/include" \ - -I"../relic-${PFX}/_deps/relic-build/include" \ - -I"../../src/" \ - -I"../gmplib-${PFX}/include" \ - -x c++ -std=c++14 -stdlib=libc++ -fembed-bitcode -arch "${ARCH}" -isysroot "${SDK}" "${EXTRA_ARGS}" \ - -c "../../src/${F}.cpp" -o "${F}.o" - done - - # shellcheck disable=SC2086 - xcrun -sdk "$PLATFORM" ar -cvq libbls.a $ALL_BLS_OBJ_FILES - - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" -} - -build_all_arch() { - PLATFORM=$1 - ARCH=$2 - build_gmp_arch "$PLATFORM" "$ARCH" - build_relic_arch "$PLATFORM" "$ARCH" - build_bls_arch "$PLATFORM" "$ARCH" -} - -build_all() { - BUILD_IN=$1 - TARGET_DIR=build/artefacts - # shellcheck disable=SC2039 - IFS='|' read -ra BUILD_PAIRS <<< "$BUILD_IN" - # shellcheck disable=SC2039 - for BUILD_PAIR in "${BUILD_PAIRS[@]}" - do - # shellcheck disable=SC2039 - IFS=';' read -ra PARSED_PAIR <<< "$BUILD_PAIR" - # shellcheck disable=SC2039 - PLATFORM=${PARSED_PAIR[0]} - # shellcheck disable=SC2039 - ARCH=${PARSED_PAIR[1]} - - GMP_LIPOARGS="" - RELIC_LIPOARGS="" - BLS_LIPOARGS="" - - # shellcheck disable=SC2039 - local NEED_LIPO=0 - # shellcheck disable=SC2039 - IFS='+' read -ra ARCHS <<< "$ARCH" - # shellcheck disable=SC2039 - for i in "${!ARCHS[@]}" - do - # shellcheck disable=SC2039 - local SINGLEARCH=${ARCHS[i]} - - # build for every platform+arch - build_all_arch "$PLATFORM" "$SINGLEARCH" - - PFX="${PLATFORM}"-"${SINGLEARCH}" - ARCH_TARGET_DIR=${TARGET_DIR}/${PFX} - rm -rf "${ARCH_TARGET_DIR}" - mkdir -p "${ARCH_TARGET_DIR}" - #mv "${BUILD}/gmplib-${PFX}/lib/libgmp.a" "${ARCH_TARGET_DIR}/libgmp.a" - #mv "${BUILD}/relic-${PFX}/_deps/relic-build/lib/librelic_s.a" "${ARCH_TARGET_DIR}/librelic.a" - #mv "${BUILD}/bls-${PFX}/libbls.a" "${ARCH_TARGET_DIR}/libbls.a" - - libtool -static -o "${ARCH_TARGET_DIR}/libbls.a" \ - "${BUILD}/gmplib-${PFX}/lib/libgmp.a" \ - "${BUILD}/relic-${PFX}/_deps/relic-build/lib/librelic_s.a" \ - "${BUILD}/bls-${PFX}/libbls.a" - - # shellcheck disable=SC2039 - GMP_LIPOARGS+="${ARCH_TARGET_DIR}/libgmp.a " - # shellcheck disable=SC2039 - RELIC_LIPOARGS+="${ARCH_TARGET_DIR}/librelic.a " - # shellcheck disable=SC2039 - BLS_LIPOARGS+="${ARCH_TARGET_DIR}/libbls.a " - - NEED_LIPO=i - done - - # Do lipo if we need https://developer.apple.com/forums/thread/666335?answerId=645963022#645963022 -# if [[ $NEED_LIPO -gt 0 ]] -# then -# FAT_TARGET_DIR=${TARGET_DIR}/${PLATFORM}-fat -# rm -rf "${FAT_TARGET_DIR}" -# mkdir -p "${FAT_TARGET_DIR}" -# # shellcheck disable=SC2086 -# xcrun lipo $GMP_LIPOARGS -create -output "${FAT_TARGET_DIR}/libgmp.a" -# # shellcheck disable=SC2086 -# xcrun lipo $RELIC_LIPOARGS -create -output "${FAT_TARGET_DIR}/librelic.a" -# # shellcheck disable=SC2086 -# xcrun lipo $BLS_LIPOARGS -create -output "${FAT_TARGET_DIR}/libbls.a" -# libtool -static -o "${FAT_TARGET_DIR}/libbls_combined.a" "${FAT_TARGET_DIR}/libgmp.a" "${FAT_TARGET_DIR}/librelic.a" "${FAT_TARGET_DIR}/libbls.a" -# rm "${FAT_TARGET_DIR}/libgmp.a" -# rm "${FAT_TARGET_DIR}/librelic.a" -# rm "${FAT_TARGET_DIR}/libbls.a" -# mv "${FAT_TARGET_DIR}/libbls_combined.a" "${FAT_TARGET_DIR}/libbls.a" -# # clean up -# # shellcheck disable=SC2039 -# for i in "${!ARCHS[@]}" -# do -# local SINGLEARCH=${ARCHS[i]} -# rm -rf "${TARGET_DIR}-${SINGLEARCH}" -# done -# fi - done -} - -#make_relic_headers_universal() { -# RELIC_TARGET_DIR=relic-iphoneos-arm64 -# perl -p -e 's/#define WSIZE.*/#ifdef __LP64__\n#define WSIZE 64\n#else\n#define WSIZE 32\n#endif/' \ -# "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" \ -# > "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h.new" -# -# rm "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" -# mv "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h.new" "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" -#} - -#copy_headers() { -# mkdir build/artefacts/include -# # Copy all headers we will need -# cp -rf src/*.hpp build/artefacts/include -# cp -rf build/gmp/include/gmp.h build/artefacts/include -# cp -rf build/contrib/relic/include/*.h build/artefacts/include -# cp -rf build/contrib/relic/include/low/*.h build/artefacts/include -# cp -rf build/contrib/relic/relic-iphoneos-arm64/include/*.h build/artefacts/include -# rm -rf build/artefacts/include/test-utils.hpp -#} - -#function make_fat_binary() -#{ -# pushd artefacts -# -# XCFRAMEWORK_ARGS="" -# -# for dir in */; do -# if [ -d "$dir" ]; then -# if [[ "$dir" != "include/" ]]; then -# libtool -static -o "${dir}libbls_combined.a" "${dir}libgmp.a" "${dir}librelic.a" "${dir}libbls.a" -# -# XCFRAMEWORK_ARGS+="-library ${dir}libbls_combined.a -headers include " -# fi -# fi -# done -# -# #xcodebuild -create-xcframework $XCFRAMEWORK_ARGS -output "libbls.xcframework" -#} - -prepare -build_all "${MACOS};x86_64+arm64" -build_all "${IPHONEOS};arm64|${IPHONESIMULATOR};arm64+x86_64" - -#make_relic_headers_universal -#copy_headers -#make_fat_binary diff --git a/apple.rust.single.sh b/apple.rust.single.sh deleted file mode 100755 index d99722bf02c76..0000000000000 --- a/apple.rust.single.sh +++ /dev/null @@ -1,404 +0,0 @@ -#!/bin/sh -set -x -# "x86_64-apple-ios" -# "x86_64-apple-ios-sim" -# "aarch64-apple-ios" -# "aarch64-apple-ios-sim" -# "x86_64-apple-darwin" -# "aarch64-apple-darwin" -# TODO: it's probably needs to be optimized in order to increase better build velocity -# TODO: so we need to combine multiple targets -TARGET=$1 -git submodule update --init -MIN_IOS="13.0" -MIN_WATCHOS="5.0" -MIN_TVOS=$MIN_IOS -MIN_MACOS="10.15" - -IPHONEOS=iphoneos -IPHONESIMULATOR=iphonesimulator -WATCHOS=watchos -WATCHSIMULATOR=watchsimulator -TVOS=appletvos -TVSIMULATOR=appletvsimulator -MACOS=macosx - -LOGICALCPU_MAX=$(sysctl -n hw.logicalcpu_max) -BUILD=build - -version_min_flag() { - PLATFORM=$1 - FLAG="" - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - FLAG="-miphoneos-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - FLAG="-mios-simulator-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $WATCHOS ]]; then - FLAG="-mwatchos-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - FLAG="-mwatchos-simulator-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $TVOS ]]; then - FLAG="-mtvos-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - FLAG="-mtvos-simulator-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $MACOS ]]; then - FLAG="-mmacosx-version-min=${MIN_MACOS}" - fi - echo $FLAG -} - - -prepare() { - download_gmp() { - GMP_VERSION="6.2.1" - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - mkdir -p "contrib" - if [ ! -s "contrib/gmp-${GMP_VERSION}.tar.bz2" ]; then - curl -L -o "contrib/gmp-${GMP_VERSION}.tar.bz2" https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2 - fi - rm -rf "contrib/gmp" - # shellcheck disable=SC2039,SC2164 - pushd contrib - tar xfj "gmp-${GMP_VERSION}.tar.bz2" - mv gmp-${GMP_VERSION} gmp - rm gmp/compat.c && cp ../../contrib/gmp-patch-6.2.1/compat.c gmp/compat.c - rm gmp/longlong.h && cp ../../contrib/gmp-patch-6.2.1/longlong.h gmp/longlong.h - # shellcheck disable=SC2039,SC2164 - popd #contrib - # shellcheck disable=SC2039,SC2164 - popd #build - } - - download_cmake_toolchain() { - if [ ! -s "${BUILD}/ios.toolchain.cmake" ]; then - SHA256_HASH="d02857ff6bd64f1d7109ca59c3e4f3b2f89d0663c412146e6977c679801b3243" - curl -o "${BUILD}/ios.toolchain.cmake" https://raw.githubusercontent.com/leetal/ios-cmake/c55677a4445b138c9ef2650d3c21f22cc78c2357/ios.toolchain.cmake - DOWNLOADED_HASH=$(shasum -a 256 ${BUILD}/ios.toolchain.cmake | cut -f 1 -d " ") - if [ $SHA256_HASH != "$DOWNLOADED_HASH" ]; then - echo "Error: sha256 checksum of ios.toolchain.cmake mismatch" >&2 - exit 1 - fi - fi - } - - download_relic() { - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - mkdir -p "${CURRENT_DIR}/${BUILD}/contrib" - if [ ! -s "${CURRENT_DIR}/${BUILD}/contrib/relic" ]; then - # shellcheck disable=SC2039,SC2164 - pushd "${CURRENT_DIR}/${BUILD}/contrib" - git clone --depth 1 --branch "feat/ios-support" https://github.com/pankcuf/relic - # shellcheck disable=SC2039,SC2164 - pushd relic - git fetch --depth 1 origin 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - git checkout 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - # shellcheck disable=SC2039,SC2164 - popd #relic - # shellcheck disable=SC2039,SC2164 - popd #contrib - fi - } - rm -rf ${BUILD} - mkdir -p ${BUILD} - download_relic - download_gmp - download_cmake_toolchain -} - -build_gmp_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - # why this works with this host only? - HOST=arm-apple-darwin - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - PLATFORM_PATH=$(xcrun --sdk "$PLATFORM" --show-sdk-platform-path) - CLANG=$(xcrun --sdk "$PLATFORM" --find clang) - DEVELOPER=$(xcode-select --print-path) - CURRENT_DIR=$(pwd) - export PATH="${PLATFORM_PATH}/Developer/usr/bin:${DEVELOPER}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin" - mkdir gmplib-"${PLATFORM}"-"${ARCH}" - CFLAGS="-Wno-unused-value -fembed-bitcode -arch ${ARCH} --sysroot=${SDK} $(version_min_flag "$PLATFORM")" - CONFIGURESCRIPT="gmp_configure_script.sh" - # shellcheck disable=SC2039,SC2164 - pushd contrib - # shellcheck disable=SC2039,SC2164 - pushd gmp - make clean || true - make distclean || true - echo "HOST: $HOST" - echo "PREFIX: ${CURRENT_DIR}/gmplib-${PFX}" - - cat >"$CONFIGURESCRIPT" << EOF -#!/bin/sh -./configure \ -CC="$CLANG" CFLAGS="$CFLAGS" CPPFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" \ ---host=${HOST} --prefix="${CURRENT_DIR}/gmplib-${PFX}" \ ---disable-shared --enable-static --disable-assembly -v -EOF - - chmod a+x "$CONFIGURESCRIPT" - sh "$CONFIGURESCRIPT" - rm "$CONFIGURESCRIPT" - - # shellcheck disable=SC2039 - mkdir -p "${CURRENT_DIR}/log" - # shellcheck disable=SC2039 - make -j "$LOGICALCPU_MAX" &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-build.log - # shellcheck disable=SC2039 - make install &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-install.log - # shellcheck disable=SC2039,SC2164 - popd # gmp - # shellcheck disable=SC2039,SC2164 - popd # contrib - # shellcheck disable=SC2039,SC2164 - popd # build -} - -build_relic_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=relic-"${PFX}" - TOOLCHAIN=$(pwd)/ios.toolchain.cmake - GMP_PFX=$(pwd)/gmplib-${PFX} - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - unset CC - # shellcheck disable=SC2155 - export CC=$(xcrun --sdk "${PLATFORM}" --find clang) - - WSIZE=0 - IOS_PLATFORM="" - OPTIMIZATIONFLAGS="" - DEPLOYMENT_TARGET="" - - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - if [[ $ARCH = "arm64" ]] || [[ $ARCH = "arm64e" ]]; then - IOS_PLATFORM=OS64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - else - IOS_PLATFORM=OS - WSIZE=32 - fi - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - if [[ $ARCH = "x86_64" ]]; then - IOS_PLATFORM=SIMULATOR64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $ARCH = "arm64" ]]; then - IOS_PLATFORM=SIMULATORARM64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - else - IOS_PLATFORM=SIMULATOR - WSIZE=32 - fi - elif [[ $PLATFORM = $WATCHOS ]]; then - IOS_PLATFORM=WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $TVOS ]]; then - IOS_PLATFORM=TVOS - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_TVOS - #TODO - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=OS64 - fi - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $MACOS ]]; then - WSIZE=64 - IOS_PLATFORM=MAC - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=MAC_ARM64 - fi - DEPLOYMENT_TARGET=$MIN_MACOS - OPTIMIZATIONFLAGS=-fomit-frame-pointer - fi - - COMPILER_ARGS="$(version_min_flag "$PLATFORM") -Wno-unused-functions" - - EXTRA_ARGS="-DOPSYS=NONE -DPLATFORM=$IOS_PLATFORM -DDEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN" - - # shellcheck disable=SC2039 - if [[ $ARCH = "i386" ]]; then - EXTRA_ARGS+=" -DARCH=X86" - elif [[ $ARCH = "x86_64" ]]; then - EXTRA_ARGS+=" -DARCH=X64" - else - EXTRA_ARGS+=" -DARCH=ARM" - if [[ $ARCH = "armv7s" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7s" - elif [[ $ARCH = "armv7k" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7k" - elif [[ $ARCH = "arm64_32" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=arm64_32" - fi - fi - - CURRENT_DIR=$(pwd) - cmake -DCMAKE_PREFIX_PATH:PATH="${GMP_PFX}" -DTESTS=0 -DBENCH=0 -DBUILD_BLS_JS_BINDINGS=0 -DBUILD_BLS_PYTHON_BINDINGS=0 \ - -DBUILD_BLS_BENCHMARKS=0 -DBUILD_BLS_TESTS=0 -DCHECK=off -DARITH=gmp -DTIMER=HPROC -DFP_PRIME=381 -DMULTI=PTHREAD \ - -DFP_QNRES=on -DFP_METHD="INTEG;INTEG;INTEG;MONTY;EXGCD;SLIDE" -DFPX_METHD="INTEG;INTEG;LAZYR" -DPP_METHD="LAZYR;OATEP" \ - -DCOMP_FLAGS="-pipe -std=c99 -O3 -funroll-loops $OPTIMIZATIONFLAGS -isysroot $SDK -arch $ARCH -fembed-bitcode ${COMPILER_ARGS}" \ - -DWSIZE=$WSIZE -DVERBS=off -DSHLIB=off -DALLOC="AUTO" -DEP_PLAIN=off -DEP_SUPER=off -DPP_EXT="LAZYR" \ - -DWITH="DV;BN;MD;FP;EP;FPX;EPX;PP;PC;CP" -DBN_METHD="COMBA;COMBA;MONTY;SLIDE;STEIN;BASIC" ${EXTRA_ARGS} ../../ - - make -j "$LOGICALCPU_MAX" - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - popd # contrib/relic -} - -build_bls_arch() { - # shellcheck disable=SC2039 - BLS_FILES=( "bls" "chaincode" "elements" "extendedprivatekey" "extendedpublickey" "legacy" "privatekey" "schemes" "threshold" ) - # shellcheck disable=SC2039 - ALL_BLS_OBJ_FILES=$(printf "%s.o " "${BLS_FILES[@]}") - - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=${BUILD}/bls-"${PFX}" - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - EXTRA_ARGS="$(version_min_flag "$PLATFORM")" - - CURRENT_DIR=$(pwd) - - # shellcheck disable=SC2039 - for F in "${BLS_FILES[@]}" - do - clang -I"../contrib/relic/include" \ - -I"../relic-${PFX}/_deps/relic-build/include" \ - -I"../../src/" \ - -I"../gmplib-${PFX}/include" \ - -x c++ -std=c++14 -stdlib=libc++ -fembed-bitcode -arch "${ARCH}" -isysroot "${SDK}" "${EXTRA_ARGS}" \ - -c "../../src/${F}.cpp" -o "${F}.o" - done - - # shellcheck disable=SC2086 - xcrun -sdk "$PLATFORM" ar -cvq libbls.a $ALL_BLS_OBJ_FILES - - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" -} - -build_all_arch() { - PLATFORM=$1 - ARCH=$2 - build_gmp_arch "$PLATFORM" "$ARCH" - build_relic_arch "$PLATFORM" "$ARCH" - build_bls_arch "$PLATFORM" "$ARCH" -} - -build_target() { - BUILD_IN=$1 - echo "Build target: $BUILD_IN" - ARCH="" - PLATFORM="" - # shellcheck disable=SC2039 - if [[ $BUILD_IN = "x86_64-apple-ios" ]]; then - ARCH=x86_64 - PLATFORM=$IPHONESIMULATOR - elif [[ $BUILD_IN = "aarch64-apple-ios" ]]; then - ARCH=arm64 - PLATFORM=$IPHONEOS - elif [[ $BUILD_IN = "aarch64-apple-ios-sim" ]]; then - ARCH=arm64 - PLATFORM=$IPHONESIMULATOR - elif [[ $BUILD_IN = "x86_64-apple-darwin" ]]; then - ARCH=x86_64 - PLATFORM=$MACOS - elif [[ $BUILD_IN = "aarch64-apple-darwin" ]]; then - ARCH=arm64 - PLATFORM=$MACOS - fi - build_all_arch "$PLATFORM" "$ARCH" - PFX="${PLATFORM}"-"${ARCH}" - rm -rf "build/artefacts/${BUILD_IN}" - mkdir -p "build/artefacts/${BUILD_IN}/include" -# libtool -static -o "build/artefacts/${BUILD_IN}/libbls.a" \ -# "build/gmplib-${PFX}/lib/libgmp.a" \ -# "build/relic-${PFX}/_deps/relic-build/lib/librelic_s.a" \ -# "build/bls-${PFX}/libbls.a" - cp "build/gmplib-${PFX}/lib/libgmp.a" "build/artefacts/${BUILD_IN}" - cp "build/relic-${PFX}/_deps/relic-build/lib/librelic_s.a" "build/artefacts/${BUILD_IN}" - cp "build/relic-${PFX}/_deps/sodium-build/libsodium.a" "build/artefacts/${BUILD_IN}" - cp "build/bls-${PFX}/libbls.a" "build/artefacts/${BUILD_IN}" - cp -rf build/bls-"${PFX}"/*.o build/artefacts/"${BUILD_IN}"/include - cp -rf src/*.hpp build/artefacts/"${BUILD_IN}"/include - cp -rf build/gmplib-"${PFX}"/include/gmp.h build/artefacts/"${BUILD_IN}"/include - cp -rf build/relic-"${PFX}"/_deps/relic-build/include/*.h build/artefacts/"${BUILD_IN}"/include -} - -#make_relic_headers_universal() { -# RELIC_TARGET_DIR=relic-iphoneos-arm64 -# perl -p -e 's/#define WSIZE.*/#ifdef __LP64__\n#define WSIZE 64\n#else\n#define WSIZE 32\n#endif/' \ -# "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" \ -# > "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h.new" -# -# rm "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" -# mv "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h.new" "build/contrib/relic/${RELIC_TARGET_DIR}/include/relic_conf.h" -#} -# -#copy_headers() { -## mkdir build/artefacts/include -# # Copy all headers we will need -# cp -rf src/*.hpp ${BUILD}/artefacts/include -# cp -rf ${BUILD}/contrib/gmp/include/gmp.h ${BUILD}/artefacts/include -# cp -rf ${BUILD}/contrib/relic/include/*.h ${BUILD}/artefacts/include -# cp -rf ${BUILD}/contrib/relic/include/low/*.h ${BUILD}/artefacts/include -# #cp -rf ${BUILD}/contrib/relic/relic-iphoneos-arm64/include/*.h ${BUILD}/artefacts/include -# rm -rf ${BUILD}/artefacts/include/test-utils.hpp -#} - -prepare -build_target "$TARGET" -#copy_headers -#build_all "${MACOS};x86_64+arm64" -#build_all "${IPHONEOS};arm64|${IPHONESIMULATOR};arm64+x86_64" - -#make_relic_headers_universal -#copy_headers -#make_fat_binary diff --git a/configure.ac b/configure.ac index 23b61ec45511f..084b4edea1fc1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([libdashbls],[1.3.0]) +AC_INIT([libdashbls],[1.3.2]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux/m4]) @@ -24,11 +24,17 @@ dnl make the compilation flags quiet unless V=1 is used m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl Compiler checks (here before libtool). +if test "x${CFLAGS+set}" = "xset"; then + CFLAGS_overridden=yes +else + CFLAGS_overridden=no +fi if test "x${CXXFLAGS+set}" = "xset"; then CXXFLAGS_overridden=yes else CXXFLAGS_overridden=no fi + AC_PROG_CXX AM_PROG_CC_C_O @@ -58,24 +64,76 @@ AC_PATH_TOOL(STRIP, strip) AM_PROG_AS -AC_ARG_ENABLE(tests, - [AS_HELP_STRING([--disable-tests], - [do not compile tests (default is to compile)])], +AC_ARG_ENABLE([tests], + [AS_HELP_STRING([--enable-tests], + [Compile with tests [default=yes]])], [use_tests=$enableval], [use_tests=yes]) -AC_ARG_ENABLE(bench, - [AS_HELP_STRING([--disable-bench], - [do not compile benchmarks (default is to compile)])], +AC_ARG_ENABLE([bench], + [AS_HELP_STRING([--enable-bench], + [Compile with benchmarks [default=yes]])], [use_bench=$enableval], [use_bench=yes]) AC_ARG_ENABLE([hardening], - [AS_HELP_STRING([--disable-hardening], - [do not attempt to harden the resulting executables (default is to harden when possible)])], + [AS_HELP_STRING([--enable-hardening], + [Enable hardening flags and arguments [default=auto]])], [use_hardening=$enableval], [use_hardening=auto]) +AC_ARG_ENABLE([optimizations], + [AS_HELP_STRING([--enable-optimizations], + [Enable compiler and library optimizations [default=yes]])], + [use_optimizations=$enableval], + [use_optimizations=yes]) + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [Build with debugging support [default=no]])], + [use_debug=$enableval], + [use_debug=no]) + +AC_LANG_PUSH([C]) + +dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may +dnl appear to succeed because by default they merely emit warnings when they fail. +dnl +dnl Note that this is not necessarily a check to see if -Werror is supported, but rather to see if +dnl a compile with -Werror can succeed. This is important because the compiler may already be +dnl warning about something unrelated, for example about some path issue. If that is the case, +dnl -Werror cannot be used because all of those warnings would be turned into errors. +AX_CHECK_COMPILE_FLAG([-Werror], [FLAG_WERROR="-Werror"], [FLAG_WERROR=""]) + +if [[[ "$use_debug" == "yes" || "$use_optimizations" == "no" ]]]; then + dnl Clear default -g -O2 flags + if test x"$CFLAGS_overridden" = x"no"; then + CFLAGS="" + fi + if test x"$CXXFLAGS_overridden" = x"no"; then + CXXFLAGS="" + fi + + dnl Disable optimizations + AX_CHECK_COMPILE_FLAG([-O0], [[DEBUG_FLAGS="$DEBUG_FLAGS -O0"]], [], [[$FLAG_WERROR]]) + + if [[[ "$use_debug" == "yes" ]]]; then + dnl Prefer -g3, fall back to -g if that is unavailable. + AX_CHECK_COMPILE_FLAG( + [-g3], + [[DEBUG_FLAGS="$DEBUG_FLAGS -g3"]], + [AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_FLAGS="$DEBUG_FLAGS -g"]])], [[$FLAG_WERROR]]) + + AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_FLAGS="$DEBUG_FLAGS -ftrapv"], [], [[$FLAG_WERROR]]) + else + dnl Reintroduce -g flag deleted during C(XX)FLAGS reset + AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_FLAGS="$DEBUG_FLAGS -g"]], [], [[$FLAG_WERROR]]) + + dnl -ftrapv and -fwrapv conflict, so we only set this if use_debug=no + AX_CHECK_COMPILE_FLAG([-fwrapv],[DEBUG_FLAGS="$DEBUG_FLAGS -fwrapv"], [], [[$FLAG_WERROR]]) + fi +fi + dnl Define enum mappings for relic config AC_DEFINE([RLC_VERSION], ["0.5.0"], [Relic Version]) @@ -114,25 +172,29 @@ AC_ARG_WITH([backend], ) if test x"$want_backend" = x"auto"; then - GMP_CHECK - if test x"$has_gmp" = x"yes"; then - case $host in - *darwin*) - case $host_cpu in - aarch*) - want_backend=easy - ;; - *) - want_backend=gmp - ;; - esac - ;; - *) - want_backend=gmp - ;; - esac - else + if test x"$use_optimizations" = x"no"; then want_backend=easy + else + GMP_CHECK + if test x"$has_gmp" = x"yes"; then + case $host in + *darwin*) + case $host_cpu in + aarch*) + want_backend=easy + ;; + *) + want_backend=gmp + ;; + esac + ;; + *) + want_backend=gmp + ;; + esac + else + want_backend=easy + fi fi else case $want_backend in @@ -257,20 +319,14 @@ AC_DEFINE([BRUCH], [6], [Hardware-friendly inversion by Brunner-Curiger-Hofste AC_DEFINE([CTAIA], [7], [Constant-time version of almost inverse.]) AC_DEFINE([LOWER], [8], [Use implementation provided by the lower layer.]) -dnl Define relic switches -AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug], - [Build with debugging support (default is no)])], - [use_debug=$enableval], - [use_debug=no]) - -if test x$use_debug = xyes; then +if test x"$use_debug" = x"yes"; then AC_DEFINE([DEBUG], [1], [Define this symbol if debugging support is enabled]) fi +dnl Define relic switches AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], - [Build with profiling support (default is no)])], + [Build with profiling support [default=no]])], [use_profiling=$enableval], [use_profiling=no]) @@ -280,7 +336,7 @@ fi AC_ARG_ENABLE([check], [AS_HELP_STRING([--enable-check], - [Build with error-checking support (default is no)])], + [Build with error-checking support [default=no]])], [use_check=$enableval], [use_check=no]) @@ -290,7 +346,7 @@ fi AC_ARG_ENABLE([verbs], [AS_HELP_STRING([--enable-verbs], - [Build with detailed error messages (default is no)])], + [Build with detailed error messages [default=no]])], [use_verbs=$enableval], [use_verbs=no]) @@ -300,7 +356,7 @@ fi AC_ARG_ENABLE([overhead], [AS_HELP_STRING([--enable-overhead], - [Build with overhead estimation (default is no)])], + [Build with overhead estimation [default=no]])], [use_overhead=$enableval], [use_overhead=no]) @@ -310,7 +366,7 @@ fi AC_ARG_ENABLE([quiet], [AS_HELP_STRING([--enable-quiet], - [Build with printing disabled (default is yes)])], + [Build with printing disabled [default=yes]])], [use_quiet=$enableval], [use_quiet=yes]) @@ -320,7 +376,7 @@ fi AC_ARG_ENABLE([color], [AS_HELP_STRING([--enable-color], - [Build with colored output support (default is yes)])], + [Build with colored output support [default=yes]])], [use_color=$enableval], [use_color=yes]) @@ -330,7 +386,7 @@ fi AC_ARG_ENABLE([big_endian], [AS_HELP_STRING([--enable-big-endian], - [Build with big-endian support (default is no)])], + [Build with big-endian support [default=no]])], [use_big_endian=$enableval], [use_big_endian=no]) @@ -340,48 +396,40 @@ fi use_pkgconfig=yes -case $host_cpu in - x86_64) - dnl Support for AMD64 (also known as x86_64 on some platforms) processors - CPU_ARCH="x64" - AC_DEFINE([ARCH], [X64], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - aarch*) - dnl Relic doesn't support aarch64 yet, set CPU_ARCH to none. - dnl Support for 64-bit ARM processors - CPU_ARCH="none" - AC_DEFINE([ARCH], [ARM], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - i?86) - dnl Support for Intel x86 processors - CPU_ARCH="x86" - AC_DEFINE([ARCH], [X86], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - arm*) - dnl Support for 32-bit native ARM processors - CPU_ARCH="arm" - AC_DEFINE([ARCH], [ARM], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - *32*) - dnl Support for an undefined 32-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - *64*) - dnl Support for an undefined 64-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - *) - AC_MSG_ERROR([Unable to determine host architecture, may not be supported!]) - ;; -esac +if [[[ "$host_cpu" == x86_64 && "$use_optimizations" == "yes" ]]]; then + dnl Support for AMD64 (also known as x86_64 on some platforms) processors + CPU_ARCH="x64" + AC_DEFINE([ARCH], [X64], [Architecture.]) + AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) +elif [[[ "$host_cpu" == aarch* && "$use_optimizations" == "yes" ]]]; then + dnl Relic doesn't support aarch64 yet, set CPU_ARCH to none. + dnl Support for 64-bit ARM processors + CPU_ARCH="none" + AC_DEFINE([ARCH], [ARM], [Architecture.]) + AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) +elif [[[ "$host_cpu" == i?86 && "$use_optimizations" == "yes" ]]]; then + dnl Support for Intel x86 processors + CPU_ARCH="x86" + AC_DEFINE([ARCH], [X86], [Architecture.]) + AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) +elif [[[ "$host_cpu" == arm* && "$use_optimizations" == "yes" ]]]; then + dnl Support for 32-bit native ARM processors + CPU_ARCH="arm" + AC_DEFINE([ARCH], [ARM], [Architecture.]) + AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) +elif [[[ "$host_cpu" == *64* ]]]; then + dnl Support for an undefined 64-bit architecture + CPU_ARCH="none" + AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) + AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) +elif [[[ "$host_cpu" == *32* || "$host_cpu" == arm* || "$host_cpu" == i?86 ]]]; then + dnl Support for an undefined 32-bit architecture + CPU_ARCH="none" + AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) + AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) +else + AC_MSG_ERROR([Unable to determine host architecture, may not be supported!]) +fi case $host in *darwin*) @@ -480,17 +528,20 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], CFLAGS="$saved_CFLAGS" ]) -AC_LANG_PUSH([C]) -AX_CHECK_COMPILE_FLAG([-Wall],[WARN_CFLAGS="$WARN_CFLAGS -Wall"],,) -AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_CFLAGS="$WARN_CFLAGS -Wextra"],,) -AX_CHECK_COMPILE_FLAG([-Wcast-align],[WARN_CFLAGS="$WARN_CFLAGS -Wcast-align"],,) -AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-unused-parameter"],,) -AX_CHECK_COMPILE_FLAG([-Wshadow],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-shadow"],,) -AX_CHECK_COMPILE_FLAG([-Wsign-compare],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-sign-compare"],,) -AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-strict-prototypes"],,) -AX_CHECK_COMPILE_FLAG([-Wunused-function],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-unused-function"],,) -AX_CHECK_COMPILE_FLAG([-Wlong-long],[NOWARN_CFLAGS="$NOWARN_CFLAGS -Wno-long-long"],,) -AC_LANG_POP([C]) +if [[[ "$CFLAGS_overridden" == "no" && "$CXXFLAGS_overridden" == "no" ]]]; then + dnl Enable warnings + AX_CHECK_COMPILE_FLAG([-Wall],[WARN_FLAGS="$WARN_FLAGS -Wall"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wcast-align],[WARN_FLAGS="$WARN_FLAGS -Wcast-align"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_FLAGS="$WARN_FLAGS -Wextra"], [], [[$FLAG_WERROR]]) + + dnl Exclude known warnings + AX_CHECK_COMPILE_FLAG([-Wlong-long],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-long-long"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wshadow],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-shadow"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wsign-compare],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-sign-compare"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-strict-prototypes"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wunused-function],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-unused-function"], [], [[$FLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-unused-parameter"], [], [[$FLAG_WERROR]]) +fi dnl set default settings for relic AC_DEFINE([ALIGN], [1], [Byte boundary to align digit vectors.]) @@ -615,19 +666,19 @@ AC_SEARCH_LIBS([clock_gettime],[rt]) if test "$TARGET_OS" != "windows"; then dnl All windows code is PIC, forcing it on just adds useless compile warnings - AX_CHECK_COMPILE_FLAG([-fPIC], [PIC_FLAGS="-fPIC"]) + AX_CHECK_COMPILE_FLAG([-fPIC], [HARDENED_FLAGS="$HARDENED_FLAGS -fPIC"], [], [[$FLAG_WERROR]]) fi dnl All versions of gcc that we commonly use for building are subject to bug dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set dnl -fstack-reuse=none for all gcc builds. (Only gcc understands this flag) -AX_CHECK_COMPILE_FLAG([-fstack-reuse=none], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-reuse=none"]) +AX_CHECK_COMPILE_FLAG([-fstack-reuse=none], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-reuse=none"], [], [[$FLAG_WERROR]]) if test "$use_hardening" != "no"; then use_hardening=yes - AX_CHECK_COMPILE_FLAG([-Wstack-protector], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) - AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) + AX_CHECK_COMPILE_FLAG([-Wstack-protector], [HARDENED_FLAGS="$HARDENED_FLAGS -Wstack-protector"]) + AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-protector-all"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-fcf-protection=full], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fcf-protection=full"]) + AX_CHECK_COMPILE_FLAG([-fcf-protection=full], [HARDENED_FLAGS="$HARDENED_FLAGS -fcf-protection=full"], [], [[$FLAG_WERROR]]) case $host in *mingw*) @@ -635,10 +686,16 @@ if test "$use_hardening" != "no"; then dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details. ;; *) - AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-clash-protection"], [], []) + AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-clash-protection"], [], [[$FLAG_WERROR]]) ;; esac + case $host in + *aarch64*) + AX_CHECK_COMPILE_FLAG([-mbranch-protection=bti], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"], [], [[$CXXFLAG_WERROR]]) + ;; + esac + AX_CHECK_LINK_FLAG([-Wl,--enable-reloc-section], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--enable-reloc-section"], [], []) AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"], [], []) AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"], [], []) @@ -646,7 +703,7 @@ if test "$use_hardening" != "no"; then AX_CHECK_LINK_FLAG([-Wl,-z,relro], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"], [], []) AX_CHECK_LINK_FLAG([-Wl,-z,now], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"], [], []) AX_CHECK_LINK_FLAG([-Wl,-z,separate-code], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,separate-code"], [], []) - AX_CHECK_LINK_FLAG([-fPIE -pie], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"], [], []) + AX_CHECK_LINK_FLAG([-fPIE -pie], [HARDENED_FLAGS="$HARDENED_FLAGS -fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"], [], []) case $host in *mingw*) @@ -708,7 +765,9 @@ if test "$TARGET_OS" = "darwin"; then fi dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. -AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers], [CORE_CXXFLAGS="$CORE_CXXFLAGS -fno-extended-identifiers"], [], []) +AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers], [CORE_FLAGS="$CORE_FLAGS -fno-extended-identifiers"], [], [[$FLAG_WERROR]]) + +AC_LANG_POP([C]) AC_MSG_CHECKING([whether to build runtest]) if test x$use_tests = xyes; then @@ -753,24 +812,23 @@ AM_CONDITIONAL(WITH_FBX, test 1 -eq 1) AM_CONDITIONAL([USE_TESTS], [test x$BUILD_TEST = xyes]) AM_CONDITIONAL([USE_BENCH], [test x$BUILD_BENCH = xyes]) AM_CONDITIONAL([HARDEN], [test "$use_hardening" = "yes"]) +AM_CONDITIONAL([OPTIMIZE], [test "$use_optimizations" = "yes"]) AM_CONDITIONAL([ARITH_EASY], [test "$want_backend" = "easy"]) AM_CONDITIONAL([ARITH_GMP], [test "$want_backend" = "gmp"]) AC_SUBST(CPU_ARCH) +AC_SUBST(DEBUG_FLAGS) AC_SUBST(RAND_PATH, hashd) AC_SUBST(RELIC_CPPFLAGS) -AC_SUBST(WARN_CFLAGS) -AC_SUBST(NOWARN_CFLAGS) +AC_SUBST(WARN_FLAGS) +AC_SUBST(NOWARN_FLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS) -AC_SUBST(HARDENED_CXXFLAGS) -AC_SUBST(HARDENED_CPPFLAGS) +AC_SUBST(HARDENED_FLAGS) AC_SUBST(HARDENED_LDFLAGS) -AC_SUBST(PIC_FLAGS) -AC_SUBST(PIE_FLAGS) AC_SUBST(CORE_LDFLAGS) AC_SUBST(CORE_CPPFLAGS) -AC_SUBST(CORE_CXXFLAGS) +AC_SUBST(CORE_FLAGS) AC_SUBST(GMP_LDFLAGS) AC_SUBST(GMP_CPPFLAGS) @@ -784,3 +842,20 @@ AC_OUTPUT dnl Peplace conflict-prone PACKAGE-prefixed macros with DASHBLS sed -i.old 's/PACKAGE/DASHBLS/g' depends/relic/include/relic_conf.h sed -i.old 's/PACKAGE/DASHBLS/g' config.status + +echo +echo "Options used to compile and link:" +echo " target os = $TARGET_OS" +echo " backend = $want_backend" +echo " build bench = $BUILD_BENCH" +echo " build test = $BUILD_TEST" +echo " use debug = $use_debug" +echo " use hardening = $use_hardening" +echo " use optimizations = $use_optimizations" +echo +echo " LDFLAGS = $HARDENED_LDFLAGS $CORE_LDFLAGS $GMP_LDFLAGS" +echo " CFLAGS = $DEBUG_FLAGS $HARDENED_FLAGS $CORE_FLAGS $WARN_FLAGS $NOWARN_FLAGS" +echo " CPPFLAGS = $CORE_CPPFLAGS $GMP_CPPFLAGS" +echo " CXXFLAGS = $DEBUG_FLAGS $HARDENED_FLAGS $CORE_FLAGS $WARN_FLAGS $NOWARN_FLAGS" +echo " PTHREAD_FLAGS = $PTHREAD_CFLAGS $PTHREAD_LIBS" +echo diff --git a/rust-bindings/bls-dash-sys/build.rs b/rust-bindings/bls-dash-sys/build.rs index cc7cdd2d44ff3..c5245e6c25a9b 100644 --- a/rust-bindings/bls-dash-sys/build.rs +++ b/rust-bindings/bls-dash-sys/build.rs @@ -32,6 +32,7 @@ fn handle_command_output(output: Output) { #[cfg(not(feature = "apple"))] fn main() { let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); // TODO: fix build for wasm32 on MacOS // errors with `error: linking with `rust-lld` failed: exit status: 1` @@ -39,6 +40,7 @@ fn main() { println!("Build for wasm32 is not fully supported"); return; } + println!("cargo:warning=Building bls-signatures for non-Apple target: {}", target_arch); let root_path = Path::new("../..") .canonicalize() @@ -63,12 +65,48 @@ fn main() { fs::create_dir_all(&bls_dash_build_path).expect("can't create build directory"); - let cmake_output = create_cross_cmake_command() + + let cmake_command_binding = create_cross_cmake_command(); + let mut cmake_command = cmake_command_binding; + + cmake_command .current_dir(&bls_dash_build_path) .arg("-DBUILD_BLS_PYTHON_BINDINGS=0") .arg("-DBUILD_BLS_TESTS=0") .arg("-DBUILD_BLS_BENCHMARKS=0") - .arg("-DBUILD_BLS_JS_BINDINGS=0") + .arg("-DBUILD_BLS_JS_BINDINGS=0"); + + // configure CMake for Android + if target_os.eq("android") { + let cmake_toolchain_path = env::var("CMAKE_TOOLCHAIN_FILE") + .or_else(|_| env::var("CARGO_NDK_CMAKE_TOOLCHAIN_PATH")) + .expect("Neither CMAKE_TOOLCHAIN_FILE nor CARGO_NDK_CMAKE_TOOLCHAIN_PATH environment variables are set"); + + let ndk_target = match env::var("CARGO_NDK_TARGET_ARCH") { + Ok(value) => value, // If set, use the value directly. + Err(_) => { + match target_arch.as_str() { + "aarch64" => "arm64-v8a".to_string(), + "arm" => "armeabi-v7a".to_string(), + "x86" => "x86".to_string(), + "x86_64" => "x86_64".to_string(), + _ => panic!("Unsupported target architecture for Android: {}", target_arch), + } + } + }; + + // Default to android-24 if ANDROID_PLATFORM is not specified + let android_abi = env::var("ANDROID_PLATFORM") + .or_else(|_| env::var("CARGO_NDK_ANDROID_PLATFORM")) + .unwrap_or_else(|_| "android-24".to_string()); + + cmake_command + .arg(format!("-DANDROID_PLATFORM={}", android_abi)) + .arg(format!("-DANDROID_ABI={}", ndk_target)) + .arg(format!("-DCMAKE_TOOLCHAIN_FILE={}", cmake_toolchain_path)); + } + + let cmake_output = cmake_command .arg("..") .output() .expect("can't run cmake"); @@ -100,8 +138,8 @@ fn main() { .collect(); include_paths.extend([ - bls_dash_build_path.join("_deps/relic-src/include"), - bls_dash_build_path.join("_deps/relic-build/include"), + bls_dash_build_path.join("depends/relic-src/include"), + bls_dash_build_path.join("depends/relic/include"), bls_dash_build_path.join("src"), root_path.join("include/dashbls"), bls_dash_build_path.join("depends/relic/include"), @@ -127,7 +165,8 @@ fn main() { cc.files(cpp_files) .includes(&include_paths) .cpp(true) - .flag_if_supported("-std=c++14"); + .flag_if_supported("-std=c++14") + .target(&env::var("TARGET").unwrap()); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); @@ -196,6 +235,7 @@ fn main() { println!("cargo:rustc-link-lib=static=gmp"); } + println!("cargo:warning=########## bls_dash_build_path:{}", bls_dash_build_path.display()); // Generate rust code for c binding to src/lib.rs // println!("Generate C binding for rust:"); @@ -290,7 +330,7 @@ fn main() { let target = env::var("TARGET").unwrap(); - println!("Building bls-signatures for apple target: {}", target); + println!("cargo:warning=Building bls-signatures for Apple target: {}", target); let root_path = Path::new("../..") .canonicalize() .expect("can't get abs path"); @@ -305,6 +345,32 @@ fn main() { fs::remove_dir_all(&bls_dash_build_path).expect("can't clean build directory"); } fs::create_dir_all(&bls_dash_build_path).expect("can't create build directory"); + + let cc_path_output = Command::new("xcrun") + .arg("--sdk") + .arg("iphoneos") + .arg("--find") + .arg("clang") + .output() + .expect("Failed to find clang"); + let cc_path = String::from_utf8_lossy(&cc_path_output.stdout).trim().to_string(); + + let cxx_path_output = Command::new("xcrun") + .arg("--sdk") + .arg("iphoneos") + .arg("--find") + .arg("clang++") + .output() + .expect("Failed to find clang++"); + let cxx_path = String::from_utf8_lossy(&cxx_path_output.stdout).trim().to_string(); + + // Print the paths for clang and clang++ + println!("cargo:warning=CC path: {}", cc_path); + println!("cargo:warning=CXX path: {}", cxx_path); + + std::env::set_var("CC", cc_path); + std::env::set_var("CXX", cxx_path); + let output = Command::new("sh") .current_dir(&root_path) .arg(script) @@ -312,6 +378,7 @@ fn main() { .output() .expect("Failed to execute the shell script"); handle_command_output(output); + let (arch, platform) = match target.as_str() { "x86_64-apple-ios" => ("x86_64", "iphonesimulator"), "aarch64-apple-ios" => ("arm64", "iphoneos"), @@ -335,8 +402,8 @@ fn main() { .collect(); include_paths.extend([ - bls_dash_build_path.join(format!("relic-{}-{}/_deps/relic-src/include", platform, arch)), - bls_dash_build_path.join(format!("relic-{}-{}/_deps/relic-build/include", platform, arch)), + bls_dash_build_path.join(format!("relic-{}-{}/depends/relic-src/include", platform, arch)), + bls_dash_build_path.join(format!("relic-{}-{}/depends/relic/include", platform, arch)), bls_dash_build_path.join("contrib/relic/src"), root_path.join("src"), root_path.join("include/dashbls"), @@ -365,8 +432,10 @@ fn main() { println!("cargo:rustc-link-search={}", target_path.display()); println!("cargo:rustc-link-lib=static=gmp"); - // println!("cargo:rustc-link-lib=static=sodium"); - // println!("cargo:rustc-link-lib=static=relic_s"); + //println!("cargo:rustc-link-lib=c++"); + //println!("cargo:rustc-link-lib=c"); + //println!("cargo:rustc-link-lib=static=sodium"); + println!("cargo:rustc-link-lib=static=relic_s"); println!("cargo:rustc-link-lib=static=bls"); println!("cargo:rustc-link-search={}", bls_dash_src_path.display()); println!("cargo:rustc-link-lib=static=dashbls"); diff --git a/rust-bindings/bls-signatures/Cargo.toml b/rust-bindings/bls-signatures/Cargo.toml index 8c6f1e3c1d9a2..5365ee42737f8 100644 --- a/rust-bindings/bls-signatures/Cargo.toml +++ b/rust-bindings/bls-signatures/Cargo.toml @@ -16,3 +16,4 @@ apple = ["bls-dash-sys/apple"] bls-dash-sys = { path = "../bls-dash-sys" } serde = { version= "1.0.160", features = ["derive"], optional = true} rand = { version= "0.8.5", optional = true} +hex = { version = "0.4.3"} diff --git a/rust-bindings/bls-signatures/src/elements.rs b/rust-bindings/bls-signatures/src/elements.rs index 3388ce022a242..b671bdf6b5c5b 100644 --- a/rust-bindings/bls-signatures/src/elements.rs +++ b/rust-bindings/bls-signatures/src/elements.rs @@ -1,4 +1,6 @@ use std::ffi::c_void; +use std::fmt::Debug; +use std::fmt::Formatter; use bls_dash_sys::{CoreMPLDeriveChildPkUnhardened, G1ElementFree, G1ElementFromBytes, G1ElementGenerator, G1ElementGetFingerprint, G1ElementIsEqual, G1ElementSerialize, G1ElementCopy, G2ElementCopy, G2ElementFree, G2ElementFromBytes, G2ElementIsEqual, G2ElementSerialize, ThresholdPublicKeyRecover, ThresholdSignatureRecover}; #[cfg(feature = "use_serde")] @@ -17,17 +19,28 @@ pub type PublicKey = G1Element; #[cfg(feature = "dash_helpers")] pub type Signature = G2Element; -#[derive(Debug)] pub struct G1Element { pub(crate) c_element: *mut c_void, } +// G1Element is immutable and thread safe +unsafe impl Send for G1Element {} +unsafe impl Sync for G1Element {} + impl PartialEq for G1Element { fn eq(&self, other: &Self) -> bool { unsafe { G1ElementIsEqual(self.c_element, other.c_element) } } } +impl Debug for G1Element { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let g1_hex = hex::encode(self.to_bytes().as_slice()); + + write!(f, "G1Element({:?})", g1_hex) + } +} + impl Eq for G1Element {} impl G1Element { @@ -181,17 +194,28 @@ impl Drop for G1Element { } } -#[derive(Debug)] pub struct G2Element { pub(crate) c_element: *mut c_void, } +// G2Element is immutable and thread safe +unsafe impl Send for G2Element {} +unsafe impl Sync for G2Element {} + impl PartialEq for G2Element { fn eq(&self, other: &Self) -> bool { unsafe { G2ElementIsEqual(self.c_element, other.c_element) } } } +impl Debug for G2Element { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let g2_hex = hex::encode(self.to_bytes().as_slice()); + + write!(f, "G2Element({:?})", g2_hex) + } +} + impl Eq for G2Element {} impl G2Element { @@ -311,6 +335,7 @@ impl Drop for G2Element { #[cfg(test)] mod tests { + use std::thread; use super::*; use crate::{ schemes::{AugSchemeMPL, Scheme}, @@ -365,4 +390,22 @@ mod tests { assert_eq!(g1_element.fingerprint(), 2093959050); } + + #[test] + fn should_be_thread_safe() { + let bytes = [ + 151, 241, 211, 167, 49, 151, 215, 148, 38, 149, 99, 140, 79, 169, 172, 15, 195, 104, + 140, 79, 151, 116, 185, 5, 161, 78, 58, 63, 23, 27, 172, 88, 108, 85, 232, 63, 249, + 122, 26, 239, 251, 58, 240, 10, 219, 34, 198, 187, + ]; + + let g1_element = + G1Element::from_bytes(&bytes).expect("should create g1 element from bytes"); + + let test_thread = thread::spawn(move|| { + assert_eq!(g1_element.fingerprint(), 2093959050); + }); + + test_thread.join().unwrap(); + } } diff --git a/rust-bindings/bls-signatures/src/legacy/elements.rs b/rust-bindings/bls-signatures/src/legacy/elements.rs index ca205a8073c5a..eae5bc4eda061 100644 --- a/rust-bindings/bls-signatures/src/legacy/elements.rs +++ b/rust-bindings/bls-signatures/src/legacy/elements.rs @@ -5,6 +5,10 @@ impl G1Element { self.to_bytes_with_legacy_flag(true) } + pub fn serialize(&self) -> Box<[u8; G1_ELEMENT_SIZE]> { + self.to_bytes_with_legacy_flag(false) + } + pub fn from_bytes_legacy(bytes: &[u8]) -> Result { Self::from_bytes_with_legacy_flag(bytes, true) } @@ -22,4 +26,8 @@ impl G2Element { pub fn serialize_legacy(&self) -> Box<[u8; G2_ELEMENT_SIZE]> { self.to_bytes_with_legacy_flag(true) } + + pub fn serialize(&self) -> Box<[u8; G2_ELEMENT_SIZE]> { + self.to_bytes_with_legacy_flag(false) + } } diff --git a/rust-bindings/bls-signatures/src/lib.rs b/rust-bindings/bls-signatures/src/lib.rs index e6d76b81495ab..fdfc6ddef3473 100644 --- a/rust-bindings/bls-signatures/src/lib.rs +++ b/rust-bindings/bls-signatures/src/lib.rs @@ -101,4 +101,26 @@ mod tests { grandchild_sk_u.g1_element().expect("cannot get public key") ); } + + #[test] + fn test_bls_public_key() { + let seed = b"seedweedseedweedseedweedseedweed"; + let scheme = LegacySchemeMPL::new(); + + let private_key = PrivateKey::key_gen(&scheme, seed).expect("unable to generate private key"); + let public_key = private_key.g1_element().expect("unable to get public key"); + + let expected_priv_key = vec![92, 116, 13, 32, 66, 150, 74, 240, 121, 255, 94, 222, 127, 180, 19, 10, 244, 212, 173, 51, 91, 198, 162, 132, 230, 105, 134, 255, 125, 191, 198, 223]; + let expected_pub_key = vec![129, 171, 183, 152, 50, 52, 28, 18, 241, 75, 118, 255, 58, 136, 184, 52, 247, 229, 14, 221, 40, 117, 194, 142, 2, 208, 193, 215, 131, 17, 234, 195, 229, 23, 249, 239, 139, 176, 18, 187, 102, 55, 162, 76, 48, 88, 228, 150]; + + assert_eq!( + private_key.to_bytes().as_slice(), + expected_priv_key + ); + + assert_eq!( + public_key.to_bytes().as_slice(), + expected_pub_key + ); + } } diff --git a/rust-bindings/bls-signatures/src/private_key.rs b/rust-bindings/bls-signatures/src/private_key.rs index bc74d710f30ac..ab129856cdd5d 100755 --- a/rust-bindings/bls-signatures/src/private_key.rs +++ b/rust-bindings/bls-signatures/src/private_key.rs @@ -1,4 +1,5 @@ use std::{ffi::c_void, ops::Mul}; +use std::fmt::{Debug, Formatter}; use bls_dash_sys::{ CoreMPLDeriveChildSk, CoreMPLDeriveChildSkUnhardened, CoreMPLKeyGen, G1ElementMul, @@ -13,7 +14,6 @@ use crate::{schemes::Scheme, utils::{c_err_to_result, SecureBox}, BasicSchemeMPL pub const PRIVATE_KEY_SIZE: usize = 32; // TODO somehow extract it from bls library -#[derive(Debug)] pub struct PrivateKey { pub(crate) c_private_key: *mut c_void, } @@ -26,6 +26,13 @@ impl PartialEq for PrivateKey { impl Eq for PrivateKey {} +impl Debug for PrivateKey { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let private_key_hex = hex::encode(self.to_bytes().as_slice()); + + write!(f, "PrivateKey({:?})", private_key_hex) + } +} impl Mul for PrivateKey { type Output = Result; From ee4c0b7b5d56a4250fc41b949226f7710788e4d7 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 28 Jun 2023 23:44:03 +0300 Subject: [PATCH 3/3] build: stop tracking cmake dependency relic_conf.h.in This reverts commit 0b3ab8d5e9e19fc9b259dcb2a061f6c765957427. --- .../depends/relic/include/relic_conf.h.in | 717 ------------------ 1 file changed, 717 deletions(-) delete mode 100644 src/dashbls/depends/relic/include/relic_conf.h.in diff --git a/src/dashbls/depends/relic/include/relic_conf.h.in b/src/dashbls/depends/relic/include/relic_conf.h.in deleted file mode 100644 index 7db6f5b509c45..0000000000000 --- a/src/dashbls/depends/relic/include/relic_conf.h.in +++ /dev/null @@ -1,717 +0,0 @@ -/* - * RELIC is an Efficient LIbrary for Cryptography - * Copyright (c) 2009 RELIC Authors - * - * This file is part of RELIC. RELIC is legal property of its developers, - * whose names are not listed here. Please refer to the COPYRIGHT file - * for contact information. - * - * RELIC is free software; you can redistribute it and/or modify it under the - * terms of the version 2.1 (or later) of the GNU Lesser General Public License - * as published by the Free Software Foundation; or version 2.0 of the Apache - * License as published by the Apache Software Foundation. See the LICENSE files - * for more details. - * - * RELIC is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the LICENSE files for more details. - * - * You should have received a copy of the GNU Lesser General Public or the - * Apache License along with RELIC. If not, see - * or . - */ - -/** - * @file - * - * Project configuration. - * - * @version $Id: relic_conf.h.in 45 2009-07-04 23:45:48Z dfaranha $ - * @ingroup relic - */ - -#ifndef RLC_CONF_H -#define RLC_CONF_H - -/** Project version. */ -#define RLC_VERSION "@VERSION@" - -/** Debugging support. */ -#cmakedefine DEBUG -/** Profiling support. */ -#cmakedefine PROFL -/** Error handling support. */ -#cmakedefine CHECK -/** Verbose error messages. */ -#cmakedefine VERBS -/** Build with overhead estimation. */ -#cmakedefine OVERH -/** Build documentation. */ -#cmakedefine DOCUM -/** Build only the selected algorithms. */ -#cmakedefine STRIP -/** Build with printing disabled. */ -#cmakedefine QUIET -/** Build with colored output. */ -#cmakedefine COLOR -/** Build with big-endian support. */ -#cmakedefine BIGED -/** Build shared library. */ -#cmakedefine SHLIB -/** Build static library. */ -#cmakedefine STLIB - -/** Number of times each test is ran. */ -#define TESTS @TESTS@ -/** Number of times each benchmark is ran. */ -#define BENCH @BENCH@ -/** Number of available cores. */ -#define CORES @CORES@ - -/** Atmel AVR ATMega128 8-bit architecture. */ -#define AVR 1 -/** MSP430 16-bit architecture. */ -#define MSP 2 -/** ARM 32-bit architecture. */ -#define ARM 3 -/** Intel x86-compatible 32-bit architecture. */ -#define X86 4 -/** AMD64-compatible 64-bit architecture. */ -#define X64 5 -/** Architecture. */ -#cmakedefine ARCH @ARCH@ - -/** Size of word in this architecture. */ -#define WSIZE @WSIZE@ - -/** Byte boundary to align digit vectors. */ -#define ALIGN @ALIGN@ - -/** Build multiple precision integer module. */ -#cmakedefine WITH_BN -/** Build prime field module. */ -#cmakedefine WITH_FP -/** Build prime field extension module. */ -#cmakedefine WITH_FPX -/** Build binary field module. */ -#cmakedefine WITH_FB -/** Build prime elliptic curve module. */ -#cmakedefine WITH_EP -/** Build prime field extension elliptic curve module. */ -#cmakedefine WITH_EPX -/** Build binary elliptic curve module. */ -#cmakedefine WITH_EB -/** Build elliptic Edwards curve module. */ -#cmakedefine WITH_ED -/** Build elliptic curve cryptography module. */ -#cmakedefine WITH_EC -/** Build pairings over prime curves module. */ -#cmakedefine WITH_PP -/** Build pairing-based cryptography module. */ -#cmakedefine WITH_PC -/** Build block ciphers. */ -#cmakedefine WITH_BC -/** Build hash functions. */ -#cmakedefine WITH_MD -/** Build cryptographic protocols. */ -#cmakedefine WITH_CP -/** Build Multi-party computation primitives. */ -#cmakedefine WITH_MPC - -/** Easy C-only backend. */ -#define EASY 1 -/** GMP backend. */ -#define GMP 2 -/** GMP constant-time backend. */ -#define GMP_SEC 3 -/** Arithmetic backend. */ -#define ARITH @ARITH@ - -/** Required precision in bits. */ -#define BN_PRECI @BN_PRECI@ -/** A multiple precision integer can store w words. */ -#define SINGLE 0 -/** A multiple precision integer can store the result of an addition. */ -#define CARRY 1 -/** A multiple precision integer can store the result of a multiplication. */ -#define DOUBLE 2 -/** Effective size of a multiple precision integer. */ -#define BN_MAGNI @BN_MAGNI@ -/** Number of Karatsuba steps. */ -#define BN_KARAT @BN_KARAT@ - -/** Schoolbook multiplication. */ -#define BASIC 1 -/** Comba multiplication. */ -#define COMBA 2 -/** Chosen multiple precision multiplication method. */ -#define BN_MUL @BN_MUL@ - -/** Schoolbook squaring. */ -#define BASIC 1 -/** Comba squaring. */ -#define COMBA 2 -/** Reuse multiplication for squaring. */ -#define MULTP 4 -/** Chosen multiple precision multiplication method. */ -#define BN_SQR @BN_SQR@ - -/** Division modular reduction. */ -#define BASIC 1 -/** Barrett modular reduction. */ -#define BARRT 2 -/** Montgomery modular reduction. */ -#define MONTY 3 -/** Pseudo-Mersenne modular reduction. */ -#define PMERS 4 -/** Chosen multiple precision modular reduction method. */ -#define BN_MOD @BN_MOD@ - -/** Binary modular exponentiation. */ -#define BASIC 1 -/** Sliding window modular exponentiation. */ -#define SLIDE 2 -/** Montgomery powering ladder. */ -#define MONTY 3 -/** Chosen multiple precision modular exponentiation method. */ -#define BN_MXP @BN_MXP@ - -/** Basic Euclidean GCD Algorithm. */ -#define BASIC 1 -/** Lehmer's fast GCD Algorithm. */ -#define LEHME 2 -/** Stein's binary GCD Algorithm. */ -#define STEIN 3 -/** Chosen multiple precision greatest common divisor method. */ -#define BN_GCD @BN_GCD@ - -/** Basic prime generation. */ -#define BASIC 1 -/** Safe prime generation. */ -#define SAFEP 2 -/** Strong prime generation. */ -#define STRON 3 -/** Chosen prime generation algorithm. */ -#define BN_GEN @BN_GEN@ - -/** Multiple precision arithmetic method */ -#define BN_METHD "@BN_METHD@" - -/** Prime field size in bits. */ -#define FP_PRIME @FP_PRIME@ -/** Number of Karatsuba steps. */ -#define FP_KARAT @FP_KARAT@ -/** Prefer Pseudo-Mersenne primes over random primes. */ -#cmakedefine FP_PMERS -/** Use -1 as quadratic non-residue. */ -#cmakedefine FP_QNRES -/** Width of window processing for exponentiation methods. */ -#define FP_WIDTH @FP_WIDTH@ - -/** Schoolbook addition. */ -#define BASIC 1 -/** Integrated modular addtion. */ -#define INTEG 3 -/** Chosen prime field multiplication method. */ -#define FP_ADD @FP_ADD@ - -/** Schoolbook multiplication. */ -#define BASIC 1 -/** Comba multiplication. */ -#define COMBA 2 -/** Integrated modular multiplication. */ -#define INTEG 3 -/** Chosen prime field multiplication method. */ -#define FP_MUL @FP_MUL@ - -/** Schoolbook squaring. */ -#define BASIC 1 -/** Comba squaring. */ -#define COMBA 2 -/** Integrated modular squaring. */ -#define INTEG 3 -/** Reuse multiplication for squaring. */ -#define MULTP 4 -/** Chosen prime field multiplication method. */ -#define FP_SQR @FP_SQR@ - -/** Division-based reduction. */ -#define BASIC 1 -/** Fast reduction modulo special form prime. */ -#define QUICK 2 -/** Montgomery modular reduction. */ -#define MONTY 3 -/** Chosen prime field reduction method. */ -#define FP_RDC @FP_RDC@ - -/** Inversion by Fermat's Little Theorem. */ -#define BASIC 1 -/** Binary inversion. */ -#define BINAR 2 -/** Integrated modular multiplication. */ -#define MONTY 3 -/** Extended Euclidean algorithm. */ -#define EXGCD 4 -/** Constant-time inversion by Bernstein-Yang division steps. */ -#define DIVST 5 -/** Use implementation provided by the lower layer. */ -#define LOWER 8 -/** Chosen prime field inversion method. */ -#define FP_INV @FP_INV@ - -/** Binary modular exponentiation. */ -#define BASIC 1 -/** Sliding window modular exponentiation. */ -#define SLIDE 2 -/** Constant-time Montgomery powering ladder. */ -#define MONTY 3 -/** Chosen multiple precision modular exponentiation method. */ -#define FP_EXP @FP_EXP@ - -/** Prime field arithmetic method */ -#define FP_METHD "@FP_METHD@" - -/** Basic quadratic extension field arithmetic. */ -#define BASIC 1 -/** Integrated extension field arithmetic. */ -#define INTEG 3 -/* Chosen extension field arithmetic method. */ -#define FPX_QDR @FPX_QDR@ - -/** Basic cubic extension field arithmetic. */ -#define BASIC 1 -/** Integrated extension field arithmetic. */ -#define INTEG 3 -/* Chosen extension field arithmetic method. */ -#define FPX_CBC @FPX_CBC@ - -/** Basic quadratic extension field arithmetic. */ -#define BASIC 1 -/** Lazy-reduced extension field arithmetic. */ -#define LAZYR 2 -/* Chosen extension field arithmetic method. */ -#define FPX_RDC @FPX_RDC@ - -/** Prime extension field arithmetic method */ -#define FPX_METHD "@FPX_METHD@" - -/** Irreducible polynomial size in bits. */ -#define FB_POLYN @FB_POLYN@ -/** Number of Karatsuba steps. */ -#define FB_KARAT @FB_KARAT@ -/** Prefer trinomials over pentanomials. */ -#cmakedefine FB_TRINO -/** Prefer square-root friendly polynomials. */ -#cmakedefine FB_SQRTF -/** Precompute multiplication table for sqrt(z). */ -#cmakedefine FB_PRECO -/** Width of window processing for exponentiation methods. */ -#define FB_WIDTH @FB_WIDTH@ - -/** Shift-and-add multiplication. */ -#define BASIC 1 -/** Lopez-Dahab multiplication. */ -#define LODAH 2 -/** Integrated modular multiplication. */ -#define INTEG 3 -/** Chosen binary field multiplication method. */ -#define FB_MUL @FB_MUL@ - -/** Basic squaring. */ -#define BASIC 1 -/** Table-based squaring. */ -#define QUICK 2 -/** Integrated modular squaring. */ -#define INTEG 3 -/** Chosen binary field squaring method. */ -#define FB_SQR @FB_SQR@ - -/** Shift-and-add modular reduction. */ -#define BASIC 1 -/** Fast reduction modulo a trinomial or pentanomial. */ -#define QUICK 2 -/** Chosen binary field modular reduction method. */ -#define FB_RDC @FB_RDC@ - -/** Square root by repeated squaring. */ -#define BASIC 1 -/** Fast square root extraction. */ -#define QUICK 2 -/** Chosen binary field modular reduction method. */ -#define FB_SRT @FB_SRT@ - -/** Trace by repeated squaring. */ -#define BASIC 1 -/** Fast trace computation. */ -#define QUICK 2 -/** Chosen trace computation method. */ -#define FB_TRC @FB_TRC@ - -/** Solve by half-trace computation. */ -#define BASIC 1 -/** Solve with precomputed half-traces. */ -#define QUICK 2 -/** Chosen method to solve a quadratic equation. */ -#define FB_SLV @FB_SLV@ - -/** Inversion by Fermat's Little Theorem. */ -#define BASIC 1 -/** Binary inversion. */ -#define BINAR 2 -/** Almost inverse algorithm. */ -#define ALMOS 3 -/** Extended Euclidean algorithm. */ -#define EXGCD 4 -/** Itoh-Tsuji inversion. */ -#define ITOHT 5 -/** Hardware-friendly inversion by Brunner-Curiger-Hofstetter.*/ -#define BRUCH 6 -/** Constant-time version of almost inverse. */ -#define CTAIA 7 -/** Use implementation provided by the lower layer. */ -#define LOWER 8 -/** Chosen binary field inversion method. */ -#define FB_INV @FB_INV@ - -/** Binary modular exponentiation. */ -#define BASIC 1 -/** Sliding window modular exponentiation. */ -#define SLIDE 2 -/** Constant-time Montgomery powering ladder. */ -#define MONTY 3 -/** Chosen multiple precision modular exponentiation method. */ -#define FB_EXP @FB_EXP@ - -/** Iterated squaring/square-root by consecutive squaring/square-root. */ -#define BASIC 1 -/** Iterated squaring/square-root by table-based method. */ -#define QUICK 2 -/** Chosen method to solve a quadratic equation. */ -#define FB_ITR @FB_ITR@ - -/** Binary field arithmetic method */ -#define FB_METHD "@FB_METHD@" - -/** Support for ordinary curves. */ -#cmakedefine EP_PLAIN -/** Support for supersingular curves. */ -#cmakedefine EP_SUPER -/** Support for prime curves with efficient endormorphisms. */ -#cmakedefine EP_ENDOM -/** Use mixed coordinates. */ -#cmakedefine EP_MIXED -/** Build precomputation table for generator. */ -#cmakedefine EP_PRECO -/** Enable isogeny map for SSWU map-to-curve. */ -#cmakedefine EP_CTMAP -/** Width of precomputation table for fixed point methods. */ -#define EP_DEPTH @EP_DEPTH@ -/** Width of window processing for unknown point methods. */ -#define EP_WIDTH @EP_WIDTH@ - -/** Affine coordinates. */ -#define BASIC 1 -/** Projective coordinates. */ -#define PROJC 2 -/** Jacobian coordinates. */ -#define JACOB 3 -/** Chosen prime elliptic curve coordinate method. */ -#define EP_ADD @EP_ADD@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** Sliding window. */ -#define SLIDE 2 -/** Montgomery powering ladder. */ -#define MONTY 3 -/** Left-to-right Width-w NAF. */ -#define LWNAF 4 -/** Left-to-right Width-w NAF. */ -#define LWREG 5 -/** Chosen prime elliptic curve point multiplication method. */ -#define EP_MUL @EP_MUL@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** Single-table comb method. */ -#define COMBS 2 -/** Double-table comb method. */ -#define COMBD 3 -/** Left-to-right Width-w NAF. */ -#define LWNAF 4 -/** Chosen prime elliptic curve point multiplication method. */ -#define EP_FIX @EP_FIX@ - -/** Basic simultaneouns point multiplication. */ -#define BASIC 1 -/** Shamir's trick. */ -#define TRICK 2 -/** Interleaving of w-(T)NAFs. */ -#define INTER 3 -/** Joint sparse form. */ -#define JOINT 4 -/** Chosen prime elliptic curve simulteanous point multiplication method. */ -#define EP_SIM @EP_SIM@ - -/** Prime elliptic curve arithmetic method. */ -#define EP_METHD "@EP_METHD@" - -/** Support for ordinary curves without endormorphisms. */ -#cmakedefine EB_PLAIN -/** Support for Koblitz anomalous binary curves. */ -#cmakedefine EB_KBLTZ -/** Use mixed coordinates. */ -#cmakedefine EB_MIXED -/** Build precomputation table for generator. */ -#cmakedefine EB_PRECO -/** Width of precomputation table for fixed point methods. */ -#define EB_DEPTH @EB_DEPTH@ -/** Width of window processing for unknown point methods. */ -#define EB_WIDTH @EB_WIDTH@ - -/** Binary elliptic curve arithmetic method. */ -#define EB_METHD "@EB_METHD@" - -/** Affine coordinates. */ -#define BASIC 1 -/** López-Dahab Projective coordinates. */ -#define PROJC 2 -/** Chosen binary elliptic curve coordinate method. */ -#define EB_ADD @EB_ADD@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** L�pez-Dahab point multiplication. */ -#define LODAH 2 -/** Halving. */ -#define HALVE 3 -/** Left-to-right width-w (T)NAF. */ -#define LWNAF 4 -/** Right-to-left width-w (T)NAF. */ -#define RWNAF 5 -/** Chosen binary elliptic curve point multiplication method. */ -#define EB_MUL @EB_MUL@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** Single-table comb method. */ -#define COMBS 2 -/** Double-table comb method. */ -#define COMBD 3 -/** Left-to-right Width-w NAF. */ -#define LWNAF 4 -/** Chosen binary elliptic curve point multiplication method. */ -#define EB_FIX @EB_FIX@ - -/** Basic simultaneouns point multiplication. */ -#define BASIC 1 -/** Shamir's trick. */ -#define TRICK 2 -/** Interleaving of w-(T)NAFs. */ -#define INTER 3 -/** Joint sparse form. */ -#define JOINT 4 -/** Chosen binary elliptic curve simulteanous point multiplication method. */ -#define EB_SIM @EB_SIM@ - -/** Build precomputation table for generator. */ -#cmakedefine ED_PRECO -/** Width of precomputation table for fixed point methods. */ -#define ED_DEPTH @ED_DEPTH@ -/** Width of window processing for unknown point methods. */ -#define ED_WIDTH @ED_WIDTH@ - -/** Edwards elliptic curve arithmetic method. */ -#define ED_METHD "@ED_METHD@" - -/** Affine coordinates. */ -#define BASIC 1 -/** Simple projective twisted Edwards coordinates */ -#define PROJC 2 -/** Extended projective twisted Edwards coordinates */ -#define EXTND 3 -/** Chosen binary elliptic curve coordinate method. */ -#define ED_ADD @ED_ADD@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** Sliding window. */ -#define SLIDE 2 -/** Montgomery powering ladder. */ -#define MONTY 3 -/** Left-to-right Width-w NAF. */ -#define LWNAF 4 -/** Left-to-right Width-w NAF. */ -#define LWREG 5 -/** Chosen prime elliptic twisted Edwards curve point multiplication method. */ -#define ED_MUL @ED_MUL@ - -/** Binary point multiplication. */ -#define BASIC 1 -/** Single-table comb method. */ -#define COMBS 2 -/** Double-table comb method. */ -#define COMBD 3 -/** Left-to-right Width-w NAF. */ -#define LWNAF 4 -/** Chosen prime elliptic twisted Edwards curve point multiplication method. */ -#define ED_FIX @ED_FIX@ - -/** Basic simultaneouns point multiplication. */ -#define BASIC 1 -/** Shamir's trick. */ -#define TRICK 2 -/** Interleaving of w-(T)NAFs. */ -#define INTER 3 -/** Joint sparse form. */ -#define JOINT 4 -/** Chosen prime elliptic curve simulteanous point multiplication method. */ -#define ED_SIM @ED_SIM@ - -/** Prime curves. */ -#define PRIME 1 -/** Binary curves. */ -#define CHAR2 2 -/** Edwards curves */ -#define EDDIE 3 -/** Chosen elliptic curve type. */ -#define EC_CUR @EC_CUR@ - -/** Chosen elliptic curve cryptography method. */ -#define EC_METHD "@EC_METHD@" -/** Prefer curves with efficient endomorphisms. */ -#cmakedefine EC_ENDOM - -/** Basic quadratic extension field arithmetic. */ -#define BASIC 1 -/** Lazy-reduced extension field arithmetic. */ -#define LAZYR 2 -/* Chosen extension field arithmetic method. */ -#define PP_EXT @PP_EXT@ - -/** Bilinear pairing method. */ -#define PP_METHD "@PP_METHD@" - -/** Tate pairing. */ -#define TATEP 1 -/** Weil pairing. */ -#define WEILP 2 -/** Optimal ate pairing. */ -#define OATEP 3 -/** Chosen pairing method over prime elliptic curves. */ -#define PP_MAP @PP_MAP@ - -/** SHA-224 hash function. */ -#define SH224 2 -/** SHA-256 hash function. */ -#define SH256 3 -/** SHA-384 hash function. */ -#define SH384 4 -/** SHA-512 hash function. */ -#define SH512 5 -/** BLAKE2s-160 hash function. */ -#define B2S160 6 -/** BLAKE2s-256 hash function. */ -#define B2S256 7 -/** Chosen hash function. */ -#define MD_MAP @MD_MAP@ - -/** Choice of hash function. */ -#define MD_METHD "@MD_METHD@" - -/** Chosen RSA method. */ -#cmakedefine CP_CRT -/** RSA without padding. */ -#define BASIC 1 -/** RSA PKCS#1 v1.5 padding. */ -#define PKCS1 2 -/** RSA PKCS#1 v2.1 padding. */ -#define PKCS2 3 -/** Chosen RSA padding method. */ -#define CP_RSAPD @CP_RSAPD@ - -/** Automatic memory allocation. */ -#define AUTO 1 -/** Dynamic memory allocation. */ -#define DYNAMIC 2 -/** Chosen memory allocation policy. */ -#define ALLOC @ALLOC@ - -/** NIST HASH-DRBG generator. */ -#define HASHD 1 -/** Intel RdRand instruction. */ -#define RDRND 2 -/** Operating system underlying generator. */ -#define UDEV 3 -/** Override library generator with the callback. */ -#define CALL 4 -/** Chosen random generator. */ -#define RAND @RAND@ - -/** Standard C library generator. */ -#define LIBC 1 -/** Intel RdRand instruction. */ -#define RDRND 2 -/** Device node generator. */ -#define UDEV 3 -/** Use Windows' CryptGenRandom. */ -#define WCGR 4 -/** Chosen random generator seeder. */ -#cmakedefine SEED @SEED@ - -/** GNU/Linux operating system. */ -#define LINUX 1 -/** FreeBSD operating system. */ -#define FREEBSD 2 -/** Windows operating system. */ -#define MACOSX 3 -/** Windows operating system. */ -#define WINDOWS 4 -/** Android operating system. */ -#define DROID 5 -/** Arduino platform. */ -#define DUINO 6 -/** OpenBSD operating system. */ -#define OPENBSD 7 -/** Detected operation system. */ -#cmakedefine OPSYS @OPSYS@ - -/** OpenMP multithreading support. */ -#define OPENMP 1 -/** POSIX multithreading support. */ -#define PTHREAD 2 -/** Chosen multithreading API. */ -#cmakedefine MULTI @MULTI@ - -/** Per-process high-resolution timer. */ -#define HREAL 1 -/** Per-process high-resolution timer. */ -#define HPROC 2 -/** Per-thread high-resolution timer. */ -#define HTHRD 3 -/** POSIX-compatible timer. */ -#define POSIX 4 -/** ANSI-compatible timer. */ -#define ANSI 5 -/** Cycle-counting timer. */ -#define CYCLE 6 -/** Performance monitoring framework. */ -#define PERF 7 -/** Chosen timer. */ -#cmakedefine TIMER @TIMER@ - -/** Prefix to identity this build of the library. */ -#cmakedefine LABEL @LABEL@ - -#ifndef ASM - -#include "relic_label.h" - -/** - * Prints the project options selected at build time. - */ -void conf_print(void); - -#endif /* ASM */ - -#endif /* !RLC_CONF_H */