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

Feature: Implement a Passkey SignatureValidator factory #306

Merged
merged 6 commits into from
Mar 7, 2024

Conversation

mmv08
Copy link
Member

@mmv08 mmv08 commented Mar 5, 2024

This PR is a partial solution for #288. What needs to be added is a proper test suite for the factory. It only has one migrated end-to-end test from the 4337 module package.

What was done:

  • Introduce ICustomECSignerFactory and ICustom256BitECSignerFactory interfaces for custom signer factories. The first is generic and should work with signing algorithms of any key length, while the second is optimized for EC signing and 256-bit key sizes. The first one is not used in the project and is kept as an example or for future reference.
  • Add the WebAuthnVerifier and make it use the new P256Library introduced in Introduce P-256 Verifier Contract #298
  • Migrate the SafeSignerLaunchpad contract and make it implement the ICustom256BitECSignerFactory interface thus making it Safe256BitECSignerLaunchpad
  • Migrate and adjust the end-to-end test from the 4337 module for the launchpad

To be done:

  • Remove the migrated contracts from the 4337 package

@coveralls
Copy link

coveralls commented Mar 5, 2024

Pull Request Test Coverage Report for Build 8177592072

Details

  • 4 of 95 (4.21%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-62.4%) to 14.474%

Changes Missing Coverage Covered Lines Changed/Added Lines %
modules/passkey/contracts/SignatureValidator.sol 0 4 0.0%
modules/passkey/contracts/verifiers/WebAuthnVerifier.sol 1 12 8.33%
modules/passkey/contracts/WebAuthnSigner.sol 0 21 0.0%
modules/passkey/contracts/4337/Safe256BitECSignerLaunchpad.sol 3 58 5.17%
Totals Coverage Status
Change from base Build 8160381332: -62.4%
Covered Lines: 17
Relevant Lines: 108

💛 - Coveralls

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch 6 times, most recently from d59f4f5 to cd78a75 Compare March 6, 2024 12:08
@mmv08 mmv08 marked this pull request as ready for review March 6, 2024 12:09
@mmv08 mmv08 requested a review from a team as a code owner March 6, 2024 12:09
@mmv08 mmv08 requested review from nlordell, akshay-ap and remedcu and removed request for a team March 6, 2024 12:09
@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch 6 times, most recently from e273052 to a966519 Compare March 6, 2024 12:31
@@ -5,7 +5,6 @@ pragma solidity >=0.8.0;
import {SignatureValidatorConstants} from "./SignatureValidatorConstants.sol";
import {IUniqueSignerFactory} from "./SafeSignerLaunchpad.sol";
import {SignatureValidator} from "./SignatureValidator.sol";
import {SignatureValidatorConstants} from "./SignatureValidatorConstants.sol";
Copy link
Member Author

Choose a reason for hiding this comment

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

removed a duplicated import

},
"exclude": ["node_modules"],
"exclude": ["node_modules"]
Copy link
Member Author

Choose a reason for hiding this comment

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

the formatter wanted me to do it

modules/4337/package.json Outdated Show resolved Hide resolved
modules/4337/package.json Outdated Show resolved Hide resolved
* @dev Interface for creating and verifying ECDSA signers. This is a generalized interface that should be
* compatible with curves of any order size. Currently not used in the project and exists here for reference.
*/
interface ICustomECSignerFactory {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, this isn't an EC signer - in particular, it would support an interface to passkey with RSA key.

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from a838c9d to a966519 Compare March 6, 2024 13:49
@@ -0,0 +1,2 @@
# Entrypoint address to use for the Safe 4337 module deployment in 4337 tests. Default is the canonical EntryPoint v0.7 address
TESTS_4337_MODULE_DEPLOYMENT_ENTRY_POINT_ADDRESS="0x0000000071727De22E5E9d8BAf0edAc6f37da032"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: missing trailing newline.

}
}

interface SafeSetup {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can we move this to an ISafe file?

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from a966519 to 7e21926 Compare March 6, 2024 13:53
* @title ICustom256BitECSignerFactory
* @dev Interface for creating and verifying ECDSA signers using 256-bit elliptic curves.
*/
interface ICustom256BitECSignerFactory {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seeing as ICustomECSignerFactory isn't used at all, I would actually suggest removing it. It feels a bit like we are trying to future proof, even if there is no demand for using passkeys with algorithms other than ECDSA over the P-256 curve.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I mentioned in the @dev natspec that it's just kept for the future reference. I can remove it.

@@ -0,0 +1,12 @@
FROM docker.io/library/node:18
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can ln-s this file, so it is always the same as the 4337 file. It is a lightweight way to share the docker file between both projects 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

I was researching whether it works on Windows and can't find a concrete answer. Example: https://unix.stackexchange.com/questions/63172/does-windows-recognize-linuxs-symbolic-links

Do you know if it works across different OS? I know we don't have anyone on the team on Windows but for the sake of good open-source etiquette wanna check it

Comment on lines 17 to 18
} else if (!ENTRY_POINT) {
throw new Error('TESTS_4337_MODULE_DEPLOYMENT_ENTRY_POINT_ADDRESS must be set')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is for testing, do we ever even need this? Might be simpler to always deploy the EntryPoint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh... we need it for the launchpad contract. In that case, I think it should be DEPLOYMENT_ENTRY_POINT, since when we deploy it for real on Polygon for example, it feels weird to use a TEST_* variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea, removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I didn't read the second comment 🤦 will restore it

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch 2 times, most recently from 84b2878 to 64a6bc2 Compare March 6, 2024 14:26
@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch 3 times, most recently from d1e4049 to 56f09b4 Compare March 6, 2024 14:45
@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from 56f09b4 to 6a7f007 Compare March 6, 2024 15:33
@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from 6a7f007 to d355e21 Compare March 6, 2024 15:38
@mmv08
Copy link
Member Author

mmv08 commented Mar 6, 2024

I'm not sure why e2e tests fail; they work on my machine (including with a fresh dependency installation). I will debug it later today,

@nlordell
Copy link
Collaborator

nlordell commented Mar 6, 2024

Maybe related to fresh vs cached docker compose image?

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch 2 times, most recently from 6444076 to c7c79a6 Compare March 6, 2024 18:42
@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from c7c79a6 to 8a814f6 Compare March 6, 2024 18:57
@mmv08
Copy link
Member Author

mmv08 commented Mar 6, 2024

Maybe related to fresh vs cached docker compose image?

I fixed the first one (I could reproduce it in the end; it required removing all the build files and reinstalling dependencies from scratch), but now there's a new one with a SERVER_ERROR I can't seem to reproduce: https://github.com/safe-global/safe-modules/actions/runs/8177290950/job/22358636900?pr=306. I'm not sure what it can be 🤷

@mmv08 mmv08 force-pushed the 288-implement-a-passkey-signaturevalidator-factory branch from 102d665 to ac86d21 Compare March 6, 2024 19:12
@nlordell nlordell merged commit a2914d2 into main Mar 7, 2024
11 checks passed
@nlordell nlordell deleted the 288-implement-a-passkey-signaturevalidator-factory branch March 7, 2024 07:57
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 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.

3 participants