@@ -42,17 +42,17 @@ public void testShamirSecretResplit()
4242 SecureRandom random = new SecureRandom ();
4343 ShamirSecretSplitter .Algorithm algorithm = ShamirSecretSplitter .Algorithm .AES ;
4444 ShamirSecretSplitter .Mode mode = ShamirSecretSplitter .Mode .Table ;
45- ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , m , n , random ); //, secretshare );
45+ ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , random );
4646
47- ShamirSplitSecret splitSecret = splitter .split ();
47+ ShamirSplitSecret splitSecret = splitter .split (m , n );
4848 ShamirSplitSecretShare [] secretShares = splitSecret .getSecretShares ();
4949
5050 ShamirSplitSecretShare [] secretShares1 = new ShamirSplitSecretShare []{secretShares [0 ], secretShares [1 ], secretShares [2 ]};
5151 ShamirSplitSecret splitSecret1 = new ShamirSplitSecret (algorithm , mode , secretShares1 );
5252 byte [] secret1 = splitSecret1 .getSecret ();
5353
5454
55- ShamirSplitSecret splitSecret2 = splitter .resplit (secret1 );
55+ ShamirSplitSecret splitSecret2 = splitter .resplit (secret1 , m , n );
5656 ShamirSplitSecretShare [] secretShares2 = splitSecret2 .getSecretShares ();
5757 ShamirSplitSecretShare [] secretShares3 = new ShamirSplitSecretShare []{secretShares2 [0 ], secretShares2 [1 ], secretShares2 [2 ]};
5858 ShamirSplitSecret splitSecret3 = new ShamirSplitSecret (algorithm , mode , secretShares3 );
@@ -62,7 +62,6 @@ public void testShamirSecretResplit()
6262 Assert .assertArrayEquals (secret1 , secret3 );
6363 Assert .assertFalse (Arrays .areEqual (Arrays .concatenate (secretShares [0 ].getEncoded (), secretShares [1 ].getEncoded (), secretShares [2 ].getEncoded ()),
6464 Arrays .concatenate (secretShares2 [0 ].getEncoded (), secretShares2 [1 ].getEncoded (), secretShares2 [2 ].getEncoded ())));
65-
6665 }
6766
6867 public void testShamirSecretMultipleDivide ()
@@ -72,9 +71,9 @@ public void testShamirSecretMultipleDivide()
7271 SecureRandom random = new SecureRandom ();
7372 ShamirSecretSplitter .Algorithm algorithm = ShamirSecretSplitter .Algorithm .AES ;
7473 ShamirSecretSplitter .Mode mode = ShamirSecretSplitter .Mode .Table ;
75- ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , m , n , random ); //, secretshare );
74+ ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , random );
7675
77- ShamirSplitSecret splitSecret = splitter .split ();
76+ ShamirSplitSecret splitSecret = splitter .split (m , n );
7877 ShamirSplitSecretShare [] secretShares = splitSecret .getSecretShares ();
7978
8079 ShamirSplitSecretShare [] secretShares1 = new ShamirSplitSecretShare []{secretShares [0 ], secretShares [1 ], secretShares [2 ]};
@@ -110,14 +109,14 @@ public void testShamirSecretSplitterSplitAround()
110109 int l = 9 , m = 3 , n = 9 ;
111110 ShamirSecretSplitter .Algorithm algorithm = ShamirSecretSplitter .Algorithm .AES ;
112111 ShamirSecretSplitter .Mode mode = ShamirSecretSplitter .Mode .Table ;
113- ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , m , n , new SecureRandom ()); //, secretshare );
112+ ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , new SecureRandom ());
114113 byte [] seed = Hex .decode ("010203040506070809" );
115114 //SecureRandom random = new SecureRandom();
116115
117116 //random.nextBytes(seed);
118117 //System.out.println(Hex.decode(seed));
119118 ShamirSplitSecretShare ss = new ShamirSplitSecretShare (seed );
120- ShamirSplitSecret splitSecret = splitter .splitAround (ss );
119+ ShamirSplitSecret splitSecret = splitter .splitAround (ss , m , n );
121120 ShamirSplitSecretShare [] secretShares = splitSecret .getSecretShares ();
122121 Assert .assertArrayEquals (secretShares [0 ].getEncoded (), seed );
123122
@@ -154,8 +153,8 @@ public void testShamirSecretSplitter()
154153 int l = 9 , m = 3 , n = 9 ;
155154 ShamirSecretSplitter .Algorithm algorithm = ShamirSecretSplitter .Algorithm .AES ;
156155 ShamirSecretSplitter .Mode mode = ShamirSecretSplitter .Mode .Table ;
157- ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , m , n , new SecureRandom ());//, secretshare);
158- ShamirSplitSecret splitSecret = splitter .split (); //integers multiply/ divide
156+ ShamirSecretSplitter splitter = new ShamirSecretSplitter (algorithm , mode , l , new SecureRandom ());//, secretshare);
157+ ShamirSplitSecret splitSecret = splitter .split (m , n ); //integers multiply/ divide
159158 ShamirSplitSecretShare [] secretShares = splitSecret .getSecretShares ();
160159
161160 ShamirSplitSecretShare [] secretShares1 = new ShamirSplitSecretShare []{secretShares [0 ], secretShares [1 ], secretShares [2 ]};
@@ -955,7 +954,7 @@ public void testPolynomial()
955954 @ Override
956955 public ShamirSecretSplitter newInstance (int l , int m , int n , SecureRandom random )
957956 {
958- return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .AES , ShamirSecretSplitter .Mode .Native , l , m , n , random );
957+ return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .AES , ShamirSecretSplitter .Mode .Native , l , random );
959958 }
960959
961960 @ Override
@@ -970,7 +969,7 @@ public ShamirSplitSecret newInstance(ShamirSplitSecretShare[] secretShares)
970969 @ Override
971970 public ShamirSecretSplitter newInstance (int l , int m , int n , SecureRandom random )
972971 {
973- return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .AES , ShamirSecretSplitter .Mode .Table , l , m , n , random );
972+ return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .AES , ShamirSecretSplitter .Mode .Table , l , random );
974973 }
975974
976975 @ Override
@@ -985,7 +984,7 @@ public ShamirSplitSecret newInstance(ShamirSplitSecretShare[] secretShares)
985984 @ Override
986985 public ShamirSecretSplitter newInstance (int l , int m , int n , SecureRandom random )
987986 {
988- return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .RSA , ShamirSecretSplitter .Mode .Native , l , m , n , random );
987+ return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .RSA , ShamirSecretSplitter .Mode .Native , l , random );
989988 }
990989
991990 @ Override
@@ -1000,7 +999,7 @@ public ShamirSplitSecret newInstance(ShamirSplitSecretShare[] secretShares)
1000999 @ Override
10011000 public ShamirSecretSplitter newInstance (int l , int m , int n , SecureRandom random )
10021001 {
1003- return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .RSA , ShamirSecretSplitter .Mode .Table , l , m , n , random );
1002+ return new ShamirSecretSplitter (ShamirSecretSplitter .Algorithm .RSA , ShamirSecretSplitter .Mode .Table , l ,random );
10041003 }
10051004
10061005 @ Override
@@ -1015,27 +1014,27 @@ private void testPolynoimial1(PolynomialFactory polynomialFactory)
10151014 throws IOException
10161015 {
10171016 ShamirSecretSplitter splitter = polynomialFactory .newInstance (5 , 2 , 2 , getSecureRandom (TV011B_TV1_SR ));
1018- testMatrixMultiplication (splitter , TV011B_TV1_SPLITS );
1017+ testMatrixMultiplication (splitter , TV011B_TV1_SPLITS , 2 , 2 );
10191018 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011B_TV1_1_2_SPLITS )), TV011B_TV1_SECRET );
10201019 splitter = polynomialFactory .newInstance (5 , 2 , 4 , getSecureRandom (TV011B_TV2_SR ));
1021- testMatrixMultiplication (splitter , TV011B_TV2_SPLITS );
1020+ testMatrixMultiplication (splitter , TV011B_TV2_SPLITS , 2 , 4 );
10221021 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011B_TV2_1_2_SPLITS )), TV011B_TV2_SECRET );
10231022 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 4 }, TV011B_TV2_1_4_SPLITS )), TV011B_TV2_SECRET );
10241023 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{3 , 4 }, TV011B_TV2_3_4_SPLITS )), TV011B_TV2_SECRET );
10251024 splitter = polynomialFactory .newInstance (5 , 3 , 4 , getSecureRandom (TV011B_TV3_SR ));
1026- testMatrixMultiplication (splitter , TV011B_TV3_SPLITS );
1025+ testMatrixMultiplication (splitter , TV011B_TV3_SPLITS , 3 , 4 );
10271026 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 }, TV011B_TV3_1_2_3_SPLITS )), TV011B_TV3_SECRET );
10281027 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 4 }, TV011B_TV3_1_2_4_SPLITS )), TV011B_TV3_SECRET );
10291028 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 3 , 4 }, TV011B_TV3_1_3_4_SPLITS )), TV011B_TV3_SECRET );
10301029 splitter = polynomialFactory .newInstance (5 , 4 , 4 , getSecureRandom (TV011B_TV4_SR ));
1031- testMatrixMultiplication (splitter , TV011B_TV4_SPLITS );
1030+ testMatrixMultiplication (splitter , TV011B_TV4_SPLITS , 4 , 4 );
10321031 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 , 4 }, TV011B_TV4_1_2_3_4_SPLITS )), TV011B_TV4_SECRET );
10331032 splitter = polynomialFactory .newInstance (9 , 2 , 9 , getSecureRandom (TV011B_TV5_SR ));
1034- testMatrixMultiplication (splitter , TV011B_TV5_SPLITS );
1033+ testMatrixMultiplication (splitter , TV011B_TV5_SPLITS , 2 , 9 );
10351034 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011B_TV5_1_2_SPLITS )), TV011B_TV5_SECRET );
10361035 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{8 , 9 }, TV011B_TV5_8_9_SPLITS )), TV011B_TV5_SECRET );
10371036 splitter = polynomialFactory .newInstance (15 , 3 , 5 , getSecureRandom (TV011B_TV6_SR ));
1038- testMatrixMultiplication (splitter , TV011B_TV6_SPLITS );
1037+ testMatrixMultiplication (splitter , TV011B_TV6_SPLITS , 3 , 5 );
10391038 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 }, TV011B_TV6_1_2_3_SPLITS )), TV011B_TV6_SECRET );
10401039 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{2 , 3 , 4 }, TV011B_TV6_2_3_4_SPLITS )), TV011B_TV6_SECRET );
10411040 }
@@ -1044,27 +1043,27 @@ private void testPolynoimial2(PolynomialFactory polynomialFactory)
10441043 throws IOException
10451044 {
10461045 ShamirSecretSplitter poly = polynomialFactory .newInstance (5 , 2 , 2 , getSecureRandom (TV011D_TV1_SR ));
1047- testMatrixMultiplication (poly , TV011D_TV1_SPLITS );
1046+ testMatrixMultiplication (poly , TV011D_TV1_SPLITS , 2 , 2 );
10481047 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011D_TV1_1_2_SPLITS )), TV011D_TV1_SECRET );
10491048 poly = polynomialFactory .newInstance (5 , 2 , 4 , getSecureRandom (TV011D_TV2_SR ));
1050- testMatrixMultiplication (poly , TV011D_TV2_SPLITS );
1049+ testMatrixMultiplication (poly , TV011D_TV2_SPLITS , 2 , 4 );
10511050 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011D_TV2_1_2_SPLITS )), TV011D_TV2_SECRET );
10521051 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 4 }, TV011D_TV2_1_4_SPLITS )), TV011D_TV2_SECRET );
10531052 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{3 , 4 }, TV011D_TV2_3_4_SPLITS )), TV011D_TV2_SECRET );
10541053 poly = polynomialFactory .newInstance (5 , 3 , 4 , getSecureRandom (TV011D_TV3_SR ));
1055- testMatrixMultiplication (poly , TV011D_TV3_SPLITS );
1054+ testMatrixMultiplication (poly , TV011D_TV3_SPLITS , 3 , 4 );
10561055 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 }, TV011D_TV3_1_2_3_SPLITS )), TV011D_TV3_SECRET );
10571056 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 4 }, TV011D_TV3_1_2_4_SPLITS )), TV011D_TV3_SECRET );
10581057 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 3 , 4 }, TV011D_TV3_1_3_4_SPLITS )), TV011D_TV3_SECRET );
10591058 poly = polynomialFactory .newInstance (5 , 4 , 4 , getSecureRandom (TV011D_TV4_SR ));
1060- testMatrixMultiplication (poly , TV011D_TV4_SPLITS );
1059+ testMatrixMultiplication (poly , TV011D_TV4_SPLITS , 4 , 4 );
10611060 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 , 4 }, TV011D_TV4_1_2_3_4_SPLITS )), TV011D_TV4_SECRET );
10621061 poly = polynomialFactory .newInstance (9 , 2 , 9 , getSecureRandom (TV011D_TV5_SR ));
1063- testMatrixMultiplication (poly , TV011D_TV5_SPLITS );
1062+ testMatrixMultiplication (poly , TV011D_TV5_SPLITS , 2 , 9 );
10641063 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 }, TV011D_TV5_1_2_SPLITS )), TV011D_TV5_SECRET );
10651064 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{8 , 9 }, TV011D_TV5_8_9_SPLITS )), TV011D_TV5_SECRET );
10661065 poly = polynomialFactory .newInstance (15 , 3 , 5 , getSecureRandom (TV011D_TV6_SR ));
1067- testMatrixMultiplication (poly , TV011D_TV6_SPLITS );
1066+ testMatrixMultiplication (poly , TV011D_TV6_SPLITS , 3 , 5 );
10681067 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{1 , 2 , 3 }, TV011D_TV6_1_2_3_SPLITS )), TV011D_TV6_SECRET );
10691068 testRecombine (polynomialFactory .newInstance (getShamirSplitSecretShareArray (new int []{2 , 3 , 4 }, TV011D_TV6_2_3_4_SPLITS )), TV011D_TV6_SECRET );
10701069 }
@@ -1092,10 +1091,10 @@ static ShamirSplitSecretShare[] getShamirSplitSecretShareArray(int[] rr, byte[][
10921091 return secretShares ;
10931092 }
10941093
1095- static void testMatrixMultiplication (ShamirSecretSplitter poly , byte [][] splits )
1094+ static void testMatrixMultiplication (ShamirSecretSplitter poly , byte [][] splits , int m , int n )
10961095 throws IOException
10971096 {
1098- ShamirSplitSecretShare [] secretShares = poly .split ().getSecretShares ();
1097+ ShamirSplitSecretShare [] secretShares = poly .split (m , n ).getSecretShares ();
10991098 byte [][] result = new byte [splits .length ][splits [0 ].length ];
11001099 for (int i = 0 ; i < result .length ; ++i )
11011100 {
0 commit comments