@parmanasystems/crypto 1.71.12 → 1.71.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +66 -24
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@ Ed25519 signing and verification primitives for governance artifacts.
10
10
 
11
11
  `@parmanasystems/crypto` provides the low-level cryptographic operations used across the Parmana Systems governance pipeline: signing and verifying bundle manifests, loading trust root keys from disk, and packaging bundles with Ed25519 signatures.
12
12
 
13
- Most applications should use `@parmanasystems/core`. Use this package directly only when building tooling that needs the raw signing primitives — for example, a CI step that signs a bundle before deployment.
13
+ Most applications should use `@parmanasystems/core` or `@parmanasystems/governance`. Use this package directly only when building tooling that needs the raw signing primitives — for example, a CI step that signs a bundle before deployment.
14
14
 
15
15
  ---
16
16
 
@@ -22,53 +22,95 @@ npm install @parmanasystems/crypto
22
22
 
23
23
  ---
24
24
 
25
- ## Usage
25
+ ## Key Management
26
+
27
+ Generate an Ed25519 keypair and store the PEM files on disk:
26
28
 
27
29
  ```typescript
28
- import { signBundle, loadPublicKey } from "@parmanasystems/crypto";
29
- import { LocalSigner } from "@parmanasystems/execution";
30
30
  import crypto from "crypto";
31
+ import fs from "fs";
31
32
 
32
- const { privateKey } = crypto.generateKeyPairSync("ed25519", {
33
+ const { privateKey, publicKey } = crypto.generateKeyPairSync("ed25519", {
33
34
  privateKeyEncoding: { type: "pkcs8", format: "pem" },
34
35
  publicKeyEncoding: { type: "spki", format: "pem" },
35
36
  });
36
37
 
37
- const signer = new LocalSigner(privateKey);
38
+ // Store keys in production use a secrets manager, not plain files
39
+ fs.mkdirSync("trust", { recursive: true });
40
+ fs.writeFileSync("trust/root.key", privateKey, { mode: 0o600 });
41
+ fs.writeFileSync("trust/root.pub", publicKey);
42
+ ```
38
43
 
39
- // Sign a built bundle directorywrites bundle.sig next to bundle.manifest.json
40
- await signBundle({
41
- bundlePath: "./dist/bundles/loan-approval",
42
- signer,
43
- });
44
+ Pass paths **explicitly** to all signing and verification functions there is no implicit key discovery.
45
+
46
+ ---
47
+
48
+ ## Usage
49
+
50
+ ### Load keys from disk
51
+
52
+ ```typescript
53
+ import { loadPrivateKey, loadPublicKey } from "@parmanasystems/crypto";
54
+
55
+ // Both functions require an explicit path — there is no default path fallback
56
+ const privateKeyPem = loadPrivateKey("./trust/root.key");
57
+ const publicKeyPem = loadPublicKey("./trust/root.pub");
44
58
  ```
45
59
 
46
- ### Sign a manifest file directly
60
+ ### Sign a manifest file
47
61
 
48
62
  ```typescript
49
63
  import { signManifest } from "@parmanasystems/crypto";
50
64
 
51
- // Reads bundle.manifest.json, canonicalizes, signs with trust root key from disk
52
- const signature = signManifest("./dist/bundles/loan-approval/bundle.manifest.json");
65
+ // Both arguments are required
66
+ const signature = signManifest(
67
+ "./policies/loan-approval/v1/bundle.manifest.json", // path to manifest
68
+ "./trust/root.key" // path to Ed25519 private key PEM
69
+ );
53
70
  console.log(signature); // base64-encoded Ed25519 signature
54
71
  ```
55
72
 
56
- ---
73
+ ### Verify a manifest signature
57
74
 
58
- ## Exports
75
+ ```typescript
76
+ import { verifySignature } from "@parmanasystems/crypto";
77
+
78
+ // All three arguments are required
79
+ const ok = verifySignature(
80
+ "./policies/loan-approval/v1/bundle.manifest.json", // path to manifest
81
+ signature, // base64 signature string
82
+ "./trust/root.pub" // path to Ed25519 public key PEM
83
+ );
84
+ console.log(ok); // true
85
+ ```
59
86
 
60
- | Export | Description |
61
- |---|---|
62
- | `signBundle` | Sign a bundle directory — reads `bundle.manifest.json`, writes `bundle.sig` |
63
- | `signManifest` | Sign a manifest file using the trust root private key from disk |
64
- | `loadPrivateKey` | Load the trust root Ed25519 private key PEM from `trust/root.key` |
65
- | `loadPublicKey` | Load the trust root Ed25519 public key PEM from `trust/root.pub` |
87
+ ### Sign a bundle directory
88
+
89
+ ```typescript
90
+ import { signBundle } from "@parmanasystems/crypto";
91
+
92
+ // Signs bundle.manifest.json in the directory and writes bundle.sig
93
+ await signBundle({
94
+ bundlePath: "./policies/loan-approval/v1",
95
+ privateKeyPath: "./trust/root.key",
96
+ });
97
+ ```
66
98
 
67
99
  ---
68
100
 
69
- ## Trust root key location
101
+ ## Exports
70
102
 
71
- By default `loadPrivateKey` and `loadPublicKey` read from `trust/root.key` and `trust/root.pub` relative to `process.cwd()`. In production, inject key material via a secrets manager rather than files on disk.
103
+ | Export | Description |
104
+ |---|---|
105
+ | `loadPrivateKey` | Load Ed25519 private key PEM from an explicit file path |
106
+ | `loadPublicKey` | Load Ed25519 public key PEM from an explicit file path |
107
+ | `signManifest` | Sign a `bundle.manifest.json` file; returns base64 Ed25519 signature |
108
+ | `verifySignature` | Verify a base64 signature over a manifest file using a public key path |
109
+ | `verifyPayloadSignature` | Verify a base64 signature over an arbitrary UTF-8 payload string |
110
+ | `verifyManifestSignature` | Verify a `bundle.sig` file against a manifest on disk |
111
+ | `signBundle` | Sign a bundle directory — reads manifest, writes `bundle.sig` |
112
+ | `writeSignature` | Write a base64 signature string to `bundle.sig` in a directory |
113
+ | `readSignature` | Read a `bundle.sig` file and return the base64 signature string |
72
114
 
73
115
  ---
74
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parmanasystems/crypto",
3
- "version": "1.71.12",
3
+ "version": "1.71.14",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "sideEffects": false,
20
20
  "dependencies": {
21
- "@parmanasystems/bundle": "^1.71.12"
21
+ "@parmanasystems/bundle": "^1.71.14"
22
22
  },
23
23
  "description": "Signing and verification primitives for deterministic governance infrastructure.",
24
24
  "license": "Apache-2.0",