Skip to content

Commit

Permalink
[#312] Create public getters in singleton, mark proxy variables as in…
Browse files Browse the repository at this point in the history
…ternal
  • Loading branch information
akshay-ap committed Apr 25, 2024
1 parent 409e0aa commit f7aed3c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions modules/passkey/contracts/SafeWebAuthnSignerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ contract SafeWebAuthnSignerProxy {
/**
* @notice The X coordinate of the P-256 public key of the WebAuthn credential.
*/
uint256 public immutable X;
uint256 internal immutable X;
/**
* @notice The Y coordinate of the P-256 public key of the WebAuthn credential.
*/
uint256 public immutable Y;
uint256 internal immutable Y;
/**
* @notice The P-256 verifiers used for ECDSA signature validation.
*/
P256.Verifiers public immutable VERIFIERS;
P256.Verifiers internal immutable VERIFIERS;

/**
* @notice The contract address to which proxy contract forwards the call via delegatecall.
Expand Down
21 changes: 21 additions & 0 deletions modules/passkey/contracts/SafeWebAuthnSignerSingleton.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,25 @@ contract SafeWebAuthnSignerSingleton is SignatureValidator {
}
success = WebAuthn.verifySignature(message, signature, WebAuthn.USER_VERIFICATION, x, y, verifiers);
}

function getX() external view returns (uint256 x) {
// solhint-disable-next-line no-inline-assembly
assembly {
x := calldataload(sub(calldatasize(), 88))
}
}

function getY() external view returns (uint256 y) {
// solhint-disable-next-line no-inline-assembly
assembly {
y := calldataload(sub(calldatasize(), 56))
}
}

function getVerifiers() external view returns (P256.Verifiers verifiers) {
// solhint-disable-next-line no-inline-assembly
assembly {
verifiers := shr(64, calldataload(sub(calldatasize(), 24)))
}
}
}
1 change: 0 additions & 1 deletion modules/passkey/contracts/base/SignatureValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity >=0.8.0;

import {ERC1271} from "../libraries/ERC1271.sol";
import {P256} from "../libraries/WebAuthn.sol";

/**
* @title Signature Validator Base Contract
Expand Down
9 changes: 3 additions & 6 deletions modules/passkey/test/SafeWebAuthnSignerProxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ describe('SafeWebAuthnSignerProxy', () => {
describe('constructor', function () {
it('Should set immutables', async () => {
const { x, y, verifiers, signer } = await setupTests()

const signerProxy = await ethers.getContractAt('SafeWebAuthnSignerProxy', signer.target)
expect(await signerProxy.X()).to.equal(x)
expect(await signerProxy.Y()).to.equal(y)

expect(await signerProxy.VERIFIERS()).to.equal(verifiers)
expect(await signer.getX()).to.equal(x)
expect(await signer.getY()).to.equal(y)
expect(await signer.getVerifiers()).to.equal(verifiers)
})
})

Expand Down

0 comments on commit f7aed3c

Please sign in to comment.