Skip to content

Commit

Permalink
refactoring code to change serializedsealdata to bfvnodetype
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-liu801 committed Jul 26, 2023
1 parent 21496d4 commit 2924eb2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 12 additions & 1 deletion sunscreen_runtime/src/debugger/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ use sunscreen_compiler_common::Operation;
use sunscreen_compiler_common::Type;
use sunscreen_compiler_common::{EdgeInfo, NodeInfo};

pub enum DebugNodeType {
Bfv(BfvNodeType),
Zkp(ZkpNodeType)
}

#[derive(Clone, Serialize, Deserialize)]
pub struct SerializedSealData {
pub struct BfvNodeType {
pub value: i64,
pub data_type: Type,
pub noise_budget: Option<u32>,
Expand Down Expand Up @@ -49,5 +54,11 @@ where
max_depth
}

#[derive(Clone, Serialize, Deserialize)]
pub struct ZkpNodeType {
pub value: i64,

}

#[test]
fn test_get_mul_depth() {}
8 changes: 4 additions & 4 deletions sunscreen_runtime/src/debugger/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use seal_fhe::{BfvEncryptionParametersBuilder, Context, Decryptor, Modulus};
use semver::Version;

use crate::{
debugger::SerializedSealData,
debugger::BfvNodeType,
debugger::{get_mult_depth, get_sessions},
Ciphertext, InnerCiphertext, InnerPlaintext, Plaintext, Runtime, SealData, Type, WithContext,
};
Expand Down Expand Up @@ -144,7 +144,7 @@ pub async fn get_fhe_node_data(
let runtime = Runtime::new_fhe(&pk.0.params).unwrap();
let stable_graph = &curr_session.graph.graph;

let data_for_server: SerializedSealData = match data {
let data_for_server: BfvNodeType = match data {
SealData::Ciphertext(ct) => {
let with_context = WithContext {
params: pk.0.params.clone(),
Expand Down Expand Up @@ -216,7 +216,7 @@ pub async fn get_fhe_node_data(

// TODO: implement detection for overflow. Values overflow if two input operands have the same sign
// but the output is opposite sign. Values are negative if greater than plaintextmodulus/2, else positive
SerializedSealData {
BfvNodeType {
// WARNING: `value` and `data_type` are nonsense values
value: 0,
data_type: sunscreen_ciphertext.data_type,
Expand Down Expand Up @@ -252,7 +252,7 @@ pub async fn get_fhe_node_data(
}
coefficients.push(inner_coefficients);

SerializedSealData {
BfvNodeType {
// WARNING: `value` and `data_type` contain nonsense
value: 0,
data_type: sunscreen_plaintext.data_type,
Expand Down

0 comments on commit 2924eb2

Please sign in to comment.