Skip to content

Commit

Permalink
[#312] Fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Apr 25, 2024
1 parent 53ff837 commit b5e0d57
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
}
26 changes: 14 additions & 12 deletions modules/passkey/contracts/base/SignatureValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -57,14 +59,14 @@ 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(
bytes32 message,
bytes calldata signature,
uint256 x,
uint256 y,
address verifier
P256.Verifiers verifiers
) internal view virtual returns (bool success);
}
3 changes: 2 additions & 1 deletion modules/passkey/test/GasBenchmarkingProxy.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down

0 comments on commit b5e0d57

Please sign in to comment.