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

Use bytes for signature instead of v,r,s #223

Merged
merged 6 commits into from
Oct 16, 2024
Merged

Conversation

kevincheng96
Copy link
Collaborator

@kevincheng96 kevincheng96 commented Sep 27, 2024

QuarkWallets currently take v, r, s as inputs for the ECDSA signature. This limits the wallet to only support ECDSA signatures, even if the signer of the wallet is a EIP-1271 smart contract that supports other signature schemes (e.g. BLS, Passkey). To make the wallet more flexible and be able to support other signature schemes, we change the signature input to a generic bytes type.

Note: This only increases flexibility for Quark wallets that have an EIP-1271 contract as a signer, where the EIP-1271 contract is upgradeable. Quark wallets owned by EOA signers will still need to be migrated over to a new wallet implementation in order to support other types of signature schemes.

Gas impact: Seems like this change bumps up gas usage by 900-1k (negligible). This is likely because the wallet now needs to take the extra step of decoding bytes signature into v,r,s. The tests that fail the gas snapshot are all ones that run executeQuarkOperation multiple times, exceeding the gas diff tolerance.

@kevincheng96 kevincheng96 changed the title Switch from v,r,s to bytes for signature Use bytes for signature instead of v,r,s Sep 27, 2024
@kevincheng96 kevincheng96 marked this pull request as ready for review September 27, 2024 21:28
@kevincheng96 kevincheng96 requested review from hayesgm and fluffywaffles and removed request for hayesgm September 27, 2024 23:35
Copy link
Collaborator

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -448,7 +409,8 @@ contract QuarkWallet is IERC1271 {
revert InvalidEIP1271Signature();
}
} else {
(address recoveredSigner, ECDSA.RecoverError recoverError) = ECDSA.tryRecover(digest, v, r, s);
// For EOA signers, this implementation of the QuarkWallet only supports ECDSA signatures
(address recoveredSigner, ECDSA.RecoverError recoverError) = ECDSA.tryRecover(digest, signature);
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh nice, OZ did the decoding for us 👍

Copy link
Contributor

@hayesgm hayesgm left a comment

Choose a reason for hiding this comment

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

looks good. one comment on the natspec

src/quark-core/src/QuarkWallet.sol Outdated Show resolved Hide resolved
Base automatically changed from kevin/delegatecall to main October 16, 2024 18:29
@kevincheng96 kevincheng96 merged commit 5c01d18 into main Oct 16, 2024
4 checks passed
@kevincheng96 kevincheng96 deleted the kevin/remove-vrs branch October 16, 2024 19:14
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