private static PgpPublicKey GetTrustedMasterPublicKey()

in net/JetBrains.DownloadPgpVerifier/src/PgpSignaturesVerifier.cs [80:91]


    private static PgpPublicKey GetTrustedMasterPublicKey(Stream stream)
    {
      if (stream == null) throw new ArgumentNullException(nameof(stream));
      using var decodedStream = PgpUtilities.GetDecoderStream(stream);
      var bundle = new PgpPublicKeyRingBundle(decodedStream);
      var ring = bundle.GetKeyRings().Cast<PgpPublicKeyRing>().SingleOrDefault() ?? throw new Exception("Only one key ring is expected");
      var publicKey = ring.GetPublicKeys().Cast<PgpPublicKey>().SingleOrDefault() ?? throw new Exception("Only one public key is expected");
      if (!publicKey.IsMasterKey)
        throw new Exception($"Master key is required. KeyID={publicKey.KeyId:X16}");
      CheckPublicKeyFormat(publicKey, err => throw new Exception(err));
      return publicKey;
    }