private unsafe static BsonDocument SerializeKey(Jwk key) { using var bufferWriter = new PooledByteBufferWriter(1024); using var jsonWriter = new Utf8JsonWriter(bufferWriter); jsonWriter.WriteStartObject(); key.WriteTo(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); return(BsonDocument.Parse(Encoding.UTF8.GetString(bufferWriter.WrittenSpan))); }