this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ensure key bytes are correctly extracted based on prefix length

Actually fixes #1

futurGH 664ca1d8 a9ce6c98

+10 -3
+10 -3
src/util/crypto.ts
··· 7 7 8 8 const P256_DID_PREFIX = new Uint8Array([0x80, 0x24]); 9 9 const SECP256K1_DID_PREFIX = new Uint8Array([0xe7, 0x01]); 10 + // should equal P256_DID_PREFIX.length and SECP256K1_DID_PREFIX.length 11 + const DID_PREFIX_LENGTH = 2; 12 + 10 13 const BASE58_MULTIBASE_PREFIX = "z"; 11 14 const DID_KEY_PREFIX = "did:key:"; 12 15 ··· 101 104 const msgBytes = ui8.fromString(parts.slice(0, 2).join("."), "utf8"); 102 105 const sigBytes = ui8.fromString(sig, "base64url"); 103 106 104 - const signingKey = await resolveDidToSigningKey(payload.iss, false); 107 + const signingKey = await resolveDidToSigningKey(payload.iss, false).catch((e) => { 108 + console.error(e); 109 + throw new XRPCError(500, { kind: "InternalError", description: "Could not resolve DID" }); 110 + }); 105 111 106 112 let validSig: boolean; 107 113 try { ··· 313 319 314 320 const keyCurve = hasPrefix(prefixedBytes, P256_DID_PREFIX) 315 321 ? "p256" 316 - : hasPrefix(prefixedBytes, P256_DID_PREFIX) 322 + : hasPrefix(prefixedBytes, SECP256K1_DID_PREFIX) 317 323 ? "k256" 318 324 : null; 319 325 if (!keyCurve) throw new Error("Invalid curve for multikey: " + multikey); 320 - const keyBytes = decompressPubkey(keyCurve, prefixedBytes.subarray(keyCurve.length)); 326 + 327 + const keyBytes = decompressPubkey(keyCurve, prefixedBytes.subarray(DID_PREFIX_LENGTH)); 321 328 322 329 return { jwtAlg: keyCurve === "p256" ? P256_JWT_ALG : SECP256K1_JWT_ALG, keyBytes }; 323 330 };