{"id":25254192,"url":"https://github.com/base/webauthn-sol","last_synced_at":"2025-04-05T20:05:29.158Z","repository":{"id":225092118,"uuid":"763698579","full_name":"base/webauthn-sol","owner":"base","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-15T17:26:33.000Z","size":1046,"stargazers_count":278,"open_issues_count":25,"forks_count":115,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-03-29T19:02:16.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/base.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":"audits/report-review-coinbase-webauthn.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T19:03:21.000Z","updated_at":"2025-03-24T15:03:40.000Z","dependencies_parsed_at":"2024-04-04T21:40:57.219Z","dependency_job_id":"c6a0c7e3-a697-45ad-8b3d-07b090def701","html_url":"https://github.com/base/webauthn-sol","commit_stats":null,"previous_names":["base-org/webauthn-sol","base/webauthn-sol"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fwebauthn-sol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fwebauthn-sol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fwebauthn-sol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fwebauthn-sol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base","download_url":"https://codeload.github.com/base/webauthn-sol/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393568,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-12T05:25:43.739Z","updated_at":"2025-04-05T20:05:29.134Z","avatar_url":"https://github.com/base.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Solidity WebAuthn Authentication Assertion Verifier\n\nWebauthn-sol is a Solidity library for verifying WebAuthn authentication assertions. It builds on [Daimo's WebAuthn.sol](https://github.com/daimo-eth/p256-verifier/blob/master/src/WebAuthn.sol).\n\nThis library is optimized for Ethereum layer 2 rollup chains but will work on all EVM chains. Signature verification always attempts to use the [RIP-7212 precompile](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md) and, if this fails, falls back to using [FreshCryptoLib](https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_ecdsa.sol#L40).\n\n\u003e [!IMPORTANT]  \n\u003e FreshCryptoLib uses the `ModExp` precompile (`address(0x05)`), which is not supported on some chains, such as [Polygon zkEVM](https://www.rollup.codes/polygon-zkevm#precompiled-contracts). This library will not work on such chains, unless they support the RIP-7212 precompile. \n\nCode excerpts\n\n```solidity\nstruct WebAuthnAuth {\n    /// @dev https://www.w3.org/TR/webauthn-2/#dom-authenticatorassertionresponse-authenticatordata\n    bytes authenticatorData;\n    /// @dev https://www.w3.org/TR/webauthn-2/#dom-authenticatorresponse-clientdatajson\n    string clientDataJSON;\n    /// The index at which \"challenge\":\"...\" occurs in clientDataJSON\n    uint256 challengeIndex;\n    /// The index at which \"type\":\"...\" occurs in clientDataJSON\n    uint256 typeIndex;\n    /// @dev The r value of secp256r1 signature\n    uint256 r;\n    /// @dev The s value of secp256r1 signature\n    uint256 s;\n}\n\nfunction verify(\n    bytes memory challenge,\n    bool requireUserVerification,\n    WebAuthnAuth memory webAuthnAuth,\n    uint256 x,\n    uint256 y\n) internal view returns (bool) \n```\n\nexample usage\n```solidity\nbytes challenge = abi.encode(0xf631058a3ba1116acce12396fad0a125b5041c43f8e15723709f81aa8d5f4ccf);\nuint256 x = 28573233055232466711029625910063034642429572463461595413086259353299906450061;\nuint256 y = 39367742072897599771788408398752356480431855827262528811857788332151452825281;\nWebAuthn.WebAuthnAuth memory auth = WebAuthn.WebAuthnAuth({\n    authenticatorData: hex\"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000101\",\n    clientDataJSON: string.concat(\n        '{\"type\":\"webauthn.get\",\"challenge\":\"', Base64Url.encode(challenge), '\",\"origin\":\"http://localhost:3005\"}'\n        ),\n    challengeIndex: 23,\n    typeIndex: 1,\n    r: 43684192885701841787131392247364253107519555363555461570655060745499568693242,\n    s: 22655632649588629308599201066602670461698485748654492451178007896016452673579\n});\n```\n\n### Developing \nAfter cloning the repo, run the tests using Forge, from [Foundry](https://github.com/foundry-rs/foundry?tab=readme-ov-file)\n```bash\nforge test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase%2Fwebauthn-sol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase%2Fwebauthn-sol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase%2Fwebauthn-sol/lists"}