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

Verify Multiple P-256 Verifiers Are Supported #307

Merged
merged 4 commits into from
Mar 7, 2024

Conversation

nlordell
Copy link
Collaborator

@nlordell nlordell commented Mar 6, 2024

Partially addresses #285

This PR adds new tests that verify multiple P-256 verifiers are supported by our code. The webauthn shim code now moved to the passkey package and is imported by the 4337 package, as this made more sense to me. @mmv08 moved E2E tests for Passkey+4337 to the passkey project, so once they both merge, the dependency can be removed.

Note that for now, we use a TestWebAuthnSignerFactor contract just for implementing the tests, but it should be switched to using the canonical signing factory from #306 once merged.

The additional verifier that is being used is the one from Daimo-eth. The artifact was vendored into the project, as it is a Foundry project, and this is the easiest way to include the dependency without building it (giving us identical bytecode to what is deployed on-chain).

Adding a test for using the precompile will be done in a separate PR.


Note that this PR contains some unrelated changes to the deployment and E2E setup. This was a result of rebasing onto changes introduced in #306 to get things working as well as some nits leftover from the aforementioned PR.

@nlordell nlordell requested a review from a team as a code owner March 6, 2024 13:36
@nlordell nlordell requested review from akshay-ap, mmv08 and remedcu and removed request for a team March 6, 2024 13:36
'preferred',
'discouraged',
}
export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To match the web interface.

credential.id,
credential.cosePublicKey(),
],
authData: b2ab(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a small bug that existed before but went unnoticed as the previous version of the CBOR decoding library used in the tests accepted both types here. Essentially, we need the field to be an ArrayBuffer and not a Uint8Array. We got slightly different versions of the library when installing the dependencies in this package, which are more pedantic than their predecessors, and led to this bug being found.

/**
* Extract the x and y coordinates of the public key from a created public key credential.
* Inspired from <https://webauthn.guide/#registration>.
*/
export function extractPublicKey(response: AuthenticatorAttestationResponse): { x: bigint; y: bigint } {
const attestationObject = CBOR.decode(response.attestationObject)
const authDataView = new DataView(attestationObject.authData.buffer)
const credentialIdLength = authDataView.getUint16(53)
const authData = new DataView(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also small bug that went unnoticed - we can potentially have a Uint8Array with an offset and length, so we can't blindly create a view to its underlying buffer.

@nlordell nlordell force-pushed the 285-support-multiple-verifiers branch from f5680bb to 22f1097 Compare March 7, 2024 08:57
@coveralls
Copy link

coveralls commented Mar 7, 2024

Pull Request Test Coverage Report for Build 8187306793

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 8184727085: 62.4%
Covered Lines: 131
Relevant Lines: 155

💛 - Coveralls

@nlordell nlordell merged commit 92e5bc0 into main Mar 7, 2024
13 checks passed
@nlordell nlordell deleted the 285-support-multiple-verifiers branch March 7, 2024 11:32
@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