Skip to main content

encode

Function encode 

Source
pub fn encode(
    scalar_be: &[u8; 32],
    public_uncompressed: Option<&[u8; 65]>,
) -> Vec<u8>
Expand description

Encode an SM2 ECPrivateKey (RFC 5915) into DER bytes.

scalar_be is the 32-byte big-endian private scalar. The parameters field is emitted with namedCurve = sm2p256v1; the optional publicKey BIT STRING is emitted as the 65-byte uncompressed point when Some.

The intermediate body buffer is zeroized before return — the caller-supplied scalar_be slice is not zeroized (caller owns it).