Skip to content

Commit

Permalink
Added getConfiguration Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
yoav-el-certora committed Jun 23, 2024
1 parent e81f28b commit 99c9c6c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
26 changes: 26 additions & 0 deletions certora/confs/GetConfigurationConf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"assert_autofinder_success": true,
"files": [
"modules/passkey/contracts/SafeWebAuthnSignerProxy.sol",
"modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol",
"certora/harnesses/Utilities.sol",
"modules/passkey/contracts/libraries/P256.sol"
],
"link": [
"SafeWebAuthnSignerProxy:_VERIFIERS=P256",
"SafeWebAuthnSignerProxy:_SINGLETON=SafeWebAuthnSignerSingleton"
],
"packages":[
"@safe-global=node_modules/@safe-global",
"@account-abstraction=node_modules/@account-abstraction"
],
"solc": "solc8.23",
"rule_sanity": "basic",
"solc_via_ir": false,
"optimistic_loop": true,
"loop_iter": "6",
"optimistic_hashing": true,
"prover_version": "jtoman/CERT-6221",
"server": "production",
"verify": "SafeWebAuthnSignerProxy:certora/specs/GetConfigurationSpec.spec"
}
11 changes: 11 additions & 0 deletions certora/harnesses/Utilities.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import {P256} from "../../modules/passkey/contracts/libraries/WebAuthn.sol";


interface IConfigHolder {
function getConfiguration() external pure returns (uint256 x, uint256 y, P256.Verifiers verifiers);
}

contract Utilities {
function havocAll() external {
(bool success, ) = address(0xdeadbeef).call(abi.encodeWithSelector(0x12345678));
Expand All @@ -7,4 +14,8 @@ contract Utilities {
function justRevert() external {
revert();
}

function getConfiguration(address proxy) external view returns (uint256 x, uint256 y, P256.Verifiers verifiers) {
return IConfigHolder(proxy).getConfiguration();
}
}
33 changes: 33 additions & 0 deletions certora/specs/GetConfigurationSpec.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Utilities as utilities;
using SafeWebAuthnSignerProxy as proxy;

methods {
function _._ external => DISPATCH [ SafeWebAuthnSignerProxy._, SafeWebAuthnSignerSingleton._ ] default HAVOC_ALL;
}

/*
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
getConfiguration Function (Integrity) │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
*/

rule configGetConfiguration {
env e;

uint256 xBefore = currentContract._X;
uint256 yBefore = currentContract._Y;
P256.Verifiers verifiersBefore = currentContract._VERIFIERS;

uint256 xAfter;
uint256 yAfter;
P256.Verifiers verifiersAfter;

xAfter, yAfter, verifiersAfter = utilities.getConfiguration(e, proxy);


assert xBefore == xAfter &&
yBefore == yAfter &&
verifiersBefore == verifiersAfter;
satisfy true;
}

4 changes: 3 additions & 1 deletion modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ contract SafeWebAuthnSignerSingleton is SignatureValidator {
*/
function getConfiguration() public pure returns (uint256 x, uint256 y, P256.Verifiers verifiers) {
// solhint-disable-next-line no-inline-assembly
uint256 mask = type(uint176).max;
assembly ("memory-safe") {
x := calldataload(sub(calldatasize(), 86))
y := calldataload(sub(calldatasize(), 54))
verifiers := shr(80, calldataload(sub(calldatasize(), 22)))
// verifiers := shr(80, calldataload(sub(calldatasize(), 22)))
verifiers := and(mask, calldataload(sub(calldatasize(), 32)))
}
}
}

0 comments on commit 99c9c6c

Please sign in to comment.