This binary evaluates a given context over the provided inputs using a simple evaluator. For a secret-shared output, output is revealed if the `reveal_output` boolean binary argument is set to `true`. # Arguments `context_path` - path to a serialized context `inputs_path` - path to serialized input(s) `reveal_output` - boolean to indicate if output is to be revealed # Usage < this_binary > [-
()
| 38 | /// |
| 39 | /// < this_binary > [--reveal-output] <CONTEXT_PATH> <INPUTS_PATH> |
| 40 | fn main() { |
| 41 | // Initialize a logger that collects information about errors and panics within CipherCore. |
| 42 | // This information can be accessed via RUST_LOG. |
| 43 | env_logger::init(); |
| 44 | // Execute CipherCore code such that all the internal errors are properly formatted and logged. |
| 45 | execute_main(|| -> Result<()> { |
| 46 | // Parse the input arguments |
| 47 | let args = Args::parse(); |
| 48 | // Read the entire file containing a serialized context as a string |
| 49 | let serialized_context = fs::read_to_string(&args.context_path)?; |
| 50 | // Deserialize into a context object from the serialized context string |
| 51 | let raw_context = serde_json::from_str::<Context>(&serialized_context)?; |
| 52 | // Read the entire file containing serialized inputs as a string |
| 53 | let json_inputs = fs::read_to_string(&args.inputs_path)?; |
| 54 | // Parse inputs to obtain a vector of typed values, i.e., pair of type, and its value |
| 55 | let inputs = serde_json::from_str::<Vec<TypedValue>>(&json_inputs)?; |
| 56 | // Use the simple evaluator to obtain the typed result value |
| 57 | let result = get_evaluator_result( |
| 58 | raw_context, |
| 59 | inputs, |
| 60 | args.reveal_output, |
| 61 | SimpleEvaluator::new(None)?, |
| 62 | )?; |
| 63 | // Depending on the input argument, print whether the output is revealed |
| 64 | if args.reveal_output { |
| 65 | eprintln!("Revealing the output"); |
| 66 | } |
| 67 | // Print the serialized result to stdout |
| 68 | println!("{}", serde_json::to_string(&result)?); |
| 69 | Ok(()) |
| 70 | }); |
| 71 | } |
nothing calls this directly
no test coverage detected