Manta-Network / manta-rs

Rust Crates for the Manta Network Ecosystem
https://github.com/Manta-Network
GNU General Public License v3.0
79 stars 50 forks source link

ECLAIR Compiler Procedural Macro #224

Closed bhgomes closed 1 year ago

bhgomes commented 2 years ago

To build circuits in an abstract setting we need to pass around the compiler argument. In many cases, when we want to just compose existing primitives, we don't want to have to specify it and it would be nice to just infer it at every call site. This is where the procedural macro simplifies the work of the developer. They would go from this:

fn circuit<X, Y, Z, COM>(x: X, y: Y, z: Z, compiler: &mut COM) 
where
    X: Add<Y, COM, Output = Z>,
    Z: PartialEq<Z, COM>,
{
    compiler.assert_eq(&x.add(y, compiler), &z)
}

to this:

#[eclair]
fn circuit<X, Y, Z>(x: X, y: Y, z: Z) 
where
    X: Add<Y, Output = Z>,
    Z: PartialEq,
{
    assert_eq!(x + y, z)
}
bhgomes commented 1 year ago

Moved to https://github.com/openzklib/openzl/issues/8.