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

Feat/cross chain eip712 #10

Merged
merged 14 commits into from
Sep 26, 2024

Conversation

wr1159
Copy link

@wr1159 wr1159 commented Sep 25, 2024

Cross chain EIP712 to do processing of eip712 structure in ethermint
For https://github.com/Switcheo/carbon/pull/966

@wr1159 wr1159 changed the base branch from main to sdk-v0.50.5 September 25, 2024 03:48
if len(signedChainSplit) != 2 || len(carbonChainSplit) != 2 {
return apitypes.TypedData{}, errors.New("invalid memo")
}
aminoDoc.ChainID = signedChainSplit[1]
Copy link
Collaborator

@yan-soon yan-soon Sep 25, 2024

Choose a reason for hiding this comment

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

i think we can shift the replay attack guard here, since the chainId is just a static variable initialised in Makefile.

import the evm keeper:

evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
// Check the carbon chain ID to prevent replay attack
if carbonChainSplit[1] != evmkeeper.EvmChainId {
	return apitypes.TypedData{}, fmt.Errorf("invalid chainId, expected %v, got %v", evmkeeper.EvmChainId, carbonChainSplit[1])
}

Copy link
Author

Choose a reason for hiding this comment

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

Done in 113d5d6

@yan-soon yan-soon merged commit e6045c8 into Switcheo:sdk-v0.50.5 Sep 26, 2024
10 of 16 checks passed
yan-soon pushed a commit that referenced this pull request Sep 26, 2024
* fix verifyingContract to be a valid evm hex address (using `cosmos` as hex address)

* Add logs to decodeAminoSignDoc

* Only use 2 logs

* Add chainID logs

* Add draft memo processing to change typedData

* Update signedChainId processing

* Move memo processing above parsingchainId

* Remove unused domainID and other variables

* Remove logs

* Add memo processing chain id in protobug doc

* Add logs for protobuf signdoc

* move memo processing in protobuf below signBytes

* Fix proto signing doc

* Refactor getChainIDFromMemo and add carbon chain check

---------

Co-authored-by: Randy <randy75828@gmail.com>
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.

3 participants