mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-15 07:05:09 -05:00
refactor: Move generated code
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
rust-security-curves/target/
|
||||
rust-security-curves/Cargo.lock
|
||||
concrete-security-curves/target/
|
||||
concrete-security-curves/Cargo.lock
|
||||
|
||||
14
Makefile
14
Makefile
@@ -1,12 +1,18 @@
|
||||
CURVES_JSON_PATH=json/curves.json
|
||||
CURVES_CPP_GEN_H=cpp/include/concrete/curves.gen.h
|
||||
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
|
||||
|
||||
$(CURVES_JSON_PATH): verify_curves.py
|
||||
sage verify_curves.py > $@
|
||||
|
||||
$(CURVES_CPP_GEN_H): cpp/gen_header.py $(CURVES_JSON_PATH)
|
||||
cat $(CURVES_JSON_PATH) | python cpp/gen_header.py > $(CURVES_CPP_GEN_H)
|
||||
$(CURVES_CPP_GEN_H): concrete-security-curves-cpp/gen_header.py $(CURVES_JSON_PATH)
|
||||
cat $(CURVES_JSON_PATH) | python concrete-security-curves-cpp/gen_header.py > $(CURVES_CPP_GEN_H)
|
||||
|
||||
generate-cpp-header: $(CURVES_CPP_GEN_H)
|
||||
generate-cpp: $(CURVES_CPP_GEN_H)
|
||||
|
||||
$(CURVES_RUST_GEN_TXT): rust/gen_table.py $(CURVES_JSON_PATH)
|
||||
cat $(CURVES_JSON_PATH) | python concrete-security-curves-cpp/gen_table.py > $(CURVES_CPP_GEN_H)
|
||||
|
||||
generate-rust: $(CURVES_RUST_GEN_TXT)
|
||||
|
||||
.PHONY: generate-cpp-header
|
||||
7
concrete-security-curves-rust/Cargo.lock
generated
Normal file
7
concrete-security-curves-rust/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "concrete-security-curves"
|
||||
version = "0.1.0"
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rust-security-curves"
|
||||
name = "concrete-security-curves"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
13
concrete-security-curves-rust/gen_table.py
Normal file
13
concrete-security-curves-rust/gen_table.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import sys, json;
|
||||
|
||||
def print_curve(data):
|
||||
print(f' ({data["security_level"]}, SecurityWeights {{ slope: {data["slope"]}, bias: {data["bias"]}, minimal_lwe_dimension: {data["minimal_lwe_dimension"]} }}),')
|
||||
|
||||
|
||||
def print_rust_curves_declaration(datas):
|
||||
print("[")
|
||||
for data in datas:
|
||||
print_curve(data)
|
||||
print("]")
|
||||
|
||||
print_rust_curves_declaration(json.load(sys.stdin))
|
||||
@@ -1,4 +1,4 @@
|
||||
const SECURITY_WEIGHTS_ARRAY: [(u64, SecurityWeights); 9] = include!("../verified_curves.txt");
|
||||
const SECURITY_WEIGHTS_ARRAY: [(u64, SecurityWeights); 9] = include!("./curves.gen.rs");
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SecurityWeights {
|
||||
@@ -1,13 +0,0 @@
|
||||
import sys, json;
|
||||
|
||||
def print_curve(data):
|
||||
print(f' ({data["bits"]}, SecurityWeights {{ slope: {data["linear_term1"]}, bias: {data["linear_term2"]}, minimal_lwe_dimension: {data["n_alpha"]} }}),')
|
||||
|
||||
|
||||
def print_rust_curves_declaration(datas):
|
||||
print("[")
|
||||
for data in datas:
|
||||
print_curve(data)
|
||||
print("]")
|
||||
|
||||
print_rust_curves_declaration(json.load(open("json/curves.json")))
|
||||
Reference in New Issue
Block a user