// ---------------------------------------------------------------------- // // Sample ln3 Program // // Module: shares.cc // Description: User supplies, size_p, t, n. // Program generates a random prime P of size size_p. // Then generates a random polynomial f of degree t. // Then outputs f(i) for i = 1, ... , n . // Date: 2001 // Contributed by: Rene Peralta // // ---------------------------------------------------------------------- #include #include #include #define max_shares 100 ln a[max_shares]; int main( int argc, char *argv[ ] ) { long p_size; ln p; long t, n; cout << "enter size_p, polynomial degree t, number of shares" << endl; if( ! ( cin >> p_size ) ) return 0; if( ! ( cin >> t ) ) return 0; if( ! ( cin >> n ) ) return 0; RandomPrime( &p, p_size ); cout << "P = " << p << endl; for (long i = 0; i <= t; i++) a[i].Random(p_size) % p; for (long x = 1; x <= n; x++) { ln u = a[t]; for (long i = t-1; i != 0; i--) u = (u * x + a[i]) % p; cout << u << endl << endl; } }