Skip to content

Commit

Permalink
Merge branch 'certora' into yoav/Singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
yoav-el-certora authored Jun 23, 2024
2 parents e81f28b + e6f8e21 commit a05a177
Show file tree
Hide file tree
Showing 18 changed files with 371 additions and 370 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"assert_autofinder_success": true,
"files": [
"certora/harnesses/SafeWebAuthnSignerProxyHarness.sol",
"certora/harnesses/GetSignerHarness.sol",
"modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol",
"modules/passkey/contracts/libraries/P256.sol"
"modules/passkey/contracts/SafeWebAuthnSignerProxy.sol"
],
"link": [
"SafeWebAuthnSignerProxyHarness:_VERIFIERS=P256",
"SafeWebAuthnSignerProxyHarness:_SINGLETON=SafeWebAuthnSignerSingleton"
"GetSignerHarness:SINGLETON=SafeWebAuthnSignerSingleton"
],
"packages":[
"@safe-global=node_modules/@safe-global",
"@account-abstraction=node_modules/@account-abstraction"
],
"rule_sanity": "basic",
"solc": "solc8.23",
"solc_via_ir": false,
"optimistic_loop": true,
"loop_iter": "6",
"optimistic_hashing": true,
"rule_sanity": "basic",
"verify": "SafeWebAuthnSignerProxyHarness:certora/specs/SafeWebAuthnSignerProxyHarness.spec"
"hashing_length_bound": "4694",
"loop_iter": "144",
"verify": "GetSignerHarness:certora/specs/GetSigner.spec"
}
25 changes: 0 additions & 25 deletions certora/confs/ProxySimulator.conf

This file was deleted.

