<commit_before>﻿using System;
using Sodium;

namespace CoCSharp.Network.Cryptography
{
    /// <summary>
    /// Implements method to encrypt or decrypt network traffic of the Clash of Clan protocol
    /// version 8.x.x. This was based of clugh's work(https://github.com/clugh/cocdp/wiki/Protocol) and
    /// (https://github.com/clugh/coc-proxy-csharp). :]
    /// </summary>
    public class Crypto8 : CoCCrypto
    {
        private static readonly byte[] _standardPrivateKey = new byte[]
        {
            0x18, 0x91, 0xD4, 0x01, 0xFA, 0xDB, 0x51, 0xD2, 0x5D, 0x3A, 0x91, 0x74,
            0xD4, 0x72, 0xA9, 0xF6, 0x91, 0xA4, 0x5B, 0x97, 0x42, 0x85, 0xD4, 0x77,
            0x29, 0xC4, 0x5C, 0x65, 0x38, 0x07, 0x0D, 0x85
        };

        private static readonly byte[] _standardPublicKey = new byte[] // == PublicKeyBox.GenerateKeyPair(_standardPrivateKey);
        {
            0x72, 0xF1, 0xA4, 0xA4, 0xC4, 0x8E, 0x44, 0xDA, 0x0C, 0x42, 0x31, 0x0F,
            0x80, 0x0E, 0x96, 0x62, 0x4E, 0x6D, 0xC6, 0xA6, 0x41, 0xA9, 0xD4, 0x1C,
            0x3B, 0x50, 0x39, 0xD8, 0xDF, 0xAD, 0xC2, 0x7E
        };

        /// <summary>
        /// Gets a new instance of the standard key-pair used by custom servers and clients.
        /// </summary>
        /// <remarks>
        /// More information here (https://github.com/FICTURE7/CoCSharp/issues/54#issuecomment-173556064).
        /// </remarks>
        public static CoCKeyPair StandardKeyPair
        {
            // Cloning just not to mess up with refs
            get { return new CoCKeyPair((byte[])_standardPublicKey.Clone(), (byte[])_standardPrivateKey.Clone()); }
        }

