Skip to content

feat: minimal multi assets shielded pool impl#1

Open
p0n1 wants to merge 2 commits intomasterfrom
feat/multi-assets-pool
Open

feat: minimal multi assets shielded pool impl#1
p0n1 wants to merge 2 commits intomasterfrom
feat/multi-assets-pool

Conversation

@p0n1
Copy link
Owner

@p0n1 p0n1 commented Apr 16, 2023

In this pull request, I've implemented a minimal version of a multi-asset shielded pool based on the latest Nova code. The modifications can be divided into three parts: Circom circuits, smart contracts, and JavaScript test code.

Circom circuits:

I've added one public input publicAsset and one private input asset to the Circom circuits. The asset input has been included in the UTXO structure, so it's constrained by the Poseidon hash in both inCommitmentHasher and outCommitmentHasher. This ensures that the asset type is checked when using a UTXO. To simplify the circuit logic, I've set a constraint that one transaction can only contain one asset type, meaning all UTXOs in a transaction must have the same asset type.

The publicAsset input is used for on-chain transfers. Specifically, when extAmount is not zero, there will be an on-chain transfer for the token, and the asset type cannot be kept private. In this case, we must ensure that publicAsset equals asset to maintain security. I've chosen 0 as the default value for publicAsset. When publicAsset is 0, no on-chain transfer occurs, and there's no constraint between publicAsset and asset.

Smart contracts:

The smart contracts now support different types of tokens.

Conclusion:

I believe that with these modifications, all tokens can share the same privacy level for internal shielded transfers.

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.

1 participant