-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
'preferred', | ||
'discouraged', | ||
} | ||
export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged' |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
f5680bb
to
22f1097
Compare
Pull Request Test Coverage Report for Build 8187306793Details
💛 - Coveralls |
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 thepasskey
package and is imported by the4337
package, as this made more sense to me. @mmv08 moved E2E tests for Passkey+4337 to thepasskey
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.