Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store Credential id with passkey #270

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Store Credential id with passkey #270

wants to merge 15 commits into from

Conversation

cpb8010
Copy link
Contributor

@cpb8010 cpb8010 commented Feb 4, 2025

Description

Support multiple passkeys per domain by looking up the credential id from the authenticator data. This is more efficient than just making a list and provides more information to passkey and account management.

Additional context

We also want to update the SDK to support this new init format and to use this credential id in this module instead of storing it as the unique id within the factory.

The odds that the parsing are correct is basically zero,
but right now I can't even build this locally so hopefully CI has better luck?
cpb8010 and others added 5 commits February 4, 2025 19:22
Parsing it from the auth data would only work on creation, not on get
can't figure out how to update pnpm lockfile
Also allows checking if the passkey exists so you can avoid
adding the same passkey to multiple accounts on the same domain
Annoying to do between two repos with the lockfile
For cross-origin support it would be possible to try the same
key on another domain.
You also might want to check if you have an account already without
knowing your address and just your passkey
@cpb8010 cpb8010 changed the title [Draft] Store Credential id with passkey Store Credential id with passkey Feb 7, 2025
This should help sync the contracts to the SSO repo when interating
on contracts
cpb8010 and others added 3 commits February 10, 2025 18:30
Without the extra layer it would have been possible to hide
someone's key in the map or to make it look like the map did exist
when it shouldn't have.
leftover from debugging
@cpb8010 cpb8010 self-assigned this Feb 11, 2025
@cpb8010 cpb8010 requested review from ly0va and MiniRoman February 12, 2025 01:48
Comment on lines +35 to +38
mapping(string originDomain => mapping(bytes credentialId => mapping(address accountAddress => bytes32 publicKey)))
public lowerKeyHalf;
mapping(string originDomain => mapping(bytes credentialId => mapping(address accountAddress => bytes32 publicKey)))
public upperKeyHalf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine these into a single mapping that maps to e.g. bytes32[2]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supported on mainnet now!?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

(bytes32[2] memory key32, string memory originDomain) = abi.decode(key, (bytes32[2], string));
bytes32 initialLowerHalf = lowerKeyHalf[originDomain][msg.sender];
bytes32 initialUpperHalf = upperKeyHalf[originDomain][msg.sender];
function removeValidationKey(bytes calldata credentialId, string calldata domain) external {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for having an internal/external pair of functions instead of having one public one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I call the internal one from onUninstall! So there's a memory/calldata difference

if (uint256(initialLowerHalf) != 0 || uint256(initialUpperHalf) != 0) {
return false;
}
if (keyExistsOnDomain[originDomain][credentialId] != address(0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it is impossible (from what I see) to have a zero key, is this check (and hence mapping) really necessary?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I would leave it here, as this one could replace AAFactory.accountMappings mapping for resolving account address from credentialId (and effectively remove it from AAFactory).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is more of a sanity check to prevent keyExistsOnDomain from falling out of sync with the public key storage. I can remove if we think there's no possibility of that happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants