← Cryptography guide

K046 / Asymmetric encryption, signatures and key exchange

SM2

SM2 elliptic curve · Survey date 2026-12-05

A Chinese national elliptic-curve public-key cryptographic family defined in GB/T 32918.

CRYPTOGRAPHY LAB / K046

Cryptography Lab · SM2

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

SM2 sign + verify (precomputed digest; ZA/SM3 stage excluded)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Open lab →

Definition and overview
A Chinese national elliptic-curve public-key cryptographic family defined in GB/T 32918. Source document ↗
Classification and reversibility
Reversible public-key encryption; recipient decrypts with private key. Source document ↗
Key or secret requirements
Requires public key and 256-bit secret private key pair. Source document ↗
Operating principle and structure
Elliptic-curve point operations and random k construct shared point/ciphertext. Source document ↗
Key size, block size and parameters
Uses sm2p256v1 256-bit prime-field curve (a=p-3). Source document ↗
Security strength and recommendation
About 128-bit security with 256-bit prime-field curve. Source document ↗
Known attacks and vulnerabilities
SM2-PKE random-entropy flaws can reduce security from 128 to about 16 bits. Source document ↗
Standards and certification
RFC 9563 specifies SM2+SM3 for DNSSEC. Source document ↗
Typical uses
Used in Chinese government services, banking and certificates. Source document ↗
Implementations, libraries and tools
JavaScript libraries such as sm-crypto. Source document ↗
Decryption or decoding
Extract three ciphertext components, decrypt with private key and verify. Source document ↗
Advantages
256-bit keys provide roughly RSA-3072 strength with smaller keys and fewer operations. Source document ↗
Limitations and cautions
Ciphertext is 96 bytes longer than plaintext with the 256-bit curve. Source document ↗
Distinguishing encryption, encoding and hashing
Randomness makes identical plaintext yield different ciphertext; distinguish from fixed-output encoding/hashing. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Sender encrypts with recipient public key to C1C3C2 ciphertext; recipient decrypts privately. Sign with private key and verify publicly; key exchange agrees secret with both pairs. Handle real keys/randomness using secure generators.

Procedure

Confirm trusted public key, encrypt with secure randomness and record ciphertext mode and encoding. Parse/verify and decrypt with private key. Encoding is keyless reversible; hashing irreversible; SM2 needs key/randomness and supports decryption.

Scenario

For Chinese public/financial integrations using SM2 TLS, certificates or signatures, align GB/T 32918/RFC profiles and ciphertext format. Separate signing, exchange, encryption; hybrid encryption for large data.

Pitfalls and alternatives

Do not directly encrypt/decrypt bulk data with SM2; use symmetric keys and encapsulation/hybrid encryption. Avoid format/encoding/curve/standard mismatch, repeated or weak randomness and vulnerable implementations. Use vetted current libraries.

References