Merge branch 'mliu-backend' into bryan/add-frontend

This commit is contained in:
Bryan Li
2023-07-25 10:07:47 -07:00
3 changed files with 36 additions and 25 deletions

View File

@@ -362,6 +362,20 @@ where
// TODO: figure out updates to group and stack id?
// I think that stack id should be updated every time a node is added to the graph
// and that group id should be updated every time a function is called/returned via proc macro
// Group counter should be updated every time you push onto the group stack, and group stack is pushed/popped with functions being called and returned
// Without being able to implement grouping, can't dive into lines of code. Still can click nodes and see stack traces
// To assign group ids, look up current group stack, look up group id corresponding to it, and assign that to nodes.
// If you don't find the group id corresponding to this, then assign the group counter
// Group counter is updated every time you push onto the group stack
// Group counter is also appended to the name of functions
/*
Lines of code => graph:
- When you click a line, you know function + lineno
- Need to traverse the stack trie until you find a stack frame whose top entry contains the line of code the user clicked on
- Then everything underneath that node in the trie is a callee of the current function, and everything with that stack id is the current line
*/
// Capture backtrace and insert into lookup structure
let bt = Backtrace::new();

View File

@@ -70,6 +70,21 @@ impl StackFrameInfo {
/**
* Allows for lookup of call stack information given a ProgramNode's `group_id`.
*
* Maybe: use stack frame as key, node id as value.
*
* Forward lookup: "given a stack frame, give me the stack ID" is what the trie is for
* We need this for "while constructing the graph, want to know 'is there anything else with the same stack trace'"
* If it is, let me reuse the same stack id. This way every node with the same stack trace has the same stack id
*
* So in `add_node`, need to look up to see if this stack id already exists. If it exists, just assign that and keep stack_counter the same
* If it doesn't exist, then assign and increment stack_counter
*
* Use a hashmap (key: stack id, val: pointer to node in the trie, use unsafe to dereference it).
* Gives reverse lookup: given a stack id, what nodes does it correspond to
* Pointers not serializable so this could be a problem
* Need to figure out what to store as the value here: just need something that'll allow me to reference a node in the trie
* Value could just be the entire stack trace
*/
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct StackFrameLookup {

View File

@@ -1,6 +1,6 @@
use actix_web::{get, http::header, web, App, HttpResponse, HttpServer, Responder};
use seal_fhe::{BfvEncryptionParametersBuilder, CoefficientModulus, Context, Decryptor};
use seal_fhe::{BfvEncryptionParametersBuilder, CoefficientModulus, Context, Decryptor, Modulus};
use semver::Version;
use std::sync::OnceLock;
@@ -169,39 +169,22 @@ pub async fn get_fhe_node_data(
for inner_cipher in vec {
let mut inner_coefficients = Vec::new();
let coeff_mod: Vec<i32> = inner_cipher
// coeff_mod is supposed to be the actual modulus, not the size in bits
let coeff_mod = inner_cipher
.params
.coeff_modulus
.iter()
.map(|&num| (num.ilog2() + 1) as i32)
.collect();
.map(|&num| Modulus::new(num).unwrap())
.collect::<Vec<_>>();
// Decrypt inner ciphertext
let encryption_params_builder =
BfvEncryptionParametersBuilder::new()
.set_coefficient_modulus(
CoefficientModulus::create(
inner_cipher.params.lattice_dimension,
&coeff_mod,
)
.expect("Failed to create coefficient modulus"),
)
.set_coefficient_modulus(coeff_mod)
.set_plain_modulus_u64(inner_cipher.params.plain_modulus)
.set_poly_modulus_degree(
inner_cipher.params.lattice_dimension,
);
let encryption_params = encryption_params_builder.build().unwrap();
println!("encryption params");
println!(
"poly mod degree: {:?}",
encryption_params.get_poly_modulus_degree()
);
println!(
"coeff mod degree: {:?}",
encryption_params.get_coefficient_modulus()
);
println!("plain mod: {:?}", encryption_params.get_plain_modulus());
println!("scheme: {:?}", encryption_params.get_scheme());
let ctx = Context::new(
&encryption_params,
false,
@@ -210,8 +193,6 @@ pub async fn get_fhe_node_data(
.expect("Failed to create context");
let sk = &pk.0.data;
dbg!(ctx.get_handle(), sk.get_handle());
let decryptor =
Decryptor::new(&ctx, sk).expect("Failed to create decryptor");
let pt = decryptor.decrypt(&inner_cipher.data).unwrap();
@@ -301,6 +282,7 @@ pub async fn get_stack_trace(
if sessions.contains_key(&session) {
let curr_session = sessions.get(&session).unwrap().unwrap_bfv_session();
let stack_lookup = &curr_session.graph.metadata.stack_lookup;
if let Some(node_weight) = curr_session
.graph
.node_weight(petgraph::stable_graph::NodeIndex(nodeid as u32))