Skip to content

Support arrays as template parameters #291

@tim-hoffman

Description

@tim-hoffman

Current handling of template parameters in llzk_backend/src/module.rs is as follows:

    // Insert Operations to read templated struct parameters into an SSA Value in each function.
    // This ensures the struct parameter is available as a Value in the block context.
    for name in struct_params.into_iter() {
        compute_ctx.block_ctx.declare_name_if_not_present(name, || {
            Ok(poly::read_const(struct_loc, name, codegen.felt_type().into()))
        })?;
        constrain_ctx.block_ctx.declare_name_if_not_present(name, || {
            Ok(poly::read_const(struct_loc, name, codegen.felt_type().into()))
        })?;
    }

However, template parameters can also be arrays:

pragma circom 2.0.0;

template T(N) {
    signal output out <== N[1][1];
}

component main = T([[1,2],[3,4]]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P:MediumMedium PrioritybugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions