Skip to content

Commit 7c2c411

Browse files
committed
Removed BigInt tests
1 parent ee4e659 commit 7c2c411

File tree

1 file changed

+0
-350
lines changed

1 file changed

+0
-350
lines changed

MLAPI/NetworkingManagerComponents/Binary/BigInteger.cs

Lines changed: 0 additions & 350 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,355 +2915,5 @@ private static BigInteger[] LucasSequenceHelper(BigInteger p, BigInteger q,
29152915

29162916
return result;
29172917
}
2918-
2919-
////***********************************************************************
2920-
//// Tests the correct implementation of the /, %, * and + operators
2921-
////***********************************************************************
2922-
2923-
//public static void MulDivTest(int rounds)
2924-
//{
2925-
// Random rand = new Random();
2926-
// byte[] val = new byte[64];
2927-
// byte[] val2 = new byte[64];
2928-
2929-
// for(int count = 0; count < rounds; count++)
2930-
// {
2931-
// // generate 2 numbers of random length
2932-
// int t1 = 0;
2933-
// while(t1 == 0)
2934-
// t1 = (int)(rand.NextDouble() * 65);
2935-
2936-
// int t2 = 0;
2937-
// while(t2 == 0)
2938-
// t2 = (int)(rand.NextDouble() * 65);
2939-
2940-
// bool done = false;
2941-
// while(!done)
2942-
// {
2943-
// for(int i = 0; i < 64; i++)
2944-
// {
2945-
// if(i < t1)
2946-
// val[i] = (byte)(rand.NextDouble() * 256);
2947-
// else
2948-
// val[i] = 0;
2949-
2950-
// if(val[i] != 0)
2951-
// done = true;
2952-
// }
2953-
// }
2954-
2955-
// done = false;
2956-
// while(!done)
2957-
// {
2958-
// for(int i = 0; i < 64; i++)
2959-
// {
2960-
// if(i < t2)
2961-
// val2[i] = (byte)(rand.NextDouble() * 256);
2962-
// else
2963-
// val2[i] = 0;
2964-
2965-
// if(val2[i] != 0)
2966-
// done = true;
2967-
// }
2968-
// }
2969-
2970-
// while(val[0] == 0)
2971-
// val[0] = (byte)(rand.NextDouble() * 256);
2972-
// while(val2[0] == 0)
2973-
// val2[0] = (byte)(rand.NextDouble() * 256);
2974-
2975-
// Console.WriteLine(count);
2976-
// BigInteger bn1 = new BigInteger(val, t1);
2977-
// BigInteger bn2 = new BigInteger(val2, t2);
2978-
2979-
// // Determine the quotient and remainder by dividing
2980-
// // the first number by the second.
2981-
2982-
// BigInteger bn3 = bn1 / bn2;
2983-
// BigInteger bn4 = bn1 % bn2;
2984-
2985-
// // Recalculate the number
2986-
// BigInteger bn5 = (bn3 * bn2) + bn4;
2987-
2988-
// // Make sure they're the same
2989-
// if(bn5 != bn1)
2990-
// {
2991-
// Console.WriteLine("Error at " + count);
2992-
// Console.WriteLine(bn1 + "\n");
2993-
// Console.WriteLine(bn2 + "\n");
2994-
// Console.WriteLine(bn3 + "\n");
2995-
// Console.WriteLine(bn4 + "\n");
2996-
// Console.WriteLine(bn5 + "\n");
2997-
// return;
2998-
// }
2999-
// }
3000-
//}
3001-
3002-
////***********************************************************************
3003-
//// Tests the correct implementation of the modulo exponential function
3004-
//// using RSA encryption and decryption (using pre-computed encryption and
3005-
//// decryption keys).
3006-
////***********************************************************************
3007-
3008-
//public static void RSATest(int rounds)
3009-
//{
3010-
// Random rand = new Random(1);
3011-
// byte[] val = new byte[64];
3012-
3013-
// // private and public key
3014-
// BigInteger bi_e = new BigInteger("a932b948feed4fb2b692609bd22164fc9edb59fae7880cc1eaff7b3c9626b7e5b241c27a974833b2622ebe09beb451917663d47232488f23a117fc97720f1e7", 16);
3015-
// BigInteger bi_d = new BigInteger("4adf2f7a89da93248509347d2ae506d683dd3a16357e859a980c4f77a4e2f7a01fae289f13a851df6e9db5adaa60bfd2b162bbbe31f7c8f828261a6839311929d2cef4f864dde65e556ce43c89bbbf9f1ac5511315847ce9cc8dc92470a747b8792d6a83b0092d2e5ebaf852c85cacf34278efa99160f2f8aa7ee7214de07b7", 16);
3016-
// BigInteger bi_n = new BigInteger("e8e77781f36a7b3188d711c2190b560f205a52391b3479cdb99fa010745cbeba5f2adc08e1de6bf38398a0487c4a73610d94ec36f17f3f46ad75e17bc1adfec99839589f45f95ccc94cb2a5c500b477eb3323d8cfab0c8458c96f0147a45d27e45a4d11d54d77684f65d48f15fafcc1ba208e71e921b9bd9017c16a5231af7f", 16);
3017-
3018-
// Console.WriteLine("e =\n" + bi_e.ToString(10));
3019-
// Console.WriteLine("\nd =\n" + bi_d.ToString(10));
3020-
// Console.WriteLine("\nn =\n" + bi_n.ToString(10) + "\n");
3021-
3022-
// for(int count = 0; count < rounds; count++)
3023-
// {
3024-
// // generate data of random length
3025-
// int t1 = 0;
3026-
// while(t1 == 0)
3027-
// t1 = (int)(rand.NextDouble() * 65);
3028-
3029-
// bool done = false;
3030-
// while(!done)
3031-
// {
3032-
// for(int i = 0; i < 64; i++)
3033-
// {
3034-
// if(i < t1)
3035-
// val[i] = (byte)(rand.NextDouble() * 256);
3036-
// else
3037-
// val[i] = 0;
3038-
3039-
// if(val[i] != 0)
3040-
// done = true;
3041-
// }
3042-
// }
3043-
3044-
// while(val[0] == 0)
3045-
// val[0] = (byte)(rand.NextDouble() * 256);
3046-
3047-
// Console.Write("Round = " + count);
3048-
3049-
// // encrypt and decrypt data
3050-
// BigInteger bi_data = new BigInteger(val, t1);
3051-
// BigInteger bi_encrypted = bi_data.modPow(bi_e, bi_n);
3052-
// BigInteger bi_decrypted = bi_encrypted.modPow(bi_d, bi_n);
3053-
3054-
// // compare
3055-
// if(bi_decrypted != bi_data)
3056-
// {
3057-
// Console.WriteLine("\nError at round " + count);
3058-
// Console.WriteLine(bi_data + "\n");
3059-
// return;
3060-
// }
3061-
// Console.WriteLine(" <PASSED>.");
3062-
// }
3063-
3064-
//}
3065-
3066-
////***********************************************************************
3067-
//// Tests the correct implementation of the modulo exponential and
3068-
//// inverse modulo functions using RSA encryption and decryption. The two
3069-
//// pseudoprimes p and q are fixed, but the two RSA keys are generated
3070-
//// for each round of testing.
3071-
////***********************************************************************
3072-
3073-
//public static void RSATest2(int rounds)
3074-
//{
3075-
// Random rand = new Random();
3076-
// byte[] val = new byte[64];
3077-
3078-
// byte[] pseudoPrime1 = {
3079-
// (byte)0x85, (byte)0x84, (byte)0x64, (byte)0xFD, (byte)0x70, (byte)0x6A,
3080-
// (byte)0x9F, (byte)0xF0, (byte)0x94, (byte)0x0C, (byte)0x3E, (byte)0x2C,
3081-
// (byte)0x74, (byte)0x34, (byte)0x05, (byte)0xC9, (byte)0x55, (byte)0xB3,
3082-
// (byte)0x85, (byte)0x32, (byte)0x98, (byte)0x71, (byte)0xF9, (byte)0x41,
3083-
// (byte)0x21, (byte)0x5F, (byte)0x02, (byte)0x9E, (byte)0xEA, (byte)0x56,
3084-
// (byte)0x8D, (byte)0x8C, (byte)0x44, (byte)0xCC, (byte)0xEE, (byte)0xEE,
3085-
// (byte)0x3D, (byte)0x2C, (byte)0x9D, (byte)0x2C, (byte)0x12, (byte)0x41,
3086-
// (byte)0x1E, (byte)0xF1, (byte)0xC5, (byte)0x32, (byte)0xC3, (byte)0xAA,
3087-
// (byte)0x31, (byte)0x4A, (byte)0x52, (byte)0xD8, (byte)0xE8, (byte)0xAF,
3088-
// (byte)0x42, (byte)0xF4, (byte)0x72, (byte)0xA1, (byte)0x2A, (byte)0x0D,
3089-
// (byte)0x97, (byte)0xB1, (byte)0x31, (byte)0xB3,
3090-
// };
3091-
3092-
// byte[] pseudoPrime2 = {
3093-
// (byte)0x99, (byte)0x98, (byte)0xCA, (byte)0xB8, (byte)0x5E, (byte)0xD7,
3094-
// (byte)0xE5, (byte)0xDC, (byte)0x28, (byte)0x5C, (byte)0x6F, (byte)0x0E,
3095-
// (byte)0x15, (byte)0x09, (byte)0x59, (byte)0x6E, (byte)0x84, (byte)0xF3,
3096-
// (byte)0x81, (byte)0xCD, (byte)0xDE, (byte)0x42, (byte)0xDC, (byte)0x93,
3097-
// (byte)0xC2, (byte)0x7A, (byte)0x62, (byte)0xAC, (byte)0x6C, (byte)0xAF,
3098-
// (byte)0xDE, (byte)0x74, (byte)0xE3, (byte)0xCB, (byte)0x60, (byte)0x20,
3099-
// (byte)0x38, (byte)0x9C, (byte)0x21, (byte)0xC3, (byte)0xDC, (byte)0xC8,
3100-
// (byte)0xA2, (byte)0x4D, (byte)0xC6, (byte)0x2A, (byte)0x35, (byte)0x7F,
3101-
// (byte)0xF3, (byte)0xA9, (byte)0xE8, (byte)0x1D, (byte)0x7B, (byte)0x2C,
3102-
// (byte)0x78, (byte)0xFA, (byte)0xB8, (byte)0x02, (byte)0x55, (byte)0x80,
3103-
// (byte)0x9B, (byte)0xC2, (byte)0xA5, (byte)0xCB,
3104-
// };
3105-
3106-
// BigInteger bi_p = new BigInteger(pseudoPrime1);
3107-
// BigInteger bi_q = new BigInteger(pseudoPrime2);
3108-
// BigInteger bi_pq = (bi_p-1)*(bi_q-1);
3109-
// BigInteger bi_n = bi_p * bi_q;
3110-
3111-
// for(int count = 0; count < rounds; count++)
3112-
// {
3113-
// // generate private and public key
3114-
// BigInteger bi_e = bi_pq.genCoPrime(512, rand);
3115-
// BigInteger bi_d = bi_e.modInverse(bi_pq);
3116-
3117-
// Console.WriteLine("\ne =\n" + bi_e.ToString(10));
3118-
// Console.WriteLine("\nd =\n" + bi_d.ToString(10));
3119-
// Console.WriteLine("\nn =\n" + bi_n.ToString(10) + "\n");
3120-
3121-
// // generate data of random length
3122-
// int t1 = 0;
3123-
// while(t1 == 0)
3124-
// t1 = (int)(rand.NextDouble() * 65);
3125-
3126-
// bool done = false;
3127-
// while(!done)
3128-
// {
3129-
// for(int i = 0; i < 64; i++)
3130-
// {
3131-
// if(i < t1)
3132-
// val[i] = (byte)(rand.NextDouble() * 256);
3133-
// else
3134-
// val[i] = 0;
3135-
3136-
// if(val[i] != 0)
3137-
// done = true;
3138-
// }
3139-
// }
3140-
3141-
// while(val[0] == 0)
3142-
// val[0] = (byte)(rand.NextDouble() * 256);
3143-
3144-
// Console.Write("Round = " + count);
3145-
3146-
// // encrypt and decrypt data
3147-
// BigInteger bi_data = new BigInteger(val, t1);
3148-
// BigInteger bi_encrypted = bi_data.modPow(bi_e, bi_n);
3149-
// BigInteger bi_decrypted = bi_encrypted.modPow(bi_d, bi_n);
3150-
3151-
// // compare
3152-
// if(bi_decrypted != bi_data)
3153-
// {
3154-
// Console.WriteLine("\nError at round " + count);
3155-
// Console.WriteLine(bi_data + "\n");
3156-
// return;
3157-
// }
3158-
// Console.WriteLine(" <PASSED>.");
3159-
// }
3160-
3161-
//}
3162-
3163-
////***********************************************************************
3164-
//// Tests the correct implementation of sqrt() method.
3165-
////***********************************************************************
3166-
3167-
//public static void SqrtTest(int rounds)
3168-
//{
3169-
// Random rand = new Random();
3170-
// for(int count = 0; count < rounds; count++)
3171-
// {
3172-
// // generate data of random length
3173-
// int t1 = 0;
3174-
// while(t1 == 0)
3175-
// t1 = (int)(rand.NextDouble() * 1024);
3176-
3177-
// Console.Write("Round = " + count);
3178-
3179-
// BigInteger a = new BigInteger();
3180-
// a.genRandomBits(t1, rand);
3181-
3182-
// BigInteger b = a.sqrt();
3183-
// BigInteger c = (b+1)*(b+1);
3184-
3185-
// // check that b is the largest integer such that b*b <= a
3186-
// if(c <= a)
3187-
// {
3188-
// Console.WriteLine("\nError at round " + count);
3189-
// Console.WriteLine(a + "\n");
3190-
// return;
3191-
// }
3192-
// Console.WriteLine(" <PASSED>.");
3193-
// }
3194-
//}
3195-
3196-
//public static void Main(string[] args)
3197-
//{
3198-
// // Known problem -> these two pseudoprimes passes my implementation of
3199-
// // primality test but failed in JDK's isProbablePrime test.
3200-
3201-
// byte[] pseudoPrime1 = { (byte)0x00,
3202-
// (byte)0x85, (byte)0x84, (byte)0x64, (byte)0xFD, (byte)0x70, (byte)0x6A,
3203-
// (byte)0x9F, (byte)0xF0, (byte)0x94, (byte)0x0C, (byte)0x3E, (byte)0x2C,
3204-
// (byte)0x74, (byte)0x34, (byte)0x05, (byte)0xC9, (byte)0x55, (byte)0xB3,
3205-
// (byte)0x85, (byte)0x32, (byte)0x98, (byte)0x71, (byte)0xF9, (byte)0x41,
3206-
// (byte)0x21, (byte)0x5F, (byte)0x02, (byte)0x9E, (byte)0xEA, (byte)0x56,
3207-
// (byte)0x8D, (byte)0x8C, (byte)0x44, (byte)0xCC, (byte)0xEE, (byte)0xEE,
3208-
// (byte)0x3D, (byte)0x2C, (byte)0x9D, (byte)0x2C, (byte)0x12, (byte)0x41,
3209-
// (byte)0x1E, (byte)0xF1, (byte)0xC5, (byte)0x32, (byte)0xC3, (byte)0xAA,
3210-
// (byte)0x31, (byte)0x4A, (byte)0x52, (byte)0xD8, (byte)0xE8, (byte)0xAF,
3211-
// (byte)0x42, (byte)0xF4, (byte)0x72, (byte)0xA1, (byte)0x2A, (byte)0x0D,
3212-
// (byte)0x97, (byte)0xB1, (byte)0x31, (byte)0xB3,
3213-
// };
3214-
3215-
// byte[] pseudoPrime2 = { (byte)0x00,
3216-
// (byte)0x99, (byte)0x98, (byte)0xCA, (byte)0xB8, (byte)0x5E, (byte)0xD7,
3217-
// (byte)0xE5, (byte)0xDC, (byte)0x28, (byte)0x5C, (byte)0x6F, (byte)0x0E,
3218-
// (byte)0x15, (byte)0x09, (byte)0x59, (byte)0x6E, (byte)0x84, (byte)0xF3,
3219-
// (byte)0x81, (byte)0xCD, (byte)0xDE, (byte)0x42, (byte)0xDC, (byte)0x93,
3220-
// (byte)0xC2, (byte)0x7A, (byte)0x62, (byte)0xAC, (byte)0x6C, (byte)0xAF,
3221-
// (byte)0xDE, (byte)0x74, (byte)0xE3, (byte)0xCB, (byte)0x60, (byte)0x20,
3222-
// (byte)0x38, (byte)0x9C, (byte)0x21, (byte)0xC3, (byte)0xDC, (byte)0xC8,
3223-
// (byte)0xA2, (byte)0x4D, (byte)0xC6, (byte)0x2A, (byte)0x35, (byte)0x7F,
3224-
// (byte)0xF3, (byte)0xA9, (byte)0xE8, (byte)0x1D, (byte)0x7B, (byte)0x2C,
3225-
// (byte)0x78, (byte)0xFA, (byte)0xB8, (byte)0x02, (byte)0x55, (byte)0x80,
3226-
// (byte)0x9B, (byte)0xC2, (byte)0xA5, (byte)0xCB,
3227-
// };
3228-
3229-
// Console.WriteLine("List of primes < 2000\n---------------------");
3230-
// int limit = 100, count = 0;
3231-
// for(int i = 0; i < 2000; i++)
3232-
// {
3233-
// if(i >= limit)
3234-
// {
3235-
// Console.WriteLine();
3236-
// limit += 100;
3237-
// }
3238-
3239-
// BigInteger p = new BigInteger(-i);
3240-
3241-
// if(p.isProbablePrime())
3242-
// {
3243-
// Console.Write(i + ", ");
3244-
// count++;
3245-
// }
3246-
// }
3247-
// Console.WriteLine("\nCount = " + count);
3248-
3249-
// BigInteger bi1 = new BigInteger(pseudoPrime1);
3250-
// Console.WriteLine("\n\nPrimality testing for\n" + bi1.ToString() + "\n");
3251-
// Console.WriteLine("SolovayStrassenTest(5) = " + bi1.SolovayStrassenTest(5));
3252-
// Console.WriteLine("RabinMillerTest(5) = " + bi1.RabinMillerTest(5));
3253-
// Console.WriteLine("FermatLittleTest(5) = " + bi1.FermatLittleTest(5));
3254-
// Console.WriteLine("isProbablePrime() = " + bi1.isProbablePrime());
3255-
3256-
// Console.Write("\nGenerating 512-bits random pseudoprime. . .");
3257-
// Random rand = new Random();
3258-
// BigInteger prime = BigInteger.genPseudoPrime(512, 5, rand);
3259-
// Console.WriteLine("\n" + prime);
3260-
3261-
// //int dwStart = System.Environment.TickCount;
3262-
// //BigInteger.MulDivTest(100000);
3263-
// //BigInteger.RSATest(10);
3264-
// //BigInteger.RSATest2(10);
3265-
// //Console.WriteLine(System.Environment.TickCount - dwStart);
3266-
3267-
//}
32682918
}
32692919
}

0 commit comments

Comments
 (0)