monerium / smart-contracts

ERC20 compatible e-money deployed on Ethereum
https://monerium.com
Apache License 2.0
35 stars 21 forks source link

ERC-1271 (potentially ERC-6492) Account Ownership Verification #39

Closed kevtechi closed 2 months ago

kevtechi commented 12 months ago

Hi,

Kevin from Citizen Wallet here.

We use account abstraction (ERC4337) wallets for everything.

We were trying to set up Wallet Connect. Signing the "personal_sign" payload and sending it back to Monerium by using the address of the private key works. But attempting to sign by providing the address of our Smart Contract Wallet fails. We tried following a ERC191 version 0x00 signature, but the check always seems to use ecrecover.

Screenshot 2023-10-05 at 12 15 26

Is there something that I'm missing or do you not support Smart Contract Wallets?

kevtechi commented 6 months ago

Ok, here is a full example:

Account: 0x260965c708773E5754b5234d940AE8AbE0DF3d39

Needs to be signed: 0x4920686572656279206465636c6172652074686174204920616d207468652061646472657373206f776e65722e

Hash: 0x18f9abb68d26b9d0e47af9ceff924d13559a0905c3d931ee4c86c123b57ac70e

Signature: 0x5a6e2be870587ef2648ed58201a349673ac70a50527c330b5f81f97c6696ab3a34ffe58908a609635b0450a152311598eac10a6223cfb843efb269649d41955b1c

Test here: https://polygonscan.com/address/0x260965c708773E5754b5234d940AE8AbE0DF3d39#readProxyContract

Trigger isValidSignature with the hash and signature, it will provide the magic value as expected.

Returns the magic value: 0x1626ba7e

Follows this: https://eips.ethereum.org/EIPS/eip-1271 And this: https://docs.walletconnect.com/api/sign/smart-contract-wallet-usage

kevtechi commented 6 months ago

Yeah, ok, I understand; the problem with that setup is that it broke other wallets like Argent. I'm trying to find a more permanent solution for what we have now, but I'll do some patching, so it should be working by tomorrow afternoon.

Ah, just as I was replying 😀.

Thanks for looking into this.

einaralex commented 6 months ago

Getting the network calls would still be excellent; I had this info.

What I thought the issue was, does not seem to be it either. The setup in our front end for signatures is not much different today than on the 24th of October. So, I'm starting to run out of options.

I suspect the issue might be something changed with our wallet dependencies.

It would be extremely helpful if you could use this minimal setup to connect the wallet sign and tell me the result. If nothing happens after signing, then we can know for sure that that's the problem.

If a signature is displayed on the screen, please share it.

https://3sth7y.csb.app/ Code available here: Codesandbox

I understand that this is starting to get frustrating and believe me, I want this to be over a.s.a.p. too.

The reality is we are working in a fast-moving ecosystem where doing changes or upgrading dependencies to fix one thing almost always introduces new bugs.

kevtechi commented 6 months ago

Message: 0x48656c6c6f2c20576f726c6421

Hash: 0xc8ee0d506e864589b799a645ddb88b08f5d39e8049f9f702b3b61fa15e55fc73

Signature: 0x277df3e901a9f428d5bc92995e4d7d7042090ee495d779d7cbd69f29bf652ac871d47a02f2025f2ee128cf7a3dde2df3a60847942ec6dc36b9f602a52a741a8d1c

The Sandbox app you gave me receives the signature.

Screenshot 2024-03-27 at 12 28 36

Validates against the contract on-chain.

Screenshot 2024-03-27 at 12 27 34

einaralex commented 6 months ago

Thank you!

kevtechi commented 6 months ago

If the Monerium Wallet Connect integration could expose the internal error that occurs, I could send you those or check to see what is wrong.

einaralex commented 6 months ago

Unfortunately, at least not yet, we can not catch them with the wallet provider we use. I've been in discussion with their team about it.

