Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit e83f71f

Browse files
committed
Fixes #44: non-default security level signing
1 parent 4a76d81 commit e83f71f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/main/java/jota/utils/IotaAPIUtils.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,19 @@ public static List<String> signInputsAndReturn(final String seed,
9696

9797
// Because the signature is > 2187 trytes, we need to
9898
// find the second transaction to add the remainder of the signature
99-
for (int k = 0; k < bundle.getTransactions().size(); k++) {
100-
// Same address as well as value = 0 (as we already spent the input)
101-
if (bundle.getTransactions().get(k).getAddress().equals(thisAddress) && bundle.getTransactions().get(k).getValue() == 0) {
102-
// Use the second 6562 trits
103-
int[] secondFragment = Arrays.copyOfRange(key, 6561, 6561 * 2);
99+
// Same address as well as value = 0 (as we already spent the input)
100+
if (bundle.getTransactions().get(i + j).getAddress().equals(thisAddress) && bundle.getTransactions().get(i + j).getValue() == 0) {
101+
// Use the second 6562 trits
102+
int[] secondFragment = Arrays.copyOfRange(key, 6561 * j, 6561 * (j + 1));
104103

105-
// The second 27 to 54 trytes of the bundle hash
106-
int[] secondBundleFragment = Arrays.copyOfRange(normalizedBundleHash, 27, 27 * 2);
104+
// The second 27 to 54 trytes of the bundle hash
105+
int[] secondBundleFragment = Arrays.copyOfRange(normalizedBundleHash, 27 * j, 27 * (j + 1));
107106

108-
// Calculate the new signature
109-
int[] secondSignedFragment = new Signing(curl).signatureFragment(secondBundleFragment, secondFragment);
107+
// Calculate the new signature
108+
int[] secondSignedFragment = new Signing(curl).signatureFragment(secondBundleFragment, secondFragment);
110109

111-
// Convert signature to trytes and assign it again to this bundle entry
112-
bundle.getTransactions().get(k).setSignatureFragments(Converter.trytes(secondSignedFragment));
113-
}
110+
// Convert signature to trytes and assign it again to this bundle entry
111+
bundle.getTransactions().get(i+j).setSignatureFragments(Converter.trytes(secondSignedFragment));
114112
}
115113
}
116114
}

0 commit comments

Comments
 (0)