fix: Take output file as parameter and fix the makefile

This commit is contained in:
Quentin Bourgerie
2023-01-11 20:28:31 +01:00
parent a09438653f
commit a6d1d3f9bd
2 changed files with 14 additions and 7 deletions

View File

@@ -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)

View File

@@ -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))