-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into modular_permission
- Loading branch information
Showing
15 changed files
with
1,203 additions
and
149 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/solady"] | ||
path = lib/solady | ||
url = https://github.com/vectorized/solady | ||
[submodule "lib/I4337"] | ||
path = lib/I4337 | ||
url = https://github.com/leekt/I4337 | ||
[submodule "lib/p256-verifier"] | ||
path = lib/p256-verifier | ||
url = https://github.com/daimo-eth/p256-verifier | ||
[submodule "lib/FreshCryptoLib"] | ||
path = lib/FreshCryptoLib | ||
url = https://github.com/rdubois-crypto/FreshCryptoLib | ||
[submodule "lib/solady"] | ||
path = lib/solady | ||
url = https://github.com/vectorized/solady |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
solady/=lib/solady/src/ | ||
p256-verifier/=lib/p256-verifier/src/ | ||
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/ | ||
I4337/=lib/I4337/src/ | ||
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "src/factory/KernelFactory.sol"; | ||
import "src/utils/P256VerifierWrapper.sol"; | ||
import "src/validator/webauthn//WebAuthnFclValidator.sol"; | ||
import "forge-std/Script.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
contract DeployWebAuthnFclValidator is Script { | ||
function run() public { | ||
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(key); | ||
|
||
P256VerifierWrapper p256VerifierWrapper = new P256VerifierWrapper{salt: 0}(); | ||
console.log("p256 wrapper address: %s", address(p256VerifierWrapper)); | ||
|
||
WebAuthnFclValidator validator = new WebAuthnFclValidator{salt: 0}(address(p256VerifierWrapper)); | ||
console.log("validator address: %s", address(validator)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {FCL_ecdsa} from "FreshCryptoLib/FCL_ecdsa.sol"; | ||
|
||
/// @title P256VerifierWrapper | ||
/// @author rdubois-crypto | ||
/// @author KONFeature | ||
/// @notice Wrapper arround the P256Verifier contract of @rdubois-crypto, using it to accept EIP-7212 compliant verification (p256 pre-compiled curve) | ||
/// @dev This lib is only a wrapper around the P256Verifier contract. | ||
/// It will call the verifySignature function of the P256Verifier contract. | ||
/// Once the RIP-7212 will be deployed and effective, this contract will be useless. | ||
/// Tracker on polygon: PR: https://github.com/maticnetwork/bor/pull/1069 | ||
/// Now waiting on the Napoli hardfork to be deployed | ||
contract P256VerifierWrapper { | ||
/** | ||
* Precompiles don't use a function signature. The first byte of callldata | ||
* is the first byte of an input argument. In this case: | ||
* | ||
* input[ 0: 32] = signed data hash | ||
* input[ 32: 64] = signature r | ||
* input[ 64: 96] = signature s | ||
* input[ 96:128] = public key x | ||
* input[128:160] = public key y | ||
* | ||
* result[ 0: 32] = 0x00..00 (invalid) or 0x00..01 (valid) | ||
* | ||
* For details, see https://eips.ethereum.org/EIPS/eip-7212 | ||
*/ | ||
fallback(bytes calldata input) external returns (bytes memory) { | ||
if (input.length != 160) { | ||
return abi.encodePacked(uint256(0)); | ||
} | ||
|
||
bytes32 hash = bytes32(input[0:32]); | ||
uint256 r = uint256(bytes32(input[32:64])); | ||
uint256 s = uint256(bytes32(input[64:96])); | ||
uint256 x = uint256(bytes32(input[96:128])); | ||
uint256 y = uint256(bytes32(input[128:160])); | ||
|
||
uint256 ret = FCL_ecdsa.ecdsa_verify(hash, r, s, x, y) ? 1 : 0; | ||
|
||
return abi.encodePacked(ret); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.