Skip to content

Commit

Permalink
Merge pull request #62 from blooo-io/feat/LDG-526-nano-app-implement-…
Browse files Browse the repository at this point in the history
…signupdatecredential-method

Feat/ldg 526 nano app implement signupdatecredential method
  • Loading branch information
n4l5u0r authored Dec 16, 2024
2 parents 4e9d229 + 8921142 commit 78c7439
Show file tree
Hide file tree
Showing 37 changed files with 383 additions and 11 deletions.
81 changes: 75 additions & 6 deletions src/common/ui/display_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,21 +380,90 @@ void startConfigureDelegationDisplay(void) {
}

void uiSignUpdateCredentialThresholdDisplay(volatile unsigned int *flags) {
return;
// Create tag-value pairs for the content
uint8_t pairIndex = 0;

// Add threshold information
pairs[pairIndex].item = "Threshold";
pairs[pairIndex].value = (char *)global.signCredentialDeploymentContext.threshold;
pairIndex++;

// Create the page content
nbgl_contentTagValueList_t content;
content.nbPairs = pairIndex;
content.pairs = pairs;
content.smallCaseForValue = false;
content.nbMaxLinesForValue = 0;
content.startIndex = 0;

// Setup the review screen - this is the final step so use nbgl_useCaseReview
nbgl_useCaseReview(TYPE_TRANSACTION,
&content,
&C_app_concordium_64px,
"Review Transaction",
NULL, // No subtitle
"Sign transaction",
review_choice_sign);

*flags |= IO_ASYNCH_REPLY;
// TODO: Implement this
}

void uiSignUpdateCredentialInitialDisplay(volatile unsigned int *flags) {
return;
// Create tag-value pairs for the content
uint8_t pairIndex = 0;

// Add sender address
pairs[pairIndex].item = "Sender";
pairs[pairIndex].value = (char *)global_account_sender.sender;
pairIndex++;

// Create the page content
nbgl_contentTagValueList_t content;
content.nbPairs = pairIndex;
content.pairs = pairs;
content.smallCaseForValue = false;
content.nbMaxLinesForValue = 0;
content.startIndex = 0;

// Setup the review screen
nbgl_useCaseReviewLight(TYPE_OPERATION,
&content,
&C_app_concordium_64px,
"Review",
"details",
"Continue with transaction",
sendSuccessNoIdleCallback);

*flags |= IO_ASYNCH_REPLY;
// TODO: Implement this
}

void uiSignUpdateCredentialIdDisplay(volatile unsigned int *flags) {
return;
// Create tag-value pairs for the content
uint8_t pairIndex = 0;

// Add credential ID information
pairs[pairIndex].item = "Credential ID";
pairs[pairIndex].value = (char *)global.signCredentialDeploymentContext.credentialId;
pairIndex++;

// Create the page content
nbgl_contentTagValueList_t content;
content.nbPairs = pairIndex;
content.pairs = pairs;
content.smallCaseForValue = false;
content.nbMaxLinesForValue = 0;
content.startIndex = 0;

// Setup the review screen
nbgl_useCaseReviewLight(TYPE_OPERATION,
&content,
&C_app_concordium_64px,
"Review",
"details",
"Continue with transaction",
sendSuccessNoIdleCallback);

*flags |= IO_ASYNCH_REPLY;
// TODO: Implement this
}

void uiSignCredentialDeploymentVerificationKeyDisplay(volatile unsigned int *flags) {
Expand Down
151 changes: 151 additions & 0 deletions tests/application_client/boilerplate_command_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,157 @@ def credential_deployment_part_3(
print("km--------sent new or existing", response)
yield response

@contextmanager
def credential_update_part_1(
self,
data: bytes,
) -> Generator[None, None, None]:
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_NONE,
p2=P2.P2_NONE,
data=data,
) as response:
yield response

@contextmanager
def sign_update_credential_part_2(
self,
key_index: bytes,
number_of_keys: int,
key: bytes,
) -> Generator[None, None, None]:
# Send all keys
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_NONE,
p2=P2.P2_CREDENTIAL_CREDENTIAL_INDEX,
data=key_index,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_VERIFICATION_KEY_LENGTH,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=bytes.fromhex(f"{number_of_keys:02x}"),
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_VERIFICATION_KEY,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=key,
) as response:
yield response

@contextmanager
def sign_update_credential_part_3(
self,
signature_threshold: bytes,
ar_identity: bytes,
credential_dates: bytes,
attribute_tag: bytes,
attribute_value: bytes,
proof_length: bytes,
proofs: bytes,
credential_id_list: List[bytes],
) -> Generator[None, None, None]:
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_SIGNATURE_THRESHOLD,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=signature_threshold,
):
pass

with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_AR_IDENTITY,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=ar_identity,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_CREDENTIAL_DATES,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=credential_dates,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_ATTRIBUTE_TAG,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=attribute_tag,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_ATTRIBUTE_VALUE,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=attribute_value,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_LENGTH_OF_PROOFS,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=proof_length,
):
pass
proof_chunks = split_message(proofs, MAX_APDU_LEN)
for i, chunk in enumerate(proof_chunks):
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_PROOFS,
p2=P2.P2_CREDENTIAL_CREDENTIAL,
data=chunk,
):
pass
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_NONE,
p2=P2.P2_CREDENTIAL_ID_COUNT,
data=bytes.fromhex(f"{len(credential_id_list):02x}"),
):
pass
for i, credential_id in enumerate(credential_id_list):
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_NONE,
p2=P2.P2_CREDENTIAL_ID,
data=credential_id,
) as response:
if i == len(credential_id_list) - 1:
yield response

@contextmanager
def sign_update_credential_part_4(
self,
threshold: bytes,
) -> Generator[None, None, None]:
with self.backend.exchange_async(
cla=CLA,
ins=InsType.SIGN_UPDATE_CREDENTIAL,
p1=P1.P1_NONE,
p2=P2.P2_THRESHOLD,
data=threshold,
) as response:
yield response

@contextmanager
def sign_public_information_for_ip_part_1(
self, chunks: List[bytes]
Expand Down
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 78c7439

Please sign in to comment.