From a6d1d3f9bd9ae4065a06843fc14aa59a99856e52 Mon Sep 17 00:00:00 2001 From: Quentin Bourgerie Date: Wed, 11 Jan 2023 20:28:31 +0100 Subject: [PATCH] fix: Take output file as parameter and fix the makefile --- Makefile | 9 +++++---- lattice-scripts/verify_curves.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 17e2ad0e1..49f67b0d9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SECURITY_LEVELS=80 112 128 192 SAGE_OBJECT_DIR=sage-object SAGE_SECURITY_CURVES=$(SECURITY_LEVELS:%=$(SAGE_OBJECT_DIR)/%.sobj) -SAGE_VERIFED_CURVES=$(CURVES_SAGE_OBJECT_DIR)/verified_curves.sobj +SAGE_VERIFIED_CURVES=$(SAGE_OBJECT_DIR)/verified_curves.sobj CURVES_JSON_PATH=json/curves.json CURVES_CPP_GEN_H=concrete-security-curves-cpp/include/concrete/curves.gen.h CURVES_RUST_GEN_TXT=concrete-security-curves-rust/src/curves.gen.rs @@ -35,15 +35,16 @@ compare-curves: $(SAGE_OBJECT_DIR)/outdated_curves.timestamp $(SAGE_OBJECT_DIR)/%.sobj: $(SAGE_OBJECT_DIR)/outdated_curves.timestamp ./lattice-scripts/generate_data.sh ./lattice-scripts/generate_data.py PYTHONPATH=$(PWD)/lattice-estimator ./lattice-scripts/generate_data.sh \ - $* --output $(SAGE_OBJECT_DIR) --old-models $(SAGE_OBJECT_DIR)/verified_curves.sobj + $* --output $(SAGE_OBJECT_DIR) --old-models $(SAGE_VERIFIED_CURVES) generate-curves: $(SAGE_SECURITY_CURVES) # Verify curves ####################### -$(CURVES_JSON_PATH): ./lattice-scripts/verify_curves.py $(SAGE_SECURITY_CURVES) +$(CURVES_JSON_PATH) $(SAGE_VERIFIED_CURVES): ./lattice-scripts/verify_curves.py #$(SAGE_SECURITY_CURVES) python3 ./lattice-scripts/verify_curves.py \ - --curves-dir $(SAGE_OBJECT_DIR) --security-levels $(SECURITY_LEVELS) --log-q 64 > $(CURVES_JSON_PATH) + --curves-dir $(SAGE_OBJECT_DIR) --verified-curves-path $(SAGE_VERIFIED_CURVES) \ + --security-levels $(SECURITY_LEVELS) --log-q 64 > $(CURVES_JSON_PATH) verify-curves: $(CURVES_JSON_PATH) diff --git a/lattice-scripts/verify_curves.py b/lattice-scripts/verify_curves.py index d63824511..fc4315510 100644 --- a/lattice-scripts/verify_curves.py +++ b/lattice-scripts/verify_curves.py @@ -78,7 +78,7 @@ def verify_curve(security_level, a, b, curves_dir): return True, n_min -def generate_and_verify(security_levels, log_q, curves_dir, name="verified_curves.sobj"): +def generate_and_verify(security_levels, log_q, curves_dir, verified_curves_path): success = [] json = [] @@ -97,13 +97,19 @@ def generate_and_verify(security_levels, log_q, curves_dir, name="verified_curve else: fail.append(sec) - save(success, os.path.join(curves_dir, name)) + save(success, verified_curves_path) return json, fail if __name__ == "__main__": CLI = argparse.ArgumentParser() + CLI.add_argument( + "--verified-curves-path", + help="The path to store the verified curves (sage object)", + type=str, + required=True, + ) CLI.add_argument( "--curves-dir", help="The directory where curves has been saved (sage object)", @@ -123,7 +129,7 @@ if __name__ == "__main__": required=True ) args = CLI.parse_args() - (success, fail) = generate_and_verify(args.security_levels, log_q=args.log_q, curves_dir=args.curves_dir) + (success, fail) = generate_and_verify(args.security_levels, log_q=args.log_q, curves_dir=args.curves_dir, verified_curves_path=args.verified_curves_path) if (fail): print("FAILURE: Fail to verify the following curves") print(json.dumps(fail))