exportKeyPairForStorage method

Map<String, String> exportKeyPairForStorage()

Serializes the RSA keypair into a JSON-safe map of hex strings.

This is useful when callers want to persist the paired keypair and restore it later with keyPairFromStorageMap.

Implementation

Map<String, String> exportKeyPairForStorage() {
  final privateKey = _keyPair.privateKey;
  return <String, String>{
    'modulus': _encodeBigIntHex(privateKey.modulus!),
    'publicExponent': _encodeBigIntHex(privateKey.publicExponent!),
    'privateExponent': _encodeBigIntHex(privateKey.privateExponent!),
    'p': _encodeBigIntHex(privateKey.p!),
    'q': _encodeBigIntHex(privateKey.q!),
  };
}