12 changes: 1 addition & 11 deletions certora/confs/SafeWebAuthnSignerFactory.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
"certora/harnesses/SafeWebAuthnSignerFactoryHarness.sol",
"modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol",
"modules/passkey/contracts/SafeWebAuthnSignerProxy.sol",
"certora/harnesses/ERC20Like/DummyWeth.sol",
"certora/harnesses/Utilities.sol",
],
"java_args": [
" -ea -Dlevel.setup.helpers=info"
],
"link": [
"SafeWebAuthnSignerFactoryHarness:SINGLETON=SafeWebAuthnSignerSingleton"
],
"msg": "sanity_with_all_default_summaries",
"process": "emv",
"packages":[
"@safe-global=node_modules/@safe-global",
"@account-abstraction=node_modules/@account-abstraction"
Expand All @@ -24,9 +17,6 @@
"solc_via_ir": false,
"optimistic_loop": true,
"optimistic_hashing": true,
"hashing_length_bound": "4694",
"loop_iter": "144",
"prover_version": "master",
"server": "production",
"loop_iter": "6",
"verify": "SafeWebAuthnSignerFactoryHarness:certora/specs/SafeWebAuthnSignerFactory.spec"
}
2 changes: 0 additions & 2 deletions certora/confs/SafeWebAuthnSignerSingleton.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
"optimistic_loop": true,
"loop_iter": "6",
"optimistic_hashing": true,
"prover_version": "master",
"server": "production",
"verify": "SafeWebAuthnSignerSingleton:certora/specs/SafeWebAuthnSignerSingleton.spec"
}
7 changes: 0 additions & 7 deletions certora/confs/WebAuthn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
"files": [
"certora/harnesses/WebAuthnHarness.sol"
],
"java_args": [
" -ea -Dlevel.setup.helpers=info"
],
"msg": "sanity_with_all_default_summaries",
"process": "emv",
"packages":[
"@safe-global=node_modules/@safe-global",
"@account-abstraction=node_modules/@account-abstraction"
Expand All @@ -16,8 +11,6 @@
"solc_via_ir": false,
"optimistic_loop": true,
"optimistic_hashing": true,
"prover_version": "master",
"server": "production",
"rule_sanity": "basic",
"loop_iter": "6",
"verify": "WebAuthnHarness:certora/specs/WebAuthn.spec"
Expand Down
25 changes: 0 additions & 25 deletions certora/confs/WebAuthnBitVectorTheory.conf

This file was deleted.

43 changes: 43 additions & 0 deletions certora/harnesses/GetSignerHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;

import {SafeWebAuthnSignerFactory} from "../munged/SafeWebAuthnSignerFactory.sol";
import {P256} from "../../modules/passkey/contracts/libraries/P256.sol";
import {SafeWebAuthnSignerProxy} from "../../modules/passkey/contracts/SafeWebAuthnSignerProxy.sol";

contract GetSignerHarness is SafeWebAuthnSignerFactory {

function getSignerHarnessed(uint256 x, uint256 y, P256.Verifiers verifiers) public view returns (uint256 value) {
bytes32 codeHash = keccak256(
abi.encodePacked(
type(SafeWebAuthnSignerProxy).creationCode,
"01234567891011121314152546",
uint256(uint160(address(SINGLETON))),
x,
y,
uint256(P256.Verifiers.unwrap(verifiers))
)
);
value = uint256(keccak256(abi.encodePacked(hex"ff", address(this), bytes32(0), codeHash)));
}
function castToAddress(uint256 value) public pure returns (address addr){
addr = address(uint160(value));
}

/**
* munged getSigner
*/
function getSigner(uint256 x, uint256 y, P256.Verifiers verifiers) public view override returns (address signer) {
bytes32 codeHash = keccak256(
abi.encodePacked(
type(SafeWebAuthnSignerProxy).creationCode,
"01234567891011121314152546", // munged for word alignment workaround (32 bytes)
uint256(uint160(address(SINGLETON))),
x,
y,
uint256(P256.Verifiers.unwrap(verifiers))
)
);
signer = address(uint160(uint256(keccak256(abi.encodePacked(hex"ff", address(this), bytes32(0), codeHash)))));
}
}
2 changes: 1 addition & 1 deletion certora/harnesses/SafeWebAuthnSignerFactoryHarness.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;

import {SafeWebAuthnSignerFactory} from "../../modules/passkey/contracts/SafeWebAuthnSignerFactory.sol";
import {SafeWebAuthnSignerFactory} from "../munged/SafeWebAuthnSignerFactory.sol";
import {P256} from "../../modules/passkey/contracts/libraries/P256.sol";
import {SafeWebAuthnSignerProxy} from "../../modules/passkey/contracts/SafeWebAuthnSignerProxy.sol";

Expand Down
53 changes: 0 additions & 53 deletions certora/harnesses/SafeWebAuthnSignerProxyHarness.sol

This file was deleted.

17 changes: 17 additions & 0 deletions certora/harnesses/WebAuthnHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ pragma solidity ^0.8.0;
import {P256, WebAuthn} from "../../modules/passkey/contracts/libraries/WebAuthn.sol";

contract WebAuthnHarness {

mapping (bytes32 => mapping (bytes32 => string)) symbolicClientDataJson;

function summaryEncodeDataJson(bytes32 challenge, string calldata clientDataFields) public returns (string memory){
bytes32 hashClientDataFields = keccak256(abi.encodePacked(clientDataFields));
string memory stringResult = symbolicClientDataJson[challenge][hashClientDataFields];
bytes32 hashResult = keccak256(abi.encodePacked(stringResult));

require (checkInjective(challenge, hashClientDataFields, hashResult));

return stringResult;
}

function checkInjective(bytes32 challenge, bytes32 clientDataFields, bytes32 result) internal view returns (bool){
return true;
}

function compareSignatures(WebAuthn.Signature memory sig1, WebAuthn.Signature memory sig2) public pure returns (bool) {
if (sig1.r != sig2.r || sig1.s != sig2.s) {
return false;
Expand Down
24 changes: 0 additions & 24 deletions certora/helpers/ProxySimulator.sol

This file was deleted.

Loading

0 comments on commit a05a177

Please sign in to comment.