Skip to content

Commit

Permalink
Feature: Implement a Passkey SignatureValidator factory (#306)
Browse files Browse the repository at this point in the history
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 #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
  • Loading branch information
mmv08 authored Mar 7, 2024
1 parent f03be94 commit a2914d2
Show file tree
Hide file tree
Showing 36 changed files with 3,521 additions and 17,391 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_4337.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_4337_gas_metering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_4337_upstream_bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/ci_passkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run coverage -w modules/passkey
- run: |
npm ci
npm run coverage -w modules/passkey
- uses: coverallsapp/github-action@master
with:
path-to-lcov: modules/passkey/coverage/lcov.info
Expand All @@ -24,12 +25,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run lint -w modules/passkey
- run: npm run fmt:check -w modules/passkey
- run: npm run build -w modules/passkey
- run: |
npm ci
npm run lint -w modules/passkey
npm run fmt:check -w modules/passkey
npm run build -w modules/passkey
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: |
npm ci
npm run test:e2e -w modules/passkey
2 changes: 1 addition & 1 deletion .github/workflows/ci_passkey_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
Expand Down
4 changes: 2 additions & 2 deletions examples/4337-gas-metering/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"outDir": "./dist" /* Redirect output structure to the directory. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */
},
"exclude": ["node_modules"],
"exclude": ["node_modules"]
}
1 change: 0 additions & 1 deletion modules/4337/contracts/experimental/WebAuthnSigner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
import {IWebAuthnVerifier, WebAuthnConstants} from "./verifiers/WebAuthnVerifier.sol";

struct SignatureData {
Expand Down
2 changes: 0 additions & 2 deletions modules/4337/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ const userConfig: HardhatUserConfig = {
tags: ['dev', 'safe'],
},
hardhat: {
blockGasLimit: 100000000,
gas: 100000000,
gasPrice: 10000000000,
tags: ['test'],
},
Expand Down
10 changes: 6 additions & 4 deletions modules/4337/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"build"
],
"scripts": {
"build": "hardhat compile",
"build": "npm run build:sol && npm run build:ts",
"build:ts": "npx rimraf dist && tsc",
"build:sol": "npx rimraf build && hardhat compile",
"test": "hardhat test --deploy-fixture",
"test:e2e": "./test/e2e/run.sh",
"test:e2e:upstream": "USE_UPSTREAM_BUNDLER=1 ./test/e2e/run.sh",
Expand All @@ -31,7 +32,8 @@
"fmt": "prettier --write ./contracts/**/*.sol",
"fmt:check": "prettier --check ./**/*.sol",
"prepack": "npm run build",
"prepublish": "npx rimraf build && npm run build && npm run build:ts"
"prepublish": "npm run build",
"postinstall": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -72,10 +74,10 @@
},
"overrides": {
"@safe-global/safe-contracts": {
"ethers": "^6.8.0"
"ethers": "^6.11.0"
}
},
"dependencies": {
"@safe-global/safe-contracts": "^1.4.1"
"@safe-global/safe-contracts": "^1.4.1-build.0"
}
}
2 changes: 2 additions & 0 deletions modules/passkey/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Entrypoint address to use for the Safe 4337 Signer Launchpad deployment. Defaults to the canonical entrypoint v0.7 address.
LAUNCHPAD_DEPLOYMENT_ENTRY_POINT_ADDRESS="0x0000000071727De22E5E9d8BAf0edAc6f37da032"
Loading

0 comments on commit a2914d2

Please sign in to comment.