To generate these keys, I xor two values together. The methods that perform this operation yield the keySeed value. This operation was considered trivial and hence it isn’t disclosed in the code that I have quoted.
Using SHA1 keys, I go about calculating the key pair twice. I then compare the first key pair to the second and see if I get a true or a false answer.
I have tried a comparison using mock-up code, and I have disclosed the main method here. The code generates what I believed would be the same key pair twice and compares them…
var arg1="65cfa78989387ca19f18d1d54af0d45dfb8fd9ee";
var arg2="783C82C2E6394A329A8149564E1B6AB74AA70FBD";
var keySeed=Sovereignty.bitwiseXor(Sovereignty.hexStringToByteArray(arg1),Sovereignty.hexStringToByteArray(arg2));
SecureRandom random;
try{
random=SecureRandom.getInstance("SHA1PRNG");
}catch(NoSuchAlgorithmException x){
throw new RuntimeException(x);
}
// First key...
random.setSeed(keySeed);
KeyPairGenerator keyGen1;
try{
keyGen1=KeyPairGenerator.getInstance("DSA");
}catch(NoSuchAlgorithmException x){
throw new RuntimeException(x);
}
keyGen1.initialize(1024,random);
var firstKey=keyGen1.generateKeyPair();
// Second key...
random.setSeed(keySeed);
KeyPairGenerator keyGen2;
try{
keyGen2=KeyPairGenerator.getInstance("DSA");
}catch(NoSuchAlgorithmException x){
throw new RuntimeException(x);
}
keyGen2.initialize(1024,random);
var secondKey=keyGen2.generateKeyPair();
System.out.println(firstKey.getPublic().equals(secondKey.getPublic()));
However, the test on the final line returns false, when I am expecting it to return true.
What am I doing wrong?