Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
tlv_use_case_trusted_name.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 following cross-application specification:
25 * https://ledgerhq.atlassian.net/wiki/spaces/TrustServices/pages/3736863735/LNS+Arch+Nano+Trusted+Names+Descriptor+Format+APIs
26 *
27 * Please refer to the tlv_library.h file for documentation on how to write your own use-case if it
28 * does not follow the above specification.
29 *
30 * This descriptor associates a Blockchain address to a trusted domain name.
31 * The trusted information comes from the Ledger CAL and is forwarded by the Ledger Live.
32 */
33
34#define TRUSTED_NAME_STRINGS_MAX_SIZE 64
35#define NFT_ID_SIZE 32
36
37// source_contract_received field exists from version 2
38#define SOURCE_CONTRACT_RECEIVED_MIN_VERSION 2
39#define CURRENT_TRUSTED_NAME_SPEC_VERSION 3
40
41#define SEMVER_SIZE 3
42
43#define DER_SIGNATURE_MIN_SIZE 64 // Ed25519 size
44#define DER_SIGNATURE_MAX_SIZE 72 // ECDSA max size
45
49
58
68
73
83
84typedef struct semver_s {
85 uint8_t major;
86 uint8_t minor;
87 uint16_t patch;
89
90// Output of the use-case TLV parser
91typedef struct tlv_trusted_name_out_s {
92 // Version number of the serialization format
93 uint8_t version;
94 // Encodes what type of trusted name this descriptor describes. tlv_trusted_name_type_t
96 // Describes the namespace in which the trusted name is defined. tlv_trusted_name_source_t
98 // The trusted name (UTF-8 string)
100 // The chain id of the network for which the trusted name was set.
101 uint64_t chain_id;
102 // The address resolved by the trusted name
104
105 // Optional fields, set only if the individual flags below are true
106 // The token id of the NFT)
108 // The source contract which created this address)
110 // A challenge to ensure the freshness of the trusted name.
111 uint32_t challenge;
112 // A version date to revoke the trusted name validity.
114
115 // Flag optional tags reception
121
135
tlv_trusted_name_status_t tlv_use_case_trusted_name(const buffer_t *payload, tlv_trusted_name_out_t *out)
Processes a TLV dynamic descriptor use case.
tlv_trusted_name_signer_key_id_e
@ TLV_TRUSTED_NAME_SIGNER_KEY_ID_PROD
@ TLV_TRUSTED_NAME_SIGNER_KEY_ID_TEST
@ TLV_TRUSTED_NAME_TYPE_EOA
@ TLV_TRUSTED_NAME_TYPE_TOKEN
@ TLV_TRUSTED_NAME_TYPE_COLLECTION
@ TLV_TRUSTED_NAME_TYPE_WALLET
@ TLV_TRUSTED_NAME_TYPE_SMART_CONTRACT
@ TLV_TRUSTED_NAME_TYPE_CONTEXT_ADDRESS
enum tlv_trusted_name_status_e tlv_trusted_name_status_t
@ TLV_STRUCTURE_TYPE_TRUSTED_NAME
enum tlv_trusted_name_type_e tlv_trusted_name_type_t
enum tlv_trusted_name_source_e tlv_trusted_name_source_t
@ TLV_TRUSTED_NAME_WRONG_KEY_ID
@ TLV_TRUSTED_NAME_SIGNATURE_ERROR
@ TLV_TRUSTED_NAME_PARSING_ERROR
@ TLV_TRUSTED_NAME_UNKNOWN_VERSION
@ TLV_TRUSTED_NAME_SUCCESS
@ TLV_TRUSTED_NAME_MISSING_TAG
@ TLV_TRUSTED_NAME_UNSUPPORTED_TAG
@ TLV_TRUSTED_NAME_MISSING_STRUCTURE_TAG
@ TLV_TRUSTED_NAME_WRONG_TYPE
@ TLV_TRUSTED_NAME_HASH_FAILED
struct semver_s semver_t
@ TLV_TRUSTED_NAME_SOURCE_CRYPTO_ASSET_LIST
@ TLV_TRUSTED_NAME_SOURCE_ENS
@ TLV_TRUSTED_NAME_SOURCE_UNSTOPPABLE_DOMAINS
@ TLV_TRUSTED_NAME_SOURCE_DNS
@ TLV_TRUSTED_NAME_SOURCE_DYNAMIC_RESOLVER
@ TLV_TRUSTED_NAME_SOURCE_LOCAL_ADDRESS_BOOK
@ TLV_TRUSTED_NAME_SOURCE_FREENAME
enum tlv_trusted_name_signer_algorithm_e tlv_trusted_name_signer_algorithm_t
tlv_trusted_name_signer_algorithm_e
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_ECDSA_SHA3_256
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_EDDSA_KECCAK_256
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_ECDSA_SHA256
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_ECDSA_KECCAK_256
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_EDDSA_SHA3_256
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_ECDSA_RIPEMD160
@ TLV_TRUSTED_NAME_SIGNER_ALGORITHM_ECDSA_SHA512
enum tlv_structure_type_e tlv_structure_type_t
enum tlv_trusted_name_signer_key_id_e tlv_trusted_name_signer_key_id_t
struct tlv_trusted_name_out_s tlv_trusted_name_out_t