Skip to content

Commit

Permalink
🔨 util script to extract signer from authdata
Browse files Browse the repository at this point in the history
  • Loading branch information
qd-qd committed Apr 4, 2024
1 parent e3ce147 commit 69845c9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions script/utils/ExtractSignerAuthData.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: APACHE-2.0
pragma solidity >=0.8.19 <0.9.0;

import { BaseScript } from "script/Base.s.sol";
import { SignerVaultWebAuthnP256R1 } from "src/utils/SignerVaultWebAuthnP256R1.sol";

/// @title ExtractSignerAuthData
/// @notice Extract a signer from the auth data
contract ExtractSignerAuthData is BaseScript {
function extractSignerAuthData(bytes calldata authData)
external
pure
returns (bytes memory credId, bytes32 credIdHash, uint256 pubkeyX, uint256 pubkeyY)
{
return SignerVaultWebAuthnP256R1.extractSignerFromAuthData(authData);
}

function run()
external
view
returns (
bytes memory credId,
bytes32 credIdHash,
uint256 pubkeyX,
bytes32 pubkeyXHex,
uint256 pubkeyY,
bytes32 pubkeyYHex
)
{
// 1. get the auth data
bytes memory authData = vm.envBytes("AUTH_DATA");

// 2. extract the signer from the auth data
(credId, credIdHash, pubkeyX, pubkeyY) = ExtractSignerAuthData(address(this)).extractSignerAuthData(authData);

// 3. convert the pubkey coordinates to hex
pubkeyXHex = bytes32(pubkeyX);
pubkeyYHex = bytes32(pubkeyY);
}
}

0 comments on commit 69845c9

Please sign in to comment.