Skip to content

Commit

Permalink
fix compiler error
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeExplorer29 committed Jan 3, 2024
1 parent ff3bb87 commit d80be81
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../keystore/L1/interfaces/IKeyStoreValidator.sol";
import "./libraries/ValidatorSigDecoder.sol";
import "../libraries/WebAuthn.sol";
import "../libraries/Errors.sol";
import "../libraries/TypeConversion.sol";

contract KeyStoreValidator is IKeyStoreValidator{
contract KeyStoreValidator is IKeyStoreValidator {
using TypeConversion for address;

function recoverSignature(
bytes32 rawHash,
bytes calldata rawSignature
) external view returns (bytes32 recovered, bool success) {
function recoverSignature(bytes32 rawHash, bytes calldata rawSignature)
external
view
returns (bytes32 recovered, bool success)
{
uint8 signatureType;
bytes calldata signature;
uint256 validationData;
(signatureType, validationData, signature) = ValidatorSigDecoder
.decodeValidatorSignature(rawSignature);
(signatureType, validationData, signature) = ValidatorSigDecoder.decodeValidatorSignature(rawSignature);

bytes32 hash = _packSignatureHash(
rawHash,
signatureType,
validationData
);
bytes32 hash = _packSignatureHash(rawHash, signatureType, validationData);

(recovered, success) = recover(signatureType, hash, signature);
}

function _packSignatureHash(
bytes32 _hash,
uint8 signatureType,
uint256 validationData
) internal pure returns (bytes32 packedHash) {
function _packSignatureHash(bytes32 _hash, uint8 signatureType, uint256 validationData)
internal
pure
returns (bytes32 packedHash)
{
if (signatureType == 0x0) {
packedHash = _hash;
} else if (signatureType == 0x1) {
Expand All @@ -47,15 +44,14 @@ contract KeyStoreValidator is IKeyStoreValidator{
}
}

function recover(
uint8 signatureType,
bytes32 rawHash,
bytes calldata rawSignature
) internal view returns (bytes32 recovered, bool success) {
function recover(uint8 signatureType, bytes32 rawHash, bytes calldata rawSignature)
internal
view
returns (bytes32 recovered, bool success)
{
if (signatureType == 0x0 || signatureType == 0x1) {
//ecdas recover
(address recoveredAddr, ECDSA.RecoverError error, ) = ECDSA
.tryRecover(rawHash, rawSignature);
(address recoveredAddr, ECDSA.RecoverError error,) = ECDSA.tryRecover(rawHash, rawSignature);
if (error != ECDSA.RecoverError.NoError) {
success = false;
} else {
Expand Down

0 comments on commit d80be81

Please sign in to comment.