Skip to content

Commit

Permalink
update tests and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsoncusack committed Feb 27, 2024
1 parent b3d56b0 commit caaba24
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
11 changes: 9 additions & 2 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
WebAuthnTest:test_chrome() (gas: 245261)
WebAuthnTest:test_safari() (gas: 240505)
WebAuthnTest:test_CB() (gas: 294338)
WebAuthnTest:test_CBCalldataSize() (gas: 354149)
WebAuthnTest:test_CBCalldataSize2() (gas: 370966)
WebAuthnTest:test_Daimo() (gas: 424627)
WebAuthnTest:test_DaimoCalldataSize() (gas: 432582)
WebAuthnTest:test_FCL() (gas: 301259)
WebAuthnTest:test_FCLCalldataSize() (gas: 415293)
WebAuthnTest:test_chrome() (gas: 249746)
WebAuthnTest:test_safari() (gas: 245050)
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: test

on: workflow_dispatch
on:
pull_request:
branches:
- main

env:
FOUNDRY_PROFILE: ci
Expand Down
1 change: 0 additions & 1 deletion Makefile

This file was deleted.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ function test() public view {
)
);
}
```
```

### Calldata fee comparison
A comparison with some other WebAuthn verifiers.
Numbers from Base mainnet as of February 26, 2024.

| Library | Calldata size (bytes) | L1 fee wei | L1 fee cents |
|--------|---------------|------------|--------------|
| WebAuthn-sol | 576 | 212990146162662 | 63 |
| [Daimo's WebAuthn.sol](https://github.com/daimo-eth/p256-verifier/blob/master/src/WebAuthn.sol) | 672 | 262592374578294 | 78 |
| [FCL_WebAuthn.sol](https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol) | 640 | 258426308149685 | 77 |
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
src = "src"
out = "out"
libs = ["lib"]
no_match_path = "test/Benchmarks.t.sol"
via_ir = true
optimizer_runs = 999999

Expand Down
15 changes: 10 additions & 5 deletions test/Benchmarks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ interface IGasPriceOracle {
}

contract WebAuthnTest is Test {
FCLWrapper fclWrapper = new FCLWrapper();
DaimoWrapper daimoWrapper = new DaimoWrapper();
CBWrapper cbWrapper = new CBWrapper();
FCLWrapper fclWrapper;
DaimoWrapper daimoWrapper;
CBWrapper cbWrapper;
IGasPriceOracle oracle = IGasPriceOracle(0x420000000000000000000000000000000000000F);
bytes32 digest = sha256("hello world");
uint256 privateKey = 0xa11ce;
Expand All @@ -33,6 +33,11 @@ contract WebAuthnTest is Test {
uint256 constant P256_N = uint256(0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551);

function setUp() public {
vm.createSelectFork("https://mainnet.base.org");
fclWrapper = new FCLWrapper();
daimoWrapper = new DaimoWrapper();
cbWrapper = new CBWrapper();

WebAuthnInfo memory webAuthnInfo = Utils.getWebAuthnStruct(digest);
(bytes32 r_, bytes32 s_) = vm.signP256(privateKey, webAuthnInfo.messageHash);
r = uint256(r_);
Expand Down Expand Up @@ -133,7 +138,7 @@ contract WebAuthnTest is Test {
WebAuthn.WebAuthnAuth({
authenticatorData: authenticatorData,
origin: "https://sign.coinbase.com",
crossOriginAndRemainder: "",
crossOriginAndRemainder: '"crossOrigin":false',
r: r,
s: s
}),
Expand All @@ -148,7 +153,7 @@ contract WebAuthnTest is Test {
console2.log(testName);
console2.log("Calldata size", data.length);
console2.log("L1 fee wei", oracle.getL1Fee(data));
console2.log("L1 fee cents", oracle.getL1Fee(data) * 2500 / 1e16);
console2.log("L1 fee cents", oracle.getL1Fee(data) * 3000 / 1e16);
}
}

Expand Down

0 comments on commit caaba24

Please sign in to comment.