From 379853a3ab04c18c7683b587fe95b8c54288ef70 Mon Sep 17 00:00:00 2001 From: lodge Date: Tue, 5 Nov 2024 17:34:45 -0400 Subject: [PATCH] chore: Encrypt circuit macro name update to #[encrypted(compile)] - Updated the circuit macros in the codebase to use the new #[encrypted] attribute instead of #[circuit]. - Modified the client.rs and server.rs files in the server/src/bin directory to use the #[encrypted(compile)] attribute. - Updated the loan_eligibility_1.rs, loan_eligibility_2.rs, loan_eligibility_3.rs, threshold_voting.rs, temperature.rs, age_content_control.rs, spending.rs, discount_eligibility.rs, access_control.rs, and single_macro.rs files in the compute/examples directory to use the #[encrypted(execute)] attribute. - Renamed the circuit_macro::circuit function to circuit_macro::encrypted in the circuit_macro/src/lib.rs file. - Updated the compute::prelude module to use the circuit_macro::encrypted function instead of circuit_macro::circuit. - Added the util.rs file in the compute/src/operations directory, which contains utility functions for serializing and deserializing circuits. --- circuit_macro/src/lib.rs | 2 +- compute/examples/access_control.rs | 2 +- compute/examples/age_content_control.rs | 2 +- compute/examples/discount_eligibility.rs | 2 +- compute/examples/loan_eligibility_1.rs | 2 +- compute/examples/loan_eligibility_2.rs | 2 +- compute/examples/loan_eligibility_3.rs | 2 +- compute/examples/spending.rs | 2 +- compute/examples/temperature.rs | 2 +- compute/examples/threshold_voting.rs | 2 +- compute/src/lib.rs | 2 +- compute/src/operations/util.rs | 136 +++++++++++++++++++++++ compute/tests/macro.rs | 132 +++++++++++----------- compute/tests/single_macro.rs | 6 +- server/src/bin/client.rs | 2 +- server/src/bin/server.rs | 2 +- 16 files changed, 218 insertions(+), 82 deletions(-) create mode 100644 compute/src/operations/util.rs diff --git a/circuit_macro/src/lib.rs b/circuit_macro/src/lib.rs index f4d0973..506e655 100644 --- a/circuit_macro/src/lib.rs +++ b/circuit_macro/src/lib.rs @@ -10,7 +10,7 @@ use syn::{ }; #[proc_macro_attribute] -pub fn circuit(attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn encrypted(attr: TokenStream, item: TokenStream) -> TokenStream { let mode = parse_macro_input!(attr as syn::Ident).to_string(); // Retrieve the mode (e.g., "compile" or "execute") generate_macro(item, &mode) } diff --git a/compute/examples/access_control.rs b/compute/examples/access_control.rs index a01d748..4e4fbec 100644 --- a/compute/examples/access_control.rs +++ b/compute/examples/access_control.rs @@ -4,7 +4,7 @@ use compute::prelude::*; /// Circuit macro annotation to indicate this function will be executed within a secure circuit context. /// This access control function determines the level of access a user has based on their role, returning /// only the data they are authorized to view in a privacy-preserving manner. -#[circuit(execute)] +#[encrypted(execute)] fn access_control(role: u8) -> u8 { // Define constants representing access to different types of data. // Each constant holds a value that signifies specific data access rights. diff --git a/compute/examples/age_content_control.rs b/compute/examples/age_content_control.rs index 85c29ea..5fcc8e9 100644 --- a/compute/examples/age_content_control.rs +++ b/compute/examples/age_content_control.rs @@ -37,7 +37,7 @@ use compute::prelude::*; /// let access_level = access_content(age); /// assert_eq!(access_level, 0); // Invalid age /// ``` -#[circuit(execute)] +#[encrypted(execute)] fn access_content(age: u8) -> u8 { // Access level codes let RESTRICTED = 1; // Restricted access for underage users diff --git a/compute/examples/discount_eligibility.rs b/compute/examples/discount_eligibility.rs index 4b10660..4842a89 100644 --- a/compute/examples/discount_eligibility.rs +++ b/compute/examples/discount_eligibility.rs @@ -12,7 +12,7 @@ use compute::prelude::*; /// /// # Example /// This example demonstrates checking if a purchase of 100 qualifies for a discount with a threshold of 80. -#[circuit(execute)] +#[encrypted(execute)] fn qualifies_for_discount(purchase_amount: u16) -> bool { let DISCOUNT_THRESHOLD = 80; purchase_amount >= DISCOUNT_THRESHOLD diff --git a/compute/examples/loan_eligibility_1.rs b/compute/examples/loan_eligibility_1.rs index e2fe382..a103853 100644 --- a/compute/examples/loan_eligibility_1.rs +++ b/compute/examples/loan_eligibility_1.rs @@ -30,7 +30,7 @@ use compute::prelude::*; /// assert_eq!(eligibility, 1); // Prime eligibility /// ``` -#[circuit(execute)] +#[encrypted(execute)] fn check_loan_eligibility(credit_score: u16, income: u16, debt_ratio: u16) -> u8 { // Eligibility levels let PRIME = 1; diff --git a/compute/examples/loan_eligibility_2.rs b/compute/examples/loan_eligibility_2.rs index 251aeff..ae8aced 100644 --- a/compute/examples/loan_eligibility_2.rs +++ b/compute/examples/loan_eligibility_2.rs @@ -30,7 +30,7 @@ use compute::prelude::*; /// assert_eq!(eligibility, 1); // Prime eligibility /// ``` -#[circuit(execute)] +#[encrypted(execute)] fn check_loan_eligibility(credit_score: u16, income: u16, debt_ratio: u16) -> u16 { // Eligibility levels let PRIME = 1; diff --git a/compute/examples/loan_eligibility_3.rs b/compute/examples/loan_eligibility_3.rs index 2514a63..ab0b70d 100644 --- a/compute/examples/loan_eligibility_3.rs +++ b/compute/examples/loan_eligibility_3.rs @@ -30,7 +30,7 @@ use compute::prelude::*; /// assert_eq!(eligibility, 1); // Prime eligibility /// ``` -#[circuit(execute)] +#[encrypted(execute)] fn check_loan_eligibility(credit_score: u16, income: u16, debt_ratio: u16) -> u16 { // Eligibility levels let PRIME = 1; diff --git a/compute/examples/spending.rs b/compute/examples/spending.rs index e0686d6..da6760b 100644 --- a/compute/examples/spending.rs +++ b/compute/examples/spending.rs @@ -13,7 +13,7 @@ use compute::prelude::*; /// # Example /// This example demonstrates checking if a remaining budget of 3000 (after spending 2000 from a budget of 5000) /// stays within the maximum allowable limit of 3000. -#[circuit(execute)] +#[encrypted(execute)] fn can_spend(budget: u16, spent: u16) -> bool { let MAX_ALLOWED = 5000; let remaining_budget = budget - spent; diff --git a/compute/examples/temperature.rs b/compute/examples/temperature.rs index 9dce405..3a09690 100644 --- a/compute/examples/temperature.rs +++ b/compute/examples/temperature.rs @@ -13,7 +13,7 @@ use compute::prelude::*; /// /// # Example /// This example demonstrates verifying if a room with a temperature of 70°F is within the range of 65°F to 75°F. -#[circuit(execute)] +#[encrypted(execute)] fn within_temperature_range(current_temp: u8) -> bool { let MIN_TEMP = 65; let MAX_TEMP = 75; diff --git a/compute/examples/threshold_voting.rs b/compute/examples/threshold_voting.rs index 76b31a9..708b590 100644 --- a/compute/examples/threshold_voting.rs +++ b/compute/examples/threshold_voting.rs @@ -12,7 +12,7 @@ use compute::prelude::*; /// /// # Example /// This example demonstrates checking if a candidate with 150 votes meets a threshold of 100 votes. -#[circuit(execute)] +#[encrypted(execute)] fn has_enough_votes(votes: u8) -> bool { let THRESHOLD = 100; votes >= THRESHOLD diff --git a/compute/src/lib.rs b/compute/src/lib.rs index 62995a8..7f9418b 100644 --- a/compute/src/lib.rs +++ b/compute/src/lib.rs @@ -18,7 +18,7 @@ pub mod prelude { GarbledBoolean, GarbledUint, GarbledUint128, GarbledUint16, GarbledUint2, GarbledUint256, GarbledUint32, GarbledUint4, GarbledUint512, GarbledUint64, GarbledUint8, }; - pub use circuit_macro::circuit; + pub use circuit_macro::encrypted; pub use tandem::{Circuit, Gate}; pub use crate::evaluator::Evaluator; diff --git a/compute/src/operations/util.rs b/compute/src/operations/util.rs new file mode 100644 index 0000000..c0e23fd --- /dev/null +++ b/compute/src/operations/util.rs @@ -0,0 +1,136 @@ +use serde::{Deserialize, Serialize}; +use tandem::Circuit; +use tandem::Gate; +use tandem::GateIndex; + +// wrapper Gate +#[derive(Serialize, Deserialize, Clone, Debug)] +pub enum GateW { + /// A single input bit coming from the circuit contributor. + InContrib, + /// A single input bit coming from the circuit evaluator. + InEval, + /// A gate computing the XOR of the two specified gates. + Xor(GateIndex, GateIndex), + /// A gate computing the AND of the two specified gates. + And(GateIndex, GateIndex), + /// A gate computing the NOT of the specified gate. + Not(GateIndex), +} + +impl Into for GateW { + fn into(self) -> Gate { + match self { + GateW::InContrib => Gate::InContrib, + GateW::InEval => Gate::InEval, + GateW::Xor(a, b) => Gate::Xor(a, b), + GateW::And(a, b) => Gate::And(a, b), + GateW::Not(a) => Gate::Not(a), + } + } +} + +impl From for GateW { + fn from(gate: Gate) -> Self { + match gate { + Gate::InContrib => GateW::InContrib, + Gate::InEval => GateW::InEval, + Gate::Xor(a, b) => GateW::Xor(a, b), + Gate::And(a, b) => GateW::And(a, b), + Gate::Not(a) => GateW::Not(a), + } + } +} + +// Assuming `Gate` and `GateIndex` implement `Serialize` and `Deserialize` +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct CircuitWrapper { + gates: Vec, + output_gates: Vec, + and_gates: usize, + eval_inputs: usize, + contrib_inputs: usize, +} + +// Implement conversions from `Circuit` to `CircuitWrapper` and vice versa +impl From<&Circuit> for CircuitWrapper { + fn from(circuit: &Circuit) -> Self { + CircuitWrapper { + gates: circuit + .gates() + .iter() + .map(|gate| gate.clone().into()) + .collect(), + output_gates: circuit.output_gates().clone(), + and_gates: circuit.and_gates(), + eval_inputs: circuit.eval_inputs(), + contrib_inputs: circuit.contrib_inputs(), + } + } +} + +impl Into for CircuitWrapper { + fn into(self) -> Circuit { + Circuit::new( + self.gates.iter().map(|gate| gate.clone().into()).collect(), + self.output_gates, + ) + } +} + +pub fn serialize_circuit(circuit: &Circuit) -> anyhow::Result> { + // Convert `Circuit` to `CircuitWrapper` + let wrapper: CircuitWrapper = circuit.into(); + + // Serialize `CircuitWrapper` using bincode + let serialized_data = bincode::serialize(&wrapper)?; + Ok(serialized_data) +} + +pub fn deserialize_circuit(data: &[u8]) -> anyhow::Result { + // Deserialize into `CircuitWrapper` + let wrapper: CircuitWrapper = bincode::deserialize(data)?; + + // Convert `CircuitWrapper` back into `Circuit` + let circuit: Circuit = wrapper.into(); + Ok(circuit) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::prelude::*; + + #[test] + fn test_serialize_deserialize_circuit_struct() -> anyhow::Result<()> { + #[circuit(compile)] + fn multi_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { + let res = a * b; + let res = res + c; + res - d + } + + // Initialize the evaluator instance with circuit and dummy input + let (circuit, _) = multi_arithmetic(0_u8, 0_u8, 0_u8, 0_u8); + + // Serialize the circuit + let serialized_data = serialize_circuit(&circuit)?; + println!("Serialized Circuit data: {:?}", serialized_data); + + // Deserialize back into a `Circuit` struct + let deserialized_circuit = deserialize_circuit(&serialized_data)?; + println!("Deserialized Circuit: {:?}", deserialized_circuit); + + // Check if the deserialized circuit is the same as the original circuit + assert_eq!(circuit.gates(), deserialized_circuit.gates()); + assert_eq!(circuit.output_gates(), deserialized_circuit.output_gates()); + assert_eq!(circuit.and_gates(), deserialized_circuit.and_gates()); + assert_eq!(circuit.eval_inputs(), deserialized_circuit.eval_inputs()); + assert_eq!( + circuit.contrib_inputs(), + deserialized_circuit.contrib_inputs() + ); + + Ok(()) + } +} diff --git a/compute/tests/macro.rs b/compute/tests/macro.rs index 447760d..7fe3e8f 100644 --- a/compute/tests/macro.rs +++ b/compute/tests/macro.rs @@ -2,7 +2,7 @@ use compute::prelude::*; #[test] fn test_macro_arithmetic_compiler() { - #[circuit(compile)] + #[encrypted(compile)] fn multi_arithmetic(a: u8, b: u8, c: u8, d: u8) -> (Circuit, Vec) { let res = a * b; let res = res + c; @@ -23,7 +23,7 @@ fn test_macro_arithmetic_compiler() { #[test] fn test_macro_arithmetic() { - #[circuit(execute)] + #[encrypted(execute)] fn multi_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a * b; let res = res + c; @@ -41,7 +41,7 @@ fn test_macro_arithmetic() { #[test] fn test_macro_arithmetic_u128() { - #[circuit(execute)] + #[encrypted(execute)] fn multi_arithmetic_u128(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a + b; let res = res + c; @@ -59,7 +59,7 @@ fn test_macro_arithmetic_u128() { #[test] fn test_macro_mixed_arithmetic() { - #[circuit(execute)] + #[encrypted(execute)] fn mixed_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a * b; let res = context.add(&res, c); @@ -78,7 +78,7 @@ fn test_macro_mixed_arithmetic() { #[test] fn test_macro_addition() { - #[circuit(execute)] + #[encrypted(execute)] fn addition(a: u8, b: u8) -> u8 { a + b } @@ -92,7 +92,7 @@ fn test_macro_addition() { #[test] fn test_macro_subtraction() { - #[circuit(execute)] + #[encrypted(execute)] fn subtraction(a: u8, b: u8) -> u8 { a - b } @@ -106,7 +106,7 @@ fn test_macro_subtraction() { #[test] fn test_macro_multiplication() { - #[circuit(execute)] + #[encrypted(execute)] fn multiplication(a: u8, b: u8) -> u8 { a * b } @@ -120,7 +120,7 @@ fn test_macro_multiplication() { #[test] fn test_macro_mux() { - #[circuit(execute)] + #[encrypted(execute)] fn mux_circuit(a: u8, b: u8) -> u8 { let condition = a == b; &context.mux(&condition, a, b) @@ -135,7 +135,7 @@ fn test_macro_mux() { #[test] fn test_macro_if_else() { - #[circuit(execute)] + #[encrypted(execute)] fn mux_circuit(a: T, b: T) -> T { if a == b { let c = a * b; @@ -154,7 +154,7 @@ fn test_macro_if_else() { #[test] fn test_macro_if_else2() { - #[circuit(execute)] + #[encrypted(execute)] fn mux_circuit(a: u8, b: u8) -> u8 { let true_branch = a * b; let false_branch = a + b; @@ -179,7 +179,7 @@ fn test_macro_if_else2() { #[test] fn test_macro_if_else3() { - #[circuit(execute)] + #[encrypted(execute)] fn mux_circuit(a: u8, b: u8) -> u8 { if a == b { a * b @@ -201,7 +201,7 @@ fn test_macro_if_else3() { #[test] fn test_macro_if_else4() { - #[circuit(execute)] + #[encrypted(execute)] fn mux_circuit(a: u8, b: u8) -> u8 { if a == b { let c = a * b; @@ -222,7 +222,7 @@ fn test_macro_if_else4() { #[ignore = "division not yet supported"] #[test] fn test_macro_division() { - #[circuit(execute)] + #[encrypted(execute)] fn division(a: u8, b: u8) -> u8 { a / b } @@ -237,7 +237,7 @@ fn test_macro_division() { #[ignore = "modulo not yet supported"] #[test] fn test_macro_remainder() { - #[circuit(execute)] + #[encrypted(execute)] fn remainder(a: u8, b: u8) -> u8 { a % b } @@ -251,7 +251,7 @@ fn test_macro_remainder() { #[test] fn test_macro_nested_arithmetic() { - #[circuit(execute)] + #[encrypted(execute)] fn nested_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a * b; let res = res + c; @@ -270,7 +270,7 @@ fn test_macro_nested_arithmetic() { // test bitwise operations #[test] fn test_macro_bitwise_and() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_and(a: u8, b: u8) -> u8 { a & b } @@ -284,7 +284,7 @@ fn test_macro_bitwise_and() { #[test] fn test_macro_bitwise_or() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_or(a: u8, b: u8) -> u8 { a | b } @@ -298,7 +298,7 @@ fn test_macro_bitwise_or() { #[test] fn test_macro_bitwise_xor() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_xor(a: u8, b: u8) -> u8 { a ^ b } @@ -312,7 +312,7 @@ fn test_macro_bitwise_xor() { #[test] fn test_macro_bitwise_not() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_not(a: u8) -> u8 { !a } @@ -325,7 +325,7 @@ fn test_macro_bitwise_not() { #[test] fn test_macro_bitwise_nand() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_nand(a: u8, b: u8) -> u8 { let and = a & b; !and @@ -340,7 +340,7 @@ fn test_macro_bitwise_nand() { #[test] fn test_macro_bitwise_nor() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_nor(a: u8, b: u8) -> u8 { let or = a | b; !or @@ -355,7 +355,7 @@ fn test_macro_bitwise_nor() { #[test] fn test_macro_bitwise_xnor() { - #[circuit(execute)] + #[encrypted(execute)] fn bitwise_xnor(a: u8, b: u8) -> u8 { let xor = a ^ b; !xor @@ -370,7 +370,7 @@ fn test_macro_bitwise_xnor() { #[test] fn test_macro_equal() { - #[circuit(execute)] + #[encrypted(execute)] fn equal(a: u8, b: u8) -> u8 { if a == b { a * b @@ -388,7 +388,7 @@ fn test_macro_equal() { #[test] fn test_macro_not_equal() { - #[circuit(execute)] + #[encrypted(execute)] fn not_equal(a: u8, b: u8) -> u8 { if a != b { a * b @@ -406,7 +406,7 @@ fn test_macro_not_equal() { #[test] fn test_macro_greater_than() { - #[circuit(execute)] + #[encrypted(execute)] fn greater_than(a: u8, b: u8) -> u8 { if a > b { a * b @@ -432,7 +432,7 @@ fn test_macro_greater_than() { #[test] fn test_macro_greater_than_or_equal() { - #[circuit(execute)] + #[encrypted(execute)] fn greater_than_or_equal(a: u8, b: u8) -> u8 { if a >= b { a * b @@ -458,7 +458,7 @@ fn test_macro_greater_than_or_equal() { #[test] fn test_macro_less_than() { - #[circuit(execute)] + #[encrypted(execute)] fn less_than(a: u8, b: u8) -> u8 { if a < b { a * b @@ -484,7 +484,7 @@ fn test_macro_less_than() { #[test] fn test_macro_less_than_or_equal() { - #[circuit(execute)] + #[encrypted(execute)] fn less_than_or_equal(a: u8, b: u8) -> u8 { if a <= b { a * b @@ -510,7 +510,7 @@ fn test_macro_less_than_or_equal() { #[test] fn test_macro_bool_return() { - #[circuit(execute)] + #[encrypted(execute)] fn equal(a: u8, b: u8) -> bool { a == b } @@ -525,7 +525,7 @@ fn test_macro_bool_return() { // div #[test] fn test_macro_div() { - #[circuit(execute)] + #[encrypted(execute)] fn div(a: u8, b: u8) -> u8 { a / b } @@ -539,7 +539,7 @@ fn test_macro_div() { #[test] fn test_macro_div_with_remainder() { - #[circuit(execute)] + #[encrypted(execute)] fn div(a: u8, b: u8) -> u8 { a / b } @@ -553,7 +553,7 @@ fn test_macro_div_with_remainder() { #[test] fn test_macro_div_with_remainder2() { - #[circuit(execute)] + #[encrypted(execute)] fn div(a: u8, b: u8) -> u8 { a / b } @@ -568,7 +568,7 @@ fn test_macro_div_with_remainder2() { // rem #[test] fn test_macro_rem() { - #[circuit(execute)] + #[encrypted(execute)] fn rem(a: u8, b: u8) -> u8 { a % b } @@ -582,7 +582,7 @@ fn test_macro_rem() { #[test] fn test_macro_rem_with_remainder() { - #[circuit(execute)] + #[encrypted(execute)] fn rem(a: u8, b: u8) -> u8 { a % b } @@ -596,7 +596,7 @@ fn test_macro_rem_with_remainder() { #[test] fn test_macro_constants() { - #[circuit(execute)] + #[encrypted(execute)] fn constants(a: u8) -> u8 { a + 20 } @@ -608,7 +608,7 @@ fn test_macro_constants() { #[test] fn test_macro_embedded_constants() { - #[circuit(execute)] + #[encrypted(execute)] fn embedded_constants(a: u8) -> u8 { let B = 20; a + B @@ -621,7 +621,7 @@ fn test_macro_embedded_constants() { #[test] fn test_order_of_operations() { - #[circuit(execute)] + #[encrypted(execute)] fn order_of_operations(a: u16, b: u16, c: u16) -> u16 { a + b * c } @@ -635,7 +635,7 @@ fn test_order_of_operations() { #[test] fn test_order_of_operations2() { - #[circuit(execute)] + #[encrypted(execute)] fn order_of_operations(a: u16, b: u16, c: u16) -> u16 { (a + b) * c } @@ -649,7 +649,7 @@ fn test_order_of_operations2() { #[test] fn test_add_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn add_assign(a: u8, b: u8) -> u8 { let c = a; c += b @@ -663,7 +663,7 @@ fn test_add_assign() { #[test] fn test_sub_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn sub_assign(a: u8, b: u8) -> u8 { let c = a; c -= b @@ -677,7 +677,7 @@ fn test_sub_assign() { #[test] fn test_mul_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn mul_assign(a: u8, b: u8) -> u8 { let c = a; c *= b @@ -691,7 +691,7 @@ fn test_mul_assign() { #[test] fn test_div_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn div_assign(a: u8, b: u8) -> u8 { let c = a; c /= b @@ -705,7 +705,7 @@ fn test_div_assign() { #[test] fn test_rem_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn rem_assign(a: u8, b: u8) -> u8 { let c = a; c %= b @@ -719,7 +719,7 @@ fn test_rem_assign() { #[test] fn test_bitand_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn bitand_assign(a: u8, b: u8) -> u8 { let c = a; c &= b @@ -733,7 +733,7 @@ fn test_bitand_assign() { #[test] fn test_bitor_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn bitor_assign(a: u8, b: u8) -> u8 { let c = a; c |= b @@ -747,7 +747,7 @@ fn test_bitor_assign() { #[test] fn test_bitxor_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn bitxor_assign(a: u8, b: u8) -> u8 { let c = a; c ^= b @@ -761,7 +761,7 @@ fn test_bitxor_assign() { #[test] fn test_if_elif_else() { - #[circuit(execute)] + #[encrypted(execute)] fn if_statement(a: u8) -> u8 { if a > 100 { a + 1 @@ -787,7 +787,7 @@ fn test_if_elif_else() { #[test] fn test_nested_if() { - #[circuit(execute)] + #[encrypted(execute)] fn nested_if(a: u8) -> u8 { if a > 100 { if a > 200 { @@ -815,7 +815,7 @@ fn test_nested_if() { #[test] fn test_nested_if_else() { - #[circuit(execute)] + #[encrypted(execute)] fn nested_if_else(a: u8) -> u8 { if a > 100 { if a > 200 { @@ -851,7 +851,7 @@ fn test_nested_if_else() { #[test] fn test_nested_if_else_if() { - #[circuit(execute)] + #[encrypted(execute)] fn nested_if_else_if(a: u8) -> u8 { if a > 100 { if a > 200 { @@ -885,7 +885,7 @@ fn test_nested_if_else_if() { #[test] fn test_if_else() { - #[circuit(execute)] + #[encrypted(execute)] fn if_else(a: u8) -> u8 { if a > 100 { a + 1 @@ -905,7 +905,7 @@ fn test_if_else() { #[test] fn test_macro_bool_literal() { - #[circuit(execute)] + #[encrypted(execute)] fn boolean_literal(a: bool) -> bool { let x = false; let y = true; @@ -924,7 +924,7 @@ fn test_macro_bool_literal() { #[test] fn test_macro_bool_literal2() { - #[circuit(execute)] + #[encrypted(execute)] fn boolean_literal2(a: bool) -> bool { if a { false @@ -940,7 +940,7 @@ fn test_macro_bool_literal2() { #[test] fn macro_test_if_assign() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { let y = 22; @@ -965,7 +965,7 @@ fn macro_test_if_assign() { #[test] fn macro_test_assignment2() { - #[circuit(execute)] + #[encrypted(execute)] fn assignment_test2(a: u8) -> u8 { let mut x = 11; x = a + 1; @@ -979,7 +979,7 @@ fn macro_test_assignment2() { #[test] fn macro_test_assignment() { - #[circuit(execute)] + #[encrypted(execute)] fn assignment_test(a: u8) -> u8 { let mut x = 11; x = a; @@ -993,7 +993,7 @@ fn macro_test_assignment() { #[test] fn test_macro_match() { - #[circuit(execute)] + #[encrypted(execute)] fn match_test(a: u8) -> u8 { match a { 1 => 7, @@ -1022,7 +1022,7 @@ fn test_macro_match() { #[test] fn test_macro_match_with_expr() { - #[circuit(execute)] + #[encrypted(execute)] fn match_test_with_expr(a: u8) -> u8 { match a { 1 => { @@ -1054,7 +1054,7 @@ fn test_macro_match_with_expr() { #[test] fn test_macro_match_with_block() { - #[circuit(execute)] + #[encrypted(execute)] fn match_test_with_block(a: u8) -> u8 { match a { 1 => { @@ -1092,7 +1092,7 @@ fn test_macro_match_with_block() { #[test] fn macro_test_if_with_consts() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { if a == 42 { a + 1 @@ -1112,7 +1112,7 @@ fn macro_test_if_with_consts() { #[test] fn macro_test_if_with_consts2() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { let accum = 0; let if_else = if a == 42 { @@ -1143,7 +1143,7 @@ fn macro_test_if_with_consts2() { #[test] fn macro_test_if_with_consts1() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { let ACCUM = 5; @@ -1180,7 +1180,7 @@ fn macro_test_if_with_consts1() { #[test] fn macro_test_match_with_consts() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { let FIRST_ARM = 49; let SECOND_ARM = 40; @@ -1219,7 +1219,7 @@ fn macro_test_match_with_consts() { #[test] fn macro_test_if_and_match_with_consts() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { let ACCUM = 5; @@ -1272,7 +1272,7 @@ fn macro_test_if_and_match_with_consts() { #[test] fn test_macro_if_bool() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: bool) -> bool { if a { true @@ -1293,7 +1293,7 @@ fn test_macro_if_bool() { #[test] fn test_macro_if() { - #[circuit(execute)] + #[encrypted(execute)] fn if_test(a: u8) -> u8 { if a <= 50 { 25 diff --git a/compute/tests/single_macro.rs b/compute/tests/single_macro.rs index 17ed221..397ee28 100644 --- a/compute/tests/single_macro.rs +++ b/compute/tests/single_macro.rs @@ -2,7 +2,7 @@ use compute::prelude::*; #[test] fn test_macro_range_expr() { - #[circuit(execute)] + #[encrypted(execute)] fn describe_number(n: u16) -> u16 { match n { 1..=5 => 5, @@ -31,7 +31,7 @@ fn test_macro_range_expr() { #[test] fn test_macro_range_expr_bool() { - #[circuit(execute)] + #[encrypted(execute)] fn describe_number(n: u16) -> bool { match n { 1..=5 => true, @@ -60,7 +60,7 @@ fn test_macro_range_expr_bool() { #[test] fn test_macro_range_if_let() { - #[circuit(execute)] + #[encrypted(execute)] fn describe_number(n: u16) -> u16 { if let 1..=5 = n { 5 diff --git a/server/src/bin/client.rs b/server/src/bin/client.rs index ebe035b..1ad6881 100644 --- a/server/src/bin/client.rs +++ b/server/src/bin/client.rs @@ -7,7 +7,7 @@ use std::{error::Error, net::SocketAddr, path::Path}; use tracing::debug; use tracing::info; -#[circuit(compile)] +#[encrypted(compile)] fn multi_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a * b; let res = res + c; diff --git a/server/src/bin/server.rs b/server/src/bin/server.rs index d08b881..7088b2c 100644 --- a/server/src/bin/server.rs +++ b/server/src/bin/server.rs @@ -5,7 +5,7 @@ use server::util::prepare; use std::{error::Error, path::Path}; use tracing::{debug, error, info, instrument}; -#[circuit(compile)] +#[encrypted(compile)] fn multi_arithmetic(a: u8, b: u8, c: u8, d: u8) -> u8 { let res = a * b; let res = res + c;