Skip to content

Commit

Permalink
Merge pull request #7 from iden3/feature/babypbk
Browse files Browse the repository at this point in the history
Add babyjub pvk->pbk circuit
  • Loading branch information
jbaylina authored May 11, 2019
2 parents e7c4a97 + d9d6e43 commit fdce2a9
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 186 deletions.
27 changes: 27 additions & 0 deletions circuits/babyjub.circom
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/

include "bitify.circom";
include "escalarmulfix.circom";

template BabyAdd() {
signal input x1;
signal input y1;
Expand Down Expand Up @@ -77,3 +80,27 @@ template BabyCheck() {

a*x2 + y2 === 1 + d*x2*y2;
}

// Extracts the public key from private key
template BabyPbk() {
signal private input in;
signal output Ax;
signal output Ay;

var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
];

component pvkBits = Num2Bits(253);
pvkBits.in <== in;

component mulFix = EscalarMulFix(253, BASE8);

var i;
for (i=0; i<253; i++) {
mulFix.e[i] <== pvkBits.out[i];
}
Ax <== mulFix.out[0];
Ay <== mulFix.out[1];
}
Loading

0 comments on commit fdce2a9

Please sign in to comment.