Large integer factorization method and device based on bit weight hierarchical parallel collision detection

CN122475869BActive Publication Date: 2026-10-27SHENZHEN Y& D ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610953858.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-10-27
Estimated Expiration
2046-06-30

AI Technical Summary

Technical Problem

然而,该算法需要通用量子计算机支持,目前无法在实际硬件上实例化,短期内无法应用于工程实践

Benefits of technology

(1)具有并行扩展性:在复杂度框架内,工作节点数量增加时加速比近似线性。这是由于静态负载均衡保证了各工作节点计算量均衡,无调度瓶颈。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122475869B_ABST
    Figure CN122475869B_ABST
Patent Text Reader

Abstract

The application belongs to the cross field of numerical calculation and cryptanalysis, and relates to a large integer factorization method and device based on bit weight hierarchical parallel collision detection. The method comprises the following steps: initializing a large integer to be factorized and randomly selecting a base number, detecting the co-primeness, and directly outputting the factor if the greatest common divisor is greater than 1; based on the number of binary bits, the exponential space is layered according to the number of 1s in the binary representation, the number of combinations of each layer is calculated, and the power module sequence is pre-calculated; according to the workload proportion of each layer, all work nodes are statically distributed to each layer, a task description containing the layer number and the index subset range is generated and distributed to the work nodes; each work node independently calculates the function value using the power module sequence and submits it to the master node in batches; the master node maintains a global hash table to detect collisions, and broadcasts a stop signal and outputs the collision pair when a collision is found; based on the collision pair, the period is extracted and the factor is solved, and if it fails, the base number is reselected. It has the advantages of parallel expansion, early stopping optimization, load balancing, hardware independence and closed loop completeness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of numerical computation and cryptography, and in particular to a method and apparatus for large integer factorization based on bit-weighted hierarchical parallel collision detection. Background Technology

[0002] Currently, there are two main technical approaches in the field of large integer factorization: The first category is the general number field sieve (NFS) algorithm, which is currently the fastest classic algorithm for factoring large integers. This algorithm can use MPI for distributed computation in the relation collection stage, but its parallelism is severely limited in the linear algebra stage, making it difficult to achieve linear acceleration on multi-core / GPU clusters.

[0003] The second type is Shor's algorithm, which is based on quantum superposition and quantum Fourier transform, and has a time complexity of O(n log n). This is a multinomial-time algorithm. However, it requires a general-purpose quantum computer and cannot currently be instantiated on actual hardware, making it unsuitable for engineering practice in the short term.

[0004] Therefore, how can we decompose the exponential space search into parallel tasks that can be independently parallelized, load-balanced, and optimized for early stopping in a classic multi-core / GPU / FPGA cluster environment, so that medium-sized integers (such as...) can be searched? Achieving near-linear acceleration of the classical decomposition (or teaching demonstration scale) on heterogeneous clusters without relying on any specific hardware has become a pressing technical problem in this field. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a method for large integer factorization based on bit-weighted hierarchical parallel collision detection, employing the following technical solution, including the following steps: Initialize the large integer to be factored, randomly select the base, and check the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, output the factor directly and terminate; otherwise, confirm that the base is valid and record the number of binary bits. Based on the number of binary bits, the exponent space is divided into several independent layers according to the number of 1s in the binary representation. The number of exponents in each layer is calculated using the combination formula. At the same time, the power modulus sequence is pre-calculated, and the layer number and the corresponding combination value are output. Based on the combined values ​​of each layer, the total number of worker nodes in the distributed computing cluster is statically allocated to each layer according to the workload ratio of each layer. The exponential subset within each layer is divided into subsets equal to the number of allocated worker nodes. A task description is generated for each worker node. The task description includes at least the layer number, the start position and end position of the exponential subset that the worker node is responsible for. The task description is then sent to the corresponding worker node. A worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task. Each working node, based on the task description, independently calculates the function value corresponding to the assigned exponent using a pre-computed power modulus sequence, and submits the calculation results to the master node in batches. Based on the calculation results, the master node maintains a global hash table and detects in real time whether there are collisions where different exponents correspond to the same function value. Once a collision is detected, it immediately broadcasts a stop signal to all worker nodes and outputs the collision pair. Based on the collision pairs, candidate periods are extracted and verified to obtain the true periods, and then the non-trivial factors of the large integers to be decomposed are solved. If the solution fails, the base is reselected.

[0006] Preferably, the steps of initializing the large integer to be factored, randomly selecting a base, and detecting the greatest common divisor (GCD) between the base and the large integer to be factored, and directly outputting the factor and terminating if the GCD is greater than 1, and otherwise confirming the validity of the base and recording the number of binary digits, specifically include: Perform validity verification and binary bit calculation on the large integer to be factored; Randomly select a base and calculate its greatest common divisor with the integer to be factored. If the greatest common divisor is greater than 1, the factors are obtained directly. Confirm that the base and the modulus are coprime, and record the global parameters.

[0007] Preferably, the steps of dividing the exponent space into several independent layers based on the number of 1s in the binary representation, calculating the number of exponents in each layer using the combination formula, pre-calculating the modulo exponent sequence, and outputting the layer number and corresponding combination value specifically include: Pre-compute the power modulus sequence based on binary bit width; The exponent space is divided into several layers according to the number of 1s in the binary representation. The number of exponents in each layer is calculated using the combination formula, and the layer number and its corresponding combination value are output. A method for generating on-demand enumeration indices for each layer is provided, supporting dynamic index generation in a distributed environment.

[0008] Preferably, the steps of statically allocating all worker nodes in the distributed computing cluster to each layer based on the combined values ​​of each layer and the workload ratio of each layer, dividing the exponential subset within each layer into subsets equal to the number of allocated worker nodes, generating a task description corresponding to each worker node, wherein the task description at least includes the layer number, the start position and end position of the exponential subset handled by the worker node, and then distributing the task description to the corresponding worker node, wherein a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task, specifically include: Establish mathematical models of workload at each level and determine the direct proportional relationship between workload and number of combinations; The total number of work nodes is allocated according to the probability ratio of workload at each level; The index set within each layer is divided into subsets equal to the number of assigned work nodes. A task description is generated for each work node. This task description is a triplet data structure containing the layer number k, the start ordinal number and the end ordinal number of the index subset. It is used to uniquely determine the entire range of indexes that the work node needs to calculate. The task description is then distributed to the corresponding work nodes.

[0009] Preferably, the step of each working node independently calculating the function value corresponding to the assigned exponent based on the task description and using a pre-calculated power modulus sequence, and then submitting the calculation results to the master node in batches, specifically includes: The worker node receives the task description from the master node and initializes its local computing environment; Using a pre-computed sequence of power modulo powers, the function value corresponding to each exponent is calculated through a chain of multiplications; The calculation results are submitted to the master node in batches, while the system continuously listens for early stop signals.

[0010] Preferably, the master node maintains a global hash table based on the calculation results, detects in real time whether there are collisions where different exponents correspond to the same function value, and broadcasts a stop signal to all worker nodes immediately upon detecting a collision, and outputs the collision pair. The specific steps include: The master node maintains a global hash table with function values ​​as keys and exponent values ​​as values; For each newly submitted exponent-function value pair, perform collision detection. If different exponents are found to correspond to the same function value, record the collision pair. Upon detecting a collision, a stop signal is immediately broadcast to all working nodes, and confirmation is awaited before the collision pair is output.

