Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments to non-inputs do not yield an error #33

Open
m1cm1c opened this issue Oct 7, 2021 · 0 comments
Open

Assignments to non-inputs do not yield an error #33

m1cm1c opened this issue Oct 7, 2021 · 0 comments

Comments

@m1cm1c
Copy link

m1cm1c commented Oct 7, 2021

Steps to reproduce

  1. Create an XJSnark program with the following code:
private uint_150 t0; 
private uint_150 t1; 
private uint_150 t2; 
private uint_150 t4; 
 
inputs { 
  t1, t2 
} 
outputs { 
  t4  
} 
witnesses_AssertRange { 
  << ... >>  
} 
witnesses { 
  << ... >>  
} 
 
 
public void outsource() { 
  uint_150 t3 = t1 + t2; 
  verifyEq ( t0 , t3 ); 
  t4 = t3; 
} 
 
SampleRun("Sample_Run1", true){ 
  pre { 
      t0.val = new BigInteger("7252435245245243524352435243535635463546356356354635424352345234"); 
      t1.val = new BigInteger("7252435245245243524352435243535635463546356356354635424352345233"); 
      t2.val = new BigInteger("1"); 
  } 
  post { 
      System.out.println(t4.val); 
  } 
}
  1. Save the file.
  2. Right-click the file and choose Run [...].

Problem

As you can see, t0 and t1 are identical except for the last digit where t0 is 1 larger than t1. So if you add t2 to t1, the result should be equal to t0. However, the assertion fails:

Error - Assertion Failed assert in 2 <1 0> out 1 <189> 		# Equality assertion of long elements | case 2 | index 0
Exception in thread "main" 0*1!=886742162
java.lang.RuntimeException: Error During Circuit Evaluation
	at backend.operations.primitive.AssertBasicOp.compute(AssertBasicOp.java:29)
	at backend.operations.primitive.BasicOp.evaluate(BasicOp.java:71)
	at backend.eval.CircuitEvaluator.evaluate(CircuitEvaluator.java:160)
	at backend.structure.CircuitGenerator.__evaluateSampleRun(CircuitGenerator.java:463)
	at xjsnark.rsa.RSAModExpFixedModulusVariableExponent.<init>(RSAModExpFixedModulusVariableExponent.java:25)
	at xjsnark.rsa.RSAModExpFixedModulusVariableExponent.main(RSAModExpFixedModulusVariableExponent.java:19)

The reason for this is that t0 was not declared as an input.

(The problem does not occur in the original RSAModExpFixedModulusVariableExponent file. I simply modified this file.)

Expected behavior

The compiler should tell the user that he trying to assign a value to something that is not an input.

@m1cm1c m1cm1c changed the title verifyEq() yields the wrong result for big numbers Assignments to non-inputs do not yield an error Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant