forked from Concordium/concordium-ledger-app
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/LDG-535--nano-app-implement-deploy-method #36
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
04c3d10
feat(deploy): implement deployModule instruction and test
keiff3r d8a2d85
fix: add previously deleted function
keiff3r 2f5611f
fix(test): correct deploy module test and decorator
keiff3r 4ee2f7a
fix(test): remove incorrect decorator from credential_deployment_part_1
keiff3r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "os.h" | ||
#include "common/ui/display.h" | ||
#include "common/responseCodes.h" | ||
#include "common/sign.h" | ||
#include "common/util.h" | ||
#include "deployModule.h" | ||
|
||
static deployModule_t *ctx_deploy_module = &global.deployModule; | ||
static tx_state_t *tx_state = &global_tx_state; | ||
|
||
#define P1_INITIAL 0x00 | ||
#define P1_SOURCE 0x01 | ||
|
||
void handleDeployModule(uint8_t *cdata, uint8_t p1, uint8_t lc) { | ||
if (p1 == P1_INITIAL) { | ||
cdata += parseKeyDerivationPath(cdata); | ||
cx_sha256_init(&tx_state->hash); | ||
cdata += hashAccountTransactionHeaderAndKind(cdata, DEPLOY_MODULE); | ||
|
||
// hash the version and source length | ||
updateHash((cx_hash_t *) &tx_state->hash, cdata, 8); | ||
ctx_deploy_module->version = U4BE(cdata, 0); | ||
ctx_deploy_module->sourceLength = U4BE(cdata, 4); | ||
ctx_deploy_module->remainingSourceLength = ctx_deploy_module->sourceLength; | ||
// TODO: Format the version | ||
numberToText((uint8_t *) ctx_deploy_module->versionDisplay, | ||
sizeof(ctx_deploy_module->versionDisplay), | ||
ctx_deploy_module->version); | ||
sendSuccessNoIdle(); | ||
} | ||
|
||
else if (p1 == P1_SOURCE && ctx_deploy_module->remainingSourceLength > 0) { | ||
if (ctx_deploy_module->remainingSourceLength < lc) { | ||
THROW(ERROR_INVALID_SOURCE_LENGTH); | ||
} | ||
|
||
updateHash((cx_hash_t *) &tx_state->hash, cdata, lc); | ||
ctx_deploy_module->remainingSourceLength -= lc; | ||
if (ctx_deploy_module->remainingSourceLength > 0) { | ||
sendSuccessNoIdle(); | ||
} else if (ctx_deploy_module->remainingSourceLength == 0) { | ||
uiDeployModuleDisplay(); | ||
} | ||
|
||
} else { | ||
THROW(ERROR_INVALID_STATE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
/** | ||
* Handles the DEPLOY_MODULE instruction, which deploys a module | ||
* | ||
* | ||
*/ | ||
void handleDeployModule(uint8_t *cdata, uint8_t p1, uint8_t p2); | ||
|
||
typedef struct { | ||
uint32_t version; | ||
uint32_t sourceLength; | ||
uint32_t remainingSourceLength; | ||
uint8_t sourceHash[32]; | ||
char sourceHashDisplay[65]; | ||
char versionDisplay[11]; | ||
} deployModule_t; | ||
|
||
// typedef struct { | ||
// uint8_t version[32]; | ||
// uint8_t sourceLength[32]; | ||
// } deployModuleBlob_t; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
|
||
from application_client.boilerplate_command_sender import ( | ||
BoilerplateCommandSender, | ||
Errors, | ||
) | ||
from application_client.boilerplate_response_unpacker import ( | ||
unpack_get_public_key_response, | ||
) | ||
from ragger.bip import calculate_public_key_and_chaincode, CurveChoice | ||
from ragger.error import ExceptionRAPDU | ||
from ragger.navigator import NavInsID, NavIns | ||
from ragger.firmware import Firmware | ||
from utils import navigate_until_text_and_compare, instructions_builder | ||
|
||
|
||
@pytest.mark.active_test_scope | ||
def test_deploy_module( | ||
backend, firmware, navigator, test_name, default_screenshot_path | ||
): | ||
client = BoilerplateCommandSender(backend) | ||
path = "m/1105/0/0/0/0/2/0/0" | ||
header_and_type = bytes.fromhex( | ||
"20a845815bd43a1999e90fbf971537a70392eb38f89e6bd32b3dd70e1a9551d7000000000000000a0000000000000064000000290000000063de5da700" | ||
) | ||
version = 1 | ||
source = b"source" | ||
|
||
with client.deploy_module( | ||
path=path, header_and_type=header_and_type, version=version, source=source | ||
): | ||
navigate_until_text_and_compare( | ||
firmware, navigator, "Sign", default_screenshot_path, test_name | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Commented-out code Note