A DAG-based hardware wallet transaction fast synchronization method, medium and system
By building a lightweight transaction structure based on DAG and the TransformerDAG model, combined with the TEE environment and lattice cryptographic conflict proof, the problem of slow transaction confirmation in hard wallets is solved, and parallel processing and fast and secure confirmation of transactions are achieved.
Patent Information
- Application Number
- CN202510912410.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-07-03
AI Technical Summary
Traditional hardware wallet technology has problems such as slow transaction confirmation, inability to process in parallel, lack of transaction priority management mechanism, and insecure lightweight verification, which are particularly prominent in high-frequency transactions and unstable network environments.
It adopts a lightweight transaction structure based on DAG, combined with local verification, Bloom filter screening and lattice cryptographic conflict proof in the TEE environment, uses the TransformerDAG model for structural optimization, and optimizes transactions through a dynamic pruning algorithm and adaptive gating weight function.
It realizes parallel processing and rapid confirmation of transactions, reduces the amount of network synchronization data, ensures transaction security and system stability, and improves transaction confirmation speed and system throughput.
Smart Images

Figure CN120410528B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of hard wallet transactions, and in particular, relates to a DAG-based fast synchronization method, medium, and system for hard wallet transactions. Background Art
[0002] Blockchain hardware wallets, as a crucial medium for secure storage and transaction of digital assets, are widely used in financial transactions, cross-border payments, and other fields. Traditional hardware wallets use a chained structure to store transaction data, ensuring security through full node verification. After offline transactions, they require synchronization with the mainnet to confirm transaction validity. Currently, most hardware wallets use the UTXO model to manage transaction outputs, relying on centralized nodes for transaction broadcast and confirmation, or employ the Simplified Payment Verification (SPV) protocol for lightweight verification. However, traditional hardware wallet technology faces numerous challenges: the chained storage structure creates a sequential dependency for transaction confirmation, limiting parallel processing capabilities; offline transactions require full synchronization with the mainnet, resulting in lengthy synchronization times; the lack of an efficient transaction priority management mechanism makes it difficult to prioritize critical transactions during network congestion; and lightweight verification fails to provide comprehensive security guarantees, making it vulnerable to double-spending attacks. These issues are primarily manifested in the slow transaction confirmation process during offline hardware wallet synchronization with the network, which is particularly prominent in high-frequency transactions or under unstable network conditions. Existing technologies struggle to achieve fast transaction confirmation while ensuring security, necessitating an innovative solution that addresses this core issue. Summary of the Invention
[0003] In view of this, the present invention provides a DAG-based fast synchronization method, medium and system for hard wallet transactions, which can solve the technical problem of slow transaction confirmation speed during the synchronization of hard wallet offline transactions and network in the prior art.
[0004] The present invention is implemented as follows: In a first aspect, the present invention provides a DAG-based fast synchronization method for hard wallet transactions, comprising: constructing a local lightweight DAG transaction structure for a hard wallet; a user initiates an offline transaction through a hard wallet, performs a transaction validity check in a local TEE environment, screens whether the UTXO has been consumed through a Bloom filter, and generates a transaction security status identifier; constructs a DAG node based on transaction information, verifies validity through DAG path backtracing, generates a lattice space commitment using lattice cryptographic conflict proof, and verifies the existence of no conflict vectors; after the transaction is completed, signs the DAG transaction structure through an SM2 signature, and transmits the transaction information to the counterparty's hard wallet through a near-field protocol; when the hard wallet is connected to an online transaction terminal, the transaction content is uploaded, the core system returns the difference range, and calls a transaction optimization function for preprocessing; the core system performs global verification, uses a TransformerDAG model to perform DAG structure optimization prediction, and generates a DAG optimization plan; the core system performs DAG merging based on the DAG optimization plan, selects the branch with the largest weight as the main chain through the ghost protocol, and performs DAG optimization and status update based on a dynamic pruning algorithm combined with an adaptive gating weight function.
[0005] In the local lightweight DAG transaction structure of the hard wallet, each transaction node contains a transaction hash value, a predecessor transaction hash set, signature information, and a weight field. The weight field is used for subsequent DAG merging and pruning operations.
[0006] The transaction optimization function is used to preprocess and optimize transaction data uploaded by the hard wallet. The input includes transaction set data, transaction history depth, current load level, network congestion and user transaction priority. The output is an optimized and sorted transaction sequence and its corresponding priority weight.
[0007] Among them, the transaction optimization function first deeply analyzes transaction dependencies based on transaction history, then determines the resource allocation strategy based on the current system load and network congestion, then adjusts the processing order according to the user transaction priority, and finally generates an optimized transaction sequence.
[0008] The specific structure of the TransformerDAG model is a graph neural network based on the Transformer architecture, which includes an encoder part and a decoder part. The encoder uses a multi-head self-attention mechanism to process transaction node features, and the decoder generates an optimized DAG structure through a cross-attention mechanism.
[0009] The TransformerDAG model uses a graph attention layer to capture the topological relationship between nodes, integrates position encoding to retain transaction timing information, processes node features through a feedforward neural network and layer normalization, and finally generates a DAG optimization solution using a multi-layer perceptron.
[0010] Among them, the adaptive gating weight function is calculated based on four core data: transaction load intensity, network congestion level, security threat level and user priority, to obtain a comprehensive balance value, and different weight adjustment functions are selected according to the comprehensive balance value to adjust the gating openness.
[0011] The DAG optimization scheme includes node weight adjustment suggestions, priority merging paths, and a pruning candidate list, which serve as a guide for the DAG merging process, ensuring that the Ghost Protocol can select the optimal branch as the main chain, thereby improving transaction confirmation speed and system throughput.
[0012] A second aspect of the present invention provides a computer-readable storage medium having program instructions stored therein. When the program instructions are executed in a computer, the program instructions are used to execute the above-mentioned DAG-based hard wallet transaction fast synchronization method.
[0013] A third aspect of the present invention provides a DAG-based hardware wallet transaction fast synchronization system, comprising the above-mentioned computer-readable storage medium, wherein the system is any one of a computer, a server, and a single-chip microcomputer, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor for executing program instructions stored in the computer-readable storage medium.
[0014] The present invention achieves rapid transaction verification and synchronization by constructing a lightweight DAG transaction structure, combined with local verification, Bloom filter screening, and lattice cryptographic conflict proof in a TEE environment. The method uses the TransformerDAG model for structural optimization and adjusts the DAG structure through a dynamic pruning algorithm and an adaptive gating weight function. The present invention effectively solves the problems faced by traditional hard wallet technology: the DAG structure replaces chain storage, supports parallel transaction processing and verification, and significantly improves transaction confirmation speed; local verification and Bloom filter screening in the TEE environment reduce the amount of data required for network synchronization and speed up the synchronization process; the transaction optimization function and adaptive gating weight mechanism achieve intelligent transaction priority management, ensuring that key transactions are processed first; the lattice cryptographic conflict proof and dynamic pruning algorithm provide an efficient and secure transaction verification mechanism. Through the synergistic effect of the above-mentioned technical means, the present invention successfully solves the technical problem of slow transaction confirmation speed during offline transactions and network synchronization of hard wallets, achieves rapid transaction confirmation, and at the same time ensures transaction security and system stability, providing a new solution for the further development of blockchain hard wallet technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is a flow chart of the method of the present invention.
[0016] Figure 2This is the neural network structure diagram of the TransformerDAG model in Example 2.
[0017] Figure 3 This is the architecture diagram of the DAG-based hardware wallet transaction fast synchronization system in Example 2. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0019] like Figure 1 FIG. 1 is a flowchart of a DAG-based fast synchronization method for hard wallet transactions provided by the first aspect of the present invention. The method includes the following steps:
[0020] S01. Construct a lightweight DAG transaction structure locally on the hard wallet. Each transaction node contains a transaction hash value, a set of predecessor transaction hashes, signature information, and a weight field. The weight field is used for subsequent DAG merging and pruning operations.
[0021] S02. The user initiates an offline transaction through the hard wallet, performs a transaction validity check in the local TEE environment, screens whether the UTXO has been consumed through the Bloom filter, and generates a transaction security status identifier;
[0022] S03. Construct a DAG node based on the transaction information and the transaction security status identifier, verify the validity by backtracking the DAG path, generate a lattice space commitment using lattice cryptographic conflict proof, and verify the existence of a conflict-free vector;
[0023] S04. After the transaction is completed, the DAG transaction structure is signed using the SM2 signature, and the transaction information is transmitted to the counterparty's hard wallet via Bluetooth or NFC near-field protocol;
[0024] S05. When the hard wallet is connected to the online transaction terminal, it sends the real-time transaction content and the stored offline transaction content to the core system. The core system returns the difference range and simultaneously calls the transaction optimization function to pre-process the uploaded data and output an optimized transaction sequence.
[0025] S06. After receiving the optimized and sorted transaction sequence, the core system performs global verification. First, it verifies the validity of the signature. Then, it uses the Bloom filter to complete blacklist screening and UTXO multiple consumption detection. It also uses the TransformerDAG model to perform DAG structure optimization prediction and generate a DAG optimization plan.
[0026] S07. The core system performs DAG merging based on the DAG optimization solution, selects the branch with the largest weight as the main chain through the Ghost Protocol, and performs DAG optimization and status update based on the dynamic pruning algorithm combined with the adaptive gating weight function;
[0027] The dynamic pruning algorithm refers to an algorithm that calculates transaction node weights through dynamic weights and optimizes the DAG structure based on a pruning threshold. The dynamic weights are calculated based on the transaction node's coin string split level, parent transaction weight, and transaction time decay factor. The pruning threshold is determined based on the average weight and standard deviation of all nodes in the current DAG.
[0028] The TEE environment refers to a trusted execution environment, which is a secure area independent of the operating system and ensures the confidentiality and integrity of the code and data running in it.
[0029] The Bloom filter is a probabilistic data structure with high space efficiency, which is used to detect whether an element is in a set. It has the characteristics of fast query but may have false positives.
[0030] Among them, the lattice cryptographic conflict proof is a zero-knowledge proof mechanism built based on the principles of lattice cryptography, which is used to prove that the transaction has no double-spending conflict without revealing the transaction details.
[0031] Among them, the Ghost Protocol is a blockchain fork selection algorithm that considers all blocks rather than just the main chain blocks and selects the best link through cumulative proof of work.
[0032] The DAG is an abbreviation for directed acyclic graph, which is a data structure that allows multiple predecessor and successor nodes. In this method, it is used to achieve parallel processing and fast synchronization of transactions.
[0033] The UTXO is the abbreviation of unspent transaction output, which represents the transaction output that has not been spent in the blockchain network and is used as the input of new transactions.
[0034] Among them, the transaction optimization function is used to preprocess and optimize the transaction data uploaded by the hard wallet. The input includes transaction set data, transaction history depth, current load level, network congestion and user transaction priority. The transaction history depth is obtained from the storage record of the hard wallet, the current load level and the network congestion are obtained from the operating status of the core system, and the user transaction priority is obtained from the user account information. The output is an optimized and sorted transaction sequence and its corresponding priority weight; the transaction optimization function first analyzes the transaction dependency based on the transaction history depth, and then determines the resource allocation strategy in combination with the current system load and the network congestion. Then, the processing order is adjusted according to the user transaction priority. Finally, the optimized and sorted transaction sequence is generated to ensure that key transactions are processed first and improve the overall transaction throughput.
[0035] Among them, the specific structure of the TransformerDAG model is a graph neural network based on the Transformer architecture, which includes an encoder part and a decoder part. The encoder uses a multi-head self-attention mechanism to process transaction node features, and the decoder generates an optimized DAG structure through a cross-attention mechanism; the model uses a graph attention layer to capture the topological relationship between nodes, integrates position encoding to retain transaction timing information, processes node features through a feedforward neural network and layer normalization, and finally generates the DAG optimization solution through a multi-layer perceptron; the number of attention heads and hidden layer dimensions in the model are dynamically adjusted according to transaction complexity, the system load and security level to ensure optimal performance in different scenarios.
[0036] The steps for establishing a training dataset for the TransformerDAG model specifically include collecting historical transaction data and performance indicators during its processing, annotating the optimal DAG structure and pruning decisions as labels, extracting transaction attribute features including transaction amount, timestamp, priority and dependency, constructing a graph structure to represent each transaction node and its associations, classifying and organizing system performance data under different load conditions, generating training sample pairs containing input DAG structures and optimal output structures, simulating various extreme transaction scenarios through data augmentation technology, and finally dividing the dataset into training set, validation set and test set to evaluate model performance.
[0037] Among them, the steps of TransformerDAG model training specifically include initializing model parameters using pre-trained graph neural network weights, using cross-entropy loss function to evaluate the difference between model predictions and actual optimal structures, implementing gradient clipping to avoid gradient explosion problems, using Adam optimizer to adaptively adjust the learning rate, introducing early stopping mechanism to prevent overfitting, using batch normalization technology to stabilize the training process, implementing a progressive learning strategy to gradually increase the complexity from simple trading scenarios, and finally improving the model's ability to distinguish similar trading patterns through comparative learning methods.
[0038] The adaptive gating weight function is used to adjust the gating mechanism of the neural network. The adaptive gating weight function is calculated based on four core data items: transaction load intensity, network congestion level, security threat level, and user priority. The transaction load intensity is obtained from the core system processing queue, the network congestion level is obtained from the network monitoring module, the security threat level is obtained from the security monitoring system, and the user priority is obtained from user account information. An overall balance value is obtained. When the overall balance value is below a threshold of 0.3, a conservative weight adjustment function is used to reduce the gate openness to ensure security. When the overall balance value is between 0.3 and 0.7, a balanced weight adjustment function is used to strike a balance between performance and security. When the overall balance value is above 0.7, an aggressive weight adjustment function is used to increase the gate openness to maximize transaction processing efficiency. The adaptive gating weight function dynamically adjusts the focus range and intensity of the attention mechanism in the TransformerDAG model by continuously monitoring the system status, thereby achieving intelligent control of transaction processing priority and resource allocation, ensuring system stability and transaction processing efficiency under high load conditions.
[0039] The conservative weight adjustment function, the balanced weight adjustment function, and the aggressive weight adjustment function respectively adjust the parameters of the attention layer in the TransformerDAG model through different weight allocation strategies, affecting the generation process of the DAG optimization solution and ultimately affecting the execution effect of the dynamic pruning algorithm, ensuring that optimal transaction processing performance can be maintained under various system states.
[0040] The DAG optimization scheme includes node weight adjustment suggestions, priority merging paths, and a pruning candidate list, which serve as a guide for the DAG merging process, ensuring that the Ghost Protocol can select the optimal branch as the main chain, thereby improving transaction confirmation speed and system throughput.
[0041] The specific implementation of the above steps is described in detail below. The specific implementation of step S01 is to establish a lightweight DAG transaction structure in the hard wallet system. First, a unique identifier is assigned to each transaction node, and the transaction hash value is calculated using the SHA-256 hash algorithm. Secondly, the predecessor transaction hash set is stored, and the dependencies between transactions are represented by directed edges. Then, ECDSA signature information is integrated to ensure the authenticity and immutability of the transaction. Finally, the weight field is initialized and the initial weight is calculated using a weighted sum formula based on the transaction amount, number of confirmations, and timestamp. The weight value ranges from 0 to 100, and the initial default value is 10. This weight field determines the importance of the transaction in the DAG and provides a quantitative basis for subsequent merging and pruning operations. This step uses a B+ tree index structure to store transaction information, ensuring retrieval efficiency and storage space optimization, supporting the efficient operation of hard wallets in resource-constrained environments.
[0042] The specific implementation method of step S02 is to perform local validity verification when the user initiates an offline transaction through a hard wallet. First, the balance of transaction inputs and outputs is verified in the TEE environment to ensure that the transaction amount does not exceed the total available UTXO, and the legitimacy of the transaction signature is verified. Secondly, the UTXO consumption check is performed through the Bloom filter. The Bloom filter uses 4 hash functions and 8KB of storage space, and the error rate is controlled below 0.1%. The Bloom filter stores known consumed UTXO information and determines whether the current UTXO has been consumed through rapid retrieval. Then, a transaction security status identifier is generated based on the verification result. The identifier is a 32-bit integer that contains three parts of information: transaction validity, double-spending risk level, and confirmation priority. This step uses ARM TrustZone technology to implement the TEE environment, ensuring that the verification process is executed in a secure isolation area, preventing malicious code from interfering with the verification logic, and effectively improving the security and reliability of offline transactions.
[0043] The specific implementation of step S03 involves constructing a DAG node and performing validity verification. First, a new DAG node is constructed based on the transaction information and transaction security status identifier and inserted into the local DAG structure. Next, a recursive backtracking algorithm is used to trace back along the DAG path, checking the validity of all predecessor nodes. The maximum backtracking depth is 20 levels; if the depth exceeds this, the predecessor node is assumed to be valid. A lattice space commitment is then generated using a lattice cryptographic collision proof mechanism. Specifically, the NTRU lattice cryptography scheme is employed, based on the SVP (Shortest Vector Problem) difficulty, with a lattice dimension of 256 and a modulus q of 12289. This scheme represents the transaction input as a vector in the lattice and generates a zero-knowledge proof by solving for conflicts between this vector and the known set of spent UTXO vectors. Finally, a conflict-free vector is verified to confirm that the current transaction does not cause a double-spend conflict with any known transactions. This step achieves efficient verification of transaction validity by combining graph traversal algorithms with the principles of post-quantum-secure lattice cryptography.
[0044] The specific implementation of step S04 involves completing the transaction signature and performing near-field transmission. First, the DAG transaction structure is digitally signed using the national secret SM2 elliptic curve algorithm. This signing process is performed within the TEE environment to ensure that the private key is not leaked. The SM2 algorithm is based on elliptic curve cryptography and uses a 256-bit key, providing security strength comparable to RSA 2048-bit. Second, the signed transaction data is serialized using a compact binary format to reduce the amount of data transmitted, with typical transaction data sizes under 1KB. Finally, the transaction information is transmitted to the counterparty's hard wallet via Bluetooth Low Energy (BLE) or NFC. In BLE mode, the GATT protocol is used for block-based transmission, with a maximum transmission distance of 10 meters. In NFC mode, the ISO / IEC 14443 standard is used, with a maximum transmission distance of 10 centimeters. This step combines the highly secure national secret algorithm with low-power near-field communication technology to ensure secure transaction transmission in an offline environment.
[0045] Step S05 involves connecting the hard wallet to the online transaction terminal to synchronize transaction data. First, the hard wallet establishes a secure connection with the online terminal via USB, Bluetooth, or Wi-Fi, using TLS 1.3 to ensure communication security. Next, the hard wallet sends locally stored offline transaction data and the latest real-time transaction data to the core system, using a differential compression algorithm to reduce transmission volume. The core system then calculates the difference range based on the latest synchronization timestamp uploaded by the hard wallet and returns the incremental updated data. Finally, a transaction optimization function is called to pre-process the uploaded data. This function comprehensively considers five parameters: transaction set data, transaction history depth (default value is 100 blocks), current load level (range 0 to 1, threshold 0.8), network congestion (range 0 to 1, threshold 0.7), and user transaction priority (range 1 to 5), and outputs an optimized transaction sequence. This step utilizes an incremental synchronization strategy and data preprocessing mechanism to significantly reduce synchronization time and system resource consumption.
[0046] The specific implementation of step S06 is that the core system performs global transaction verification and optimization prediction. First, receive the optimized sorted transaction sequence and use batch processing to improve verification efficiency. Secondly, verify the validity of the signature of each transaction, using a batch signature verification algorithm, which improves efficiency by 40% compared to single verification. Then, perform blacklist screening through a 32MB Bloom filter to filter known malicious addresses and marked UTXOs. Next, combine the UTXO set index to quickly detect multiple consumption situations. The UTXO index is stored using a Merkle Patricia tree structure, and the query complexity is Finally, the TransformerDAG model is used to analyze and predict the current DAG structure. This model takes the current DAG topology and transaction features as input, processes them through an 8-layer Transformer encoder and a 4-layer decoder, with a hidden layer dimension of 512 and 8 attention heads, and outputs a DAG optimization solution. This step achieves efficient and accurate global transaction verification by combining traditional cryptographic verification with deep learning prediction.
[0047] The specific implementation of step S07 is to perform DAG merging and dynamic pruning optimization. First, the DAG merge operation is performed based on the DAG optimization solution generated in step S06, and the merging order is determined by the topological sorting algorithm. Secondly, the branch with the largest weight is selected as the main chain through the ghost protocol, the weight values of all transaction nodes are accumulated, and the total weight of each possible path is calculated. The path with the highest total weight is selected. The weight calculation formula comprehensively considers the number of transaction confirmations, timestamps, and transaction amounts. Then, DAG optimization is performed based on the dynamic pruning algorithm combined with the adaptive gating weight function. The dynamic weight calculation formula is: , where L is the coin string split level (value ranges from 1 to 10), is the parent transaction weight, t is the time decay factor, 、 、 and The default values of the adjustment parameters are 0.3, 0.4, 0.3 and 0.01 respectively. The pruning threshold is set to ,in is the average weight of all nodes in the current DAG, is the standard deviation. Finally, the DAG state is updated based on the pruning results, and the pruned nodes are moved to archival storage. This step combines graph theory algorithms and statistical methods to achieve dynamic optimization of the DAG structure, significantly improving transaction processing efficiency and storage space utilization.
[0048] The TransformerDAG model is a graph neural network based on the Transformer architecture, optimized for DAGs. The model consists of two parts: an encoder and a decoder. The encoder consists of eight Transformer encoding layers, each of which is composed of a multi-head self-attention mechanism and a feedforward neural network. The self-attention mechanism has eight attention heads, each with a dimension of 64, and both the input and output dimensions are 512. The encoder uses positional encoding to preserve transaction timing information, generating position vectors using sine and cosine functions. The feedforward neural network consists of two fully connected layers. The first layer maps from 512 dimensions to 2048 dimensions using the ReLU activation function, and the second layer maps back from 2048 dimensions to 512 dimensions. Each encoding layer also uses residual connections and layer normalization to ensure training stability. The decoder consists of four decoding layers, each of which incorporates a masked multi-head self-attention mechanism, a crisscross attention mechanism, and a feedforward neural network. The crisscross attention layer uses the decoder's query vector and the encoder's output as key-value pairs to perform attention calculations, achieving information fusion. The model also integrates a graph attention network layer to capture topological relationships between nodes. The attention coefficient is calculated using the LeakyReLU activation function. The final output layer consists of a multilayer perceptron, which maps from 512 dimensions to the output dimension, generating a DAG optimization solution. The model's hyperparameters are dynamically adjusted based on transaction complexity, system load, and security level. When the load index exceeds 0.8, the number of attention heads is reduced to 4 to reduce computational complexity. When the security level increases, the hidden layer dimension is increased to 768 to improve the model's expressiveness.
[0049] The training dataset for the TransformerDAG model is constructed as follows: First, large-scale transaction data and related performance metrics, including transaction confirmation time, system throughput, and resource utilization, are collected from system historical records. The data volume is no less than 10 million transaction records. Second, an expert system annotates the historical data, identifying the optimal DAG structure and pruning decisions as training labels. This annotation process is semi-automated, combining a rule engine and manual verification. Transaction attribute features are then extracted, including transaction amount (normalized to the range 0 to 1), timestamp (converted to relative time), priority (integer value 1 to 5), and dependency relationships (represented as a binary adjacency matrix). System performance data under different load conditions is then categorized into three scenarios: low load (less than 0.3), medium load (0.3 to 0.7), and high load (greater than 0.7). Data augmentation techniques are then used to simulate various extreme trading scenarios, including bursty high-frequency trading, network partitions, and Byzantine behavior, to enhance model robustness. The entire dataset construction process is based on an incremental update mechanism, with weekly updates to maintain the model's adaptability to new trading patterns. Secondly, the cross entropy loss function is used to evaluate the difference between the model prediction and the actual optimal structure. The balance coefficient of 1.5 is added to the pruning decision part to prevent excessive pruning. Then, the Adam optimizer is used to adaptively adjust the learning rate. The initial learning rate is set to , using the cosine annealing strategy for dynamic adjustment, the minimum learning rate is Then, an early stopping mechanism is introduced. If the performance of the validation set does not improve for 10 consecutive cycles, the training is stopped to prevent overfitting. Then, a progressive learning strategy is implemented. The training starts from a smaller DAG (with less than 100 nodes), gradually increases the complexity of the structure, and finally processes a large-scale DAG (with more than 100 nodes). Finally, a comparative learning approach is used to improve the model's ability to distinguish similar trading patterns. Convergence is achieved when the validation set loss is less than 0.01 or when the maximum training epochs are 200. The model is regularly updated online, with parameters fine-tuned monthly using the latest data to ensure it adapts to changing trading patterns.
[0050] It should be noted that the first main technical idea of the present invention is the combined application of a lightweight DAG transaction structure and a dynamic pruning algorithm. Traditional blockchain systems use a linear blockchain structure to store transaction data, resulting in high transaction confirmation delays and limited throughput. The present invention, by constructing a lightweight DAG transaction structure, each transaction node contains a transaction hash value, a predecessor transaction hash set, signature information, and a weight field, thereby achieving parallel processing and fast synchronization of transactions. At the same time, the dynamic pruning algorithm dynamically adjusts the DAG structure based on the transaction node weight. The weight calculation comprehensively considers the coin string splitting level, the parent transaction weight, and the time decay factor, effectively avoiding the problem of infinite expansion of the DAG structure. Through this combined application, the hard wallet can efficiently manage large amounts of transaction data in a resource-constrained environment, significantly reducing storage space requirements while maintaining the integrity and consistency of the transaction data, providing reliable support for offline transactions.
[0051] The second key technical concept of this invention is the fusion of local transaction verification within a TEE environment and a lattice cryptographic conflict proof mechanism. Traditional hardware wallets typically require an online connection for full transaction verification. However, this invention utilizes a Trusted Execution Environment (TEE) to enable offline transaction validity verification, using a Bloom filter to rapidly screen whether UTXOs have been spent. Even more innovative is the introduction of a zero-knowledge proof mechanism based on lattice cryptography principles. This mechanism represents transaction inputs as vectors within the lattice. By solving for conflicts between these vectors and a known set of spent UTXO vectors, a zero-knowledge proof is generated, demonstrating the absence of double-spend conflicts without revealing transaction details. This fusion significantly enhances the security and credibility of offline transactions, effectively resolving the technical challenge of traditional hardware wallets' inability to effectively verify transaction validity offline.
[0052] The third core technical idea of the present invention is the intelligent optimization system of the TransformerDAG model and the adaptive gating weight function. Traditional DAG optimization relies on preset rules or simple heuristic algorithms, which are difficult to adapt to complex and changing trading environments. The present invention innovatively introduces a graph neural network based on the Transformer architecture, which is specially designed for DAG optimization. It processes transaction node features through a multi-head self-attention mechanism and captures complex topological relationships between nodes. The model is combined with an adaptive gating weight function, and based on real-time data such as transaction load intensity, network congestion, security threat level and user priority, it dynamically adjusts the focus range and intensity of the attention mechanism in the model to achieve intelligent control of transaction processing priority and resource allocation. This combination greatly enhances the system's adaptability to complex trading patterns, and can automatically adjust strategies under different load conditions to maintain optimal performance.
[0053] The synergy of these three key technical approaches forms a complete closed-loop system, significantly improving the efficiency, security, and reliability of hard wallet transactions. A lightweight DAG structure and dynamic pruning algorithm provide a foundation for efficient data organization. Local verification and lattice cryptographic collision proofs within the TEE environment ensure the security of offline transactions, while the TransformerDAG model and adaptive gating weight function enable intelligent self-optimization of the system. These three elements work together to enable reliable transaction verification and processing even when the hard wallet is offline, while also enabling efficient data synchronization and integration when connected to core systems. Compared to traditional methods, this collaborative mechanism not only significantly reduces transaction confirmation time and system resource consumption, but also improves the system's ability to handle sudden, high-frequency transactions while maintaining high security and reliability. This opens new avenues for the application of blockchain technology on resource-constrained devices.
[0054] A second aspect of the present invention provides a computer-readable storage medium having program instructions stored therein. When the program instructions are executed in a computer, the program instructions are used to execute the above-mentioned DAG-based hard wallet transaction fast synchronization method.
[0055] A third aspect of the present invention provides a DAG-based hardware wallet transaction fast synchronization system, comprising the above-mentioned computer-readable storage medium, wherein the system is any one of a computer, a server, and a single-chip microcomputer, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor for executing program instructions stored in the computer-readable storage medium.
[0056] Specifically, the principle of this invention is: based on the characteristics of the DAG (Directed Acyclic Graph) data structure, combined with TEE (Trusted Execution Environment), Bloom filters, lattice cryptography, and deep learning technologies, it builds an efficient and secure hard wallet transaction synchronization mechanism. Its core principles are:
[0057] First, the DAG structure replaces the traditional chain structure, allowing transaction nodes to have multiple predecessors and successors, breaking the linear dependencies of transaction processing. This structure naturally supports parallel processing, overcoming the limitation of the traditional chain structure that transaction confirmations must be performed sequentially. In this invention, each transaction node includes a weight field, which is used in subsequent DAG merging and pruning operations, ensuring that the system can optimize the DAG structure while preserving key transaction information.
[0058] Secondly, this invention implements local transaction verification within the hardware wallet TEE environment. Combined with a Bloom filter to screen UTXO spending status, this significantly reduces the amount of data required for synchronization. The TEE environment ensures the security of the verification process, while the efficient query characteristics of the Bloom filter enable rapid transaction verification. A lattice cryptographic conflict proof mechanism uses zero-knowledge proof technology to verify transaction conflict-free transactions without disclosing transaction details, further enhancing the security and efficiency of transaction verification.
[0059] Furthermore, this paper introduces the TransformerDAG model to optimize and predict DAG structures. Based on a graph neural network built on the Transformer architecture, this model utilizes multi-head self-attention and cross-attention mechanisms to process transaction node features and capture complex relationships between nodes. By learning the optimal DAG structure from historical transaction data, the model generates an optimal DAG optimization solution for the current transaction, including node weight adjustment, prioritized merging paths, and a list of pruning candidates.
[0060] Finally, the combination of a dynamic pruning algorithm and an adaptive gating weight function enables dynamic optimization of the DAG structure. The dynamic pruning algorithm optimizes the DAG structure based on transaction node weights, while the adaptive gating weight function dynamically adjusts the focus range and intensity of the attention mechanism in the TransformerDAG model based on system state, ensuring optimal transaction processing performance under varying load conditions.
[0061] The organic combination of these technical principles enables the present invention to significantly improve transaction confirmation speed while ensuring transaction security, thereby effectively solving the core technical problems in the process of offline transactions and network synchronization of hard wallets.
[0062] A specific embodiment 1 of the present invention is provided below. The specific implementation of each step in this embodiment 1 is described in detail as follows.
[0063] The specific implementation of step S01 is to establish a lightweight DAG transaction structure in the hard wallet system. First, a unique identifier is assigned to each transaction node, and the transaction hash value is calculated using the SHA-256 hash algorithm. Second, the hash set of predecessor transactions is stored, and the dependencies between transactions are represented by directed edges. Then, ECDSA signature information is integrated to ensure the authenticity and immutability of the transaction. Finally, the weight field is initialized and the initial weight is calculated using a weighted sum formula based on the transaction amount, number of confirmations, and timestamp. The weight calculation formula is:
[0064] ;
[0065] Where, is the initial weight value, ranging from 0 to 100, and the initial default value is 10; is the normalized transaction amount, ranging from 0 to 1; is the confirmation number, a non-negative integer; is the current timestamp; is the base timestamp; The maximum time difference is 604800 seconds (7 days) by default. 、 、 is the weight coefficient, the default values are 0.4, 0.3, 0.3, and meet This weight field determines the importance of the transaction in the DAG and provides a quantitative basis for subsequent merging and pruning operations. This step uses a B+ tree index structure to store transaction information, ensuring retrieval efficiency and storage space optimization, supporting the efficient operation of hard wallets in resource-constrained environments.
[0066] The specific implementation of step S02 is to perform local validity verification when the user initiates an offline transaction through a hard wallet. First, the transaction input and output balance is verified in the TEE environment to ensure that the transaction amount does not exceed the total available UTXO, and the legitimacy of the transaction signature is verified. Secondly, the UTXO consumption is checked through the Bloom filter. The Bloom filter uses 4 hash functions and 8KB of storage space, and the error rate is controlled below 0.1%. The hash function combination of the Bloom filter is:
[0067] ;
[0068] Where, For the A hash function, The value ranges from 0 to 3; and There are two basic hash functions, MurmurHash and FNV-1a algorithms respectively; The Bloom filter bit array length is set to 65536. The Bloom filter stores known consumed UTXO information and determines whether the current UTXO has been consumed through fast retrieval. Then, based on the verification result, a transaction security status identifier is generated. The identifier is a 32-bit integer consisting of the following structure:
[0069] ;
[0070] Where, It is a safety status indicator; Transaction validity flag, value is 0 or 1; The double-spending risk level ranges from 0 to 255. To confirm the priority, the value ranges from 0 to 65535; Represents a left shift operation, Indicates a bitwise OR operation. This step utilizes ARM TrustZone technology to implement a TEE environment, ensuring that the verification process is executed in a secure, isolated area, preventing malicious code from interfering with the verification logic and effectively improving the security and reliability of offline transactions.
[0071] The specific implementation of step S03 is to construct a DAG node and perform validity verification. First, a new DAG node is constructed based on the transaction information and transaction security status identifier and inserted into the local DAG structure. Second, a recursive backtracking algorithm is used to trace back along the DAG path, checking the validity of all predecessor nodes. The maximum backtracking depth is 20 levels. If the depth exceeds this, the predecessor node is assumed to be valid. The recursive backtracking algorithm can be expressed as:
[0072] ;
[0073] Where, Representation node effectiveness; is the current backtracking depth; is the maximum backtracking depth, set to 20; For nodes local validity; For nodes The set of all predecessor nodes; Then, the lattice cryptography conflict proof mechanism is used to generate the lattice space commitment. Specifically, the NTRU lattice cryptography scheme is used, which is based on the SVP (shortest vector problem) difficulty. The lattice dimension is set to 256 and the modulus is Set to 12289. This scheme represents the transaction input as a vector in the lattice, and generates a zero-knowledge proof by solving the conflict between this vector and the known set of consumed UTXO vectors. The polynomial multiplication operation in the NTRU scheme can be expressed as:
[0074] ;
[0075] Where, is the public key polynomial; is the private key polynomial; is another private key polynomial; for In the model Finally, we verify the existence of a conflict-free vector to confirm that the current transaction does not conflict with any known transactions. This step achieves efficient verification of transaction validity by combining graph traversal algorithms with post-quantum secure lattice cryptography principles.
[0076] The specific implementation of step S04 is to complete the transaction signature and perform near-field transmission. First, the DAG transaction structure is digitally signed using the national secret SM2 elliptic curve algorithm. The signing process is performed in the TEE environment to ensure that the private key is not leaked. The SM2 algorithm is based on elliptic curve cryptography and uses a 256-bit key, providing security strength equivalent to RSA 2048 bits. The mathematical representation of the SM2 signature algorithm is:
[0077] ;
[0078] Where, is the generated signature pair; is the message digest; The user's private key. Secondly, the signed transaction data is serialized using a compact binary format to reduce the amount of data transmitted, keeping the typical transaction data size under 1KB. Finally, the transaction information is transmitted to the counterparty's hard wallet via Bluetooth Low Energy (BLE) or NFC. In BLE mode, the GATT protocol is used for block transmission, with a maximum transmission distance of 10 meters. In NFC mode, the ISO / IEC 14443 standard is used, with a maximum transmission distance of 10 centimeters. This step combines the highly secure national encryption algorithm with low-power near-field communication technology to ensure the secure transmission of transactions in an offline environment.
[0079] The specific implementation method of step S05 is to connect the hard wallet to the online transaction terminal to synchronize transaction data. First, the hard wallet establishes a secure connection with the online terminal via USB, Bluetooth or Wi-Fi, and adopts the TLS 1.3 protocol to ensure communication security. Secondly, the locally stored offline transaction content and the latest acquired real-time transaction content are sent to the core system, and the data uses a differential compression algorithm to reduce the transmission volume. Then, the core system calculates the difference range based on the latest synchronization timestamp uploaded by the hard wallet, and returns the incremental update data. Finally, the transaction optimization function is called to pre-process the uploaded data. The function comprehensively considers five parameters: transaction set data, transaction history depth, current load level, network congestion and user transaction priority, and outputs an optimized transaction sequence. The transaction optimization function can be expressed as:
[0080] ;
[0081] Where, Optimizing functions for trading; is a transaction collection; The transaction history depth, the default value is 100 blocks; is the current load level, ranging from 0 to 1, with a threshold of 0.8; is the network congestion, ranging from 0 to 1, with a threshold of 0.7; The user's transaction priority, ranging from 1 to 5; For optimized transactions and its corresponding weight ; Optimize the weight for the transaction set size. The calculation formula is:
[0082] ;
[0083] Where, For transactions The dependency of is normalized to the range of 0 to 1 based on the number of predecessor transactions; For transactions The user priority is normalized to the range of 0 to 1; 、 、 、 is the weight coefficient, the default values are 0.4, 0.2, 0.2, 0.2, and meet This step adopts an incremental synchronization strategy and data preprocessing mechanism to significantly reduce synchronization time and system resource consumption.
[0084] The specific implementation of step S06 is that the core system performs global transaction verification and optimization prediction. First, receive the optimized sorted transaction sequence and use batch processing to improve verification efficiency. Secondly, verify the validity of the signature of each transaction, using a batch signature verification algorithm, which improves efficiency by 40% compared to single verification. Then, perform blacklist screening through a 32MB Bloom filter to filter known malicious addresses and marked UTXOs. Next, combine the UTXO set index to quickly detect multiple consumption situations. The UTXO index is stored using the Merkle Patricia tree structure, and the query complexity is Finally, the TransformerDAG model is used to analyze and predict the current DAG structure. The model inputs the current DAG topology and transaction features, processes them through an 8-layer Transformer encoder and a 4-layer decoder, with a hidden layer dimension of 512 and 8 attention heads, and outputs a DAG optimization solution. The core self-attention mechanism of the TransformerDAG model can be expressed as:
[0085] ;
[0086] Where, is the query matrix; is the bond matrix; is the value matrix; is the dimension of the key; is a normalized exponential function. This step achieves efficient and accurate global transaction verification by combining traditional cryptographic verification and deep learning prediction.
[0087] The specific implementation of step S07 is to perform DAG merging and dynamic pruning optimization. First, the DAG merging operation is performed based on the DAG optimization solution generated in step S06, and the merging order is determined by the topological sorting algorithm. Second, the branch with the largest weight is selected as the main chain through the Ghost Protocol. The weight values of all transaction nodes are accumulated, and the total weight of each possible path is calculated. The path with the highest total weight is selected. The path weight calculation formula is:
[0088] ;
[0089] Where, is the total path weight; is a path in the DAG; Transaction nodes on the path Then, based on the dynamic pruning algorithm combined with the adaptive gating weight function, DAG optimization is performed. The dynamic weight calculation formula is:
[0090] ;
[0091] Where, is the dynamic weight; The level of coin string splitting, ranging from 1 to 10; is the parent transaction weight; is the time decay factor; 、 、 and The default values of the adjustment parameters are 0.3, 0.4, 0.3 and 0.01 respectively. The pruning threshold is set as:
[0092] ;
[0093] Where, is the pruning threshold; is the average weight of all nodes in the current DAG; is the standard deviation. Finally, the DAG state is updated based on the pruning results, and the pruned nodes are moved to archival storage. This step combines graph theory algorithms and statistical methods to achieve dynamic optimization of the DAG structure, significantly improving transaction processing efficiency and storage space utilization.
[0094] The TransformerDAG model is a graph neural network based on the Transformer architecture, optimized for DAGs. The model consists of two parts: an encoder and a decoder. The encoder contains eight Transformer encoding layers, each composed of a multi-head self-attention mechanism and a feedforward neural network. The self-attention mechanism has eight attention heads, each with a dimension of 64, and both input and output dimensions of 512. The encoder uses positional encoding to preserve transaction timing information, employing sine and cosine functions to generate position vectors:
[0095] ;
[0096] ;
[0097] Where, and Position Positional encoding of even and odd dimensions at ; is the dimension index; The model dimension is set to 512. The feedforward neural network consists of two fully connected layers. The first layer maps from 512 dimensions to 2048 dimensions using the ReLU activation function, and the second layer maps back from 2048 dimensions to 512 dimensions. Each encoding layer also uses residual connections and layer normalization to ensure training stability. The decoder consists of four decoding layers, each of which incorporates a masked multi-head self-attention mechanism, a crisscross attention mechanism, and a feedforward neural network. The crisscross attention layer uses the decoder's query vector and the encoder's output as key-value pairs to perform attention calculations, achieving information fusion. The model also integrates a graph attention network layer to capture the topological relationships between nodes. The attention coefficient is calculated using the LeakyReLU activation function. The final output layer consists of a multilayer perceptron, mapping from 512 dimensions to the output dimension to generate a DAG optimization solution. The model's hyperparameters are dynamically adjusted based on transaction complexity, system load, and security level. When the load index exceeds 0.8, the number of attention heads is reduced to 4 to reduce computational complexity. When the security level is increased, the hidden layer dimension is increased to 768 to improve model expressiveness.
[0098] The steps for establishing a training dataset for the TransformerDAG model are as follows: First, large-scale transaction data and related performance indicators are collected from the system's historical records, including transaction confirmation time, system throughput, and resource utilization. The data volume should be no less than 10 million transaction records. Secondly, an expert system annotates the historical data to identify the optimal DAG structure and pruning decisions as training labels. The annotation process is semi-automatic, combining a rule engine and manual verification. Then, transaction attribute features are extracted, including transaction amount (normalized to the range of 0 to 1), timestamp (converted to relative time), priority (integer value from 1 to 5), and dependency relationship (represented by a binary adjacency matrix). Next, a graph structure is constructed to represent each transaction node and its associated relationships. The graph structure can be expressed as:
[0099] ;
[0100] Where, is a graph structure; is a set of nodes, each node corresponds to a transaction; is a set of edges, representing the dependency relationship between transactions; is the adjacency matrix, Representation node To Node There is an edge, otherwise . Then, the system performance data under different load conditions was classified and organized into three scenarios: low load (less than 0.3), medium load (0.3 to 0.7), and high load (greater than 0.7). Next, various extreme trading scenarios were simulated through data enhancement technology, including sudden high-frequency trading, network partitioning, and Byzantine behavior, to increase the robustness of the model. Finally, the dataset was divided into a training set (70%), a validation set (15%), and a test set (15%) to evaluate the model performance. The entire dataset construction process is based on an incremental update mechanism, updated once a week to maintain the model's adaptability to new trading patterns.
[0101] The specific steps of TransformerDAG model training include initializing model parameters using pre-trained graph neural network weights and using the cross-entropy loss function to evaluate the difference between the model prediction and the actual optimal structure. The loss function can be expressed as:
[0102] ;
[0103] Where, is the cross entropy loss; is the sample size; is the number of categories; For samples Belong to category The true label (0 or 1); Predict samples for the model Belong to category The probability of gradient clipping is implemented to avoid the gradient explosion problem, and the clipping threshold is set to 5.0. The Adam optimizer is used to adaptively adjust the learning rate, and the initial learning rate is set to , using the cosine annealing strategy for dynamic adjustment, the minimum learning rate is An early stopping mechanism is introduced, stopping training if the validation set performance does not improve after 10 consecutive cycles to prevent overfitting. Batch normalization technology is used to stabilize the training process, with a batch size of 64. A progressive learning strategy is implemented, starting with a smaller DAG and gradually increasing the structural complexity. Finally, a contrastive learning method is used to improve the model's ability to distinguish similar trading patterns. The contrastive loss function is:
[0104] ;
[0105] Where, is the contrast loss; and is the feature representation of the positive sample pair; is the cosine similarity function; is the temperature parameter, set to 0.07; is the indicator function, when The model is 1 when the validation set loss is less than 0.01 and 0 otherwise. Convergence is achieved when the validation set loss is less than 0.01 or when the maximum training epoch is 200. The model is regularly updated online, with parameters fine-tuned monthly using the latest data to ensure it adapts to changing trading patterns.
[0106] The adaptive gating weight function is used to adjust the gating mechanism of the neural network in the TransformerDAG model to ensure optimal transaction processing performance under different system states. This function calculates a comprehensive balance value based on four core data points: transaction load intensity, network congestion, security threat level, and user priority:
[0107] ;
[0108] Where, is the overall balance value, ranging from 0 to 1; is the transaction load intensity, ranging from 0 to 1; is the degree of network congestion, ranging from 0 to 1; is the security threat level, ranging from 0 to 1; is the user priority, ranging from 0 to 1; 、 、 、 is the weight coefficient, the default value is 0.25, and satisfies When the comprehensive balance value is lower than the threshold of 0.3, a conservative weight adjustment function is used to reduce the gate openness to ensure safety:
[0109] ;
[0110] Where, is the conservative weight adjustment function; is the input parameter; is the scaling factor, set to 0.5; is the slope factor, set to 2.0; When the overall balance value is between 0.3 and 0.7, the balanced weight adjustment function is used to achieve a balance between performance and security:
[0111] ;
[0112] Where, is the balanced weight adjustment function, which is a linear mapping. When the overall balance value is higher than 0.7, an aggressive weight adjustment function is used to increase the gate openness to maximize transaction processing efficiency:
[0113] ;
[0114] Where, The adaptive gating weight function continuously monitors the system state to dynamically adjust the focus range and intensity of the attention mechanism in the TransformerDAG model, thereby achieving intelligent control of transaction processing priorities and resource allocation, ensuring system stability and transaction processing efficiency under high load conditions.
[0115] In order to better understand and implement the present invention, the following provides Example 2 of a specific application scenario of the present invention: Researchers developed a hard wallet prototype that supports a DAG-based transaction fast synchronization method and verified the method in actual application. Figure 3 The following is an architecture diagram of the DAG-based fast synchronization system for hardware wallet transactions in Example 2, which shows the components and data flow of the entire system. The hardware wallet uses an ARM Cortex-M4 processor with a main frequency of 80MHz, built-in 4MB flash memory and 256KB RAM, equipped with a 2.4-inch touch screen, and supports NFC and Bluetooth communication. In the implementation step S01, the researchers constructed a lightweight DAG transaction structure using the SHA-256 hash algorithm and used a B+ tree index for storage. The index depth was set to 3 layers, and each node could store up to 128 transaction records. Initialize the weight coefficient in the weight formula 、 、 Set to 0.35, 0.4, and 0.25 respectively.
[0116] To verify the effectiveness of steps S02 and S03, researchers conducted offline transaction tests, using ARM TrustZone technology to establish a TEE environment. The Bloom filter used 4 hash functions and 8KB of storage space, and the false positive rate was controlled at 0.08%. In the verification process of the lattice cryptographic collision proof mechanism, the lattice dimension of the NTRU lattice cryptographic scheme was set to 256, and the modulus was 1. The value is 12289. The test results are shown in Table 1:
[0117] Table 1 Offline transaction verification performance test results
[0118]
[0119] In step S04, the researchers used the SM2 elliptic curve algorithm, a 256-bit key length, to sign the transaction, resulting in an average signing time of 12.8ms. Data transmission performance was tested using both NFC and Bluetooth Low Energy (BLE). At a transmission rate of 424Kbps for NFC and 1Mbps for BLE, the transmission times for typical transaction data (approximately 850 bytes) were 16.1ms and 6.8ms, respectively.
[0120] The system-level tests of steps S05 to S07 were conducted in a test environment consisting of 8 servers, each of which was configured with an Intel Xeon E5-2680 processor, 64GB of memory, and 2TB of SSD storage. The researchers deployed the TransformerDAG model, such as Figure 2 The figure shows the neural network structure of the TransformerDAG model in Example 2, which details the model's hierarchical structure and connection method. The model has a hidden layer dimension of 512, 8 attention heads, and approximately 15.8 million model parameters. The training dataset is constructed from 8.5 million historical transaction records and is divided into training, validation, and test sets in a ratio of 7:1.5:1.5. Adjustment parameters in the dynamic pruning algorithm 、 、 、 The weight coefficients of the adaptive gating weight function are set to 0.3, 0.4, 0.3 and 0.01 respectively. 、 、 、 Both are set to 0.25.
[0121] The researchers tested the system’s performance using transaction data of varying sizes, ranging from 10,000 to 100,000 transactions. The results are shown in Table 2.
[0122] Table 2 System performance test results under different transaction sizes
[0123]
[0124] To evaluate the effectiveness of this invention, researchers conducted a comparative test between the DAG-based hard wallet transaction fast synchronization method and the traditional blockchain-based hard wallet synchronization method. The test environment and data set were the same. The results are shown in Table 3:
[0125] Table 3 Performance comparison test results of the present invention and the traditional method
[0126]
[0127] Traditional hard wallet transaction synchronization methods use a linear blockchain structure, meaning each transaction can only have one predecessor and one successor, and are prone to transaction confirmation delays when the system load is high. Traditional methods use a basic hash verification mechanism, which cannot efficiently detect double-spending in an offline state and lacks an adaptive optimization mechanism, resulting in significant performance fluctuations under varying load conditions. The present invention utilizes a DAG structure to support parallel transaction processing, provides higher security through lattice cryptographic collision proofs, and integrates the TransformerDAG model to achieve intelligent optimization and prediction, resulting in improvements in transaction confirmation time, system throughput, and security. As shown in the comparative data in Table 3, the present invention improves average transaction confirmation time, system throughput, and memory usage efficiency by 18.6%, 17.1%, and 13.9%, respectively, significantly enhancing transaction processing capabilities and security while maintaining low resource consumption. In particular, with regard to offline transaction security, the risk detection rate has increased to 99.9%, 8.2 percentage points higher than traditional methods, providing a more secure and reliable transaction environment for hard wallet users.
[0128] It should be noted that the variables involved in the present invention are explained in detail as shown in Tables 4 and 5 below.
[0129] Table 4 Variable Explanation Table (Part 1)
[0130]
[0131] Table 5 Variable Explanation Table (Part II)
[0132]
[0133] The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be covered by the scope of protection of the present invention.
Claims
1. A fast synchronization method for hard wallet transactions based on DAG, characterized in that: include: Build a lightweight DAG transaction structure for the hard wallet; Users initiate offline transactions through hard wallets, conduct transaction validity checks in the local TEE environment, screen whether UTXO has been consumed through Bloom filters, and generate transaction security status identifiers; construct DAG nodes based on transaction information, verify validity through DAG path backtracking, generate lattice space commitments using lattice cryptographic conflict proofs, and verify the existence of conflict-free vectors; after the transaction is completed, the DAG transaction structure is signed using SM2 signatures, and the transaction information is transmitted to the counterparty's hard wallet via the near-field protocol; when the hard wallet is connected to the online transaction terminal, the transaction content is uploaded, the core system returns incremental update data, and calls the transaction optimization function for preprocessing; the core system performs global verification, uses the TransformerDAG model to perform DAG structure optimization predictions, and generates a DAG optimization solution; The core system performs DAG merging based on the DAG optimization solution, selects the branch with the largest weight as the main chain through the ghost protocol, and performs DAG optimization and status updates based on the dynamic pruning algorithm combined with the adaptive gating weight function.
2. The DAG-based fast synchronization method for hard wallet transactions according to claim 1, characterized in that: In the local lightweight DAG transaction structure of the hard wallet, each transaction node contains a transaction hash value, a predecessor transaction hash set, signature information, and a weight field. The weight field is used for subsequent DAG merging and pruning operations.
3. The DAG-based fast synchronization method for hard wallet transactions according to claim 2, characterized in that: The transaction optimization function is used to preprocess and optimize the transaction data uploaded by the hard wallet. The input includes transaction set data, transaction history depth, current load level, network congestion and user transaction priority. The output is an optimized and sorted transaction sequence and its corresponding priority weight.
4. The DAG-based fast synchronization method for hard wallet transactions according to claim 3, characterized in that: The transaction optimization function first analyzes transaction dependencies based on transaction history, then determines resource allocation strategies based on current system load and network congestion, adjusts the processing order based on user transaction priorities, and finally generates an optimized transaction sequence.
5. The DAG-based fast synchronization method for hard wallet transactions according to claim 4, characterized in that: The specific structure of the TransformerDAG model is a graph neural network based on the Transformer architecture, which includes an encoder part and a decoder part. The encoder uses a multi-head self-attention mechanism to process transaction node features, and the decoder generates an optimized DAG structure through a cross-attention mechanism.
6. The DAG-based fast synchronization method for hard wallet transactions according to claim 5, characterized in that: The TransformerDAG model uses a graph attention layer to capture the topological relationship between nodes, integrates position encoding to retain transaction timing information, processes node features through a feedforward neural network and layer normalization, and finally generates a DAG optimization solution using a multi-layer perceptron.
7. The DAG-based fast synchronization method for hard wallet transactions according to claim 6, characterized in that: The adaptive gating weight function is calculated based on four core data items: transaction load intensity, network congestion, security threat level, and user priority, to obtain a comprehensive balance value. Different weight adjustment functions are selected according to the comprehensive balance value to adjust the gating openness.
8. The DAG-based fast synchronization method for hard wallet transactions according to claim 7, characterized in that: The DAG optimization scheme includes node weight adjustment suggestions, priority merging paths, and a pruning candidate list, which serve as a guide for the DAG merging process.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores program instructions, and when the program instructions are executed in a computer, they are used to execute the DAG-based hard wallet transaction fast synchronization method according to any one of claims 1 to 8.
10. A DAG-based hardware wallet transaction fast synchronization system, characterized in that: The computer-readable storage medium according to claim 9 is included, the system is any one of a computer, a server, and a single-chip microcomputer, the computer-readable storage medium is arranged in the system, and the system is provided with a microprocessor for executing program instructions stored in the computer-readable storage medium.
Citation Information
Patent Citations
Block chain consensus achieving method and device based on directed acyclic graph
CN111080288A
Block chain of directed acyclic graph structure and implementation method thereof
CN113516557A