+
Skip to content

Constraint with variable number of signals #333

Open
@hilder-vitor

Description

@hilder-vitor

How can I express a constraint that depends on a variable number of signals instead of a fixed one?

For example, let's say I want to prove I have computed the inner product of two given vectors, then, I could have a template like this:

template InnerProd(n) {

    signal input a[n];
    signal input b[n];
    signal output out;
    
   // First compute the inner product
    var x = 0;
    for(var i = 0; i < n; i++){
	x += a[i]*b[i];
    }

    out <-- x;
    // Now check 
   // so, at this point, I would like to use a single R1CS constraint to write something like
    out === a[0]*b[0] + a[1]*b[1] + .... + a[n-1]*b[n-1];
}

component main {public [a, b]} = InnerProd(10); // fix a value of n

How can I express out === a[0]*b[0] + a[1]*b[1] + .... + a[n-1]*b[n-1] with a single constraint?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载