As per #2416 we must keep track of spent CLAIM note via nullifier tracking.
There are two methods of achieving this, both with slight tradeoffs:
-
Simple way: Use PROOF_DATA_KEY as nullifier for the CLAIM note. The PROOF_DATA_KEY is the RPO hash (will be posiedon2 hash) of the underlying proof data required by the solidity bridgeIn() method. Since the proof data will always be unique, a hash of the proof data, PROOF_DATA_KEY, should be sufficient to use as a nullifier value to track spent CLAIM notes. However this would mean that the only way to check if a given CLAIM note has been spent, is to know its corresponding PROOF_DATA_KEY.
-
More complex: Use bitmap to track leafIndex values as is done in Agglayer solidity contract. This would mean implementing _setAndCheckClaimed() and isClaimed() logic in MASM. It is likely that aggkit needs a getClaimed() function equivalent on Miden agglayer contracts, which takes leafIndex & sourceBridgeNetwork as parameters.
Pros and Cons of each approach:
Downsides of approach 1:
Requires computing hash of proof data PROOF_DATA_KEY to check if it exists in the nullifier mapping. Each nullifier is a single Word. The isClaimed() procedure doesn't match agglayer Solidity contracts.
Benefits of approach 1:
Super easy to do, can have a PR up and merged in 1-2 days.
Downsides of approach 2:
More time to implement bitmap tracking in MASM similar to how its done in Solidity. Minimum 2 days to implement, and 1-2 days on review.
Benefits of approach 2:
Matches Agglayer Solidity contracts. MASM isClaimed() procedure matches Solidity logic.
Conclusion:
I think that approach 1 is the way to go, unless it is absolutely necessary for Aggkit to have access to a isClaimed() procedure which matches 1:1 the Solidity implementation.
As per #2416 we must keep track of spent
CLAIMnote via nullifier tracking.There are two methods of achieving this, both with slight tradeoffs:
Simple way: Use
PROOF_DATA_KEYas nullifier for theCLAIMnote. ThePROOF_DATA_KEYis the RPO hash (will be posiedon2 hash) of the underlying proof data required by the soliditybridgeIn()method. Since the proof data will always be unique, a hash of the proof data,PROOF_DATA_KEY, should be sufficient to use as a nullifier value to track spentCLAIMnotes. However this would mean that the only way to check if a givenCLAIMnote has been spent, is to know its correspondingPROOF_DATA_KEY.More complex: Use bitmap to track
leafIndexvalues as is done in Agglayer solidity contract. This would mean implementing _setAndCheckClaimed() and isClaimed() logic in MASM. It is likely that aggkit needs a getClaimed() function equivalent on Miden agglayer contracts, which takesleafIndex&sourceBridgeNetworkas parameters.Pros and Cons of each approach:
Downsides of approach 1:
Requires computing hash of proof data
PROOF_DATA_KEYto check if it exists in the nullifier mapping. Each nullifier is a singleWord. TheisClaimed()procedure doesn't match agglayer Solidity contracts.Benefits of approach 1:
Super easy to do, can have a PR up and merged in 1-2 days.
Downsides of approach 2:
More time to implement bitmap tracking in MASM similar to how its done in Solidity. Minimum 2 days to implement, and 1-2 days on review.
Benefits of approach 2:
Matches Agglayer Solidity contracts. MASM
isClaimed()procedure matches Solidity logic.Conclusion:
I think that approach 1 is the way to go, unless it is absolutely necessary for Aggkit to have access to a
isClaimed()procedure which matches 1:1 the Solidity implementation.