Skip to content

Commit 35493c5

Browse files
authored
refine signing example review fixes
1 parent 415aaaa commit 35493c5

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

.agents/skills/building-with-hypercerts-lexicons/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ const cidBytes = cid.bytes; // 36 bytes: 0x01 0x71 0x12 0x20 + 32-byte hash
557557
// ECDSA hash-then-sign convention and enforces low-S per BIP-0062.
558558
const keypair = await Secp256k1Keypair.create({ exportable: false });
559559
const signerDid = keypair.did();
560+
if (!signerDid.startsWith("did:key:")) {
561+
throw new Error(`Expected did:key signer, got ${signerDid}`);
562+
}
560563
const signerKey = `${signerDid}#${signerDid.slice("did:key:".length)}`;
561564
const signatureBytes = await keypair.sign(cidBytes);
562565

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ const cidBytes = cid.bytes; // 36 bytes: 0x01 0x71 0x12 0x20 + 32-byte hash
641641
// ECDSA hash-then-sign convention and enforces low-S per BIP-0062.
642642
const keypair = await Secp256k1Keypair.create({ exportable: false });
643643
const signerDid = keypair.did();
644+
if (!signerDid.startsWith("did:key:")) {
645+
throw new Error(`Expected did:key signer, got ${signerDid}`);
646+
}
644647
const signerKey = `${signerDid}#${signerDid.slice("did:key:".length)}`;
645648
const signatureBytes = await keypair.sign(cidBytes);
646649

tests/validate-signing-example.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { verifySignature } from "@atproto/crypto";
2626
import * as Activity from "../generated/types/org/hypercerts/claim/activity.js";
2727

2828
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
29-
const EXTRACT_DIR = resolve(ROOT, "tmp/extracted-signing-examples");
29+
const EXTRACT_DIR = resolve(ROOT, "tmp/extracted");
3030

3131
interface ExtractedExample {
3232
signedActivity: { signatures: unknown[] };
@@ -244,7 +244,7 @@ for (const [label, relPath, basename] of SOURCES) {
244244
expect(result.success).toBe(true);
245245
});
246246

247-
it("produced signature verifies against the signing public key", async () => {
247+
it("the produced signature verifies against the signing public key", async () => {
248248
const ok = await verifySignature(
249249
example.keypair.did(),
250250
example.cidBytes,

0 commit comments

Comments
 (0)