Skip to content

Commit

Permalink
fixxed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-sekanina committed May 16, 2023
1 parent d152389 commit 3a1af21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions applet/src/main/java/applet/MainApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ short validatePolicy(){
break;

case Policy.signedPSBT:
SetAndVerify.setPublicKey(privDataStorage[policy[(short) (stepCounter + 1)]].array,
privDataStorage[policy[(short) (stepCounter + 1)]].offset);
try {
if (SetAndVerify.verifyECDSA(PSBTdata, transactionOffset, pubDataStorage[policy[(short) (stepCounter + 1)]].array,
pubDataStorage[policy[(short) (stepCounter + 1)]].offset)) {
Expand Down
7 changes: 3 additions & 4 deletions applet/src/test/java/tests/AppletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void appletSignedTimeTest() throws Exception {
}

@Test
void appletSignedPSBTtest() throws Exception {
void appletSignedPSBTTest() throws Exception {
Download download = new Download();
Upload upload = new Upload();
CardManager manager = connect();
Expand All @@ -396,7 +396,7 @@ void appletSignedPSBTtest() throws Exception {
setBoth(priKey, pubKey);
short sigLen = SetSignAndVerify.SignECDSA(transaction, signatureTMP);
byte[] signature = new byte[sigLen];
Util.arrayCopyNonAtomic(signatureTMP, (short) 0, signature, (short) 0, sigLen); // disgusting stuff I know
Util.arrayCopyNonAtomic(signatureTMP, (short) 0, signature, (short) 0, sigLen);

byte[] policy = fromHex("0800"); // policy checks signed transaction

Expand All @@ -405,9 +405,8 @@ void appletSignedPSBTtest() throws Exception {
upload.sendData(policy, (byte) AppletInstructions.CLASS_POLICY_UP, manager);

upload.sendData(signature, (byte) AppletInstructions.CLASS_ADD_DATA_UP, (byte) 0, (byte) 0, manager);

upload.sendData(transaction2, (byte) AppletInstructions.CLASS_PSBT_UP, manager);
upload.sendData(signature, (byte) AppletInstructions.CLASS_ADD_DATA_UP, (byte) 0, (byte) 0, manager);

Assertions.assertEquals(0, download.downloadValidation(manager));

upload.sendData(signature, (byte) AppletInstructions.CLASS_ADD_DATA_UP, (byte) 0, (byte) 0, manager);
Expand Down

0 comments on commit 3a1af21

Please sign in to comment.