acceleration-program icon indicating copy to clipboard operation
acceleration-program copied to clipboard

Proposal: Porting zk-kit Circom circuits to Noir - 1

Open RajeshRk18 opened this issue 10 months ago • 21 comments

General Grant Proposal

  • Project: Porting over zk-kit circuits from Circom to Noir - 1 https://github.com/privacy-scaling-explorations/acceleration-program/issues/45

Project Overview :page_facing_up:

Overview

This is a project to port circomlib circuits from Circom to Noir for integrating with zk-kit circuit repo for Noir. The circuits are;

  • Baby-JubJub curve
  • EdDSA Poseidon

Project Details

  • As Noir is improving day-by-day with new features added and bugs fixed, rigorous testing of circuits are required.
  • Provide detailed documentation on every circuit to be ported.
  • Optimize circuits by leveraging unconstrained functions wherever possible.

Team :busts_in_silhouette:

Team

Team Website

N/A

Team's experience

  • Implemented ECDH and KZG Commitment verifiers in Noir.
  • Contributor and maintainer of Cryptography library in Noir. Helped with refactoring, optimizing, and fixing bugs.
  • Built a Map like data structure which takes $O(1)$ constraint for insertion/removal.
  • Contributor of Halo2 Backend for Noir.

Team Code Repos

  • https://github.com/RajeshRk18

Development Roadmap :nut_and_bolt:

Overview

  • Total Estimated Duration: 1 month
  • Total Estimated Working Hours: 60 hrs
  • Full-time equivalent (FTE): 0.25
  • Expected Start Date: May 20th 2024
  • Expected End Date: June 20th 2024

Milestone 1: Port circuits

  • Estimated Duration: 10 days
  • FTE: 0.25
  • Estimated delivery date: June 1st 2024

Milestone 2: Add tests

  • Estimated Duration: 10 days
  • FTE: 0.25
  • Estimated delivery date: June 20th 2024

Milestone 3: Optimize constraints

  • Estimated Duration: 10 days
  • FTE: 0.25
  • Estimated delivery date: June 20th 2024

Deliverables and Specifications

0a. Codebase (Milestone 1+Milestone 2+Milestone 3, mostly Milestone 1)

Will have noir circuits for Baby-JubJub Curve, and Eddsa poseidon.

0b. Documentation (Milestone 1+Milestone 2+Milestone 3)

I will provide inline documentation of the circuits.

0c. Testing Guide (Milestone 2)

The circuits will come with lots of unit tests and integration tests(wherever possible).

0d. Benchmarks (MIlestone 3)

I will try to add the number of constraints for each circuit.

RajeshRk18 avatar Apr 18 '24 19:04 RajeshRk18

Thanks for submission, I'll get the task detail out asap. A potential reviewer is currently ooo til 25th, please kindly wait till he come back

NOOMA-42 avatar Apr 19 '24 02:04 NOOMA-42

@NOOMA-42 when it will be reviewed?

RajeshRk18 avatar Apr 27 '24 15:04 RajeshRk18

@NOOMA-42 when it will be reviewed?

We'll try to fill out the task detail this week and start to review. Thanks for your patience

NOOMA-42 avatar Apr 28 '24 07:04 NOOMA-42

@RajeshRk18 I've updated the task detail. the scope of first part covers eddsa-poseidon, baby-jubjub, and utils. Would you like to modify the proposal based on this? We'll also have 2 more tasks covering the rest of the zk-kit circuit

NOOMA-42 avatar Apr 30 '24 00:04 NOOMA-42

@RajeshRk18 I've updated the task detail. the scope of first part covers eddsa-poseidon, baby-jubjub, and utils. Would you like to modify the proposal based on this? We'll also have 2 more tasks covering the rest of the zk-kit circuit

Ok, I'll adjust. Shall I also apply for the other 2 proposals?

RajeshRk18 avatar Apr 30 '24 04:04 RajeshRk18

I'd said let's focus on this one first. Let me know when you've modified the proposal

@RajeshRk18 I've updated the task detail. the scope of first part covers eddsa-poseidon, baby-jubjub, and utils. Would you like to modify the proposal based on this? We'll also have 2 more tasks covering the rest of the zk-kit circuit

Ok, I'll adjust. Shall I also apply for the other 2 proposals?

NOOMA-42 avatar Apr 30 '24 05:04 NOOMA-42

Hey @NOOMA-42 , I have updated the proposal.

RajeshRk18 avatar May 02 '24 16:05 RajeshRk18

Thank you! @aguzmant103 is looking for a grant liaison to review this proposal.

Hey @NOOMA-42 , I have updated the proposal.

NOOMA-42 avatar May 02 '24 23:05 NOOMA-42

@cedoor would review this proposal

