Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
tlv_use_case_transaction_check.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2025 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include "tlv_library.h"
20#include "buffer.h"
21
22/* TLV use-case API on top of the TLV library
23 *
24 * This SDK helper implements the Transaction Check descriptor parsing.
25 *
26 * Please refer to the tlv_library.h file for documentation on how to write your own use-case if it
27 * does not follow the above specification.
28 *
29 * This descriptor associates a transaction or typed-data hash with a risk assessment from a
30 * security provider. The trusted information comes from the Ledger backend and is forwarded by
31 * Ledger Live.
32 */
33
34// Maximum sizes from the spec
35#define TRANSACTION_CHECK_HASH_SIZE CX_SHA3_256_SIZE
36#define TRANSACTION_CHECK_MSG_SIZE 25
37#define TRANSACTION_CHECK_URL_SIZE 30
38// EVM address is 20 bytes, Solana base58 address is up to 44 bytes
39#define TRANSACTION_CHECK_MIN_ADDRESS_SIZE 20
40#define TRANSACTION_CHECK_MAX_ADDRESS_SIZE 44
41
42#define TRANSACTION_CHECK_PARTNER_SIZE 20
43
50
56
65
66// Output of the use-case TLV parser
68 // Chain ID (required for transactions, optional for typed data)
69 uint64_t chain_id;
70 // Transaction or message hash (32 bytes, zero-copy)
72 // Domain hash for EIP-712 typed data (32 bytes, zero-copy)
74 // Provider message (ASCII printable, null-terminated)
76 // Report URL (null-terminated)
78 // Sender address (variable size, zero-copy)
80 // Partner name (from PKI certificate, null-terminated)
82 // Risk level
84 // Simulation type
86 // Risk category
88
89 // Flag optional tags reception
95
106
char partner[TRANSACTION_CHECK_PARTNER_SIZE+1]
transaction_check_category_t category
char provider_msg[TRANSACTION_CHECK_MSG_SIZE+1]
char tiny_url[TRANSACTION_CHECK_URL_SIZE+1]
#define TRANSACTION_CHECK_URL_SIZE
#define TRANSACTION_CHECK_PARTNER_SIZE
enum transaction_check_risk_e transaction_check_risk_t
enum tlv_transaction_check_status_e tlv_transaction_check_status_t
enum transaction_check_type_e transaction_check_type_t
@ TRANSACTION_CHECK_CATEGORY_LOSING_OPERATION
@ TRANSACTION_CHECK_CATEGORY_COUNT
@ TRANSACTION_CHECK_CATEGORY_ADDRESS
@ TRANSACTION_CHECK_CATEGORY_DAPP
@ TRANSACTION_CHECK_CATEGORY_OTHERS
@ TRANSACTION_CHECK_TYPE_TRANSACTION
@ TRANSACTION_CHECK_TYPE_TYPED_DATA
struct tlv_transaction_check_out_s tlv_transaction_check_out_t
tlv_transaction_check_status_t tlv_use_case_transaction_check(const buffer_t *payload, tlv_transaction_check_out_t *out)
Parse a Transaction Check TLV payload.
@ TRANSACTION_CHECK_RISK_MALICIOUS
#define TRANSACTION_CHECK_MSG_SIZE
@ TLV_TRANSACTION_CHECK_SIGNATURE_ERROR
@ TLV_TRANSACTION_CHECK_UNKNOWN_VERSION
@ TLV_TRANSACTION_CHECK_MISSING_STRUCTURE_TAG
@ TLV_TRANSACTION_CHECK_MISSING_TAG
@ TLV_TRANSACTION_CHECK_PARSING_ERROR
enum transaction_check_category_e transaction_check_category_t