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

fix: make GatewayContract compatible with current KMS in trustless case #181

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

jatZama
Copy link
Member

@jatZama jatZama commented Dec 9, 2024

This PR makes the code of GatewayContract and Gateway library a lot more complex than previously, but this was needed since KMS did not implement the specific data handling in the trustless decryption case, and we decided not to change anything from KMS side. Since the trustless case became more complex, it consumes more gas, but we had no other option since we want the KMS to be agnostic to wether decryption was requested in trustless or trusted mode.

To mitigate the increase in gas cost, I implementend one of the optimizations we talked about : I am no longer doing a KMSVerifier call inside the GatewayContract in the trustless case (since in this case we assume that the dapp will do the verification itself).

Some other more minor improvements include : switching the external modifier of removeOffset to internal, and moving the $.isFulfilled[requestID] = true; line at the start of the fulfillRequest function as this will be needed to avoid reentrancy later, because in a future version we will probably remove the onlyRelayer modifier, to avoid "relayer censorship" risk.

Once you approve the PR, I will need to release the patched version of fhevm-core-contracts to also upgrade the gateway library similarly in fhevm and also release then a patch of fhevm fyi.

@jatZama jatZama force-pushed the fixGatewayContract branch from 727a67f to 161dcce Compare December 9, 2024 17:17
@jatZama jatZama merged commit cc62ab0 into main Dec 9, 2024
3 checks passed
@jatZama
Copy link
Member Author

jatZama commented Dec 12, 2024

This closes #180

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.

2 participants