codahale / shamir

A Java implementation of Shamir's Secret Sharing algorithm over GF(256).
Apache License 2.0
209 stars 84 forks source link

generator test uses random source #15

Open simbo1905 opened 5 years ago

simbo1905 commented 5 years ago

The following test:

 @Test
  void generate() {
    final SecureRandom random = new SecureRandom(); // <- random 
    final byte[] p = GF256.generate(random, 5, (byte) 20);
   // removed for brevity
   assertThat(p[p.length - 1]).isNotZero();
  }

Will find it hard to catch a bug where generate doesn't loop on the random source until p[p.length - 1] != (byte) 0. If a regression is introduced it is unlikely to be caught before the code is released.

simbo1905 commented 5 years ago

I have submitted PR 16 for this.