// generate test cases for sub.c // // Usage: java gen [n] // // number of test cases (n) default is 10 // // Each test case consists of: // // u, v, u-v, v-u // import java.math.BigInteger; import java.util.Random; public class gen_sub { static BigInteger ZERO = BigInteger.ZERO; static BigInteger ONE = BigInteger.ONE; static BigInteger TWO = BigInteger.valueOf(2); static BigInteger TEN = BigInteger.valueOf(10); static BigInteger EIGHTEEN = BigInteger.valueOf(18); // 2^255 - 19 // static BigInteger m = ONE.shiftLeft(255).subtract(BigInteger.valueOf(19)); // print in hex // public static void print( BigInteger x) { String s = x.toString(16); int len = s.length(); while( len++ < 64) System.out.print( "0"); // leading 0's System.out.println( s); } public static void main( String args[]) { int n = 10; // number of test cases to generate if( args.length > 0) n = Integer.parseInt( args[0]); Random R = new Random(); BigInteger u, v; for( int i = 1; i <= n; ++i) { switch(i) { case 1: u = ZERO; v = u; break; case 2: u = m.subtract(ONE); v = ONE; break; case 3: u = m.subtract(ONE); v = TWO; break; case 4: u = m.add(TEN); v = m.add(EIGHTEEN); break; case 5: u = m.add(EIGHTEEN); v = m.add(ONE); break; case 6: u = m.add(EIGHTEEN); v = m.subtract(ONE); break; default: u = (new BigInteger( 256, R)).mod(m); v = (new BigInteger( 256, R)).mod(m); break; } print(u); print(v); print( u.subtract(v).mod(m)); print( v.subtract(u).mod(m)); } } }