zk-kit.circom icon indicating copy to clipboard operation
zk-kit.circom copied to clipboard

noop variable assert

Open 0xDatapunk opened this issue 1 year ago • 3 comments

The variables lta and ltb are no-oping here and may be removed. There are no constraints applied to either variable, the assert statement is a witness computation time operation, not a proving operation.

The only case where they do an operation is if the value of either a or b is attempting to be constrained to the constant 252 bits. If this is the case it should be implemented with Num2Bits directly as LessThan does not apply this constraint.

There is another no-op occurence here. This value should instead be constrained with isz === 0

0xDatapunk avatar Oct 07 '24 20:10 0xDatapunk

@cedoor Can I work on this task?

and also replace

lt = LessEqThan(n)([x, y]);
    assert(lt == 1);

with

lt = LessEqThan(n)([x, y]);
lt === 1;

which are present at these lines ,121,146,187-188

Vishalkulkarni45 avatar Feb 07 '25 07:02 Vishalkulkarni45

@Vishalkulkarni45 yes of course!

cedoor avatar Feb 20 '25 16:02 cedoor

@cedoor I've created the PR for this issue here #21. Should I add a range check here too?

ToFloat

 lt = LessEqThan(252)([in, 10 ** (75 - W)]);

if in > 2^252 then the comparison may return wrong result

same issue in DivisionFromFloat

  lt = LessEqThan(252)([a, 10 ** (75 - W)]);

Vishalkulkarni45 avatar Feb 22 '25 11:02 Vishalkulkarni45