PLSM2Sign
Cryptography
Description
Generates a GB/T 32918.2 signature over ZA || Message with a caller-supplied nonce source
Syntax
Delphi
Function PLSM2Sign(Const Curve: TPLSM2Curve; Const PrivateKey: TPLSM2Int;
Const Message, ZA: AnsiString; Const RandomK: TPLSM2RandomK;
Out R, S: AnsiString): Boolean;Parameters
| Curve | Curve parameters, normally the SM2P256V1 constant |
|---|---|
| PrivateKey | Private scalar d |
| Message | Raw message bytes; ZA must be prepended by the caller |
| ZA | User-ID digest from PLSM2ComputeZA |
| RandomK | Callback returning a fresh nonce per round as a 32-byte big-endian value; degenerate rounds are retried with a new nonce automatically |
| R | Receives the 32-byte big-endian signature part r |
| S | Receives the 32-byte big-endian signature part s |
Return values
| False | The nonce source failed or the private key is out of range |
|---|---|
| True | R and S hold the DER-ready signature pair in big-endian form |
Remarks
Part of the pure-Pascal SM2 suite (GB/T 32918) covering 256-bit prime-field arithmetic, Jacobian point operations and the SM3-based ZA derivation; the recommended sm2p256v1 curve ships as the SM2P256V1 constant and the specification appendix curve as SM2ExampleCurve
The nonce policy stays in the integrator's control, so CSPRNG and deterministic schemes are both possible; the published example-curve signature verifies byte-for-byte
See also
PLSM2Verify, PLSM2ComputeZA, PLSM2PublicKeyFromPrivate, PLValidateSM2Identity