Skip to content

Commit

Permalink
Squashed 'src/chiabls/' changes from 676ea45e80..bc64f128f0
Browse files Browse the repository at this point in the history
bc64f128f0 Merge PIVX-Project/bls-signatures#10: Threshold:  don't copy the entire vector just to cache the initial size.
8c75dd860d Merge PIVX-Project/bls-signatures#9: [Build] Fix autotools builds on M1 Mac CPU
46926a2216 Poly::Evaluate, don't copy the entire vector just to cache the initial vector size.
544d00ed23 [Build] Fix autotools builds on M1 Mac CPU

git-subtree-dir: src/chiabls
git-subtree-split: bc64f128f009fd8825f249090be9d64a74834093
  • Loading branch information
furszy committed Sep 25, 2021
1 parent 4a71f9a commit ad308f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I build-aux/m4

AM_CPPFLAGS = $(GMP_CPPFLAGS) $(SODIUM_CPPFLAGS)
AM_CPPFLAGS = $(SODIUM_CPPFLAGS) $(SODIUM_CFLAGS)
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS)

LIBRELIC = librelic.la
Expand Down Expand Up @@ -419,7 +419,7 @@ libchiabls_la_SOURCES = \
libchiabls_la_CPPFLAGS = $(AM_CPPFLAGS) $(CHIABLS_INCLUDES) -DBLSALLOC_SODIUM=1
libchiabls_la_CXXFLAGS = $(AM_CXXFLAGS)

libchiabls_la_LIBADD = $(LIBRELIC) $(SODIUM_LIBS) $(GMP_LIBS)
libchiabls_la_LIBADD = $(LIBRELIC) $(SODIUM_LIBS)


if USE_BENCH
Expand All @@ -435,7 +435,7 @@ runbench_CPPFLAGS = $(AM_CPPFLAGS) $(CHIABLS_INCLUDES)
runbench_CXXFLAGS = $(AM_CXXFLAGS)
runbench_LDFLAGS = $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

runbench_LDADD = $(LIBCHIABLS) $(SODIUM_LIBS) $(GMP_LIBS)
runbench_LDADD = $(LIBCHIABLS) $(SODIUM_LIBS)

endif

Expand All @@ -451,7 +451,7 @@ runtest_CPPFLAGS = $(AM_CPPFLAGS) $(CHIABLS_INCLUDES) -I$(top_srcdir)/contrib/ca
runtest_CXXFLAGS = $(AM_CXXFLAGS)
runtest_LDFLAGS = $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

runtest_LDADD = $(LIBCHIABLS) $(SODIUM_LIBS) $(GMP_LIBS)
runtest_LDADD = $(LIBCHIABLS) $(SODIUM_LIBS)

TESTS += runtest

Expand Down
20 changes: 13 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,16 @@ AC_DEFINE([LOWER], [8], [Use implementation provided by the lower layer.])
use_pkgconfig=yes
case $host in
*darwin*)
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
case $host_cpu in
x86_64)
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
;;
aarch*)
CPU_ARCH="none"
AC_DEFINE([ARCH], [ARM], [Architecture.])
;;
esac
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.])
AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.])
Expand All @@ -172,8 +180,8 @@ case $host in

gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
if test x$gmp_prefix != x; then
GMP_CPPFLAGS="-I$gmp_prefix/include"
GMP_LIBS="-L$gmp_prefix/lib"
CPPFLAGS="$CPPFLAGS -I$gmp_prefix/include"
LIBS="$LIBS -L$gmp_prefix/lib"
fi
fi
fi
Expand Down Expand Up @@ -387,7 +395,7 @@ AC_DEFINE(MULTI, PTHREAD, Chosen multithreading API.)
AC_DEFINE(TIMER, CYCLE, Chosen timer.)


AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS=-lgmp;])], AC_MSG_ERROR(gmp headers missing),)
AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; LIBS="$LIBS -lgmp";])], AC_MSG_ERROR(gmp headers missing),)

if test x$has_gmp = xyes; then
AC_DEFINE(ARITH, GMP, Arithmetic backend.)
Expand Down Expand Up @@ -452,8 +460,6 @@ AC_SUBST(CPU_ARCH)
AC_SUBST(RAND_PATH, hashd)
AC_SUBST(SODIUM_CPPFLAGS)
AC_SUBST(SODIUM_LIBS)
AC_SUBST(GMP_CPPFLAGS)
AC_SUBST(GMP_LIBS)
AC_SUBST(RELIC_CPPFLAGS)
AC_SUBST(WARN_CFLAGS)
AC_SUBST(NOWARN_CFLAGS)
Expand Down
8 changes: 4 additions & 4 deletions src/threshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ namespace bls {
BLSType Poly::Evaluate(const std::vector<BLSType>& vecIn, const Bytes& id) {
typedef PolyOps<BLSType> Ops;
Ops ops;
std::vector<BLSType> vec = vecIn;
if (vec.size() < 2) {
const int vecSize = vecIn.size();
if (vecSize < 2) {
throw std::length_error("At least 2 coefficients required");
}

Expand All @@ -172,9 +172,9 @@ namespace bls {
bn_read_bin(x, id.begin(), Poly::nIdSize);
ops.ModOrder(x);

BLSType y = vecIn[vec.size() - 1];
BLSType y = vecIn[vecSize - 1];

for (int i = (int) vec.size() - 2; i >= 0; i--) {
for (int i = (int) vecSize - 2; i >= 0; i--) {
y = ops.Mul(y, x);
y = ops.Add(y, vecIn[i]);
}
Expand Down

0 comments on commit ad308f2

Please sign in to comment.