        /// <summary>
        /// Gets a new instance of Supercell server's public key.
        /// </summary>
        /// <remarks>
        /// This was extracted from the android version of libg.so
        /// </remarks>
        public static byte[] SupercellPublicKey
        {
            get
            {
                return new byte[]
                {
                    // 8.551.4
                    0x34, 0x9C, 0xE7, 0x8B, 0x78, 0xA0, 0x6A, 0x4E, 0x94, 0x64, 0x54, 0x35, 0xAC,
                    0xBA, 0x1D, 0xFF, 0xFC, 0x40, 0xCC, 0x22, 0x76, 0x55, 0x8E, 0xD2, 0xD1,
                    0x18, 0xF1, 0x34, 0x3A, 0x19, 0x78, 0x76

                    // 8.322.16 ->
                    //0xBB, 0x9C, 0xA4, 0xC6, 0xB5, 0x2E, 0xCD, 0xB4, 0x02, 0x67, 0xC3, 0xBC,
                    //0xCA, 0x03, 0x67, 0x92, 0x01, 0xA4, 0x03, 0xEF, 0x62, 0x30, 0xB9, 0xE4,
                    //0x88, 0xDB, 0x94, 0x9B, 0x58, 0xBC, 0x74, 0x79

                    // 8.212.12 ->
                    //0x9B, 0x39, 0xB4, 0x40, 0xFF, 0x6C, 0x13, 0xAD, 0x07, 0xB5, 0x06, 0xFC,
                    //0x55, 0xE3, 0x7F, 0x69, 0x85, 0x68, 0x95, 0xC3, 0xFD, 0x5A, 0xB3, 0x59,
                    //0x78, 0xCD, 0xF5, 0xE3, 0x4E, 0xB3, 0x74, 0x71

                    // 8.212.9 ->
                    //0x46, 0x9b, 0x70, 0x4e, 0x7f, 0x60, 0x09, 0xba, 0x8f, 0xc7, 0x2e, 0x9b,
                    //0x5c, 0x86, 0x4c, 0x8e, 0x92, 0x85, 0xa7, 0x55, 0xc5, 0x19, 0x0f, 0x03,
                    //0xf5, 0xc7, 0x48, 0x52, 0xf6, 0xd9, 0xf4, 0x19

                    // 8.212.3 ->
                    //0x15, 0x0C, 0x52, 0xDB, 0x12, 0xBA, 0x1C, 0x9D, 0xD8, 0x09, 0xB8, 0x93,
                    //0x4A, 0x53, 0x5F, 0x42, 0x8A, 0x91, 0xB7, 0xB6, 0x1E, 0x15, 0xAB, 0x46,
                    //0x9E, 0x42, 0xB9, 0x61, 0x4C, 0x76, 0xA3, 0x25,
<commit_msg>Updated keys to 8.551.18<commit_after>﻿using System;
using Sodium;

namespace CoCSharp.Network.Cryptography
{
    /// <summary>
    /// Implements method to encrypt or decrypt network traffic of the Clash of Clan protocol
    /// version 8.x.x. This was based of clugh's work(https://github.com/clugh/cocdp/wiki/Protocol) and
    /// (https://github.com/clugh/coc-proxy-csharp). :]
    /// </summary>
    public class Crypto8 : CoCCrypto
    {
        private static readonly byte[] _standardPrivateKey = new byte[]
        {
            0x18, 0x91, 0xD4, 0x01, 0xFA, 0xDB, 0x51, 0xD2, 0x5D, 0x3A, 0x91, 0x74,
            0xD4, 0x72, 0xA9, 0xF6, 0x91, 0xA4, 0x5B, 0x97, 0x42, 0x85, 0xD4, 0x77,
            0x29, 0xC4, 0x5C, 0x65, 0x38, 0x07, 0x0D, 0x85
        };

        private static readonly byte[] _standardPublicKey = new byte[] // == PublicKeyBox.GenerateKeyPair(_standardPrivateKey);
        {
            0x72, 0xF1, 0xA4, 0xA4, 0xC4, 0x8E, 0x44, 0xDA, 0x0C, 0x42, 0x31, 0x0F,
            0x80, 0x0E, 0x96, 0x62, 0x4E, 0x6D, 0xC6, 0xA6, 0x41, 0xA9, 0xD4, 0x1C,
            0x3B, 0x50, 0x39, 0xD8, 0xDF, 0xAD, 0xC2, 0x7E
        };

        /// <summary>
        /// Gets a new instance of the standard key-pair used by custom servers and clients.
        /// </summary>
        /// <remarks>
        /// More information here (https://github.com/FICTURE7/CoCSharp/issues/54#issuecomment-173556064).
        /// </remarks>
        public static CoCKeyPair StandardKeyPair
        {
            // Cloning just not to mess up with refs
            get { return new CoCKeyPair((byte[])_standardPublicKey.Clone(), (byte[])_standardPrivateKey.Clone()); }
        }

        /// <summary>
        /// Gets a new instance of Supercell server's public key.
        /// </summary>
        /// <remarks>
        /// This was extracted from the android version of libg.so
        /// </remarks>
        public static byte[] SupercellPublicKey
        {
            get
            {
                return new byte[]
                {
                    // 8.551.18 ->
                    0x13, 0x15, 0xD5, 0xBA, 0x8E, 0x41, 0xD4, 0x0D, 0x2A, 0xD1, 0x48, 0x0A, 0xA6,
                    0x21, 0xAD, 0x86, 0x4C, 0xF2, 0x55, 0x75, 0x69, 0xD1, 0x84, 0xFA, 0x00, 0xFC,
                    0x11, 0x47, 0x1D, 0xD3, 0x1F, 0x4B

                    // 8.551.4 ->
                    //0x34, 0x9C, 0xE7, 0x8B, 0x78, 0xA0, 0x6A, 0x4E, 0x94, 0x64, 0x54, 0x35,
                    //0xAC, 0xBA, 0x1D, 0xFF, 0xFC, 0x40, 0xCC, 0x22, 0x76, 0x55, 0x8E, 0xD2,
                    //0xD1, 0x18, 0xF1, 0x34, 0x3A, 0x19, 0x78, 0x76

                    // 8.322.16 ->
                    //0xBB, 0x9C, 0xA4, 0xC6, 0xB5, 0x2E, 0xCD, 0xB4, 0x02, 0x67, 0xC3, 0xBC,
                    //0xCA, 0x03, 0x67, 0x92, 0x01, 0xA4, 0x03, 0xEF, 0x62, 0x30, 0xB9, 0xE4,
                    //0x88, 0xDB, 0x94, 0x9B, 0x58, 0xBC, 0x74, 0x79

                    // 8.212.12 ->
                    //0x9B, 0x39, 0xB4, 0x40, 0xFF, 0x6C, 0x13, 0xAD, 0x07, 0xB5, 0x06, 0xFC,
                    //0x55, 0xE3, 0x7F, 0x69, 0x85, 0x68, 0x95, 0xC3, 0xFD, 0x5A, 0xB3, 0x59,
                    //0x78, 0xCD, 0xF5, 0xE3, 0x4E, 0xB3, 0x74, 0x71

                    // 8.212.9 ->
                    //0x46, 0x9b, 0x70, 0x4e, 0x7f, 0x60, 0x09, 0xba, 0x8f, 0xc7, 0x2e, 0x9b,
                    //0x5c, 0x86, 0x4c, 0x8e, 0x92, 0x85, 0xa7, 0x55, 0xc5, 0x19, 0x0f, 0x03,
                    //0xf5, 0xc7, 0x48, 0x52, 0xf6, 0xd9, 0xf4, 0x19

                    // 8.212.3 ->
                    //0x15, 0x0C, 0x52, 0xDB, 0x12, 0xBA, 0x1C, 0x9D, 0xD8, 0x09, 0xB8, 0x93,
                    //0x4A, 0x53, 0x5F, 0x42, 0x8A, 0x91, 0xB7, 0xB6, 0x1E, 0x15, 0xAB, 0x46,
                    //0x9E, 0x42, 0xB9, 0x61, 0x4C, 0x76, 0xA3, 0x25,

{'fraction_non_alphanumeric': 0.13238738118198098, 'fraction_numerical': 0.16600082656013224, 'mean_word_length': 1.633297062023939, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 33, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4895168', 'n_tokens_mistral': 3832, 'n_tokens_neox': 3069, 'n_words': 734}