Commit c0c73f4b authored by Gerard Ryan's avatar Gerard Ryan

Update for v1.4.0

parent 09e112be
#
#Copyright (c) 2015, New Jersey Institute of Technology (NJIT)
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
#met:
#1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in the
#documentation and/or other materials provided with the distribution.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED.
#IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
#STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
#IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#POSSIBILITY OF SUCH DAMAGE.
#
################
# Makefile.abe builds the attribute-based encryption components of the PALISADE library
# Includes unit tests and demos
################
ABESRCDIR := src/abe
ABEBINDIR := $(BINDIR)/build/abe
ABETESTDIR := src/abe/unittest
ABEDEMODIR := src/abe/demo
ABESOURCES := $(shell find $(ABESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
ABEUNITSOURCES := $(wildcard $(ABESRCDIR)/unittest/*.cpp)
ABEDEMOSOURCES := $(wildcard $(ABESRCDIR)/demo/*.cpp)
ABEOBJECTSALL = $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABESOURCES)))
ABEOBJECTS = $(filter %-impl.o,$(ABEOBJECTSALL))
ABEUNITOBJECTS := $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABEUNITSOURCES)))
ABEDEMOOBJECTS += $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABEDEMOSOURCES)))
ABE_TEST_TARGET := $(EXTTESTDIR)/abe/tests$(EXESUFFIX)
-include $(ABEOBJECTS:.o=.d)
-include $(ABEUNITOBJECTS:.o=.d)
-include $(ABEDEMOOBJECTS:.o=.d)
.PHONY: allabe
allabe: allcore $(EXTLIBDIR)/$(PALISADEABELIB) $(ABE_TEST_TARGET) allabedemos
.PHONY: allabedemos
allabedemos: $(patsubst $(ABEBINDIR)/demo/%,$(BINDIR)/demo/abe/%,$(patsubst %.o,%$(EXESUFFIX),$(ABEDEMOOBJECTS)))
$(BINDIR)/demo/abe/%$(EXESUFFIX): $(ABEBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADEABELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $< $(EXTLIB) -lPALISADEabe -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADEABELIB): $(ABEOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@echo " -- abe:linking $@ from ABEOBJECTS"
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(ABEOBJECTS)
else
$(LIBCMD) $@ $(ABEOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(ABEBINDIR)/%
$(ABEBINDIR)/%:
@if [ "$(suffix $@)" = ".o" ] ; \
then \
mkdir -p $(@D) ;\
echo $(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
$(CC) -MM $(CPPFLAGS) $(INC) $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@) ;\
mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@) ;\
sed -e 's|.*\.o:|$(ABEBINDIR)/$*:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@) ;\
rm -f $(patsubst %.o,%.d.tmp,$@) ; \
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleanabe
cleanabe:
$(RM) -fr $(ABEBINDIR) $(EXTLIBDIR)/$(PALISADEABELIB) `dirname $(ABE_TEST_TARGET)` $(BINDIR)/demo/abe
# this links test executable from objects in the test build directory
$(ABE_TEST_TARGET): $(UNITTESTMAINOBJ) $(ABEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEABELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(ABE_TEST_TARGET)`
$(CC) -o $(ABE_TEST_TARGET) $(UNITTESTMAINOBJ) $(ABEUNITOBJECTS) $(EXTLIB) -lPALISADEabe -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
#used to run tests from make
.PHONY: testabe
testabe: $(ABE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(ABE_TEST_TARGET)
.PHONY: installabe
installabe: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADEABELIB)
.PHONY: uninstallabe
uninstallabe:
rm $(LIB_DEST)/$(PALISADEABELIB)
......@@ -50,7 +50,12 @@ ifdef COVERAGE
LIBSUFFIX=.a
LIBCMD=$(AR) crv
else
CPPFLAGS += -O3 -fopenmp $(COMPTHREADFLAG) ##optimize and threads
ifdef MEM
CPPFLAGS += -O0
else
CPPFLAGS += -O3
endif
CPPFLAGS += -fopenmp $(COMPTHREADFLAG) ##optimize and threads
endif
## set backend if user set it on the command line
......@@ -69,8 +74,8 @@ endif
# base directory of project
ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT := palisade
VERSION := 1.3.0
PACKAGE := palisade
VERSION := 1.4.0
#build directory
BUILDDIR := build
......@@ -90,7 +95,7 @@ HDREXT := h
$(objects) : %.o : %.cpp
# sub makefiles: each src subdirectory needs to be here
SUBMAKEFILES := core pke
SUBMAKEFILES := core pke abe signature
# third party directories
THIRDPARTYDIR := third-party
......@@ -101,34 +106,46 @@ THIRDPARTYINCLUDE := -I $(THIRDPARTYDIR)/include -I $(THIRDPARTYDIR)/include/rap
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
LIB_DEST := $(PREFIX)/lib/$(PROJECT)/$(VERSION)
LIB_DEST := $(PREFIX)/lib/$(PACKAGE)/$(VERSION)
EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) #no profiling
EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) $(TCMLIB) #no profiling
INC := -I src $(patsubst %,-Isrc/%/lib,$(SUBMAKEFILES)) -I test $(OMPINCLUDE) $(THIRDPARTYINCLUDE)
ABEOBJECTSALL = $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABESOURCES)))
#the name of the shared object library for palisade objects.
PALISADECORELIB := libPALISADEcore$(LIBSUFFIX)
PALISADEPKELIB := libPALISADEpke$(LIBSUFFIX)
PALISADEABELIB := libPALISADEabe$(LIBSUFFIX)
PALISADESIGNATURELIB := libPALISADEsignature$(LIBSUFFIX)
PALISADEPYLIB := pycrypto$(LIBSUFFIX)
# run make for all components. you can run any individual component separately
# by invoking "make allxxx" for example, make allcore makes everything in core only
.PHONY: all
all:
$(MAKE) gmp_all
$(MAKE) ntl_all
$(MAKE) allcore allpke utall
$(MAKE) allcore allpke allabe allsignature utall
.PHONY: docs
docs: apidocs
.PHONY: alljava
alljava: allcore allpke jwrapper
allpython: allcore allpke pywrapper
.PHONY: allpython
allpython: allcore allpke alltrapdoor allwip pywrapper
alldemos: allcoredemos allpkedemos
.PHONY: alldemos
alldemos: allcoredemos allpkedemos allabedemos allsignaturedemos
.PHONY: testall
testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TEST_TARGET) $(CIRCUIT_TEST_TARGET) $(ABE_TEST_TARGET) $(SIGNATURE_TEST_TARGET) utall
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(BINDIR)/unittest/tests$(EXESUFFIX) -t
......@@ -136,7 +153,7 @@ testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TE
# by invoking "make cleantargets" for example
# each corresponding makefile will make the cleanxxxx target
.PHONY: clean
clean: cleancore cleanpke cleandocs cleanbenchmark
clean: cleancore cleanpke cleandocs cleanbenchmark cleanabe cleansignature
@echo 'Cleaning top level autogenerated directories'
$(RM) -rf $(BINDIR)
$(RM) -rf src/*/bin
......@@ -144,15 +161,26 @@ clean: cleancore cleanpke cleandocs cleanbenchmark
.PHONY: clobber
clobber: clean clean_gmp clean_ntl
.PHONY: libdir
libdir:
.PHONY: installdirs
installdirs:
install --directory $(LIB_DEST)
.PHONY: install
install: installcore installpke
install: installcore installpke installtrapdoor installwip installcircuit installabe installsignature
.PHONY: dist
dist:
mkdir $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADECORELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADEPKELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADEABELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(PACKAGE)-$(VERSION)
tar -zcvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
rm -rf $(PACKAGE)-$(VERSION)
.PHONY: uninstall
uninstall: uninstallcore uninstallpke
uninstall: uninstallcore uninstallpke uninstallabe uninstallsignature
UNITTESTMAINOBJ := $(BINDIR)/unittest/Main_TestAll.o
......@@ -160,10 +188,13 @@ $(UNITTESTMAINOBJ): test/include/gtest/Main_TestAll.cpp src/core/lib/math/backen
@mkdir -p $(BINDIR)/unittest
$(CC) -c $(CPPFLAGS) $(INC) -o $@ $<
.PHONY: utall
utall: $(BINDIR)/unittest/tests$(EXESUFFIX)
include Makefile.core
include Makefile.pke
include Makefile.abe
include Makefile.signature
include Makefile.gmp
include Makefile.ntl
......@@ -171,6 +202,6 @@ include Makefile.ntl
include Makefile.benchmark #builds the benchmark framework
include Makefile.docs #populates doxgen documentation
$(BINDIR)/unittest/tests$(EXESUFFIX): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(NTLLIB) $(GMPLIB)
$(BINDIR)/unittest/tests$(EXESUFFIX): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(ABEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEABELIB) $(SIGNATUREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(BINDIR)/unittest
$(CC) -o $@ $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(PKEUNITOBJECTS) $(EXTLIB) -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
$(CC) -o $@ $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(PKEUNITOBJECTS) $(ABEUNITOBJECTS) $(SIGNATUREUNITOBJECTS) $(EXTLIB) -lPALISADEsignature -lPALISADEabe -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
......@@ -49,8 +49,9 @@ CORE_TEST_TARGET := $(EXTTESTDIR)/core/tests$(EXESUFFIX)
-include $(COREDEMOOBJECTS:.o=.d)
.PHONY: allcore
allcore: ntl_all $(EXTLIBDIR)/$(PALISADECORELIB) $(CORE_TEST_TARGET) allcoredemos
allcore: $(EXTLIBDIR)/$(PALISADECORELIB) $(CORE_TEST_TARGET) allcoredemos
.PHONY: allcoredemos
allcoredemos: $(EXTLIBDIR)/$(PALISADECORELIB) $(patsubst $(COREBINDIR)/demo/%,$(BINDIR)/demo/core/%,$(patsubst %.o,%$(EXESUFFIX),$(COREDEMOOBJECTS)))
$(BINDIR)/demo/core/%$(EXESUFFIX): $(COREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
......@@ -83,7 +84,6 @@ $(COREBINDIR)/%:
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleancore
cleancore:
$(RM) -fr $(COREBINDIR) $(EXTLIBDIR)/$(PALISADECORELIB) `dirname $(CORE_TEST_TARGET)` $(BINDIR)/demo/core
......@@ -98,13 +98,14 @@ testcore: $(CORE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(CORE_TEST_TARGET)
.PHONY: installcore
installcore: libdir
installcore: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADECORELIB)
.PHONY: uninstallcore
uninstallcore:
rm $(LIB_DEST)/$(PALISADECORELIB)
.PHONY: corestrings
corestrings:
@echo $(CORESOURCES)
@echo $(COREOBJECTS)
......@@ -38,5 +38,3 @@ $(INDEXFILE):
cleandocs:
@echo " Cleaning docs..."
rm -rf doc/apidocs
......@@ -9,7 +9,7 @@ TAR ?= tar
#note change the following directory to the correct one on your install
PALISADE_DIR := $(CURDIR)
GMP_VER :=6.1.2
GMP_VER := 6.1.2
#check if the palisade directory is correct
#ifneq ($(wildcard $(PALISADE_DIR)), )
......@@ -53,31 +53,40 @@ endif
$(GMPLIB): gmp_all
.PHONY: gmp_all
gmp_all: $(GMP_UNPACK_NEEDED) $(GMP_CONFIG_NEEDED) $(GMP_MAKE_NEEDED) $(GMP_CHECK_NEEDED) $(GMP_INSTALL_NEEDED)
.PHONY: gmp_unpack
gmp_unpack:
@echo 'Unpacking gmp for Palisade into $(GMP_DISTRO_DIR)'
cd $(DISTROS_DIR);\
$(TAR) xf ./gmp-$(GMP_VER).tar.lz
.PHONY: gmp_config
gmp_config: $(GMP_UNPACK_NEEDED)
@echo 'Configuring gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
./configure --prefix=$(THIRD_PARTY_DIR);
.PHONY: gmp_make
gmp_make: gmp_config
@echo 'making gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE)
.PHONY: gmp_check
gmp_check: $(GMP_MAKE_NEEDED)
@echo 'checking gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE) check
.PHONY: gmp_install
gmp_install: $(GMP_CHECK_NEEDED) $(GMP_MAKE_NEEDED)
@echo 'installing gmp for Palisade in $(THIRD_PARTY_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE) install
.PHONY: clean_gmp
clean_gmp:
@echo 'Cleaning gmp installation'
cd $(DISTROS_DIR);\
......
......@@ -17,9 +17,23 @@ else
#$(info GMP/NTL directory third-party does not exist)
endif
## library for tcmalloc for linux machines
ifneq ($(wildcard third-party/lib/libtcmalloc_minimal.a), )
#$(info TCMALLOC library third-party/lib exists)
TCMLIB := third-party/lib/libtcmalloc_minimal.so
CPPSTD := -std=gnu++11 -fPIC -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
else
#$(info TCMALLOC directory third-party does not exist)
CPPSTD := -std=gnu++11 -fPIC
endif
##CPPSTD := -std=gnu++11 -fPIC
CPPSTD := -std=gnu++11 -fPIC ##-mcmodel=large ## static allocator requires this memory model
CC := g++ $(CPPSTD)
LIBSUFFIX := .so
......@@ -35,5 +49,3 @@ LIBPYTHON := -lpython2.7
COMPTHREADFLAG := -pthread
LOADTHREADFLAG := -pthread
......@@ -56,32 +56,41 @@ else
NTL_INSTALL_NEEDED := ntl_install
endif
.PHONY: ntl_all
ntl_all: $(GMP_NEEDED) $(NTL_UNPACK_NEEDED) $(NTL_CONFIG_NEEDED) $(NTL_MAKE_NEEDED) $(NTL_CHECK_NEEDED) $(NTL_INSTALL_NEEDED)
@echo $(all)
.PHONY: ntl_unpack
ntl_unpack:
@echo 'Unpacking ntl for Palisade into $(NTL_DISTRO_DIR)'
cd $(DISTROS_DIR);\
$(TAR) xf ./ntl-$(NTL_VER).tar.gz
.PHONY: ntl_config
ntl_config: $(NTL_UNPACK_NEEDED)
@echo 'Configuring ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
./configure PREFIX=$(THIRD_PARTY_DIR) GMP_PREFIX=$(THIRD_PARTY_DIR) NTL_THREADS=on NTL_THREAD_BOOST=on NTL_EXCEPTIONS=on SHARED=on NTL_STD_CXX11=on NTL_SAFE_VECTORS=off
.PHONY: ntl_make
ntl_make: ntl_config
@echo 'making ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE)
.PHONY: ntl_check
ntl_check: $(NTL_MAKE_NEEDED)
@echo 'checking ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE) check
.PHONY: ntl_install
ntl_install: $(NTL_CHECK_NEEDED) $(NTL_MAKE_NEEDED)
@echo 'installing ntl for Palisade in $(THIRD_PARTY_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE) install
.PHONY: clean_ntl
clean_ntl:
@echo 'Cleaning ntl installation'
cd $(DISTROS_DIR);\
......
......@@ -49,7 +49,7 @@ PKE_TEST_TARGET := $(EXTTESTDIR)/pke/tests$(EXESUFFIX)
-include $(PKEUNITOBJECTS:.o=.d)
-include $(PKEDEMOOBJECTS:.o=.d)
.PHONY:allpke
.PHONY: allpke
allpke: allcore $(EXTLIBDIR)/$(PALISADEPKELIB) $(PKE_TEST_TARGET) allpkedemos
allpkedemos: $(patsubst $(PKEBINDIR)/demo/%,$(BINDIR)/demo/pke/%,$(patsubst %.o,%$(EXESUFFIX),$(PKEDEMOOBJECTS)))
......@@ -82,9 +82,8 @@ $(PKEBINDIR)/%:
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(PKEBINDIR)/%,$(PKESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi
.PHONY: cleanpke
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleanpke
cleanpke:
$(RM) -fr $(PKEBINDIR) $(EXTLIBDIR)/$(PALISADEPKELIB) `dirname $(PKE_TEST_TARGET)` $(BINDIR)/demo/pke
......@@ -99,7 +98,7 @@ testpke: $(PKE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(PKE_TEST_TARGET)
.PHONY: installpke
installpke: libdir
installpke: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADEPKELIB)
.PHONY: uninstallpke
......
#
#Copyright (c) 2015, New Jersey Institute of Technology (NJIT)
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
#met:
#1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in the
#documentation and/or other materials provided with the distribution.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED.
#IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
#STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
#IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#POSSIBILITY OF SUCH DAMAGE.
#
################
# Makefile.signature builds the attribute-based encryption components of the PALISADE library
# Includes unit tests and demos
################
SIGNATURESRCDIR := src/signature
SIGNATUREBINDIR := $(BINDIR)/build/signature
SIGNATURETESTDIR := src/signature/unittest
SIGNATUREDEMODIR := src/signature/demo
SIGNATURESOURCES := $(shell find $(SIGNATURESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
SIGNATUREUNITSOURCES := $(wildcard $(SIGNATURESRCDIR)/unittest/*.cpp)
SIGNATUREDEMOSOURCES := $(wildcard $(SIGNATURESRCDIR)/demo/*.cpp)
SIGNATUREOBJECTSALL = $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATURESOURCES)))
SIGNATUREOBJECTS = $(filter %-impl.o,$(SIGNATUREOBJECTSALL))
SIGNATUREUNITOBJECTS := $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATUREUNITSOURCES)))
SIGNATUREDEMOOBJECTS += $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATUREDEMOSOURCES)))
SIGNATURE_TEST_TARGET := $(EXTTESTDIR)/signature/tests$(EXESUFFIX)
-include $(SIGNATUREOBJECTS:.o=.d)
-include $(SIGNATUREUNITOBJECTS:.o=.d)
-include $(SIGNATUREDEMOOBJECTS:.o=.d)
.PHONY: allsignature
allsignature: allcore $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(SIGNATURE_TEST_TARGET) allsignaturedemos
.PHONY: allsignaturedemos
allsignaturedemos: $(patsubst $(SIGNATUREBINDIR)/demo/%,$(BINDIR)/demo/signature/%,$(patsubst %.o,%$(EXESUFFIX),$(SIGNATUREDEMOOBJECTS)))
$(BINDIR)/demo/signature/%$(EXESUFFIX): $(SIGNATUREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $< $(EXTLIB) -lPALISADEsignature -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADESIGNATURELIB): $(SIGNATUREOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@echo " -- signature:linking $@ from SIGNATUREOBJECTS"
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(SIGNATUREOBJECTS)
else
$(LIBCMD) $@ $(SIGNATUREOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(SIGNATUREBINDIR)/%
$(SIGNATUREBINDIR)/%:
@if [ "$(suffix $@)" = ".o" ] ; \
then \
mkdir -p $(@D) ;\
echo $(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
$(CC) -MM $(CPPFLAGS) $(INC) $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@) ;\
mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@) ;\
sed -e 's|.*\.o:|$(SIGNATUREBINDIR)/$*:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@) ;\
rm -f $(patsubst %.o,%.d.tmp,$@) ; \
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleansignature
cleansignature:
$(RM) -fr $(SIGNATUREBINDIR) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) `dirname $(SIGNATURE_TEST_TARGET)` $(BINDIR)/demo/signature
# this links test executable from objects in the test build directory
$(SIGNATURE_TEST_TARGET): $(UNITTESTMAINOBJ) $(SIGNATUREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(SIGNATURE_TEST_TARGET)`
$(CC) -o $(SIGNATURE_TEST_TARGET) $(UNITTESTMAINOBJ) $(SIGNATUREUNITOBJECTS) $(EXTLIB) -lPALISADEsignature -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
#used to run tests from make
.PHONY: testsignature
testsignature: $(SIGNATURE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(SIGNATURE_TEST_TARGET)
.PHONY: installsignature
installsignature: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADESIGNATURELIB)
.PHONY: uninstallsignature
uninstallsignature:
rm $(LIB_DEST)/$(PALISADESIGNATURELIB)
12/31/2018: PALISADE v1.4.0 is released
* Adds the Gentry-Peikert-Vaikuntanathan (GPV) digital signature scheme
* Adds the GPV identity-based encryption scheme
* Adds the Zhang-Zhang ciphertext-policy attribute-based encryption scheme
* Includes Genise-Micciancio (Eurocrypt'18) lattice trapdoor sampling algorithms and their improvements/generalizations
* Fixes bugs that were brought to our attention
11/26/2018: PALISADE v1.3.1 is released
* Improves performance of BFVrns
......
......@@ -30,7 +30,6 @@
#define _USE_MATH_DEFINES
#include "math/backend.h"
#include "lattice/backend.h"
#include "utils/inttypes.h"
#include "math/nbtheory.h"
#include "math/distrgen.h"
......@@ -38,6 +37,7 @@
#include "lattice/ilparams.h"
#include "lattice/ildcrtparams.h"
#include "lattice/ilelement.h"
#include "lattice/backend.h"
#include "lattice/poly.h"
#include "lattice/dcrtpoly.h"
#include "utils/utilities.h"
......
......@@ -100,7 +100,7 @@ void BM_encoding_PackedIntPlaintext(benchmark::State& state) {
shared_ptr<ILParams> lp;
EncodingParams ep;
std::vector<uint64_t> vectorOfInts1 = { 1,2,3,4,5,6,7,8,0,0 };
std::vector<int64_t> vectorOfInts1 = { 1,2,3,4,5,6,7,8,0,0 };
usint m = 22;
PlaintextModulus p = 89;
......@@ -134,7 +134,7 @@ void BM_encoding_PackedIntPlaintext_SetParams(benchmark::State& state) {
PlaintextModulus p = 89;
BigInteger modulusP(p);
std::vector<uint64_t> vectorOfInts1 = { 1,2,3,4,5,6,7,8,0,0 };
std::vector<int64_t> vectorOfInts1 = { 1,2,3,4,5,6,7,8,0,0 };
if( state.thread_index == 0 ) {
BigInteger modulusQ("955263939794561");
......
......@@ -42,7 +42,6 @@
#include <iostream>
#include "math/backend.h"
#include "lattice/backend.h"
#include "utils/inttypes.h"
#include "math/nbtheory.h"
#include "lattice/elemparams.h"
......@@ -50,8 +49,9 @@
#include "lattice/ildcrtparams.h"
#include "lattice/ilelement.h"
#include "math/distrgen.h"
#include "lattice/backend.h"
#include "lattice/poly.h"
#include "../../src/core/lib/lattice/dcrtpoly.h"
#include "lattice/dcrtpoly.h"
#include "utils/utilities.h"
......
......@@ -2,3 +2,4 @@
*
# Except this file
!.gitignore
!*.csv
\ No newline at end of file
......@@ -38,7 +38,7 @@ PROJECT_NAME = "PALISADE Lattice Crypto Library"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "v1.3.1"
PROJECT_NUMBER = "v1.4.0"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
/**
* @file CPABEDemo.cpp - Demo file for ciphertext-policy attribute based encryption
* @author TPOC: palisade@njit.edu
*
* @copyright Copyright (c) 2017, New Jersey Institute of Technology (NJIT)
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "palisade.h"
#include "../lib/abecontext.h"
using namespace lbcrypto;
int main(){
//Create context under security level and number of attributes
std::cout<<"This is a demo file of the CPABE scheme"<<std::endl<<std::endl;
usint ringsize = 1024;
usint numAttributes = 6;
usint base = 64;
TimeVar t1;
std::cout<<"Used parameters:"<<std::endl;
std::cout<<"Ring size: "<<ringsize<<std::endl;
std::cout<<"Number of attributes: "<<numAttributes<<std::endl;
std::cout<<"Base: "<<base<<std::endl<<std::endl;
ABEContext<NativePoly> context;
std::cout<<"Generating a context under these parameters"<<std::endl<<std::endl;
context.GenerateCPABEContext(numAttributes,ringsize,base);
std::cout<<"Generating master secret key and master public key"<<std::endl;
//Generate master keys
TIC(t1);
CPABEMasterPublicKey<NativePoly> mpk;
CPABEMasterSecretKey<NativePoly> msk;
context.Setup(&mpk,&msk);
double duration = TOC(t1);
std::cout<<"Setup: "<<duration<<" ms"<<std::endl<<std::endl;
//Create a random access policy and user attribute set
std::cout<<" Creating access policy and user attribute sets"<<std::endl;
std::vector<usint> s(6);
std::vector<int> w(6);
for(usint j=0; j<6; j++)
s[j] = rand()%2;
for(usint j=0; j<6; j++)
w[j] = s[j];