Skip to content

Commit 585c281

Browse files
authored
Update main.go
1 parent 8e30f13 commit 585c281

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

cmd/ix-an/main.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func verifyCmd(args []string) {
5050
strictHashes := fs.Bool("strict-hashes", false, "fail if parameters_hash/output_hash are placeholders or missing")
5151
strictSig := fs.Bool("strict-signature", false, "fail if signature is missing/placeholder or public key can't be resolved")
5252
strictApprovals := fs.Bool("strict-approvals", false, "fail if any approval is missing a valid signature")
53-
pubKeyPath := fs.String("pubkey", "", "optional path to an ed25519 public key (base64url). Overrides key lookup by key_id.")
53+
pubKeyPath := fs.String("pubkey", "", "optional exact path to an ed25519 public key file (base64url). Highest-precedence lookup.")
54+
pubKeyDir := fs.String("pubkey-dir", "", "optional directory containing <key_id>.pub. If unset, lookup defaults to keys/ then keys/dev/ relative to cwd.")
5455
strictChain := fs.Bool("strict-chain", false, "verify parent_receipt_id chain (loads parent receipts from --chain-dir or receipt directory). Implies strict hashes+signature for the leaf.")
5556
chainDir := fs.String("chain-dir", "", "directory to search for parent receipts (default: directory containing the receipt)")
5657

@@ -81,6 +82,7 @@ func verifyCmd(args []string) {
8182
StrictSignature: *strictSig,
8283
StrictApprovals: *strictApprovals,
8384
PublicKeyPathOpt: *pubKeyPath,
85+
PublicKeyDirOpt: *pubKeyDir,
8486
StrictChain: *strictChain,
8587
ChainDir: *chainDir,
8688
})
@@ -125,7 +127,8 @@ func verifyDirCmd(args []string) {
125127
fs.SetOutput(os.Stderr)
126128

127129
schemaPath := fs.String("schema", "", "path to receipt JSON Schema (default: spec/receipt.schema.json)")
128-
pubKeyPath := fs.String("pubkey", "", "optional path to an ed25519 public key (base64url). Overrides key lookup by key_id.")
130+
pubKeyPath := fs.String("pubkey", "", "optional exact path to an ed25519 public key file (base64url). Highest-precedence lookup.")
131+
pubKeyDir := fs.String("pubkey-dir", "", "optional directory containing <key_id>.pub. If unset, lookup defaults to keys/ then keys/dev/ relative to cwd.")
129132
strictApprovals := fs.Bool("strict-approvals", false, "fail if any approval is missing a valid signature")
130133
strictChain := fs.Bool("strict-chain", true, "verify parent_receipt_id linkage for all receipts found (default: true)")
131134

@@ -153,6 +156,7 @@ func verifyDirCmd(args []string) {
153156
Dir: dir,
154157
SchemaPath: *schemaPath,
155158
PublicKeyPath: *pubKeyPath,
159+
PublicKeyDir: *pubKeyDir,
156160
StrictHashes: true,
157161
StrictSignature: true,
158162
StrictApprovals: *strictApprovals,
@@ -319,7 +323,8 @@ func storeAppendCmd(args []string) {
319323
inPath := fs.String("in", "", "input receipt JSON path (required)")
320324
logPath := fs.String("log", "", "append-only JSONL log path (required)")
321325
schemaPath := fs.String("schema", "", "path to receipt JSON Schema (default: spec/receipt.schema.json)")
322-
pubKeyPath := fs.String("pubkey", "", "optional path to an ed25519 public key (base64url). Overrides key lookup by key_id.")
326+
pubKeyPath := fs.String("pubkey", "", "optional exact path to an ed25519 public key file (base64url). Highest-precedence lookup.")
327+
pubKeyDir := fs.String("pubkey-dir", "", "optional directory containing <key_id>.pub. If unset, lookup defaults to keys/ then keys/dev/ relative to cwd.")
323328
strictApprovals := fs.Bool("strict-approvals", false, "fail if any approval is missing a valid signature (before ingest)")
324329

325330
if err := fs.Parse(args); err != nil {
@@ -334,14 +339,14 @@ func storeAppendCmd(args []string) {
334339
os.Exit(2)
335340
}
336341

337-
// Strictly verify before ingest.
338342
if _, err := verify.Run(verify.Options{
339343
ReceiptPath: *inPath,
340344
SchemaPath: *schemaPath,
341345
StrictHashes: true,
342346
StrictSignature: true,
343347
StrictApprovals: *strictApprovals,
344348
PublicKeyPathOpt: *pubKeyPath,
349+
PublicKeyDirOpt: *pubKeyDir,
345350
}); err != nil {
346351
fmt.Fprintf(os.Stderr, "FAIL: receipt did not verify strictly; not ingesting: %v\n", err)
347352
os.Exit(1)
@@ -367,7 +372,8 @@ func storeVerifyLogCmd(args []string) {
367372

368373
logPath := fs.String("log", "", "append-only JSONL log path (required)")
369374
schemaPath := fs.String("schema", "", "path to receipt JSON Schema (default: spec/receipt.schema.json)")
370-
pubKeyPath := fs.String("pubkey", "", "optional path to an ed25519 public key (base64url). Overrides key lookup by key_id.")
375+
pubKeyPath := fs.String("pubkey", "", "optional exact path to an ed25519 public key file (base64url). Highest-precedence lookup.")
376+
pubKeyDir := fs.String("pubkey-dir", "", "optional directory containing <key_id>.pub. If unset, lookup defaults to keys/ then keys/dev/ relative to cwd.")
371377
strictChain := fs.Bool("strict-chain", true, "verify parent_receipt_id linkage within the log (default: true)")
372378
strictApprovals := fs.Bool("strict-approvals", false, "fail if any approval is missing a valid signature")
373379

@@ -413,13 +419,13 @@ func storeVerifyLogCmd(args []string) {
413419
byID[rid] = r
414420
}
415421

416-
// Strictly validate all receipts.
417422
for rid, r := range byID {
418423
_, _, _, verr := verify.ValidateReceiptObject(r, schema, verify.ReceiptValidationOptions{
419424
StrictHashes: true,
420425
StrictSignature: true,
421426
StrictApprovals: *strictApprovals,
422427
PublicKeyPath: *pubKeyPath,
428+
PublicKeyDir: *pubKeyDir,
423429
})
424430
if verr != nil {
425431
fmt.Fprintf(os.Stderr, "FAIL: receipt %s failed verify: %v\n", rid, verr)
@@ -440,6 +446,7 @@ func storeVerifyLogCmd(args []string) {
440446
StrictSignature: true,
441447
StrictApprovals: *strictApprovals,
442448
PublicKeyPath: *pubKeyPath,
449+
PublicKeyDir: *pubKeyDir,
443450
})
444451
return verr
445452
}

0 commit comments

Comments
 (0)