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

supports larger sized input & output utxos #83

Merged
merged 28 commits into from
Oct 2, 2024
Merged

Conversation

Chengxuan
Copy link
Contributor

@Chengxuan Chengxuan commented Sep 24, 2024

This PR propose a method for all the fungible tokens to support more than 2 inputs.

  • A batch version of circom circuits has been proposed for each token examples
  • The solidity contract has been updated to choose between the small (2) and large (10) input circuit depends on the input size
  • Contract with encrypted values now returns encrypted values of all outputs (rather than the first one) for batching scenario
  • didn't write new tests for batch version of the circuit as the core logic has already been covered by existing tests
  • added -v verbose mode which prints out output of circom commands. it contains the number of constraints in the generated circuit, which is helpful for picking PTAU files
  • added a test to ensure concurrent witness generation works as expected in golang SDK: golang witness generation concurrency test #87

Resolves #8

Signed-off-by: Chengxuan Xing <[email protected]>
@Chengxuan Chengxuan changed the title adding batch circuits supports more input & output utxos Sep 24, 2024
@Chengxuan Chengxuan marked this pull request as ready for review September 26, 2024 11:33
@Chengxuan Chengxuan changed the title supports more input & output utxos supports larger sized input & output utxos Sep 26, 2024
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
Copy link
Contributor

@jimthematrix jimthematrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great over all! have a few minor comments only. but did have one important question on why the verifiers for the 2-sized inputs were updated

go-sdk/integration-test/e2e_test.go Show resolved Hide resolved
go-sdk/integration-test/e2e_test.go Show resolved Hide resolved
@@ -43,35 +43,44 @@ contract Groth16Verifier_AnonEnc {
uint256 constant deltay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;


uint256 constant IC0x = 5696326670703652601376328914723856805804139150397636629981154943267586835846;
uint256 constant IC0y = 17913431813079674015620165360736989993822627917830194405007674349883405519566;
uint256 constant IC0x = 15520848054661511274945320545667385548601069271438999324366330478358568711164;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has the circuit changed for this pattern? if so what's the change? It's not obvious from the PR since the circom file got moved (so there wasn't a comparison view)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tokens that has encrypted values now returns the encrypted values of all output UTXOs. 273cf81#diff-23144eb2dba1e5a2d0426bafde4a643be7543faad3ad1af139cc84065ece1df4
Before the change, the circuit only return the first UTXO and had a convention that's the receiver's UTXOs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha! glad I asked about this, I somehow missed the updates to the circuits for the encryption part. see my comments below

solidity/contracts/lib/zeto_base.sol Outdated Show resolved Hide resolved
solidity/contracts/lib/zeto_base.sol Outdated Show resolved Hide resolved
solidity/contracts/lib/zeto_nullifier.sol Outdated Show resolved Hide resolved
solidity/contracts/zeto_anon.sol Outdated Show resolved Hide resolved
solidity/scripts/deploy_cloneable.ts Outdated Show resolved Hide resolved
jimthematrix and others added 6 commits September 30, 2024 13:07
Support ephemeral private key for generating ecdh shared key for encryption
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
solidity/test/zeto_anon_enc.ts Outdated Show resolved Hide resolved
Signed-off-by: Chengxuan Xing <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
@Chengxuan
Copy link
Contributor Author

I've missed the Golang e2e test several times as the test results were cached despite circuit changes.

Going to disable result caching for integration test

Copy link
Contributor

@jimthematrix jimthematrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! thanks @Chengxuan for the great work on this!

@jimthematrix jimthematrix merged commit b5fa621 into main Oct 2, 2024
6 checks passed
@jimthematrix jimthematrix deleted the more-inputs branch October 2, 2024 20:52
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

Successfully merging this pull request may close these issues.

Consider a larger sized inputs and outputs arrays for the fungible tokens
2 participants