Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy fixes and node id support for fhe/zkp compilers #269

Merged
merged 257 commits into from
Jul 31, 2023

Conversation

matthew-liu801
Copy link
Contributor

No description provided.

matthew-liu801 and others added 30 commits June 27, 2023 11:38
});
}

#[cfg(feature = "debugger")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to gate these, as the entire module it lives in is gates (I think)

@@ -5,12 +5,14 @@
//! (i.e. an [`FheProgram`](sunscreen_fhe_program::FheProgram)).

mod array;
mod debugger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate this module.

@@ -5,12 +5,14 @@
//! (i.e. an [`FheProgram`](sunscreen_fhe_program::FheProgram)).

mod array;
mod debugger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should gate this under the debugger feature.

mod error;
mod keys;
mod metadata;
mod run;
mod runtime;
mod serialization;
mod zkp;
Copy link
Contributor

@rickwebiii rickwebiii Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can delete this module and the file zkp.rs.


use seal_fhe::{Ciphertext as SealCiphertext, Plaintext as SealPlaintext};
use serde::{Deserialize, Serialize};
use sunscreen_zkp_backend::BigInt;

#[derive(Debug, Clone, PartialEq, Hash, Serialize, Deserialize, Eq)]
//#[serde(tag = "type")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove all these for now.

/**
* The underlying backend implementation of a plaintext (e.g. SEAL's [`Plaintext`](seal_fhe::Plaintext)).
*/
pub enum InnerPlaintext {
/**
* This plaintext wraps a SEAL [`Plaintext`](seal_fhe::Plaintext).
*/
Seal(Vec<WithContext<SealPlaintext>>),
Seal {
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, start using

/// this is a doc
/// comment

style doc comments. JS doc tends to give subtle annoying issues and we've agreed to consolodate around ///.

@@ -103,6 +128,8 @@ pub unsafe fn run_program_unchecked<E: Evaluator + Sync + Send>(
evaluator: &E,
relin_keys: &Option<&RelinearizationKeys>,
galois_keys: &Option<&GaloisKeys>,
debug_info: Option<DebugInfo>,
#[cfg(feature = "debugger")] source_code: &str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be an argument. The source code should exist on ir's metadata..

@@ -157,25 +184,70 @@ pub unsafe fn run_program_unchecked<E: Evaluator + Sync + Send>(
data.push(AtomicCell::new(None));
}

#[cfg(feature = "debugger")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to change for this code review, but check how Brian and I make a session for ZKP. It's way cleaner.


#[cfg(feature = "debugger")]
#[test]
#[cfg_attr(feature = "debugger", serial)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not have tests that require to be run serially.


use sunscreen_zkp_backend::{BigInt, Operation as ZkpOperation};

use std::time::Instant;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using this?

@@ -244,13 +281,20 @@ pub fn jit_prover<U>(
constant_inputs: &[U],
public_inputs: &[U],
private_inputs: &[U],
session_provider: Option<&dyn DebugSessionProvider<Operation, BigInt, String>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

where
S: serde::Serializer,
{
serializer.serialize_str(self.debug_name())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I don't approve of this. The expectation when you serialize something is that you can deserialize it and get a the exact thing back. This cannot be the case with Gadgets because they contain code.

Unfortunately, there isn't a simple alternative; you need to implement serialization that isn't serialization.

where
S: serde::Serializer,
{
serializer.serialize_str(self.to_string().as_str())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this prints hexadecimal?

We also need a matching Deserialize.

Copy link
Contributor

@rickwebiii rickwebiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the comments I have that are fixable, then :shipit:

@matthew-liu801 matthew-liu801 merged commit f66aa69 into debugger Jul 31, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants