Lines 1-87python
4Skill keypair management (consumer side only)
6The private key is generated by the backend during Skill registration;
7the seller persists it to .keypair.json during initialization.
8This module only reads and normalizes the format (raw Base64 -> PEM).
10File location: <skill_dir>/.keypair.json
13 "skill_code": "<32-char skillCode>",
14 "private_key": "-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----",
CriticalCritical Secret
Package contains a critical-looking secret pattern.
dist/scripts/skill_keypair.pyView on unpkg · L14 CriticalSecret Pattern
RSA private key in dist/scripts/skill_keypair.py
dist/scripts/skill_keypair.pyView on unpkg · L14 15 "sign_method": "SHA256withRSA"
18private_key can also be raw Base64 (PKCS#8 single-line); this module auto-wraps it into PEM.
21from __future__ import annotations
26from typing import Dict
31class SkillKeypairError(RuntimeError):
35def _to_pem(private_key_str: str) -> bytes:
36 """Normalize a private key string into PEM bytes.
38 Supports two input formats:
39 - Already PEM text (with -----BEGIN/-----END headers);
40 - Raw Base64 PKCS#8 single-line (no headers), auto-wrapped into PEM.
42 s = private_key_str.strip()
44 raise SkillKeypairError("private_key is empty")
45 if "BEGIN" in s and "END" in s:
46 # Already PEM; normalize line endings
47 return s.replace("\r\n", "\n").encode("utf-8")
48 # Raw Base64 -> wrap as PEM; fold at 64 chars
49 body = "\n".join(textwrap.wrap(s, 64))
50 pem = f"-----BEGIN PRIVATE KEY-----\n{body}\n-----END PRIVATE KEY-----\n"
CriticalSecret Pattern
RSA private key in dist/scripts/skill_keypair.py
dist/scripts/skill_keypair.pyView on unpkg · L50 51 return pem.encode("utf-8")
54def load_keypair(path: str = None) -> Dict:
55 """Read .keypair.json and return a dict.
59 - private_key_pem: bytes (PEM format, can be fed directly to cryptography.serialization.load_pem_private_key)
60 - sign_method: str (default SHA256withRSA)
62 path = path or config.KEYPAIR_FILE
63 if not os.path.exists(path):
64 raise SkillKeypairError(
65 f".keypair.json not found: {path}\n"
66 f"Please persist the Skill-registered private key and skillCode to this file.\n"
67 f"Template: {{\"skill_code\":\"...\",\"private_key\":\"-----BEGIN PRIVATE KEY-----...\",\"sign_method\":\"SHA256withRSA\"}}"
CriticalSecret Pattern
RSA private key in dist/scripts/skill_keypair.py
dist/scripts/skill_keypair.pyView on unpkg · L67 70 with open(path, "r", encoding="utf-8") as f:
72 except json.JSONDecodeError as e:
73 raise SkillKeypairError(f".keypair.json parse failed: {e}") from e
75 skill_code = (raw.get("skill_code") or "").strip()
76 private_key = raw.get("private_key") or ""
78 raise SkillKeypairError(".keypair.json missing skill_code")
80 raise SkillKeypairError(".keypair.json missing private_key")
83 "skill_code": skill_code,
84 "private_key_pem": _to_pem(private_key),
85 "sign_method": (raw.get("sign_method") or "SHA256withRSA").strip(),