Open bhgomes opened 1 year ago
For Constant, there is a canonical implementation for structs (each of its fields are constants). For Variable, it will depend on the explicit allocation modes we want to add to each field, so maybe something like
Constant
Variable
#[derive(Variable)] struct Thing<T> { #[secret] input: T, #[public] output: T }
which would compile to something like:
impl<T> Variable<Derived, COM> for Thing<T> where T: Variable<Public, COM> + Variable<Secret, COM>, { type Type = Thing<T::Type>; #[inline] fn new_unknown(compiler: &mut COM) -> Self { Self { input: $crate::eclair::alloc::Allocator::allocate_unknown::<Secret, _>(compiler), output: $crate::eclair::alloc::Allocator::allocate_unknown::<Public, _>(compiler), } } #[inline] fn new_known(this: &Self::Type, compiler: &mut COM) -> Self { Self { input: $crate::eclair::alloc::Allocator::allocate_known::<Secret, _>(compiler, this.input), output: $crate::eclair::alloc::Allocator::allocate_unknown::<Public, _>(compiler, this.output), } } }
For
Constant
, there is a canonical implementation for structs (each of its fields are constants). ForVariable
, it will depend on the explicit allocation modes we want to add to each field, so maybe something likewhich would compile to something like: