{
  "slug": "sm2-public-from-private",
  "name": "gizza-ai/sm2-public-from-private",
  "version": "0.1.0",
  "title": "SM2 Public Key from Private Key — Derive Q = d·G (GM/T 0003) — gizza.ai",
  "description": "Derive an SM2 public key from a private key (GM/T 0003, curve sm2p256v1) — hex scalar or PKCS#8 PEM in, SEC1 hex and SPKI PEM out. In-browser, no upload.",
  "tags": [
    "sm2",
    "sm2p256v1",
    "public key",
    "private key",
    "gm/t 0003",
    "oscca",
    "sec1",
    "pkcs8"
  ],
  "category": "security",
  "urls": {
    "page": "https://gizza.ai/tools/sm2-public-from-private/",
    "markdown": "https://gizza.ai/tools/sm2-public-from-private/index.md",
    "descriptor": "https://gizza.ai/tools/sm2-public-from-private/tool.json",
    "deep_link_example": "https://gizza.ai/tools/sm2-public-from-private/?private_key=3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8&input_format=auto&output_format=all"
  },
  "cli": "gizza tool sm2-public-from-private \"3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8\"",
  "tool": {
    "description": "Derive the SM2 public key from a private key (Chinese national standard GM/T 0003, OSCCA curve sm2p256v1). Supply private_key as a raw 32-byte private scalar in hex (input_format=hex) or a PKCS#8 PEM (input_format=pem); input_format=auto (default) detects which. The public point Q = d·G is computed locally and returned per output_format: 'all' (default) a summary of every encoding, 'uncompressed' SEC1 hex (04 || x || y), 'compressed' SEC1 hex (02|03 || x), or 'pem' SPKI PEM. Deterministic, no RNG. The private key is never echoed back — only public key material is returned. To create a fresh SM2 key pair instead, use sm2-keypair-generate.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "input_format": {
          "default": "auto",
          "description": "How to interpret private_key: 'auto' (default) detects a PEM block, otherwise parses raw hex; 'hex' forces a raw 32-byte hex scalar; 'pem' forces PKCS#8 PEM.",
          "enum": [
            "auto",
            "hex",
            "pem"
          ],
          "type": "string"
        },
        "output_format": {
          "default": "all",
          "description": "Which encoding of the derived public key to return: 'all' (default) a labelled summary of every encoding; 'uncompressed' SEC1 uncompressed hex (04 || x || y, 130 chars); 'compressed' SEC1 compressed hex (02|03 || x, 66 chars); 'pem' SPKI PEM (-----BEGIN PUBLIC KEY-----).",
          "enum": [
            "all",
            "uncompressed",
            "compressed",
            "pem"
          ],
          "type": "string"
        },
        "private_key": {
          "description": "The SM2 private key. Either a raw 32-byte private scalar in hexadecimal (64 hex chars, an optional leading 0x is accepted) or a PKCS#8 PEM block (-----BEGIN PRIVATE KEY-----). The scalar must be in [1, n-1] for the sm2p256v1 curve.",
          "type": "string"
        }
      },
      "required": [
        "private_key"
      ],
      "type": "object"
    }
  }
}