iden3 / circomlib

Library of basic circuits for circom
603 stars 210 forks source link

EdDSA/Num2Bits error #3

Closed nickgeoca closed 5 years ago

nickgeoca commented 5 years ago

Hi, I am getting the error below when trying to use the EdDSA and Num2Bits modules.

$ snarkjs calculatewitness
Error: Constraint doesn't match: 1 != 0
...

input.json

{ "M": 87521618088882671231069284
, "A": 55827404635365964770721635799969315856041517429760659189665076684285324169570
, "R": 103858265219596690085663683153809217622835068605340394886551250625399267718227
, "S": 11198587322283910980185217763598004772992920884777713219704247405759630588676
}

circuit.circom

include "./circomlib/circuits/bitify.circom";
include "./circomlib/circuits/eddsa.circom";

template Test(n) {
  signal input M;
  signal input A;
  signal input R;
  signal input S;

  var i;
  component eddsaVer = EdDSAVerifier(n);
  component bM = Num2Bits(n);
  component bA = Num2Bits(256);
  component bR = Num2Bits(256);
  component bS = Num2Bits(256);

  bM.in <== M;
  bA.in <== A;
  bR.in <== R;
  bS.in <== S;

  for (i=0; i<n; i++) {
    eddsaVer.msg[i] <== bM.out[i];
  }

  for (i=0; i<256; i++) {
    eddsaVer.A[i]  <== bA.out[i];
    eddsaVer.R8[i] <== bR.out[i];
    eddsaVer.S[i]  <== bS.out[i];
  }

}

component main = Test(88);
nickgeoca commented 5 years ago

Fixed. Used the edsamimc module instead and looked at the examples in test directory.