Skip to content

Commit 5db1417

Browse files
ly0vacpb8010
andauthored
fix: pad bytes32 values for proper abi encoding (#61)
Co-authored-by: cpb8010 <cpb8010@users.noreply.github.com>
1 parent a084b27 commit 5db1417

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/sdk/src/utils/encoding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Address, encodeAbiParameters, getAbiItem, type Hash, type Hex, parseAbiParameters, toHex } from "viem";
1+
import { type Address, encodeAbiParameters, getAbiItem, type Hash, type Hex, pad, parseAbiParameters, toHex } from "viem";
22

33
import { SessionKeyModuleAbi } from "../abi/SessionKeyModule.js";
44
import { getPeriodIdsForTransaction, type SessionConfig } from "../utils/session.js";
@@ -52,7 +52,7 @@ export const encodePasskeyModuleParameters = (passkey: { passkeyPublicKey: [Buff
5252
{ type: "string", name: "expectedOrigin" },
5353
],
5454
[
55-
[toHex(passkey.passkeyPublicKey[0]), toHex(passkey.passkeyPublicKey[1])],
55+
[pad(toHex(passkey.passkeyPublicKey[0])), pad(toHex(passkey.passkeyPublicKey[1]))],
5656
passkey.expectedOrigin,
5757
],
5858
);

packages/sdk/src/utils/passkey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ECDSASigValue } from "@peculiar/asn1-ecc";
22
import { AsnParser } from "@peculiar/asn1-schema";
33
import { bigintToBuf, bufToBigint } from "bigint-conversion";
44
import { Buffer } from "buffer";
5-
import { type Address, encodeAbiParameters, type Hex, toHex } from "viem";
5+
import { type Address, encodeAbiParameters, type Hex, pad, toHex } from "viem";
66

77
enum COSEKEYS {
88
kty = 1, // Key Type
@@ -324,7 +324,7 @@ export function passkeyHashSignatureResponseFormat(
324324
[
325325
toHex(base64UrlToUint8Array(passkeyResponse.authenticatorData)),
326326
toHex(base64UrlToUint8Array(passkeyResponse.clientDataJSON)),
327-
[toHex(signature.r), toHex(signature.s)],
327+
[pad(toHex(signature.r)), pad(toHex(signature.s))],
328328
],
329329
);
330330
const fullFormattedSig = encodeAbiParameters(

0 commit comments

Comments
 (0)