Commit 774758dd authored by rejection-free's avatar rejection-free
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+20 −0
Changes for .gitignore: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
lazer.h
*.a
*.so

scripts/modified-abdlop-codegen.sage.py
scripts/modified-quad-codegen.sage.py
scripts/modified-quad-eval-codegen.sage.py
scripts/moduli.sage.py
scripts/estimator/

src/*.o
src/lazer.c

tests/encoding-test
tests/modified-abdlop-test
tests/modified-quad-test
tests/modified-quad-many-test
tests/modified-quad-eval-test

tests/*.h

.gitmodules

0 → 100644
+7 −0
Changes for .gitmodules: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
[submodule "lazer"]
	path = lazer
	url = git@github.com:lazer-crypto/lazer

[submodule "scripts/lattice-estimator"]
	path = scripts/lattice-estimator
	url = git@github.com:malb/lattice-estimator

LICENSE

0 → 100644
+22 −0
Changes for LICENSE: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
MIT License

Copyright (c) 2025 rejection-free

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Makefile

0 → 100644
+204 −0
Changes for Makefile: 204 added lines, 0 removed lines.
Original line number Diff line number Diff line
CFLAGS_WARN = -Wall -Wextra
CFLAGS = $(CFLAGS_WARN) -O3 -g -pthread -march=native -mtune=native -fomit-frame-pointer

LIBS = -lm $(HEXL_DIR)/build/hexl/lib/libhexl.a -lstdc++

libmpfr = -lmpfr
LIBS += $(libmpfr)

libgmp = -lgmp
LIBS += $(libgmp)

.PHONY: default all
default: lib
all: lib-all

LAZER_DIR = lazer

THIRD_PARTY_DIR = $(LAZER_DIR)/third_party
HEXL_SUBDIR = hexl-development
HEXL_DIR = $(THIRD_PARTY_DIR)/$(HEXL_SUBDIR)
HEXL_ZIP = $(HEXL_DIR).zip

$(HEXL_DIR): $(HEXL_ZIP)
	cd $(THIRD_PARTY_DIR) && unzip $(HEXL_SUBDIR).zip
	cd $(HEXL_DIR) && cmake -S . -B build -DHEXL_BENCHMARK=OFF -DHEXL_TESTING=OFF
	cd $(HEXL_DIR) && cmake --build build


#### lib lazer
LAZER_INC = \
 $(LAZER_DIR)/src/aes256ctr.h \
 $(LAZER_DIR)/src/brandom.h \
 $(LAZER_DIR)/src/dom.h \
 $(LAZER_DIR)/src/grandom.h \
 $(LAZER_DIR)/src/intvec.h \
 $(LAZER_DIR)/src/lazer-in1.h \
 $(LAZER_DIR)/src/lazer-in2.h \
 $(LAZER_DIR)/src/lnp-tbox.h \
 $(LAZER_DIR)/src/memory.h \
 $(LAZER_DIR)/src/mont.h \
 $(LAZER_DIR)/src/poly.h \
 $(LAZER_DIR)/src/rng.h \
 $(LAZER_DIR)/src/shake128.h \
 $(LAZER_DIR)/src/stopwatch.h \
 $(LAZER_DIR)/src/urandom.h \

LAZER_SRC = \
 $(LAZER_DIR)/src/lazer.c \
 $(LAZER_DIR)/src/abdlop.c \
 $(LAZER_DIR)/src/aes256ctr.c \
 $(LAZER_DIR)/src/aes256ctr-amd64.c \
 $(LAZER_DIR)/src/brandom.c \
 $(LAZER_DIR)/src/bytes.c \
 $(LAZER_DIR)/src/coder.c \
 $(LAZER_DIR)/src/dcompress.c \
 $(LAZER_DIR)/src/dump.c \
 $(LAZER_DIR)/src/grandom.c \
 $(LAZER_DIR)/src/int.c \
 $(LAZER_DIR)/src/intmat.c \
 $(LAZER_DIR)/src/intvec.c \
 $(LAZER_DIR)/src/lin-proofs.c \
 $(LAZER_DIR)/src/lnp.c \
 $(LAZER_DIR)/src/lnp-quad.c \
 $(LAZER_DIR)/src/lnp-quad-eval.c \
 $(LAZER_DIR)/src/lnp-quad-many.c \
 $(LAZER_DIR)/src/lnp-tbox.c \
 $(LAZER_DIR)/src/memory.c \
 $(LAZER_DIR)/src/poly.c \
 $(LAZER_DIR)/src/polymat.c \
 $(LAZER_DIR)/src/polyring.c \
 $(LAZER_DIR)/src/polyvec.c \
 $(LAZER_DIR)/src/quad.c \
 $(LAZER_DIR)/src/rejection.c \
 $(LAZER_DIR)/src/rng.c \
 $(LAZER_DIR)/src/shake128.c \
 $(LAZER_DIR)/src/spolymat.c \
 $(LAZER_DIR)/src/spolyvec.c \
 $(LAZER_DIR)/src/stopwatch.c \
 $(LAZER_DIR)/src/urandom.c \
 $(LAZER_DIR)/src/version.c \

#### lib modified-lazer
LIB_DIR = src

LIBSOURCES = \
 $(LIB_DIR)/lazer.c \
 $(LIB_DIR)/tools.c \
 $(LIB_DIR)/encoding.c \
 $(LIB_DIR)/modified-abdlop.c \
 $(LIB_DIR)/modified-quad.c \
 $(LIB_DIR)/modified-quad-eval.c \
 $(LIB_DIR)/modified-quad-many.c \

TESTS = \
 tests/modified-abdlop-test \
 tests/modified-quad-test \
 tests/modified-quad-eval-test \
 tests/modified-quad-many-test


.PHONY: lib lib-all lib-static lib-shared lib-static-all lib-shared-all
lib-all: lazer.h lib-static-all lib-shared-all
lib: lazer.h lib-static lib-shared

lib-shared-all: lazer.h liblazer.so
lib-shared: lazer.h liblazer.so
lib-static-all: lazer.h liblazer.a
lib-static: lazer.h liblazer.a

liblazer.a: src/lazer_static.o src/hexl_static.o
	ar rcs liblazer.a src/lazer_static.o src/hexl_static.o

liblazer.so: src/lazer_shared.o src/hexl_shared.o
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -shared -o liblazer.so src/lazer_shared.o src/hexl_shared.o

src/lazer_static.o: $(LIBSOURCES) $(LAZER_INC) $(LAZER_SRC) lazer.h src/lazer.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/src -c -o src/lazer_static.o src/lazer.c

src/lazer_shared.o: $(LIBSOURCES) $(LAZER_INC) $(LAZER_SRC) lazer.h src/lazer.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/src -c -fPIC -o src/lazer_shared.o src/lazer.c

src/hexl_static.o: $(LAZER_DIR)/src/hexl.h $(HEXL_DIR)
	$(CXX) $(CPPFLAGS) $(CFLAGS) -I$(LAZER_DIR) -I$(LAZER_DIR)/src -I$(HEXL_DIR)/hexl/include -c -o src/hexl_static.o $(LAZER_DIR)/src/hexl.cpp

src/hexl_shared.o: $(LAZER_DIR)/src/hexl.h $(HEXL_DIR)
	$(CXX) $(CPPFLAGS) $(CFLAGS) -I$(LAZER_DIR) -I$(LAZER_DIR)/src -I$(HEXL_DIR)/hexl/include -c -fPIC -o src/hexl_shared.o $(LAZER_DIR)/src/hexl.cpp

src/lazer.c:
	{ head -n33 $(LAZER_DIR)/src/lazer.c; cat src/lazer-modified.c; tail -n+34 $(LAZER_DIR)/src/lazer.c; } | sed 's/blindsig.c/stopwatch.h/' > src/lazer.c

lazer.h: $(LAZER_DIR)/src/lazer-in1.h $(LAZER_DIR)/src/lazer-in2.h src/lazer-modified.h $(LAZER_DIR)/src/moduli.h $(LAZER_DIR)/config.h
	cat $(LAZER_DIR)/src/lazer-in1.h > tmp.h
	echo "" >> tmp.h

	echo "#ifndef LAZER_CONFIG_H" >> tmp.h
	echo "#define LAZER_CONFIG_H" >> tmp.h
	echo "" >> tmp.h
	cat $(LAZER_DIR)/config.h >> tmp.h
	echo "" >> tmp.h
	echo "#endif" >> tmp.h
	echo "" >> tmp.h

	cat $(LAZER_DIR)/src/lazer-in2.h >> tmp.h
	head --lines=-2 tmp.h > lazer.h
	rm tmp.h

	echo "" >> lazer.h

	cat src/lazer-modified.h >> lazer.h
	echo "" >> lazer.h
	
	cat lazer/src/moduli.h >> lazer.h	
	
TESTDEPS = $(LAZER_DIR)/tests/test.h tests/test.o lazer.h liblazer.a
TESTLIBS = tests/test.o liblazer.a $(LIBS)

.PHONY: params

params: params-setup params-abdlop params-quad params-many

params-setup: 
	cd scripts && $(MAKE) $@ $<
	

params-abdlop: params-setup
	cd scripts && $(MAKE) $@ $<

params-quad: params-setup
	cd scripts && $(MAKE) $@ $<

params-many: params-setup
	cd scripts && $(MAKE) $@ $<

.PHONY: check
check: $(TESTS)
	cd tests && ./run-modified-tests

tests/test.o: $(LAZER_DIR)/tests/test.c $(LAZER_DIR)/tests/test.h lazer.h liblazer.a
	$(CC) $(CPPFLAGS) $(CFLAGS) -I$(LAZER_DIR) -I. -c -o $@ $<

tests/lazer-test: $(LAZER_DIR)/tests/lazer-test.c $(TESTDEPS)
	$(CC) $(CPPFLAGS) $(CFLAGS) -I$(LAZER_DIR) -I. -o $@ $< $(TESTLIBS)

tests/modified-abdlop-test: tests/modified-abdlop-test.c $(TESTDEPS) tests/modified-abdlop-params1.h tests/modified-abdlop-params2.h tests/modified-abdlop-params3.h tests/modified-abdlop-params4.h tests/modified-abdlop-params5.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/tests -o $@ $< $(TESTLIBS)

tests/modified-quad-test: tests/modified-quad-test.c $(TESTDEPS) tests/modified-quad-params1.h tests/modified-quad-params2.h tests/modified-quad-params3.h tests/modified-quad-params4.h tests/modified-quad-params5.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/tests -o $@ $< $(TESTLIBS)

tests/modified-quad-eval-test: tests/modified-quad-eval-test.c $(TESTDEPS) tests/modified-quad-eval-params1.h tests/modified-quad-eval-params2.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/tests -o $@ $< $(TESTLIBS)

tests/modified-quad-many-test: tests/modified-quad-many-test.c $(TESTDEPS) tests/modified-quad-params1.h tests/modified-quad-params2.h tests/modified-quad-params3.h tests/modified-quad-params4.h tests/modified-quad-params5.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(LAZER_DIR) -I$(LAZER_DIR)/tests -o $@ $< $(TESTLIBS)

.PHONY: clean
clean:
	rm -f lazer.h src/lazer.c liblazer.a liblazer.so 
	cd scripts && rm -f moduli.sage.py modified-abdlop-codegen.sage.py modified-quad-codegen.sage.py modified-quad-eval-codegen.sage.py
	cd src && rm -f *.o
	cd lazer && $(MAKE) clean
	cd $(THIRD_PARTY_DIR) && rm -rf $(HEXL_SUBDIR)
	cd tests && rm -f *.o *.dSYM && cd .. && rm -f $(TESTS) && rm -f sage-test.sage.py  

README.md

0 → 100644
+102 −0
Changes for README.md: 102 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Implementation of a Rejection-free Zero-Knowledge framework of proof

Modification of the [LaZer library](https://github.com/lazer-crypto/lazer) in order to add our implementation 
for the paper **Rejection free Zero-Knowledge framework of proof under Hint-MLWE**. 
We do not claim any existing structures from the original library related to the [LSS24](https://eprint.iacr.org/2024/1846.pdf). 
Our implementation only concerns the use of the library's functions 
to modify existing frameworks accordingly.

The repository contains the implementation of our proof framework 
using the modified commitment scheme. It exploits the encoding protocol extracted from [HSS24](https://eprint.iacr.org/2024/306.pdf). The repository also contains several parameter sets in the `tests` sub-directory, defined in the files `params*.sage`. 

Using the `scripts` files, the user can manually generate the complete list of concrete parameters associated with these inputs for different uses: 
- a single instance of the commitment scheme,
- one instance of a quadratic function
- an instance of several quadratic functions
- an instance of several evaluations (i.e. a constant coefficient equal to zero).

Clone the repository
--------------------

As our code exploits the actual structure of the code from the [LaZer library](https://github.com/lazer-crypto/lazer), 
we manage to use and link the github repository from the Library directly in ours.
Then, in order to have the entire list of files from our code with the [LaZer library](https://github.com/lazer-crypto/lazer), run:

`git clone --recursive git@github.com:rejection-free/rejection-free-framework-under-Hint-MLWE.git`

Be aware of the dependencies
----------------------------
We provide the list of our hardware and software used to build and run our code, and their version.

- ubuntu 22.04
- kernel version 6.8.0-51-generic
- gcc version 11.4.0
- make 4.3
- cmake version 3.22.1
- sagemath version 9.5
- python3 3.10,

If you want to fully build the entire [LaZer library](https://github.com/lazer-crypto/lazer), keep in mind that 
the entire list of requirements are differents and the library must be built independently from this code.

Compile the code
----------------
To build the C library along with the required LaZer parts, 
from the base directory, run:

`make all`

To build the list of parameters specified in the `params` subfolder, from the base directory, run:

`make params`

or specifically `make params-abdlop`, `make params-quad`, `make params-eval`.

Keep in mind that this will overwrite the actual associated files `modified-__-__-params%.h` in the `tests` subdirectory.

To build the C list of tests, from the base directory, run:

`make check`

Optional: use make's `-j` option to speed up compilation.

In order to clean your repository after compilation, run:

`make clean`

Concrete modification of the library
------------------------------------

In order to give a simpler library, we have chosen to 
select and modify the list of files compiled in the [LaZer library](https://github.com/lazer-crypto/lazer), as it was required to have access to a CPU that can  use the AVX512 set of instructions. 

In general, we base our implementation in order to be joined to
the actual [LaZer library](https://github.com/lazer-crypto/lazer), reusing the global structure, types, 
and semantics.   

We also use and modify in consequence the scripts in `scripts` to provide the 
security of our different protocols. 

LWE Estimator
-------------

We imported the [LWE estimator](https://github.com/malb/lattice-estimator) as the subfolder `scripts/lattice-estimator` from 

    Martin R. Albrecht, Rachel Player and Sam Scott. On the concrete hardness of Learning with Errors.
    Journal of Mathematical Cryptology. Volume 9, Issue 3, Pages 169–203, ISSN (Online) 1862-2984,
    ISSN (Print) 1862-2976 DOI: 10.1515/jmc-2015-0016, October 2015

The first time you launch `make params` it will extract the subfolder `estimator` for this repository providing the python files 
to the sage scripts. 

Parameters
----------

We provide in the `params` subfolder our 5 sets of parameters. In the `tests` subfolder, you will have the entire list 
of parameters `modified-_-_-params%.h` for each possible instance of our framework. 

Using the `scripts` files, the user can manually generate the complete list of concrete parameters associated with these inputs for different uses: 
- an instance of the commitment scheme for the 5 parameters sets,
- an instance of the commitment scheme + a single quadratic relations for the 5 parameters sets,
- an instance of the commitment scheme + 3 quadratic relations for the 5 parameters sets,
- an instance of the commitment scheme + 3 quadratic relations + 3 evaluations for the 5 parameters sets.
 No newline at end of file
Loading