[0011] Preferably, the step of extracting candidate periods and verifying the true periods based on the collision pairs, and then solving for the nontrivial factors of the large integers to be decomposed, and reselecting the base if the solution fails, specifically includes: The candidate period is obtained by taking the absolute value of the difference between the two indices in the collision pair. True periods are extracted from candidate periods through binary verification and small factorial division. The nontrivial factors are solved by calculating the greatest common divisor using the real period. If this fails, the process returns to select a new base.

[0012] To address the aforementioned technical problems, this invention also provides a large integer factorization device based on bit-weighted hierarchical parallel collision detection, employing the following technical solution, including: The initialization module is used to initialize the large integer to be factored. It randomly selects the base and checks the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, the factor is directly output and the process terminates. Otherwise, the base is confirmed to be valid and the number of binary bits is recorded. The partitioning module is used to divide the exponent space into several independent layers based on the number of 1s in the binary representation, calculate the number of exponents in each layer using the combination formula, pre-calculate the power modulus sequence, and output the layer number and the corresponding combination value. The allocation module is used to statically allocate the total number of worker nodes in the distributed computing cluster to each layer based on the combined values ​​of each layer and the workload ratio of each layer. It also divides the exponential subset within each layer into subsets equal to the number of allocated worker nodes, generates a task description for each worker node, and the task description includes at least the layer number, the start position and end position of the exponential subset that the worker node is responsible for. Then, the task description is sent to the corresponding worker node, where a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task. The calculation module is used by each working node to independently calculate the function value corresponding to the assigned exponent based on the task description and using the pre-calculated power modulus sequence, and submit the calculation results to the master node in batches; The detection module is used by the master node to maintain a global hash table based on the calculation results, detect in real time whether there are collisions where different exponents correspond to the same function value, and immediately broadcast a stop signal to all working nodes and output the collision pair once a collision is detected. The solution module is used to extract candidate periods based on the collision pairs and verify the true periods, and then solve for the non-trivial factors of the large integers to be decomposed. If the solution fails, the base is reselected.

[0013] To address the aforementioned technical problems, the present invention also provides a computer device that employs the technical solution described below, comprising a memory and a processor. The memory stores computer-readable instructions, and the processor, when executing the computer-readable instructions, implements the steps of the aforementioned large integer factorization method based on bit-weighted hierarchical parallel collision detection.

[0014] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium, which employs the technical solution described below. The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the aforementioned large integer factorization method based on bit-weighted hierarchical parallel collision detection.

[0015] Compared with the prior art, the present invention has the following main advantages: (1) It has parallel scalability: in Within the complexity framework, the speedup is approximately linear as the number of worker nodes increases. This is because static load balancing ensures a balanced computational load across all worker nodes, eliminating scheduling bottlenecks.

[0016] (2) Early stopping optimization is possible: Based on the birthday paradox, it is expected that the search will stop early. When a collision is detected at a given index, a global early stopping mechanism is used to save an average of 30% to 60% of computing resources.

[0017] (3) Load balancing can be achieved: layer size It can accurately predict and achieve good load balancing through static scheduling, avoiding the communication overhead of dynamic scheduling.

[0018] (4) Hardware independence: It does not depend on any specific hardware (such as quantum computers or dedicated ASICs) and can run on general-purpose multi-core CPUs, GPUs, and FPGA clusters.

[0019] (5) It has closed-loop completeness: the feedback loop ensures that the algorithm will converge and will not fall into an infinite loop. Attached Figure Description

[0020] To more clearly illustrate the solutions in this invention, the accompanying drawings used in the description of the embodiments of this invention will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0021] Figure 1 This is a flowchart of an embodiment of the large integer factorization method based on bit-weighted hierarchical parallel collision detection of the present invention; Figure 2 This is a schematic diagram of an embodiment of the large integer factorization device based on bit-weighted hierarchical parallel collision detection of the present invention; Figure 3 This is a schematic diagram of the structure of an embodiment of the computer device of the present invention. Detailed Implementation

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains; the terminology used herein in the specification is for the purpose of describing particular embodiments only and is not intended to limit the invention; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings are used to distinguish different objects and not to describe a particular order.

[0023] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0024] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0025] It should be noted that the large integer factorization method based on bit-weighted hierarchical parallel collision detection provided in the embodiments of the present invention is generally executed by a server / terminal device, and correspondingly, the large integer factorization device based on bit-weighted hierarchical parallel collision detection is generally set in the server / terminal device.

[0026] It should be understood that the number of terminal devices, networks, and servers is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be used.

[0027] Example 1 Please refer to Figure 1 The flowchart illustrates an embodiment of the large integer factorization method based on bit-weighted hierarchical parallel collision detection of the present invention. The large integer factorization method based on bit-weighted hierarchical parallel collision detection includes the following steps: Step S1: Initialize the large integer to be factored, randomly select the base, and check the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, output the factor directly and terminate; otherwise, confirm that the base is valid and record the number of binary bits.

[0028] In this embodiment, the electronic device (e.g., a server / terminal device) running on the large integer factorization method based on bit-weighted hierarchical parallel collision detection can receive large integer factorization requests based on bit-weighted hierarchical parallel collision detection via wired or wireless connection. It should be noted that the aforementioned wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra-wideband) connections, and other currently known or future-developed wireless connection methods.

[0029] In this embodiment, step S1 may specifically include the following steps: S11 performs validity verification and binary bit calculation on the large integer to be factored.

[0030] Integer factorization Perform a legality check. Use the Miller-Rabin primality test algorithm for rapid determination. Is it a prime number? If it is a prime number, output " If it is a prime number, no factorization is needed, and the process terminates. If the number is even, output the factor 2 directly and terminate.

[0031] calculate The number of binary digits. Define a variable. for The position of the highest bit in the binary representation is calculated using the following formula: .

[0032] in: : Large integers to be factored, satisfying ; Base 2 The logarithm of ; The floor operator (or round down) returns the largest integer not exceeding the given number.

[0033] calculate The significance of the binary bit formula lies in determining the search range of the exponent space. This is because subsequent calculations require processing... , where the index The range is set to The choice of this range is based on the following mathematical fact: for any and coprime bases ,mold The order of the multiplication group Therefore, the cycle It must fall within this range. By setting the upper limit of the exponent... This ensures that the search space contains complete periodic information.

[0034] The specific implementation code example is as follows: function validate_input(N): if N <= 1: return error("N must be greater than 1") if N is even: output factor 2 and exit If MillerRabin(N) is prime: output "N is a prime number" and exit. n = floor(log2(N)) return n The purpose of step S11 is to ensure that the integers to be factored are... To meet the algorithm requirements, extract its binary bits to provide boundaries for subsequent exponential space partitioning.

[0035] S12, randomly select the base and calculate its greatest common divisor with the integer to be factored. If the greatest common divisor is greater than 1, the factor is obtained directly.

[0036] Using a cryptographically secure random number generator on a closed interval The base is randomly selected uniformly within the inner circle. A secure random number generator ensures that the base chosen in each run is unpredictable, thus providing a new opportunity when the factorization fails by reselecting the base.

[0037] The base is calculated using the Euclidean algorithm (the method of dividing the product by multiple steps). Large integers to be factored The greatest common divisor of is calculated using the following formula: .

[0038] in: The randomly selected base satisfies ; : Large integers to be factored; The greatest common divisor (GCD) function returns the greatest common divisor of two integers. : Calculation results, if express and Coprime, if but yes One of the factors.

