code: def create_privkey(self):
          
          if self.group in _tls_named_ffdh_groups:
              params = _ffdh_groups[_tls_named_ffdh_groups[self.group]][0]
              privkey = params.generate_private_key()
              self.privkey = privkey
              pubkey = privkey.public_key()
              self.key_exchange = pubkey.public_numbers().y
          elif self.group in _tls_named_curves:
              if _tls_named_curves[self.group] == "x25519":
                  if conf.crypto_valid_advanced:
                      privkey = x25519.X25519PrivateKey.generate()
                      self.privkey = privkey
                      pubkey = privkey.public_key()
                      self.key_exchange = pubkey.public_bytes()
              elif _tls_named_curves[self.group] != "x448":
                  curve = ec._CURVE_TYPES[_tls_named_curves[self.group]]()
                  privkey = ec.generate_private_key(curve, default_backend())
                  self.privkey = privkey
                  pubkey = privkey.public_key()
                  try:
                      # cryptography >= 2.5
                      self.key_exchange = pubkey.public_bytes(
                          serialization.Encoding.X962,
                          serialization.PublicFormat.UncompressedPoint
                      )
                  except TypeError:
                      # older versions
                      self.key_exchange = pubkey.public_numbers().encode_point()
docs: This is called by post_build() for key creation.