encrypted_mod!() { /* proc-macro */ }Expand description
Use another file as a module in an #[encrypted] module.
Use encrypted_mod!("path/to/my_module_name.rs") or
encrypted_mod!("path/to/my_module.rs", my_module_name)
to use another file as a module. The path is relative to the current file.
The other file needs to look like this:
path/to/my_module.rs:
use arcis::*;
#[encrypted_library]
mod arcis_library {
// Put your content here.
// Accessible through `my_module_name::MY_CONST`.
pub const MY_CONST: u16 = 67;
}And then it can be used it like this:
lib.rs:
use arcis::*;
#[encrypted]
mod circuits {
use arcis::*;
// Allowing to use the contents of my_module.rs as `my_module_name::...`.
encrypted_mod!("path/to/my_module.rs", my_module_name);
pub struct InputValues {
v1: u8,
v2: u8,
}
#[instruction]
pub fn add_together(input_ctxt: Enc<Shared, InputValues>) -> Enc<Shared, u16> {
let input = input_ctxt.to_arcis();
let mut sum = input.v1 as u16 + input.v2 as u16;
// Using the constant declared in the other file.
sum += my_module_name::MY_CONST;
input_ctxt.owner.from_arcis(sum)
}
}