This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from getwax/55-move-low-level-webauthn-logic-t…
…o-primitives-directory 55 move low level webauthn logic to primitives directory
- Loading branch information
Showing
19 changed files
with
162 additions
and
16 deletions.
There are no files selected for viewing
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,41 @@ | ||
name: primitives | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- primitives/** | ||
|
||
defaults: | ||
run: | ||
working-directory: ./primitives | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test |
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 @@ | ||
../../../primitives |
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
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,14 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
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,3 +1,4 @@ | ||
# Cryptographic Primitives | ||
|
||
A place to integrate primitives into a modular verification components, and test in isolation. | ||
After successful development here, the primitive can be integrated into smart accounts. |
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,6 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "forge-std/Test.sol"; | ||
import {WebAuthn} from "../../src/WebAuthn.sol"; | ||
|
||
/* solhint-disable private-vars-leading-underscore */ | ||
|
||
abstract contract TestHelper is Test { | ||
address internal constant ALICE = address(1); | ||
address internal constant BOB = address(2); | ||
address[] internal testAccounts = [ALICE, BOB]; | ||
|
||
constructor() {} | ||
|
||
function getWebAuthnPublicKey() internal pure returns (uint256[2] memory publicKey) { | ||
publicKey = [ | ||
114874632398302156264159990279427641021947882640101801130664833947273521181002, | ||
32136952818958550240756825111900051564117520891182470183735244184006536587423 | ||
]; | ||
} | ||
|
||
function getWebAuthnSignatureValues() | ||
internal | ||
pure | ||
returns ( | ||
bytes memory authenticatorData, | ||
bytes1 authenticatorDataFlagMask, | ||
bytes memory clientData, | ||
bytes32 clientChallenge, | ||
uint256 clientChallengeDataOffset, | ||
uint256[2] memory signature | ||
) | ||
{ | ||
authenticatorData = hex"f8e4b678e1c62f7355266eaa4dc1148573440937063a46d848da1e25babbd20b010000004d"; | ||
authenticatorDataFlagMask = 0x01; | ||
clientData = | ||
hex"7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a224e546f2d3161424547526e78786a6d6b61544865687972444e5833697a6c7169316f776d4f643955474a30222c226f726967696e223a2268747470733a2f2f66726573682e6c65646765722e636f6d222c2263726f73734f726967696e223a66616c73657d"; | ||
clientChallenge = hex"353a3ed5a0441919f1c639a46931de872ac3357de2ce5aa2d68c2639df54189d"; | ||
clientChallengeDataOffset = 36; | ||
signature = [ | ||
45847212378479006099766816358861726414873720355505495069909394794949093093607, | ||
55835259151215769394881684156457977412783812617123006733908193526332337539398 | ||
]; | ||
} | ||
} |
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import {WebAuthn} from "../../src/WebAuthn.sol"; | ||
|
||
/** Helper contract to expose internal functions for testing */ | ||
contract WebAuthnHarness is WebAuthn { | ||
constructor() WebAuthn() {} | ||
|
||
function exposed_verifySignature( | ||
bytes calldata authenticatorData, | ||
bytes1 authenticatorDataFlagMask, | ||
bytes calldata clientData, | ||
bytes32 clientChallenge, | ||
uint256 clientChallengeDataOffset, | ||
uint256[2] calldata signature, | ||
uint256[2] calldata publicKey | ||
) external returns (bool) { | ||
return verifySignature( | ||
authenticatorData, | ||
authenticatorDataFlagMask, | ||
clientData, | ||
clientChallenge, | ||
clientChallengeDataOffset, | ||
signature, | ||
publicKey | ||
); | ||
} | ||
} |