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

Refactor WebAuthn Implementation #320

Merged
merged 1 commit into from
Mar 18, 2024
Merged

Conversation

nlordell
Copy link
Collaborator

@nlordell nlordell commented Mar 12, 2024

This PR refactors the WebAuthn implementation into a library instead of split into multiple contracts. This removes the amount of CALLs required for verifying a signature.

I did some analysis on the deployment vs. signature verification costs comparing this code, main and this change incorporating optimizations from #289 and found this:

setup deployment verification (dummy) break even
main (viaIR = false) 373543 17789 0
main (viaIR = true) 393494 16443 15
this branch (viaIR = false) 612123 13835 61
this branch (viaIR = true) 594058 12551 43
base64 optimizations (viaIR = false) 442545 12965 15
base64 optimizations (viaIR = true) 414941 11102 7

Meaning that after 7 signatures, even with the slightly larger deployment costs, we would break even by avoiding the extra CALL (noting that ABI-encoding the call to the WebAuthnVerifier is not particularly efficient in the first place).

@nlordell nlordell marked this pull request as ready for review March 13, 2024 14:19
@nlordell nlordell requested a review from a team as a code owner March 13, 2024 14:19
@nlordell nlordell requested review from akshay-ap, mmv08 and remedcu and removed request for a team March 13, 2024 14:19
Copy link
Member

@remedcu remedcu left a comment

Choose a reason for hiding this comment

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

Should we add the bounty email before this is audited? Or adding the email doesn't signify anything until we explcitly say somewhere that these files are also available for bounty hunting?

Above and small nit, rest LGTM 👍🏾

X,
Y
);
function _verifySignature(bytes32 message, bytes calldata signature) internal view virtual override returns (bool success) {
Copy link
Member

Choose a reason for hiding this comment

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

Subjective nit: I resonate more with isValid than success in this case.

A similar change in SignatureValidator as well.

@nlordell
Copy link
Collaborator Author

Should we add the bounty email before this is audited?

Nice catch, yes we should.

Base automatically changed from chore/refactor-monorepo-4 to main March 18, 2024 14:34
@coveralls
Copy link

coveralls commented Mar 18, 2024

Pull Request Test Coverage Report for Build 8328648516

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+62.4%) to 76.923%

Totals Coverage Status
Change from base Build 8328447414: 62.4%
Covered Lines: 131
Relevant Lines: 155

💛 - Coveralls

@nlordell nlordell merged commit 7468b32 into main Mar 18, 2024
14 checks passed
@nlordell nlordell deleted the refactor-webauthn-signing branch March 18, 2024 14:53
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants