anoma / taiga

A framework for generalized shielded state transitions
https://anoma.net
GNU General Public License v3.0
137 stars 24 forks source link

Memory(resources) sharing between compliance circuits and resource logic #263

Closed XuyangSong closed 1 day ago

XuyangSong commented 5 months ago

It's straightforward to achieve and totally get rid of the limitation of having a fixed number of inputs and outputs in the transparent situation. The following discussion is gonna be in the shielded situation.

The resource logic requires us to load the necessary resources generated from public inputs of compliance proofs and ensure that we don't reveal which resources are being used. Moreover, all resource logics should have the same circuit structure to prevent information leakage. One simple approach is to pass a fixed number of resources within the access scope (partial transaction) to the logic, as currently done in Taiga. However, this method has obvious drawbacks: we need to add dummy resources when the actual number is less than the fixed one, and split it into multiple partial transactions when it exceeds.

Basically, we need an efficient way to share memory (mostly resources) between compliance circuits and resource logic. One idea is to create a Merkle tree based on all the inputs and outputs from compliance in one partial transaction(the minimal atom execution environment). Instead of directly loading all the resources, the resource logic can simply access specific ones by following their respective paths using only the Merkle root as input. This means that even though resource logics can still maintain the same structure with one root (any information could be compressed into the root theoretically) and one self-owned identifier (nullifier of input resource, commitment of output resource). Plus, this approach allows for flexibility in terms of how many resources are involved in each resource logic(partial transaction).

Additionally, we can also use other vector commitments to avoid checking the merkle path for further performance improvement.

XuyangSong commented 5 months ago
XuyangSong commented 3 months ago

The partial transaction still needs a maximum number of resources, but we don't need to create compliance proofs for the padding resources. The merkle tree in the resource logic must have a fixed depth with the maximum number of resources.