gmkitx API - v0.10.1
    正在准备搜索索引...

    变量 decompressPublicKey常量

    decompressPublicKey: (publicKey: BytesLike) => string = sm2DecompressPublicKey

    旧版无前缀 SM2 公钥解压入口。

    类型声明

      • (publicKey: BytesLike): string
      • 解压公钥(从压缩格式转换为非压缩格式)

        从压缩格式恢复完整的公钥坐标。

        解压过程:

        1. 读取 x 坐标(32 字节)
        2. 读取前缀字节(02 或 03)确定 y 的奇偶性
        3. 根据椭圆曲线方程 y² = x³ + ax + b 计算 y²
        4. 对 y² 开平方得到两个可能的 y 值
        5. 根据前缀字节选择正确的 y 值(奇数或偶数)
        6. 组合 x 和 y 得到完整的非压缩公钥

        注意:

        • 如果输入已经是非压缩格式(前缀 04),则直接返回
        • 解压过程涉及模平方根计算,需要一定的计算量
        • 使用 @noble/curves 库进行高效的椭圆曲线运算

        参数

        • publicKey: BytesLike

          压缩格式的公钥(十六进制字符串,02/03 + x)或非压缩格式

        返回 string

        非压缩格式的公钥(十六进制字符串,04 + x + y)

        const compressed = '02...'; // 66 个字符
        const uncompressed = decompressPublicKey(compressed); // 130 个字符

    请改用 sm2DecompressPublicKey