NOOMA-42 avatar May 09 '24 23:05 NOOMA-42

@NOOMA-42 would it be possible to update the description of this proposal?

EdDSA proof is actually just built on top of the Circomlib circuits (Baby Jubjub and Poseidon). We're also moving it to the Semaphore repo as it's actually quite specific (i.e. it's the Semaphore Identity schema). I don't think they should be included here.

"Baby-JubJub curve" and "EdDSA Poseidon" look fine, but their Circom implementation is not part of ZK-Kit, they're part of the Circomlib repo. The amount of time to build them in Noir defined in this proposal seems fine to me, depending on the dev's experience ofc.

Also, I'd suggest to anyone working on these circuits that they work on them in a personal repo, and then integrate them into zk-kit, which will soon provide a separate repo for Noir circuits only (zk-kit.noir).

cedoor avatar May 10 '24 10:05 cedoor

@NOOMA-42 would it be possible to update the description of this proposal?

EdDSA proof is actually just built on top of the Circomlib circuits (Baby Jubjub and Poseidon). We're also moving it to the Semaphore repo as it's actually quite specific (i.e. it's the Semaphore Identity schema). I don't think they should be included here.

Yeah, I thought of that. So, maybe porting zk-kit circuits will imply porting the circuits it builds on.

RajeshRk18 avatar May 10 '24 11:05 RajeshRk18

"Baby-JubJub curve" and "EdDSA Poseidon" look fine, but their Circom implementation is not part of ZK-Kit, they're part of the Circomlib repo. The amount of time to build them in Noir defined in this proposal seems fine to me, depending on the dev's experience ofc.

Yeah, I can make it within the deadline!

RajeshRk18 avatar May 10 '24 11:05 RajeshRk18

Also, I'd suggest to anyone working on these circuits that they work on them in a personal repo, and then integrate them into zk-kit, which will soon provide a separate repo for Noir circuits only (zk-kit.noir).

Sure

RajeshRk18 avatar May 10 '24 11:05 RajeshRk18

@cedoor I've updated it, @RajeshRk18 do you have anything you want to update?

NOOMA-42 avatar May 10 '24 23:05 NOOMA-42

@cedoor I've updated it, @RajeshRk18 do you have anything you want to update?

Yeah I'll do that

RajeshRk18 avatar May 11 '24 10:05 RajeshRk18

@NOOMA-42 I have updated the proposal!

RajeshRk18 avatar May 12 '24 12:05 RajeshRk18

LGTM @cedoor do you want to review again?

NOOMA-42 avatar May 13 '24 01:05 NOOMA-42

@NOOMA-42 where to discuss the budget?

RajeshRk18 avatar May 13 '24 06:05 RajeshRk18

There will be a separate call after we finish the content wise review

@NOOMA-42 where to discuss the budget?

NOOMA-42 avatar May 13 '24 08:05 NOOMA-42

LGTM @cedoor do you want to review again?

Hey sorry for my late reply. I've reviewed it again and looked into it. The Noir team's already implemented these circuits:

  • EdDSA: https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/eddsa.nr
  • Baby Jubjub: https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/consts/te.nr

What can be done in this proposal is to optimize them and make them more efficient, taking advantage of recursion perhaps, which should be the Noir's superpower. I would also add this idea to the proposal: https://aztecnetwork.notion.site/f06968995c124de1be359459775ca2cb?v=613d3cb893dd46899a5bd3793b01e63b, which is closely related to Baby Jubjub and another PSE project: https://github.com/cursive-team/babyjubjub-ecdsa.

Please let me know if this makes sense for you @NOOMA-42 @RajeshRk18 . It seems proportionate to the amount of work defined in this proposal to me.

cedoor avatar May 17 '24 11:05 cedoor

LGTM @cedoor do you want to review again?

Hey sorry for my late reply. I've reviewed it again and looked into it. The Noir team's already implemented these circuits:

  • EdDSA: https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/eddsa.nr
  • Baby Jubjub: https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/consts/te.nr

What can be done in this proposal is to optimize them and make them more efficient, taking advantage of recursion perhaps, which should be the Noir's superpower. I would also add this idea to the proposal: https://aztecnetwork.notion.site/f06968995c124de1be359459775ca2cb?v=613d3cb893dd46899a5bd3793b01e63b, which is closely related to Baby Jubjub and another PSE project: https://github.com/cursive-team/babyjubjub-ecdsa.

Please let me know if this makes sense for you @NOOMA-42 @RajeshRk18 . It seems proportionate to the amount of work defined in this proposal to me.

Looks good to me! Here is my rough proposal idea:

  • Optimize baby jubjub and eddsa
  • Implement ECDSA on babyjub

RajeshRk18 avatar May 21 '24 17:05 RajeshRk18