SM2-Sign
China's national elliptic-curve signature algorithm (GB/T 32918)
Experimental or unclassified. Root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About SM2-Sign
SM2-Sign is a digital signature scheme from the SM2 digital signature family. It uses a 65-byte public key, a 32-byte secret key, a 64-byte signature and a 32-byte seed. Its registry entry cites GB/T 32918.2 and RFC 8998. It is also known as sm2-dsa. NextSSL lists it in the research tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
Overview
SM2 is the Chinese national standard for elliptic-curve public-key cryptography, covering signatures, key exchange and encryption. The signature part is an ECDSA-like scheme on a 256-bit prime curve, used with the SM3 hash function.
SM2 signatures use a dedicated 256-bit prime-field curve specified in the standard. Before hashing the message, the signer computes Z_A, a hash over the user's distinguishing identifier, curve parameters and public key, and prepends it to the message, binding signatures to a specific identity. The signing equation differs from ECDSA: the signature (r, s) satisfies s = (1 + d)^-1 (k - r*d), which avoids computing a modular inverse of the nonce.
SM2 is mandated for many applications in China and is registered for TLS 1.3 by RFC 8998, together with SM3 and SM4. One variant, sm2-sign, is present; NextSSL classifies it as research because it has not yet been verified against the full set of official vectors. Beyond signatures, the SM2 standard also defines a key exchange protocol and a public-key encryption scheme, which are not part of this family.
History
2010–2021SM2 published by the Chinese State Cryptography Administration
Standardised as GB/T 32918
Used in TLS 1.3 via RFC 8998
How it works
- KeyGen picks a scalar d and publishes P = dG on the SM2 curve.
- Sign computes e = SM3(Z_A || M), picks a nonce k, and sets r = (e + x(kG)) mod n.
- It computes s = (1 + d)^-1 (k - r*d) mod n and outputs (r, s).
- Verify computes t = r + s and checks that r equals e + x(sG + tP) mod n.
Security notes
Not post-quantum. Like ECDSA, nonce reuse or bias leaks the private key, and the identifier used in Z_A must match between signer and verifier for signatures to validate.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| pk | 65 | Public key |
| sk | 32 | Secret key |
| sig | 64 | Signature |
| seed | 32 | Seed |
| ctx | 0 | Context string |
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'research' is reachable from the root API only
pk, sk = root.call("sign_keygen", "sm2-sign", None, outs=2)
sig = root.call("sign_detached", "sm2-sign", None, sk, b"message", b"")[0]
ok = root.check("verify_detached", "sm2-sign", None, pk, b"message", b"", sig)
nextssl_root_sign_keygen("sm2-sign", NULL, pk, sk);
nextssl_root_sign_detached("sm2-sign", NULL, sk, msg, ctx, sig);
nextssl_root_verify_detached("sm2-sign", NULL, pk, msg, ctx, sig);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_sign_in(reg::all(), Policy::Any, "sm2-sign", &Params::new())?;
let (pk, sk) = alg.keygen(&mut *rng)?;
let sig = alg.sign(&sk, b"message")?;
let ok = alg.verify(&pk, b"message", &sig)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Similar names
Looking for something else?More digital signatures
All 503Frequently asked questions
What is SM2-Sign?
SM2-Sign is a signature in the SM2 digital signature family. SM2 is the Chinese national standard for elliptic-curve public-key cryptography, covering signatures, key exchange and encryption. It is also known as sm2-dsa.
What are the SM2-Sign sizes?
In NextSSL, SM2-Sign uses: public key 65 bytes, signature 64 bytes.
Is SM2-Sign post-quantum?
No. SM2-Sign is a classical signature based on elliptic curves or discrete logarithms, which a large quantum computer running Shor's algorithm could break. For post-quantum use, look at ML-DSA or SLH-DSA.
Who designed SM2-Sign and when?
SM2-Sign belongs to the SM2 digital signature family, first published in 2010. Its origin: GB/T 32918.2 (China); RFC 8998.
Which standards define SM2-Sign?
SM2-Sign is referenced by GB/T 32918.2, RFC 8998.
Is SM2-Sign safe to use?
SM2-Sign is in the research tier. Experimental or unclassified. Root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).