TPLSM2Curve

Data types, cryptography

Description

TPLSM2Curve holds one SM2 prime-field curve. P is the field modulus, A and B define y^2 = x^3 + Ax + B mod P, Gx and Gy are the base point coordinates, and N is the order of the base point.

The unit exports two ready-made typed constants: SM2P256V1 for the recommended GB/T 32918.5 curve, and SM2ExampleCurve for the example curve published in the specification appendix. Either can be passed directly to any SM2 routine.

The record has no name field, so a caller that needs a curve label keeps it beside the parameters.

Syntax

Delphi

TPLSM2Curve = Record
  P, A, B, N, Gx, Gy: TPLSM2Int;
End;

Fields

PField prime
ACurve coefficient A
BCurve coefficient B
NOrder of the base point
GxX coordinate of the base point G
GyY coordinate of the base point G

Remarks

SM2P256V1 is the normal signing curve; SM2ExampleCurve exists so the published key pair, ZA, digest and signature can be reproduced byte for byte.

The routines take the record as a const parameter, and every member is public, so a custom curve can be filled field by field.

Both constants are declared in the interface section, so either can initialize a variable or be passed directly to a routine.

See also

PLSM2ComputeZA, PLSM2PublicKeyFromPrivate, PLSM2Sign, PLSM2Verify, PLSM2PointOnCurve, PLSM2PointMul