-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebAuthnValidator.sol
More file actions
35 lines (28 loc) · 1.13 KB
/
WebAuthnValidator.sol
File metadata and controls
35 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;
import { ERC7579_MODULE_TYPE_STATELESS_VALIDATOR } from "smart-sessions/DataTypes.sol";
import { ISessionValidator } from "smart-sessions/interfaces/ISessionValidator.sol";
import { P256Credentials, P256CredentialsLib } from "src/session-validators/lib/P256Credentials.sol";
contract WebAuthnValidator is ISessionValidator {
using P256CredentialsLib for P256Credentials;
function validateSignatureWithData(
bytes32 hash,
bytes calldata sig,
bytes calldata data
)
external
view
returns (bool validSig)
{
(uint256 x, uint256 y) = abi.decode(data, (uint256, uint256));
return P256Credentials(x, y).verifyWebAuthnSignature(hash, sig);
}
function isModuleType(uint256 id) external pure returns (bool) {
return id == ERC7579_MODULE_TYPE_STATELESS_VALIDATOR;
}
function onInstall(bytes calldata data) external override { }
function onUninstall(bytes calldata data) external override { }
function isInitialized(address) external pure override returns (bool) {
return true;
}
}