But it should output an error in the devTools console. Have you check there?

kevtechi commented 6 months ago

Unfortunately, at least not yet, we can not catch them with the wallet provider we use. I've been in discussion with their team about it.

But it should output an error in the devTools console. Have you check there?

No errors, which is why I assume that they are being caught somewhere.

kevtechi commented 6 months ago

Getting the network calls would still be excellent; I had this info.

What I thought the issue was, does not seem to be it either. The setup in our front end for signatures is not much different today than on the 24th of October. So, I'm starting to run out of options.

I suspect the issue might be something changed with our wallet dependencies.

It would be extremely helpful if you could use this minimal setup to connect the wallet sign and tell me the result. If nothing happens after signing, then we can know for sure that that's the problem.

If a signature is displayed on the screen, please share it.

https://3sth7y.csb.app/ Code available here: Codesandbox

I understand that this is starting to get frustrating and believe me, I want this to be over a.s.a.p. too.

The reality is we are working in a fast-moving ecosystem where doing changes or upgrading dependencies to fix one thing almost always introduces new bugs.

At least, you have a working minimal setup to continue now.

kevtechi commented 5 months ago

Hey @einaralex, any updates on the bugfix?

kevtechi commented 5 months ago

@gislik ?

einaralex commented 5 months ago

Hey, I've been cleaning up the code and tracing it back to how it was, and I've been trying to get it out; it's just currently stuck waiting on a bugfix in the backend, It's still a shot in the dark, let's hope for the best

kevtechi commented 5 months ago

You don't sound super confident about the fix 😅

einaralex commented 5 months ago

Yeah, I'm not; I've cleaned up the code, but I'm not sure it will do anything differently than it was before.

We just released the changes. Please make sure to clear the site data before. If this doesn't work, then lets set up a call for today/tomorrow.

kevtechi commented 4 months ago

It still doesn't work, still no error exposed.

Let's set up a call.

kevtechi commented 4 months ago

@einaralex , I'm also happy to submit a PR to make a fix to your dashboard.

kevtechi commented 4 months ago

That way, it will go faster to have both running at the same time and make the fix.

kevtechi commented 2 months ago

Hi @einaralex, any updates on the bug fix for ERC1271 verification?

kevtechi commented 2 months ago

No ERC1271 support, which means: impossible to implement wallet connect with Smart Account Contracts using Monerium.

Tried for almost a year. The bug was fixed last year (2023), then a regression introduced earlier this year (2024). Still no solution in sight.

einaralex commented 2 months ago

I successfully and effortlessly linked a ERC-1271 wallet, through https://sequence.app/wallet, so that's not the issue.

Payload:

{
"message":"I hereby declare that I am the address owner.",
"address":"0xB384c57268b65f7Cdfe1c547d6bE62dB105E7A4C",
"chain":"polygon",
"signature":"0x00050000000000028e7f88ff485233293d8ee7ee6ee611c4764d6ae30041eba2ec8c2b4bdf460c370ef58d7a4df0b44e561520809b2d1e3099a68f99b2cc80885e4d4d33678802311b020400007b0203761f5e29944d79d76656323f106cf2efbf5f09e90000620100010000000000011233126964a9bc193366e5a469b21395351d522a829343acc954e434e8060ed82f75fc394fedeee13563dded034aa3694877cec59571d13116d741f0becd538b1b02010190d62a32d1cc65aa3e80b567c8c0d3ca0f411e61030400001601038951fe5b3a10cc282b391d5027a371e28fcf442c",
"accounts":[{"currency":"eur","chain":"polygon","isVisible":true}]
}

I also successfully linked a 4337 wallet through Blocto app.

I'm not sure how to resolve this until we can test your product.

kevtechi commented 2 months ago

Great, you seem to be more confident that the fixes you made in April work then 👍.

We don't have plans to integrate Monerium anymore.

Maybe we'll take a look at it again in the future.