@Test
public void testGenerateShares() {

	int n = 9;
	int threshold = 5;
	// Create coefficients
	final BigInteger[] coefficients = Shamir.generateCoefficients(threshold);
	final BigInteger secret = RandomNumberGenerator.generateRandomInteger(r);
	coefficients[0] = secret;
	// Create shares
	final ShamirShare[] shares = Shamir.generateShares(coefficients, n);
	final Set<ShamirShare> shareSet = new HashSet<>(Arrays.asList(shares));
	// Interpolate at different points, secret matches for position 0 only
	for (int i = 0; i <= n; i++) {
		if (i == 0) {
			final BigInteger result = Polynomials.interpolateComplete(shareSet, threshold, i);
			Assert.assertEquals(secret, result);
		} else {
			final BigInteger result = Polynomials.interpolateComplete(shareSet, threshold, i);
			Assert.assertNotEquals(secret, result);
		}
	}
}