[0039] Calculate the base Large integers to be factored The significance of the formula for the greatest common divisor is that: if the base is... and If they are not coprime, then It must be A nontrivial factor (because) At this point, the algorithm can terminate early without performing subsequent complex modular exponentiation calculations. This pre-detection mechanism can directly factorize a portion of integers (e.g., composite numbers containing small factors) with extremely low computational cost.

[0040] The specific code example is as follows: function select_base(N): while true: a = random(2, N-1) g = gcd(a, N) / / Using Euclidean algorithm if g != 1: Output g as factor and exit / / Direct decomposition successful else: return a / / Coprime, continue with subsequent steps Euclidean algorithm complexity: For large integers, the computational cost of division operations is negligible.

[0041] The purpose of step S12 is to randomly generate the base. And calculate its value relative to the large integer to be factored. The greatest common divisor. If they are not coprime, the nontrivial factors are obtained directly, avoiding subsequent calculations.

[0042] S13, confirm that the base and the modulus are coprime, and record the global parameters.

[0043] When step S12 is confirmed After that, the base is indicated. Belongs to the model multiplication group According to Lagrange's theorem in number theory, the order (i.e., period) of any element in a multiplicative group... The order of necessarily divisible groups ,in This is the Euler totient function. Because... Therefore, the cycle It must fall within the exponential space Inside.

[0044] At this point, record the following global parameters for use in subsequent steps: Where: parameters : The large integer to be factored, with a value range of 100. , non-prime and non-even; parameter :and The base of coprime numbers is randomly selected, and its range is [value missing]. ,satisfy ; parameter : The number of binary bits, with a value range of 1. , integer; For model Down The multiplicative order (period) of has a range of values ​​of . ,and .

[0045] With coprime pre-detection, this step has two possibilities under extremely low computational cost: one is direct successful factorization (probability approximately...). For random composite numbers (approximately 10%~30%), the second step is to confirm the validity of the base to ensure the subsequent modular exponentiation function. It is a periodic function. This design avoids wasting a lot of computational resources on invalid bases.

[0046] The purpose of step S13 is to confirm that the base and the modulus are coprime, ensure the periodicity of subsequent modular exponentiation operations, and record the global parameters.

[0047] Step S1 serves as the entry point and preprocessing stage for the entire method. It is responsible for verifying the validity of the input parameters, selecting an appropriate base, and checking whether the factor can be obtained directly. This step is a safety prerequisite for all subsequent calculations.

[0048] Step S2: Based on the number of binary bits, the exponent space is divided into several independent layers according to the number of 1s in the binary representation. The number of exponents in each layer is calculated using the combination formula. At the same time, the power modulus sequence is pre-calculated, and the layer number and corresponding combination value are output.

[0049] In this embodiment, step S2 may specifically include the following steps: S21, based on the pre-computed exponential modulus sequence of binary bits.

[0050] Based on the parameters obtained in step S1 The number of powers that need to be pre-calculated is determined to be: (from arrive This is because of the index. The range is Its binary representation has at most 10 ... Position (from position 0 to position 1) Bit).

[0051] The iterative square method is used to calculate the power modulus sequence. During initialization, the lowest power is calculated first: .

[0052] Then for arrive Calculate recursively using the square relation: .

[0053] This is because: .

[0054] Therefore, the complete power modulo sequence is defined as: .

[0055] in: : The first pre-computed array Each element stores mold The result; The coprime bases selected in step S1; : Large integers to be factored; The binary bit position index in the exponentiation, starting from 0; : The number of binary bits, ; mod: Modulo operation, which means finding the remainder.

[0056] The computational complexity of this sequence is The modular multiplication operation, because That is, only This calculation is extremely low-cost, yet its value is immense: it can be used to calculate any subsequent index. When exponentiation, simply put In the binary representation, all bits that are 1 correspond to Multiply them together, and exponentiate each time from... The sum of squares multiplication is reduced to Multiplication.

[0057] Calculation example: For , Pre-computation requires only 40 modulo square operations and stores 41 modulo values, with negligible space overhead.

[0058] The function of step S21 is to pre-calculate all forms such as The value of allows subsequent arbitrary exponentiation calculations to be quickly combined using a multiplication chain, avoiding repeated square operations.

[0059] S22 divides the exponent space into several layers according to the number of 1s in the binary representation, calculates the number of exponents in each layer using the combination formula, and outputs the layer number and its corresponding combination value.

[0060] For any integer The number of "1"s in its binary representation is defined as the Hamming weight, denoted as . .For example, The binary representation of is 1101, which contains three 1s. .

[0061] Exponential space Includes all that can be used most The non-negative integers are represented by bits. These integers are grouped according to their popcount values, the th... Layer is defined as: .

[0062] in: The number of 1s in the binary representation, with a range of values ​​of 1 to 1. ; Exponential variables belong to the set of integers; :calculate The function of the number of 1s in the binary representation of ; : No. The layer is a set of all the indices it contains.

[0063] No. The size of a layer (i.e., the number of exponents contained in that layer) is given by the combination formula: .

[0064] in: Combinations, representing the number of combinations from... Select from the positions The number of ways to place 1 in each position; The upper limit of the number of binary bits in the exponent space; The number of 1s.

[0065] The derivation of this formula: exponent It can be used The binary bits represent (from bit 0 to bit 1) To get a popcount equal to (bits). The number needs to be obtained from this. Select from the positions Fill one position with 1 and the rest with 0. Therefore, there are a total of Different indices.

[0066] Verify the identity: .

[0067] This indicates that the total number of exponents across all layers is exactly equal to the size of the entire exponent space. The layers are complete and non-overlapping.

[0068] After stratification, all indices within the same stratum have the exact same popcount value. When using pre-computed sequences calculate At that time, it is necessary to In the binary representation, all bits that are 1 correspond to Multiply. Since there are exactly 1 / 2... The units digit is 1, therefore it is necessary to Modular multiplication (strictly speaking) Multiplication and Secondary modulo operation, or optimized modulo operation (Modular multiplication). This means that the computational workload for all exponents within the same layer is exactly the same, providing a precise mathematical basis for static load balancing—this is the key innovation of this invention that distinguishes it from traditional dynamic scheduling methods.

[0069] The purpose of step S22 is to: expand the exponential space Divided according to the number of 1s in the binary representation into In a series of disjoint layers, the modular exponentiation of all exponents within each layer requires the same number of modular multiplications (all of which are...). (This facilitates workload prediction and load balancing.)

[0070] S23 is a method for generating on-demand enumeration indices for each layer, supporting dynamic index generation in a distributed environment.

[0071] Traditional methods pre-calculate and store all exponents, but the exponent space is large. Follow Exponential growth, for That is, Dajou Storing such a large number of units would require several terabytes of memory, which is completely impractical. Therefore, this invention adopts an on-demand enumeration strategy.

