Skip to content

Commit

Permalink
support precompile as a verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 committed Mar 6, 2024
1 parent a966519 commit a838c9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/passkey/contracts/WebAuthnSigner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ contract WebAuthnSigner is SignatureValidator {
* @dev A factory contract for creating and managing WebAuthn signers.
*/
contract WebAuthnSignerFactory is ICustom256BitECSignerFactory, SignatureValidatorConstants {
address private constant SECP256R1_PRECOMPILE_ADDRESS = address(0x0b);

// @inheritdoc ICustom256BitECSignerFactory
function getSigner(uint256 qx, uint256 qy, address verifier) public view override returns (address signer) {
bytes32 codeHash = keccak256(abi.encodePacked(type(WebAuthnSigner).creationCode, qx, qy, uint256(uint160(verifier))));
Expand All @@ -85,7 +87,8 @@ contract WebAuthnSignerFactory is ICustom256BitECSignerFactory, SignatureValidat
*/
function _validVerifier(address verifier) internal view returns (bool) {
// The verifier should contain code (The only way to implement a webauthn verifier is with a smart contract)
return !_hasNoCode(verifier);
// or be the precompile address for the secp256r1 curve defined in the RIP-7212
return !_hasNoCode(verifier) || verifier == SECP256R1_PRECOMPILE_ADDRESS;
}

// @inheritdoc ICustom256BitECSignerFactory
Expand Down

0 comments on commit a838c9d

Please sign in to comment.