Skip to content

Fix/passkey #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/log
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "validators/webauthn/lib/openzeppelin-contracts"]
path = validators/webauthn/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "validators/webauthn/lib/kernel_v3"]
path = validators/webauthn/lib/kernel_v3
url = https://github.com/zerodevapp/kernel_v3
[submodule "signers/ecdsa/lib/kernel_v3"]
path = signers/ecdsa/lib/kernel_v3
url = https://github.com/zerodevapp/kernel_v3
Expand Down Expand Up @@ -49,9 +46,6 @@
[submodule "signers/webauthn/lib/forge-std"]
path = signers/webauthn/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "signers/webauthn/lib/kernel_v3"]
path = signers/webauthn/lib/kernel_v3
url = https://github.com/zerodevapp/kernel_v3
[submodule "signers/webauthn/lib/openzeppelin-contracts"]
path = signers/webauthn/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
Expand All @@ -72,3 +66,6 @@
[submodule "hooks/onlyEntrypoint/lib/kernel_v3"]
path = hooks/onlyEntrypoint/lib/kernel_v3
url = https://github.com/zerodevapp/kernel_v3
[submodule "signers/webauthn/lib/kernel"]
path = signers/webauthn/lib/kernel
url = https://github.com/zerodevapp/kernel
1 change: 1 addition & 0 deletions signers/webauthn/lib/kernel
Submodule kernel added at 10c099
1 change: 0 additions & 1 deletion signers/webauthn/lib/kernel_v3
Submodule kernel_v3 deleted from abe389
6 changes: 3 additions & 3 deletions signers/webauthn/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
ds-test/=lib/kernel_v3/lib/forge-std/lib/ds-test/src/
ds-test/=lib/kernel/lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
kernel/=lib/kernel_v3/src/
kernel/=lib/kernel/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/
solady/=lib/kernel_v3/lib/solady/src/
solady/=lib/kernel/lib/solady/src/
18 changes: 10 additions & 8 deletions signers/webauthn/src/WebAuthnSigner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.0;

import "kernel/sdk/moduleBase/SignerBase.sol";
import {VALIDATION_SUCCESS, VALIDATION_FAILED} from "kernel/interfaces/IERC7579Modules.sol";
import {SIG_VALIDATION_SUCCESS_UINT, SIG_VALIDATION_FAILED_UINT} from "kernel/types/Constants.sol";
import {PackedUserOperation} from "kernel/interfaces/PackedUserOperation.sol";
import {ERC1271_MAGICVALUE, ERC1271_INVALID} from "kernel/types/Constants.sol";
import {WebAuthn} from "./WebAuthn.sol";
Expand Down Expand Up @@ -50,25 +50,27 @@ contract WebAuthnSigner is SignerBase {
override
returns (uint256)
{
return _verifySignature(id, userOp.sender, userOpHash, userOp.signature);
return _verifySignature(id, msg.sender, userOpHash, userOp.signature);
}

/**
* @notice Verify a signature with sender for ERC-1271 validation.
*/
function checkSignature(bytes32 id, address sender, bytes32 hash, bytes calldata sig)
function checkSignature(bytes32 id, address, bytes32 hash, bytes calldata sig)
external
view
override
returns (bytes4)
{
return _verifySignature(id, sender, hash, sig) == VALIDATION_SUCCESS ? ERC1271_MAGICVALUE : ERC1271_INVALID;
return _verifySignature(id, msg.sender, hash, sig) == SIG_VALIDATION_SUCCESS_UINT
? ERC1271_MAGICVALUE
: ERC1271_INVALID;
}

/**
* @notice Verify a signature.
*/
function _verifySignature(bytes32 id, address sender, bytes32 hash, bytes calldata signature)
function _verifySignature(bytes32 id, address account, bytes32 hash, bytes calldata signature)
private
view
returns (uint256)
Expand All @@ -84,7 +86,7 @@ contract WebAuthnSigner is SignerBase {
) = abi.decode(signature, (bytes, string, uint256, uint256, uint256, bool));

// get the public key from storage
WebAuthnSignerData memory webAuthnData = webAuthnSignerStorage[id][sender];
WebAuthnSignerData memory webAuthnData = webAuthnSignerStorage[id][account];

// verify the signature using the signature and the public key
bool isValid = WebAuthn.verifySignature(
Expand All @@ -103,10 +105,10 @@ contract WebAuthnSigner is SignerBase {

// return the validation data
if (isValid) {
return VALIDATION_SUCCESS;
return SIG_VALIDATION_SUCCESS_UINT;
}

return VALIDATION_FAILED;
return SIG_VALIDATION_FAILED_UINT;
}
/**
* @notice Install WebAuthn signer for a kernel account.
Expand Down
1 change: 1 addition & 0 deletions validators/webauthn/lib/FreshCryptoLib
Submodule FreshCryptoLib added at 76f3f1
1 change: 1 addition & 0 deletions validators/webauthn/lib/kernel
Submodule kernel added at 10c099
1 change: 0 additions & 1 deletion validators/webauthn/lib/kernel_v3
Submodule kernel_v3 deleted from 379417
1 change: 1 addition & 0 deletions validators/webauthn/lib/p256-verifier
Submodule p256-verifier added at e210c5
6 changes: 3 additions & 3 deletions validators/webauthn/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
ds-test/=lib/kernel_v3/lib/forge-std/lib/ds-test/src/
ds-test/=lib/kernel/lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
kernel/=lib/kernel_v3/src/
kernel/=lib/kernel/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/
solady/=lib/kernel_v3/lib/solady/src/
solady/=lib/kernel/lib/solady/src/
Loading