webb-tools / zero-knowledge-gadgets

Zero-knowledge gadgets for Webb's cross-chain blockchain applications.
Apache License 2.0
89 stars 29 forks source link

[TASK] Improve dependency graph + workspace structure #131

Closed lazovicff closed 2 years ago

lazovicff commented 2 years ago

1. Structure

We should have a workspace with the following structure:

2. Tools

Use cargo-workspaces for workspace publishing.

3. Dependency graph

  1. arkworks-gadgets should not have dependency of arkworks-utils, except for testing.

  2. Move PoseidonParameters, Sbox, PoseidonError (https://github.com/webb-tools/arkworks-gadgets/blob/master/arkworks-utils/src/poseidon/mod.rs) into the arkworks-native-circuits/poseidon directory.

    • Types related to the native version goes to arkworks-native-circuits.
    • r1cs constraints version for sbox goes to arkworks-r1cs-circuits, etc.
  3. Modify utility functions for Poseidon to not return PoseidonParameters struct, but instead return tuple:

    (Vec<F>, Vec<Vec<F>>, u8, u8, u8, PoseidonSbox)
  4. Move setup_params...(https://github.com/webb-tools/arkworks-gadgets/blob/master/arkworks-utils/src/utils/common.rs#L23) functions inside the native version of poseidon.

  5. Elliptic curves should only be imported for testing, for all crates.

lazovicff commented 2 years ago

@drewstone Let me know what you think. We could also break arkworks-r1cs-circuits and arkworks-plonk-circuits into two parts: arkworks-[x]-circuits + arkworks-[x]-gadgets, and rename arkworks-native-circuits into arkworks-native-gadgets

drewstone commented 2 years ago

This looks good

drewstone commented 2 years ago

We would need updates to the documentation as well @filiplazovic. Perhaps we can add to this proper rust docs and start publishing this online.