Skip to content

Commit

Permalink
feat: new passkey signature format
Browse files Browse the repository at this point in the history
includes the credential id, which is hopefully available
  • Loading branch information
cpb8010 committed Feb 5, 2025
1 parent ba0fcdf commit e145cf9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/contracts
Submodule contracts updated 335 files
5 changes: 4 additions & 1 deletion packages/sdk/src/client/passkey/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export function createZksyncPasskeyClient<
credentialPublicKey: parameters.credentialPublicKey,
});

return passkeyHashSignatureResponseFormat(passkeySignature.passkeyAuthenticationResponse.response, parameters.contracts);
return passkeyHashSignatureResponseFormat(
passkeySignature.passkeyAuthenticationResponse.id,
passkeySignature.passkeyAuthenticationResponse.response,
parameters.contracts);
},
});
const client = createClient<transport, chain, Account, rpcSchema>({
Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/src/utils/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ function toArrayBuffer(data: string, isUrl: boolean) {
};

export function passkeyHashSignatureResponseFormat(
passkeyId: string,
passkeyResponse: {
authenticatorData: string;
clientDataJSON: string;
Expand All @@ -320,11 +321,13 @@ export function passkeyHashSignatureResponseFormat(
{ type: "bytes" }, // authData
{ type: "bytes" }, // clientDataJson
{ type: "bytes32[2]" }, // signature (two elements)
{ type: "string" }, // unique passkey id
],
[
toHex(base64UrlToUint8Array(passkeyResponse.authenticatorData)),
toHex(base64UrlToUint8Array(passkeyResponse.clientDataJSON)),
[toHex(signature.r), toHex(signature.s)],
toHex(base64UrlToUint8Array(passkeyId)),
],
);
const fullFormattedSig = encodeAbiParameters(
Expand Down

0 comments on commit e145cf9

Please sign in to comment.