[0072] Specifically, a combinatorial enumeration algorithm (such as Gosper's Hack) is used to generate the first [number] in lexicographical or Gray code order. All combinations of layers. Its core idea is: to combine the exponent... The binary representation of is regarded as a A bitmask containing exactly 10 bits. The units digit is 1. Enumerating all bitmasks is equivalent to enumerating all A combination.

[0073] The principle behind Gosper's Hack algorithm is illustrated with C language code examples below: / / Initial state: The lowest k bits are 1 mask = (1< <k) - 1; while (mask<(1<<(n+1))) { / / Output the current mask as the exponent x output(mask); / / Calculate the next mask int c = mask&-mask; / / Least significant bit 1 int r = mask + c; / / Carry mask = (((r ^ mask)>>2) / c) | r; } The algorithm generates a bitmask containing exactly k 1s in each iteration, with a time complexity of... Amortization, space complexity .

[0074] Furthermore, to support distributed task partitioning, the master node can specify a contiguous sub-interval for each worker node (e.g., the first sub-interval). One to the first (For each combination), the working node uses the combinatorial ordinal notation to directly locate the starting combination, and then enumerates them sequentially.

[0075] Distribution characteristics of the number of indices in each layer: when When the number is large, the number of combinations exist The value reaches its maximum near the nearest point, exhibiting a binomial distribution. This means that the intermediate layer ( The number of exponents in the first layer is the largest, resulting in the greatest computational workload; while the two end layers ( The number of exponents is very small. This characteristic is utilized by the load balancing in the subsequent step S3.

[0076] The significance of this step lies in achieving feasibility over a large exponent space through on-demand enumeration rather than pre-storage. Simultaneously, the mathematical structure of combinatorial enumeration ensures that the generation of each exponent is deterministic and repeatable, facilitating task partitioning and result verification.

[0077] The purpose of step S23 is to provide an iterator method for generating exponents on demand for each layer, avoiding the explicit storage of all exponents (when...). The total index space is approximately (Storage is impractical), supporting dynamic generation of local tasks by worker nodes in a distributed environment.

[0078] Step S2 is the core of the preprocessing in the entire method. It divides the exponent space into several independent layers according to the number of 1s in the binary representation (i.e., the Hamming weight, popcount), and pre-computes all... This hierarchical strategy ensures that all indices within the same layer have the same computational complexity, laying the foundation for subsequent load balancing and parallel computing.

[0079] Step S3: Based on the combined values ​​of each layer, according to the workload ratio of each layer, the total number of worker nodes in the distributed computing cluster is statically allocated to each layer, and the exponential subset within each layer is divided into subsets equal to the number of allocated worker nodes. A task description is generated for each worker node. The task description includes at least the layer number, the start position and end position of the exponential subset that the worker node is responsible for, and then the task description is sent to the corresponding worker node. Here, a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task.

[0080] In this embodiment, each worker node receives a task from the master node, performs computation independently, and returns the result. A worker node can be a CPU core, a GPU computing unit, an FPGA logic unit, a physical computer, or a virtual machine instance, depending on the deployment environment.

[0081] The master node is the central node in a distributed computing cluster responsible for task scheduling, global hash table maintenance, collision detection, and early stop broadcasting. The master node does not participate in the actual modular exponentiation calculations; it only coordinates and manages all worker nodes.

[0082] Total number of working nodes N w This refers to the total number of all worker nodes participating in this large integer factorization calculation task, which is specified by the user based on available hardware resources when the algorithm starts.

[0083] In this embodiment, step S3 may specifically include the following steps: S31. Establish a mathematical model of the workload at each level and determine the proportional relationship between workload and number of combinations.

[0084] No. The total computational load required for a layer consists of two parts: the time required to calculate the modular exponentiation of all exponents in that layer, and the time required to submit the results to the global hash table. Therefore, the first... Total workload of the layer It can be represented as: .

[0085] in: : No. Total workload of a layer (measured in time); That is, the number of combinations , indicating the first Total number of indices in each layer; : Calculate a single Required average time (for the first) The layer, this value is a constant, because each index exactly requires (modulo multiplication) : No. The total time required to submit all results from the layer to the global hash table, including network transfers and hash table insertion operations.

[0086] In practical systems, the time required for modular exponentiation is much longer than the time required for hash operations, that is: .

[0087] Therefore, it can be approximated that the workload is proportional to the number of combinations: .

[0088] in: For the first Total workload of the layer, in units of time (e.g., microseconds). For the first The number of exponents in the layer, with units / values ​​that are dimensionless integers; This represents the average time taken for a single modular exponentiation, with the unit being time. For the first Total time taken for layer hashing, unit / value is time unit.

[0089] This formula reveals the direct proportionality between workload and the number of combinations. Since the number of combinations can be precisely pre-calculated, the relative load ratio between layers can be determined without runtime measurement. This is the theoretical basis for static load balancing and the core advantage of this invention compared to traditional dynamic load balancing (such as workload stealing)—zero runtime communication overhead.

[0090] The purpose of step S31 is to establish the first A mathematical model of the total workload of each layer provides a quantitative basis for proportional allocation.

[0091] S32, allocate the total number of work nodes according to the probability ratio of workload at each level.

[0092] When calculating the index of random uniform selection, it falls on the th The probability of the layer. Since the size of the entire exponential space is... And the first Layer contains There are several exponents, therefore the probability is: .

[0093] in: : No. The probability mass function value of the layer satisfies ; : No. The number of exponents in the layer (number of combinations); The total size of the exponential space is equal to ; According to probability Total number of working nodes Calculation assigned to the first Number of worker nodes in a layer: .

[0094] in: Assigned to the first The number of working nodes in the layer; The total number of worker nodes in the entire computing cluster; : No. Layer probability weights; The rounding function ensures... It is an integer.

[0095] Adjust the allocation results to meet the total number of working nodes constraint: .

[0096] Exact equality can usually be achieved by assigning the remainders to the layers with the highest probabilities.

[0097] Allocation example: Let ,but , Total index space Let the total number of working nodes be... Central layer (Actual Optimal) The number of combinations of ) probability Assign the number of work nodes One. Both ends are like... (Only one exponent 0) and (index Each obtained 0 working nodes.

[0098] The core of this allocation strategy lies in the fact that each working node ultimately undertakes approximately the same number of exponents: The number of exponents each working node undertakes .

[0099] This is because: .

[0100] Therefore, regardless of the layer, each working node processes approximately Several indices were used to achieve load balancing.

[0101] The purpose of step S32 is to: calculate the total number of working nodes. The workload is allocated according to the proportion of each layer, so that each working node in each layer undertakes approximately the same number of exponential calculation tasks, thereby achieving overall load balancing.

[0102] S33. Divide the index set within each layer into subsets equal to the number of assigned work nodes. Generate a task description for each work node. This task description is a triplet data structure containing the layer number k, the start ordinal number and the end ordinal number of the index subset. It is used to uniquely determine the entire range of indexes that the work node needs to calculate. Then, the task description is sent to the corresponding work node.

[0103] For the Layer, this layer has a total of Each index is assigned to There are 10 working nodes. The master node needs to divide these indices into 10 working nodes. A continuous subset (in combinatorial enumeration order).

[0104] The partitioning strategy is as follows: Let the total number of exponents ; Set the basic processing capacity of each working node ; Let remainder ; forward Each work node processes One index, and the remaining working nodes each process one index. One index; The task descriptor sent by the master node to each worker node is a triple: .

[0105] in: : Layer number, determines the popcount value; : The initial combinatorial ordinal number (starting from 0) that this working node is responsible for; The closing combination number (open interval) that this working node is responsible for.

[0106] After receiving the task, the worker node uses the combined enumerator described in step S23 (which supports the combinatorial algorithm for ordinal positioning) to convert the ordinal into the actual exponent. Then perform the calculation.

[0107] Example of task assignment: For , ,distribute There are [number] worker nodes, each worker node processes approximately [number] tasks. One index.

[0108] This static allocation scheme avoids runtime task queue contention and scheduling overhead. Each worker node's task is deterministic and independent, and can be executed in full parallel without needing to communicate with each other. The master node only distributes the task description once at the start of a task (with minimal communication overhead) and remains silent throughout the computation process until it receives the results submitted by the worker nodes or a collision occurs. This architecture is well-suited for large-scale cluster environments.

[0109] The function of step S33 is to further divide the index set within each layer into... Select an equal number of subsets and distribute these subsets to the corresponding worker nodes.

[0110] Step S3, based on the precise values ​​of the combination numbers for each layer obtained in step S2, completes the task allocation of the working nodes before the calculation begins. Since the computational workload for each index within each layer is exactly the same (both are...), ... Since the layer size is precisely given by the number of combinations (modular multiplication), near-optimal load balancing can be achieved through static probability proportional allocation, completely avoiding the communication overhead and runtime uncertainty of dynamic scheduling.

[0111] In step S4, each working node independently calculates the function value corresponding to the assigned exponent based on the task description and the pre-calculated power modulus sequence, and submits the calculation results to the master node in batches.

[0112] In this embodiment, step S4 may specifically include the following steps: S41, the worker node receives the task description issued by the master node and initializes the local computing environment.

[0113] Upon startup, the worker node first establishes a connection with the master node and receives the following information: global parameters and ; Pre-computation sequence (Broadcast by the master node, or calculated locally using the same parameters); Task description for this working node .

[0114] The worker node then performs local initialization: according to and Initialize the combinatorial enumerator and locate the... Corresponding initial index ; Allocate a batch commit buffer, such as the buffer size. Used to accumulate enough Send them in batches afterward to reduce the number of network communications. Establish an early stop signal listening channel (such as a UDP port or a shared memory flag).

[0115] The purpose of a batch buffer is that network communication latency and overhead are far greater than local computation. If each... Sending data individually can become a network bottleneck. Batch submissions can reduce the number of network round trips. The typical batch size is set to [number]. A trade-off needs to be struck between latency (early stop response speed) and throughput.

[0116] The purpose of step S41 is to parse the task description issued by the master node and prepare the local computing environment, including obtaining the pre-computation sequence and initializing the batch buffer.

[0117] S42 uses a pre-computed power modulus sequence to calculate the function value corresponding to each exponent through a multiplication chain.

[0118] For a given index Its binary representation is Position (from position 0 to position 1) (Position). Let... The set of positions of all bits that are 1 in the binary representation is: .

[0119] in express The The value of each binary bit (0 or 1). Due to ,have .

[0120] Modular exponentiation can then be expressed as: .

[0121] in: : Function value, i.e. mold The result; Base, and Coprime; Exponential variables; Modulus; :index The set of positions of 1 in the binary representation; Pre-calculated value ; The multiplication symbol indicates that all elements in a set are multiplied together. Take the modulus after each multiplication step to prevent numerical inflation.

[0122] The specific code implementation example of the calculation process is as follows: function compute_f(x, val[], k): result = 1 / / Traverse all binary bits for i from 0 to n: if (x>>i)&1: / / the i-th bit is 1 result = (result * val[i]) mod N return result Because all indices within the same layer have the same popcount value The total number of times the condition is true in the above loop is exactly . If a more efficient algorithm is used, it is possible to only iterate through... The position of the record is not traversed. Ones.

[0123] Multiplication chain optimization: due to In the next multiplication, the multiplication factor These are all known pre-calculated values, allowing for some optimizations to be made in advance for this layer, such as for smaller values. The situation ( Use specialized expansion code to avoid loop overhead.

[0124] Complexity analysis: Each exponent requires This is the first modular multiplication operation. The time complexity of modular multiplication is O(n log n). ,in for Multiplication complexity of 1 / 2-bit integers. For medium-sized integers (such as...) Modular multiplication can be completed in a single CPU instruction cycle (using built-in 128-bit multiplication).

[0125] The function of step S42 is to: for each index High-efficiency computing Using the pre-calculated step S21 The combined enumeration result of sequence and step S23.

[0126] S43 submits the calculation results to the master node in batches, while continuously listening for early stop signals.

[0127] During computation, the worker node maintains a local buffer. The capacity is (like For each calculated exponent... and its function values This is appended to the buffer. When the buffer is full, a batch commit is performed: function submit_batch(buffer): / / Pack all (x, f(x)) pairs in the buffer into a single network message message = pack(buffer) / / Global hash table service sent to the master node The master node uses `_hash_table.batch_insert(message)`. / / Clear the buffer buffer.clear() In addition to batch commits, worker nodes also need to continuously listen for early stop signals. This is typically done using one of the following two methods: Method 1 (Active Polling): After each batch of computations is completed, the worker node sends a lightweight query request to the master node to inquire whether a STOP signal has been received. The advantage of this method is its simplicity, but the disadvantage is that it incurs a small amount of additional communication overhead.

[0128] Method 2 (Passive Listening): The worker node starts a separate listening thread (or uses non-blocking I / O) and waits for the master node's broadcast signal on a separate port. Once a STOP signal is received, the thread sets a global flag, which the worker node's main loop checks before each batch of computation begins. This method is faster, but requires multi-threading support.

[0129] Recommended implementation: Hybrid approach. Work nodes perform batch calculations and submissions normally, and proactively check the early stop flag after every few batches (e.g., 10 batches). When a STOP signal is received, the worker node's processing flow is as follows: Immediately stop generating new exponent calculations; Submit the results in the buffer that have not yet been committed to the master node (ensuring that the calculated results are not lost); Send a confirmation message to the master node; Normal exit.

[0130] Batch submissions reduce the number of network communications, while independent listening enables rapid early stopping responses. The combination of these two methods allows this step to efficiently utilize network bandwidth while minimizing unnecessary computation after collision detection. Experiments show that early stopping can save an average of 30% to 60% of computational resources.

[0131] The function of step S43 is to: calculate the... It efficiently transmits data to the master node while simultaneously monitoring the master node for early stop signals. Once a signal is received, the computation is terminated immediately to avoid wasting resources.

[0132] Step S4 is the actual computation execution phase. Each worker node independently executes the computation tasks distributed in step S3, calculating the assigned subset of exponents. The results are then submitted in batches to the global hash table of the master node. This step forms a close two-way interaction with step S5 (collision detection): worker nodes submit results to the master node, and the master node sends an early stop signal to the worker nodes.

[0133] In step S5, the master node maintains a global hash table based on the calculation results, and detects in real time whether there are collisions where different exponents correspond to the same function value. Once a collision is detected, it immediately broadcasts a stop signal to all worker nodes and outputs the collision pair.

[0134] In this embodiment, step S5 may specifically include the following steps: S51, the master node maintains a global hash table with function values ​​as keys and exponent values ​​as values.

[0135] The master node maintains a global hash table. The mapping relationship is as follows: .

[0136] That is, the key of the hash table is the function value. (mold The remainder, range of values The value is an exponent. (range of values) ).

[0137] Since multiple worker nodes may submit batch results simultaneously, the hash table needs to support high-concurrency read and write operations. Specific implementations can use sharded locks or lock-free hash tables (such as Java's ConcurrentHashMap or C++'s absl::flat_hash_map combined with mutexes).

[0138] Concurrent processing architecture: Divide the hash table into Each fragment (e.g.) Each segment has its own lock.

[0139] For each insertion operation, first, according to... The hash value determines the shard ID, and then only that shard is locked.

[0140] When submitting in batches, operations on different shards within the same batch can be processed in parallel.

[0141] Hash function selection: due to key space The size is (most ( ), direct modulo can be used as the hash function: .

[0142] in This is the number of partitions (usually a power of 2). This ensures a good uniform distribution.

[0143] Storage space estimation: The hash table needs to store all computed values. Yes, until a collision is found or the search is complete. In the worst case (traversing all...) (number of indices), requiring approximately [number of] storage points. One entry. But for This requires an appointment Each entry must be at least 16 bytes, requiring a total memory of approximately 32TB, which is infeasible. However, according to the birthday paradox, finding a collision actually only requires approximately [a certain amount of computation]. Each index, for Approximately Each entry requires only about 24MB of memory, which is entirely feasible. This is the key mathematical guarantee that this invention can actually run.

[0144] The purpose of step S51 is to store all calculated and submitted data. The mapping relationship supports fast deduplication and insertion operations with high concurrency.

[0145] S52 performs collision detection on each newly submitted exponent-function value pair. If different exponents are found to correspond to the same function value, the collision pair is recorded.

[0146] The following is a code example of the master node's processing flow for each submitted batch message: function process_batch(message): for each (x, f) in message: / / Query hash table If H contains key f: x_old = H.get(f) if x_old != x: Collision detected! collision_pair = (x_old, x) / / Trigger early stop broadcast_stop() / / Return collision results return collision_pair else: / / No collisions, insert into hash table H.put(f, x) return no_collision Collision detection accuracy guarantee: Due to If there are two different indices Make Then we have: .

[0147] This means It is a cycle The number of collisions must be an integer multiple of the number of collisions. Therefore, any collision will inevitably result in the extraction of periodic information.

[0148] Hash collision handling: Theoretically, there may be different but However, different situations may still occur. Corresponding to the same However, the hash key itself can be misjudged due to hash function collisions. This is because the key in a hash table is... It is not itself The hash value is used, therefore there is no hash collision problem—this is a potential source of confusion due to the naming of hash tables. More precisely, this is a hash table named after... A dictionary (associative array) with keys will ideally avoid key conflict misjudgments in its implementation.

[0149] The purpose of step S52 is to: for each new submission Yes, check if there is a collision with a stored record. If there is a collision, record the collision pair and trigger an early stop.

[0150] S53, upon detecting a collision, immediately broadcasts a stop signal to all working nodes, waits for confirmation, and outputs the collision pair.

[0151] The early stop broadcast adopts the following mechanism: function broadcast_stop(): / / Set global stop flag stop_flag = true / / Broadcast a STOP message to all worker nodes for each worker node in worker nodes s: send(worker node, STOP_SIGNAL) / / Waiting for confirmation from all working nodes for each worker node in worker nodes s: ack = recv_timeout(worker node, ACK_TIMEOUT) if not ack: / / Timeout handling: Resend resend_stop(worker node) / / Record collision pairs, proceed to step S6 Broadcast protocol selection: MPI environment: Use MPI_Bcast or MPI_Allreduce to implement collective communication.

[0152] TCP / IP network: Use the publish-subscribe pattern (such as ZeroMQ's PUB-SUB), with the master node acting as the publisher and the worker nodes acting as subscribers.

[0153] Shared memory environment: Set a global flag, and worker nodes check it periodically.

[0154] The expected mathematical benefit of stopping early: Let the total exponent space size be According to the birthday paradox, the expected collision point occurs when approximately [a certain number of points are calculated]. When there are different indices, the proportion of savings from stopping early is defined as: .

[0155] in: : The proportion of computing resources saved by stopping early (between 0 and 1); The amount of computation already completed when a collision is detected; : The total computational cost required to fully traverse all exponents.

[0156] because ,and ( (For the calculation time of a single exponential average), therefore: .

[0157] when hour, , ,therefore This means a 99.99993% reduction in computational load. Of course, this is the ideal situation. In reality, due to imperfections in parallel computing across layers and load distribution, the actual savings are approximately 30% to 60%, but it is still very significant.

[0158] The early stopping mechanism is one of the core optimizations of this invention. In traditional brute-force search methods, the entire search space needs to be traversed to confirm the existence of collisions; however, this invention utilizes the birthday paradox to stop the collision early when approximately [a certain number of collisions are found]. When the index is reached, collisions are detected with high probability, and the calculation is terminated immediately through an early stopping mechanism, avoiding invalid searches and achieving an order-of-magnitude performance improvement.

[0159] The purpose of step S53 is to immediately notify all working nodes to stop computing once a collision is detected, so as to avoid further consumption of computing resources.

[0160] Step S5 is the system's scheduling hub. The master node maintains a global hash table and receives submissions from each worker node. Yes, it detects collisions in real time (i.e., different exponents corresponding to the same function value). Once a collision is detected, a STOP signal is immediately broadcast to all working nodes, triggering early stopping. This step forms a close two-way interaction with step S4.

[0161] Step S6: Based on collision pairs, extract candidate periods and verify the true periods, and then solve for the nontrivial factors of the large integers to be decomposed. If the solution fails, the base is reselected.

[0162] In this embodiment, step S6 may specifically include the following steps: S61, the absolute value of the difference between the two indices in the collision pair is used to obtain the candidate period.

[0163] Let the collision pair found in step S5 be ,satisfy and: .

[0164] because and Coprime equations can be multiplied by both sides. (mold (using the inverse of multiplication), we get: .

[0165] To obtain a positive exponent, we define: .

[0166] Then we have: .

[0167] in: Two different indices in a collision pair satisfying ; The absolute value of the difference between two exponents, satisfying ; Base, satisfying ; : The large integer to be factored.

[0168] The verification steps are as follows: To ensure there are no calculation errors or hash table anomalies, the master node should verify... If the verification fails, it indicates that the collision is likely due to a hash table error (the probability is extremely low). In this case, the collision should be discarded, and we should continue to wait for the next collision.

[0169] Theoretical significance: assuming for mold The multiplicative order (i.e., the smallest positive integer such that) ),but Must be divisible .therefore, It is the real cycle Multiples of. The next step is to... Extract the smallest .

[0170] The function of step S61 is to determine the collision conditions. Derivation ,in It is a candidate period.

[0171] S62 extracts the true period from the candidate period through split-half verification and small factorial trial division.

[0172] because yes Integer multiples of, i.e. In order to find It is necessary to start from Redundant factors are gradually removed while ensuring that the remaining numbers still satisfy the condition that the modulus is equal to 1.

[0173] This invention employs a method combining split-half verification and small-factor trial division. A specific flowchart and code example are shown below: Phase 1: Halving Verification r = d while r is even: half = r / 2 if a^{half} mod N == 1: r = half / / Can be halved again else if a^{half} mod N == N-1: / / ie ≡ -1 mod N break / / Cannot be halved again, but the period is still r else: break / / If the condition is not met, keep r. This stage involves repeated attempts to... Divide by 2, as long as Continue halving until you encounter... Or the situation may be different.

[0174] Phase Two: Trial Division of Small Factors (Handling Odd Prime Factors) for each small prime p in [3, 5, 7, 11, ...] up to sqrt(r) or limitB: while r % p == 0: candidate = r / p if a^{candidate} mod N == 1: r = candidate / / Factor p can be removed else: break / / Cannot be removed, retain r The set of small prime numbers is typically {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}, with an upper limit of 97. It can be set to 100 or higher (adjusted according to computing resources).

[0175] Final output: The minimum value obtained after the above processing. That is, the true period (or a small multiple of the period, if it cannot be completely decomposed).

[0176] mold The formula for calculating the multiplicative order (period) is: .

[0177] in: : mold The multiplicative order (period); Collision difference ; : Factors; : Divisibility symbol, indicating Divisible ; : Verification conditions.

[0178] Compared to perfect factorization (for Reachable (Even with a scale of several orders of magnitude, the computational cost of complete decomposition is still very large). This stepwise verification method only requires a small number (at most dozens) of modular exponentiation operations to complete the periodic extraction, resulting in extremely low computational cost. Simultaneously, it utilizes... This is a key boundary condition (which happens to be one of the prerequisites for subsequent factorization).

[0179] The function of step S62 is to: start from the candidate period Extract the true minimum period This provides accurate periodic values ​​for subsequent factor solutions.

[0180] S63 uses the true period to calculate the greatest common divisor to solve for nontrivial factors. If it fails, it returns to select a new base.

[0181] Non-trivial factors are proper factors that are greater than 1 and less than the large integer N to be factored.

[0182] Factoring conditions: A sufficient condition for successfully solving for factors is... Even number and .

[0183] The solution formula is: ; .

[0184] in: The extraction cycle in step S62 satisfies... ; Base number; : Large integers to be factored; Greatest common divisor function; : The calculated factors (at least one of which is a nontrivial factor).

[0185] Mathematical Principle Derivation: From We can obtain: .

[0186] This means Divisible ,Right now: .

[0187] but It is not necessarily divisible by a single factor. However, Each prime factor is necessarily divisible or At least one of them (because prime numbers have the property: if ,but or ).therefore: Includes all divisible elements Element factors; Includes all divisible elements Element factors.

[0188] because This ensured and Neither Multiples of, therefore and All The proper factors (not equal to 1 or And because the product of two gcd values ​​equals (when (when there are no square factors), therefore and that is The decomposition of .

[0189] Failure handling and feedback loop: If any of the following conditions are true, then the current base is... Unable to decompose : It is an odd number. ; ; Calculated or equal to 1 or .

[0190] At this point, the algorithm returns to step S1 and selects a new base. (Unlike the previous method), repeat the entire process. Since the probability of success for each base has a certain lower bound (for composite numbers)... At least there exists (with a valid base), success is guaranteed after a finite number of retries. Step S63's function is to utilize the extraction cycle... By calculating the greatest common divisor, we can obtain The non-trivial factor; if it fails, return to step S1 to select the base again.

[0191] Step S6 will identify the collision pairs found in step S5. Period of the modulo exponential function Then, the solution is obtained by using number theory relations. The non-trivial factors. If the solution fails, feedback is sent back to step S1 to reselect the base. This forms a complete closed-loop process until the decomposition is successful.

[0192] This invention can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This invention can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This invention can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0193] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).

[0194] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0195] Example 2 Further reference Figure 2 As a response to the above Figure 1 The present invention provides an embodiment of a large integer factorization device based on bit-weighted hierarchical parallel collision detection, which is similar to the method shown. Figure 1 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0196] like Figure 2 As shown, the large integer factorization device 70 based on bit-weighted hierarchical parallel collision detection described in this embodiment includes: an initialization module 71, a partitioning module 72, an allocation module 73, a calculation module 74, a detection module 75, and a solution module 76. Wherein: Initialization module 71 is used to initialize the large integer to be factored, randomly select the base, and check the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, the factor is directly output and the process terminates; otherwise, the base is confirmed to be valid and the number of binary bits is recorded. The partitioning module 72 is used to divide the exponent space into several independent layers based on the number of 1s in the binary representation, calculate the number of exponents in each layer using the combination formula, pre-calculate the power modulus sequence, and output the layer number and corresponding combination value. The allocation module 73 is used to statically allocate the total number of worker nodes in the distributed computing cluster to each layer based on the combined values ​​of each layer and the workload ratio of each layer, and to divide the exponential subset within each layer into a subset equal to the number of allocated worker nodes, generate a task description corresponding to each worker node, wherein the task description includes at least the layer number, the start position and the end position of the exponential subset that the worker node is responsible for, and then distribute the task description to the corresponding worker node, wherein a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task; Calculation module 74 is used by each working node to independently calculate the function value corresponding to the assigned exponent based on the task description and using the pre-calculated power modulus sequence, and submit the calculation results to the master node in batches; The detection module 75 is used by the master node to maintain a global hash table based on the calculation results, detect in real time whether there are collisions where different exponents correspond to the same function value, and immediately broadcast a stop signal to all working nodes and output the collision pair once a collision is detected. The solution module 76 is used to extract candidate periods based on the collision pairs and verify the true periods, and then solve the non-trivial factors of the large integers to be decomposed. If the solution fails, the base is reselected.

[0197] Example 3 To address the aforementioned technical problems, embodiments of the present invention also provide a computer device. Please refer to [link / reference needed]. Figure 3 , Figure 3 This is a basic structural block diagram of the computer device in this embodiment.

[0198] The aforementioned computer device 8 includes a memory 81, a processor 82, and a network interface 83 that are interconnected via a system bus. It should be noted that only the computer device 8 with components 81, 82, and 83 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described herein is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0199] The aforementioned computer devices can be desktop computers, laptops, handheld computers, and cloud servers, among other computing devices. These devices can facilitate human-computer interaction with users through keyboards, mice, remote controls, touchpads, or voice-activated devices.

[0200] The aforementioned memory 81 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the aforementioned memory 81 may be an internal storage unit of the aforementioned computer device 8, such as the hard disk or memory of the computer device 8. In other embodiments, the aforementioned memory 81 may also be an external storage device of the aforementioned computer device 8, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 8. Of course, the aforementioned memory 81 may also include both the internal storage unit and its external storage device of the aforementioned computer device 8. In this embodiment, the aforementioned memory 81 is typically used to store the operating system and various application software installed on the aforementioned computer device 8, such as computer-readable instructions based on a large integer factorization method using bit-weighted hierarchical parallel collision detection. In addition, the aforementioned memory 81 can also be used to temporarily store various types of data that have been output or will be output.

[0201] In some embodiments, the processor 82 described above may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 82 is typically used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is used to execute computer-readable instructions stored in the memory 81 or to process data, for example, to execute the computer-readable instructions of the large integer factorization method based on bit-weighted hierarchical parallel collision detection.

[0202] The network interface 83 may include a wireless network interface or a wired network interface, which is typically used to establish a communication connection between the computer device 8 and other electronic devices.

[0203] Example 4 The present invention also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the large integer factorization method based on bit-weighted hierarchical parallel collision detection as described above.

[0204] The beneficial effects of implementing the above embodiments are as follows: (1) It has parallel scalability: in Within the complexity framework, the speedup is approximately linear as the number of worker nodes increases. This is because static load balancing ensures a balanced computational load across all worker nodes, eliminating scheduling bottlenecks.

[0205] (2) Early stopping optimization is possible: Based on the birthday paradox, it is expected that the search will stop early. When a collision is detected at a given index, a global early stopping mechanism is used to save an average of 30% to 60% of computing resources.

[0206] (3) Load balancing can be achieved: layer size It can accurately predict and achieve good load balancing through static scheduling, avoiding the communication overhead of dynamic scheduling.

[0207] (4) Hardware independence: It does not depend on any specific hardware (such as quantum computers or dedicated ASICs) and can run on general-purpose multi-core CPUs, GPUs, and FPGA clusters.

[0208] (5) It has closed-loop completeness: the feedback loop ensures that the algorithm will converge and will not fall into an infinite loop.

[0209] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0210] Obviously, the embodiments described above are merely some embodiments of the present invention, not all embodiments. The accompanying drawings show preferred embodiments of the present invention, but do not limit the patent scope of the present invention. The present invention can be implemented in many different forms; rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the patent protection scope of this invention.

Claims

1. A method for factoring large integers based on bit-weighted hierarchical parallel collision detection, characterized in that, Includes the following steps: Initialize the large integer to be factored, randomly select the base, and check the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, output the factor directly and terminate; otherwise, confirm that the base is valid and record the number of binary bits. Based on the number of binary bits, the exponent space is divided into several independent layers according to the number of 1s in the binary representation. The number of exponents in each layer is calculated using the combination formula. At the same time, the power modulus sequence is pre-calculated, and the layer number and the corresponding combination value are output. Based on the combined values ​​of each layer, the total number of worker nodes in the distributed computing cluster is statically allocated to each layer according to the workload ratio of each layer. The exponential subset within each layer is divided into subsets equal to the number of allocated worker nodes. A task description is generated for each worker node. The task description includes at least the layer number, the start position and end position of the exponential subset that the worker node is responsible for. The task description is then sent to the corresponding worker node. A worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task. Each working node, based on the task description, independently calculates the function value corresponding to the assigned exponent using a pre-computed power modulus sequence, and submits the calculation results to the master node in batches. Based on the calculation results, the master node maintains a global hash table and detects in real time whether there are collisions where different exponents correspond to the same function value. Once a collision is detected, it immediately broadcasts a stop signal to all worker nodes and outputs the collision pair. Based on the collision pairs, candidate periods are extracted and verified to obtain the true periods, and then the non-trivial factors of the large integers to be decomposed are solved. If the solution fails, the base is reselected.

2. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to claim 1, characterized in that, The steps of initializing the large integer to be factored, randomly selecting a base, and checking the greatest common divisor (GCD) between the base and the large integer to be factored, and if the GCD is greater than 1, directly outputting the factor and terminating the process; otherwise, confirming the validity of the base and recording the number of binary digits, specifically include: Perform validity verification and binary bit calculation on the large integer to be factored; Randomly select a base and calculate its greatest common divisor with the integer to be factored. If the greatest common divisor is greater than 1, the factors are obtained directly. Confirm that the base and the modulus are coprime, and record the global parameters.

3. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to claim 1, characterized in that, The steps of dividing the exponent space into several independent layers based on the number of 1s in the binary representation, calculating the number of exponents in each layer using the combination formula, pre-calculating the modulo exponent sequence, and outputting the layer number and corresponding combination value specifically include: Pre-compute the power modulus sequence based on binary bit width; The exponent space is divided into several layers according to the number of 1s in the binary representation. The number of exponents in each layer is calculated using the combination formula, and the layer number and its corresponding combination value are output. A method for generating on-demand enumeration indices for each layer is provided, supporting dynamic index generation in a distributed environment.

4. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to claim 1, characterized in that, The steps of statically allocating all worker nodes in the distributed computing cluster to each layer based on the combined values ​​of each layer and the workload ratio of each layer, dividing the exponential subset within each layer into subsets equal to the number of allocated worker nodes, generating a task description for each worker node, wherein the task description includes at least the layer number, the start position and end position of the exponential subset handled by the worker node, and then distributing the task description to the corresponding worker node, wherein a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task, specifically include: Establish mathematical models of workload at each level and determine the direct proportional relationship between workload and number of combinations; The total number of work nodes is allocated according to the probability ratio of workload at each level; The index set within each layer is divided into subsets equal to the number of assigned work nodes. A task description is generated for each work node. This task description is a triplet data structure containing the layer number k, the start ordinal number and the end ordinal number of the index subset. It is used to uniquely determine the entire range of indexes that the work node needs to calculate. The task description is then distributed to the corresponding work nodes.

5. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to claim 1, characterized in that, The steps of each working node independently calculating the function value corresponding to the assigned exponent based on the task description and using the pre-calculated power modulus sequence, and then submitting the calculation results to the master node in batches, specifically include: The worker node receives the task description from the master node and initializes its local computing environment; Using a pre-computed sequence of power modulo powers, the function value corresponding to each exponent is calculated through a chain of multiplications; The calculation results are submitted to the master node in batches, while the system continuously listens for early stop signals.

6. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to claim 1, characterized in that, The master node maintains a global hash table based on the calculation results, and detects in real time whether there are collisions where different exponents correspond to the same function value. Once a collision is detected, it immediately broadcasts a stop signal to all worker nodes and outputs the collision pair. The specific steps include: The master node maintains a global hash table with function values ​​as keys and exponent values ​​as values; For each newly submitted exponent-function value pair, perform collision detection. If different exponents are found to correspond to the same function value, record the collision pair. Upon detecting a collision, a stop signal is immediately broadcast to all working nodes, and confirmation is awaited before the collision pair is output.

7. The large integer factorization method based on bit-weighted hierarchical parallel collision detection according to any one of claims 1 to 6, characterized in that, The steps of extracting candidate periods based on the collision pairs, verifying and obtaining the true periods, and then solving for the nontrivial factors of the large integers to be decomposed, and reselecting the base if the solution fails, specifically include: The candidate period is obtained by taking the absolute value of the difference between the two indices in the collision pair. True periods are extracted from candidate periods through binary verification and small factorial division. Solve for nontrivial factors by calculating the greatest common divisor using the true period. If this fails, return and select a new base.

8. A large integer factorization device based on bit-weighted hierarchical parallel collision detection, characterized in that, include: The initialization module is used to initialize the large integer to be factored. It randomly selects the base and checks the greatest common divisor of the base and the large integer to be factored. If the greatest common divisor is greater than 1, the factor is directly output and the process terminates. Otherwise, the base is confirmed to be valid and the number of binary bits is recorded. The partitioning module is used to divide the exponent space into several independent layers based on the number of 1s in the binary representation, calculate the number of exponents in each layer using the combination formula, pre-calculate the power modulus sequence, and output the layer number and the corresponding combination value. The allocation module is used to statically allocate the total number of worker nodes in the distributed computing cluster to each layer based on the combined values ​​of each layer and the workload ratio of each layer. It also divides the exponential subset within each layer into subsets equal to the number of allocated worker nodes, generates a task description for each worker node, and the task description includes at least the layer number, the start position and end position of the exponential subset that the worker node is responsible for. Then, the task description is sent to the corresponding worker node, where a worker node refers to an independent computing unit in the cluster that actually performs the modular exponentiation calculation task. The calculation module is used by each working node to independently calculate the function value corresponding to the assigned exponent based on the task description and using the pre-calculated power modulus sequence, and submit the calculation results to the master node in batches; The detection module is used by the master node to maintain a global hash table based on the calculation results, detect in real time whether there are collisions where different exponents correspond to the same function value, and immediately broadcast a stop signal to all working nodes and output the collision pair once a collision is detected. The solution module is used to extract candidate periods based on the collision pairs and verify the true periods, and then solve for the non-trivial factors of the large integers to be decomposed. If the solution fails, the base is reselected.

9. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the large integer factorization method based on bit-weighted hierarchical parallel collision detection as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the large integer factorization method based on bit-weighted hierarchical parallel collision detection as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Ultra-long digit addition processing method and computer readable storage medium

    CN111831252A

  • RSA algorithm key cracking method and device, electronic equipment and storage medium

    CN121547179A