From b5e0d57ca315a4fdb3b1b237bf9c944fe31c3110 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 11 Apr 2024 16:04:52 +0200 Subject: [PATCH] [#312] Fix lint issue --- .../contracts/SafeWebAuthnSignerSingleton.sol | 6 ++--- .../contracts/base/SignatureValidator.sol | 26 ++++++++++--------- .../passkey/test/GasBenchmarkingProxy.spec.ts | 3 ++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol b/modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol index 640c73fb..fdd2d1b6 100644 --- a/modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol +++ b/modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; import {SignatureValidator} from "./base/SignatureValidator.sol"; import {IP256Verifier} from "./interfaces/IP256Verifier.sol"; -import {WebAuthn} from "./libraries/WebAuthn.sol"; +import {P256, WebAuthn} from "./libraries/WebAuthn.sol"; /** * @title WebAuthn Safe Signature Validator Singleton * @dev A contract that represents a WebAuthn signer. @@ -18,8 +18,8 @@ contract SafeWebAuthnSignerSingleton is SignatureValidator { bytes calldata signature, uint256 x, uint256 y, - address verifier + P256.Verifiers verifiers ) internal view virtual override returns (bool success) { - success = WebAuthn.verifySignature(message, signature, WebAuthn.USER_VERIFICATION, X, Y, VERIFIERS); + success = WebAuthn.verifySignature(message, signature, WebAuthn.USER_VERIFICATION, x, y, verifiers); } } diff --git a/modules/passkey/contracts/base/SignatureValidator.sol b/modules/passkey/contracts/base/SignatureValidator.sol index b593ea91..ec4e3a08 100644 --- a/modules/passkey/contracts/base/SignatureValidator.sol +++ b/modules/passkey/contracts/base/SignatureValidator.sol @@ -2,6 +2,8 @@ pragma solidity >=0.8.0; import {ERC1271} from "../libraries/ERC1271.sol"; +import {P256} from "../libraries/WebAuthn.sol"; + /** * @title Signature Validator Base Contract * @dev A interface for smart contract Safe owners that supports multiple ERC-1271 `isValidSignature` versions. @@ -17,14 +19,14 @@ abstract contract SignatureValidator { function isValidSignature(bytes memory data, bytes calldata signature) external view returns (bytes4 magicValue) { uint256 x; uint256 y; - address verifier; + P256.Verifiers verifiers; // solhint-disable-next-line no-inline-assembly assembly { - x := calldataload(sub(calldatasize(), 84)) - y := calldataload(sub(calldatasize(), 52)) - verifier := shr(96, calldataload(sub(calldatasize(), 20))) + x := calldataload(sub(calldatasize(), 88)) + y := calldataload(sub(calldatasize(), 56)) + verifiers := shr(96, calldataload(sub(calldatasize(), 24))) } - if (_verifySignature(keccak256(data), signature, x, y, verifier)) { + if (_verifySignature(keccak256(data), signature, x, y, verifiers)) { magicValue = ERC1271.LEGACY_MAGIC_VALUE; } } @@ -38,15 +40,15 @@ abstract contract SignatureValidator { function isValidSignature(bytes32 message, bytes calldata signature) external view returns (bytes4 magicValue) { uint256 x; uint256 y; - address verifier; + P256.Verifiers verifiers; // solhint-disable-next-line no-inline-assembly assembly { - x := calldataload(sub(calldatasize(), 84)) - y := calldataload(sub(calldatasize(), 52)) - verifier := shr(96, calldataload(sub(calldatasize(), 20))) + x := calldataload(sub(calldatasize(), 88)) + y := calldataload(sub(calldatasize(), 56)) + verifiers := shr(96, calldataload(sub(calldatasize(), 24))) } - if (_verifySignature(message, signature, x, y, verifier)) { + if (_verifySignature(message, signature, x, y, verifiers)) { magicValue = ERC1271.MAGIC_VALUE; } } @@ -57,7 +59,7 @@ abstract contract SignatureValidator { * @param signature The signature to be validated. * @param x The x coordinate of the public key. * @param y The y coordinate of the public key. - * @param verifier The address of the verifier contract. + * @param verifiers The address of the verifier contract and the fallback address. * @return success Whether the signature is valid. */ function _verifySignature( @@ -65,6 +67,6 @@ abstract contract SignatureValidator { bytes calldata signature, uint256 x, uint256 y, - address verifier + P256.Verifiers verifiers ) internal view virtual returns (bool success); } diff --git a/modules/passkey/test/GasBenchmarkingProxy.spec.ts b/modules/passkey/test/GasBenchmarkingProxy.spec.ts index 92b51224..adf70991 100644 --- a/modules/passkey/test/GasBenchmarkingProxy.spec.ts +++ b/modules/passkey/test/GasBenchmarkingProxy.spec.ts @@ -1,7 +1,8 @@ import { expect } from 'chai' import { deployments, ethers } from 'hardhat' -import { WebAuthnCredentials, decodePublicKey, encodeWebAuthnSignature } from './utils/webauthn' +import { WebAuthnCredentials } from './utils/webauthnShim' +import { decodePublicKey, encodeWebAuthnSignature } from '../src/utils/webauthn' import { IP256Verifier } from '../typechain-types' describe('Gas Benchmarking Proxy [@bench]', function () {