28
}
//Put all shares in a 2D array of
shares per set and writing
to a file. (not shown)
}
//Function to get
a non repeated value of Z
GetZ()
{
//getting a non zero random number Z lesser than key.
Z = new BigInteger(key, 10, new Random()); //BigInteger
way of generating random Z of the size of key.
redoFlag=0;
for(int i =0; i<=tempIndexCount; i++)
{
if( ( Z == KeysMod[i]) || ( Z == key - keysMod[i] ) )
{
redoFlag=1;
break;
}
}
if
(redoFlag
==0)
{
//Z
was correctly generated,
store Z
KeysMod[tempIndex]
=Z;
tempIndexCount= tempIndex;
tempIndex++;
}
else if (redoFlag ==1)
{
// Need to regenerate Z:
Z
=
GetZ();
}
return Z;
}
Consider a simplified example, where the complete private key is 1000.
We compute the
first set to show how the shares would be computed for a threshold of 5.
Do'stlaringiz bilan baham: