CN113239389B - Data processing method and device and data processing device - Google Patents

Data processing method and device and data processing device Download PDF

Info

Publication number
CN113239389B
CN113239389B CN202110783551.XA CN202110783551A CN113239389B CN 113239389 B CN113239389 B CN 113239389B CN 202110783551 A CN202110783551 A CN 202110783551A CN 113239389 B CN113239389 B CN 113239389B
Authority
CN
China
Prior art keywords
array
point number
floating point
data
encrypted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110783551.XA
Other languages
Chinese (zh)
Other versions
CN113239389A (en
Inventor
武斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huakong Tsingjiao Information Technology Beijing Co Ltd
Original Assignee
Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huakong Tsingjiao Information Technology Beijing Co Ltd filed Critical Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority to CN202110783551.XA priority Critical patent/CN113239389B/en
Publication of CN113239389A publication Critical patent/CN113239389A/en
Application granted granted Critical
Publication of CN113239389B publication Critical patent/CN113239389B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/085Secret sharing or secret splitting, e.g. threshold schemes

Abstract

The embodiment of the invention provides a data processing method and device and a device for data processing. The method comprises the following steps: randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted; determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted; converting the first floating point number to a first encoding array of an integer type and the second floating point number to a second encoding array of an integer type; and sending the first coding array and the second coding array to an operator for participating in an operation. The embodiment of the invention can realize secret sharing of the floating-point type data, so that a data provider can encode the floating-point type data into a secret sharing result and send the secret sharing result to an operator to participate in operation, and the application scene of a secret sharing algorithm can be expanded.

Description

Data processing method and device and data processing device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data processing method and apparatus, and an apparatus for data processing.
Background
Secret Share (Secret Share) is a method for distributing, saving and recovering secrets, and is an important means for implementing secure multiparty computation. At present, a ciphertext computing system based on secret sharing may use a secret sharing algorithm based on addition fragments, and the addition fragments are added to obtain a secret.
For various programming languages, the largest integer type is a long type, i.e., int64, and for longer integer types, there is generally a corresponding large number type and several basic operations are supported. However, for data of a floating point type (such as a float type or a double type), a secret sharing method for the data of the floating point type is not realized at present.
Disclosure of Invention
The embodiment of the invention provides a data processing method and device and a data processing device, which can realize secret sharing of floating point type data, so that a data provider can encode the floating point type data into a secret sharing result and send the secret sharing result to an operator to participate in operation, and the application scene of a secret sharing algorithm can be expanded.
In order to solve the above problem, an embodiment of the present invention discloses a data processing method, which is applied to a data provider, and the method includes:
randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
converting the first floating point number to a first encoding array of an integer type and the second floating point number to a second encoding array of an integer type;
and sending the first coding array and the second coding array to an operator for participating in an operation.
Optionally, the converting the first floating point number into a first coding array of an integer type and the converting the second floating point number into a second coding array of an integer type includes:
and amplifying the first floating point number by a preset multiple and converting the first floating point number into an integer type to obtain a first coding array, and amplifying the second floating point number by a preset multiple and converting the second floating point number into an integer type to obtain a second coding array.
Optionally, the converting the first floating-point number after being amplified by a preset multiple into an integer type to obtain a first coding array includes:
obtaining a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first coding array.
Optionally, the shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first coding array includes:
performing modulus calculation on the shift quantity to obtain a remainder r and a quotient q;
shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
converting the alignment data into bytes to obtain an alignment array;
filling the high positions of the aligned arrays to obtain a middle array with a preset length;
and moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
Optionally, the method further comprises:
summing the first coding array and the second coding array to obtain a result array;
and reducing the result array by preset times and converting the result array into a floating point type to obtain the data to be encrypted.
Optionally, the reducing the result array by a preset multiple and then converting the result array into a floating point type to obtain the data to be encrypted includes:
determining the sign bit of the data to be encrypted according to the first bit of the result array;
converting the effective bit segment in the result array into a preset type integer and taking an absolute value to obtain a target bit segment;
determining a first subscript according to the valid bit segment, and determining a second subscript according to the target bit segment;
determining the exponent number of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
determining a left shift amount according to the length of the effective bit section and the second subscript;
moving the target bit segment to the left by the left shift amount to obtain a bottom digit of the data to be encrypted;
and combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
Optionally, the summing the first coding array and the second coding array to obtain a result array includes:
step 1: initializing carry =0, array pointer i =0, and setting each element in result array resBytes to 0;
step 2: if i > = n, jumping to step 7, wherein n is the length of the first coding array and the second coding array;
and step 3: acquiring the ith element x of the first coding array and the ith element y of the second coding array;
and 4, step 4: if x or y is less than 0, converting x or y to a positive number;
and 5: summing the x, y and carry to obtain sum, and setting the ith element of resBytes according to the value of sum;
step 6: i is increased by 1, and the step 2 is skipped;
and 7: and outputting a result array rebytes.
On the other hand, the embodiment of the invention discloses a data processing device, which is applied to a data provider, and comprises:
the first floating point number generation module is used for randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the order of magnitude of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
the second floating point number generation module is used for determining a second floating point number, and the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
a floating point number encoding module for converting the first floating point number into a first encoding array of an integer type and converting the second floating point number into a second encoding array of an integer type;
and the result sending module is used for sending the first coding array and the second coding array to an operator for participating in the operation.
Optionally, the floating-point number encoding module is specifically configured to amplify the first floating-point number by a preset multiple and convert the first floating-point number into an integer type to obtain a first encoding array, and amplify the second floating-point number by the preset multiple and convert the second floating-point number into the integer type to obtain a second encoding array.
Optionally, the floating-point number encoding module includes:
a parameter obtaining submodule, configured to obtain a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
the shift determining submodule is used for calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and the shifting submodule is used for shifting the base number of the first floating point number by the shifting amount according to the shifting direction to obtain a first coding array.
Optionally, the shift submodule includes:
the module calculation unit is used for carrying out module calculation on the shift quantity to obtain a remainder r and a quotient q;
the alignment unit is used for shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
the conversion unit is used for converting the alignment data into bytes to obtain an alignment array;
the completion unit is used for completing the high positions of the aligned arrays to obtain a middle array with a preset length;
and the moving unit is used for moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
Optionally, the apparatus further comprises:
the array summing module is used for summing the first coding array and the second coding array to obtain a result array;
and the data reduction module is used for reducing the result array by preset times and then converting the result array into a floating point type to obtain the data to be encrypted.
Optionally, the data restoring module includes:
the sign determining submodule is used for determining the sign bit of the data to be encrypted according to the first bit of the result array;
the target determination submodule is used for converting the effective bit segments in the result array into preset type integers and taking absolute values to obtain target bit segments;
the subscript determining submodule is used for determining a first subscript according to the valid bit segment and determining a second subscript according to the target bit segment;
the exponent determining submodule is used for determining exponent bits of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
the left shift amount determining submodule is used for determining a left shift amount according to the length of the effective bit section and the second subscript;
the base number determining submodule is used for moving the target bit segment to the left by the left shift amount to obtain a base number of the data to be encrypted;
and the data splicing submodule is used for combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
In yet another aspect, the present invention discloses a device for data processing, the device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing the data processing method according to one or more of the preceding claims.
In yet another aspect, an embodiment of the present invention discloses a machine-readable medium having stored thereon instructions which, when executed by one or more processors of an apparatus, cause the apparatus to perform a data processing method as described in one or more of the preceding.
The embodiment of the invention has the following advantages:
the embodiment of the invention provides a data processing method for secretly sharing floating-point type data to be encrypted. And the data provider randomly generates a first floating point number according to the order of magnitude of the data to be encrypted, and a second floating point number can be obtained according to the difference between the data to be encrypted and the first floating point number. And converting the first floating point number into a first encoding array of an integer type, converting the second floating point number into a second encoding array of the integer type, and sending the obtained first encoding array and the obtained second encoding array to an operator for participating in operation as a secret sharing result of the data to be encrypted. The embodiment of the invention can expand the application scene of the secret sharing algorithm. In addition, the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted, so that the precision of the generated secret sharing result can be ensured. In addition, in the embodiment of the invention, except for result output, only a constant number of times of new memories are required, so that the memory occupancy rate can be saved, the efficiency of encoding and decoding the floating-point type data to be encrypted can be effectively improved, the load of a data provider system can be reduced, and the resources and the cost can be saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flow chart of the steps of one data processing method embodiment of the present invention;
FIG. 2 is a schematic diagram of the encoding rules of float type and double type according to the present invention;
FIG. 3 is a block diagram of an embodiment of a data processing apparatus according to the present invention;
FIG. 4 is a block diagram of an apparatus 800 for data processing of the present invention;
fig. 5 is a schematic diagram of a server in some embodiments of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms first, second and the like in the description and in the claims of the present invention are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the invention may be practiced other than those illustrated or described herein, and that the objects identified as "first," "second," etc. are generally a class of objects and do not limit the number of objects, e.g., a first object may be one or more. Furthermore, the term "and/or" in the specification and claims is used to describe an association relationship of associated objects, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. The term "plurality" in the embodiments of the present invention means two or more, and other terms are similar thereto.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a data processing method according to the present invention is shown, where the method is applicable to a data provider, and the method specifically includes the following steps:
step 101, randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number level of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
step 102, determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
103, converting the first floating point number into a first coding array of an integer type, and converting the second floating point number into a second coding array of the integer type;
and 104, sending the first coding array and the second coding array to an operator for participating in the operation.
The data processing method provided by the embodiment of the invention can be applied to a data provider, and can be used for encoding floating point type data to be encrypted to obtain a secret sharing result. The data provider may be a data provider in a multi-party secure computing system.
The multi-party secure computing system is a computing system that protects data privacy security. The embodiment of the present invention does not limit the security Computation protocol adopted by the multi-Party security Computation system, for example, the multi-Party security Computation system may be based on an MPC (multi-Party security Computation) protocol, in the multi-Party security Computation system based on the MPC protocol, a plurality of parties may perform collaborative Computation by using a multi-Party security Computation technology on the premise of not leaking their own data to obtain a Computation result, and the data, the intermediate result, and the final result participating in the Computation may be ciphertext. Of course, the multi-party secure computing system may also be a multi-party secure computing protocol implemented based on techniques such as secret sharing, semi-homomorphism, and oblivious transmission.
The data provider can encode data to be encrypted of a floating point type (such as a float type or a double type) to obtain a first encoding array and a second encoding array, and the first encoding array and the second encoding array are used as secret sharing results of the data to be encrypted and sent to corresponding operators to participate in operation. The operator can be a computing node in the multi-party secure computing system, and the participating operation can be an operation in a secure computing task.
The secure computing task includes, but is not limited to, any one or more of: privacy-preserving-based computational operations, privacy-preserving-based model training and prediction, privacy-preserving-based database query operations, and the like. Wherein the computing operations include, but are not limited to: digital calculations such as addition, multiplication, comparison, and the like, and logical calculations such as and/or inequality, and the like. It is to be understood that embodiments of the present invention do not impose limitations on the specific types of secure computing tasks.
In this embodiment of the present invention, the data to be encrypted may be floating-point type plaintext data held by the data provider.
Specifically, for plaintext data whose data d to be encrypted is a floating-point type, first, a first floating-point number x of an order of magnitude equivalent to or higher than d is randomly generated. Then, y = d-x is calculated, resulting in a second floating point number y, such that x + y = d. Finally, the first floating-point number x is converted into a first coded array of integer type, assumed to be xBytes, and the second floating-point number y is converted into a second coded array of integer type, assumed to be yBytes. The data provider can send xBytes and yBytes to the arithmetic party as the secret sharing result of d. For example, the first encoding array xBytes is sent to the operator s1, and the second encoding array yBytes is sent to the operator s 2. s1 and s2 may perform cooperative computation based on the first coding array or the second coding array that are owned by themselves, and neither of s1 and s2 can recover the plaintext of the data d using the first coding array or the second coding array that is owned by itself, so that the privacy and security of the computation can be ensured.
In order to ensure the precision of the secret sharing result, the embodiment of the invention generates the first floating point number which is equal to or higher than the order of magnitude of the data to be encrypted. Further, a first floating point number within 4 orders of magnitude or more of the data to be encrypted may be generated. Wherein, 4 orders of magnitude are only used as an example, the selected order of magnitude is related to the precision of the secret sharing result, the higher the order of magnitude is, the higher the precision is, and the reduction or estimation of the original data can be prevented. But the higher the order of magnitude, the larger the computation load. Since the precision of the double type is 52 bits, if the first floating point number which is 3 orders of magnitude larger than the original data is generated, after the difference is made to obtain the second floating point number, the effective number of the second floating point number becomes (52-lg 1000/lg 2), which is about 42, and can be cut off as required.
In an optional embodiment of the present invention, the converting the first floating point number into a first coding array of an integer type and the converting the second floating point number into a second coding array of an integer type may include:
and amplifying the first floating point number by a preset multiple and converting the first floating point number into an integer type to obtain a first coding array, and amplifying the second floating point number by a preset multiple and converting the second floating point number into an integer type to obtain a second coding array.
Wherein the integer type refers to a large integer (bigInteger) type, such as a first floating point number and a second floating point number that may be converted to a 128-bit large integer. And then converting the large integer into an array of 16 bytes according to the specified byte order, and enabling the first floating point number and the second floating point number to respectively correspond to the array of 16 bytes, namely the secret sharing result. The 16-byte array obtained after the first floating point number conversion is called a first encoding array, and the 16-byte array obtained after the second floating point number conversion is called a second encoding array. Each byte is 8 bits, and thus the first code array and the second code array are each 128 bits in length. Of course, in practical applications, the lengths of the first coding array and the second coding array are not limited.
It should be noted that, the embodiment of the present invention does not limit the size of the preset multiple and the length of the coding array. In the embodiment of the present invention, the predetermined multiple is 2^40, and the encoding array is 128 bits signed integer (i.e. 16 bytes of byte array).
The preset multiple can be determined according to actual requirements, as long as the occurrence of less or no low-order overflow can be ensured. The embodiment of the invention sets the preset multiple to 2^40 because the double significant bit is 52 bits, the int128 significant bit is 128 bits, and if the 52 bits of significant data are exactly in the middle position, the data should be left shifted by (128-52)/2 =38 bits, but since 40 is more convenient for intuitive understanding and calculation and is a multiple of 8, 2^40 is selected as the preset multiple. Of course, the preset multiple may be adjusted according to the size of the actual data to be encrypted. For example, 2^38 can be selected.
In an optional embodiment of the present invention, the converting the first floating-point number into an integer type after amplifying the first floating-point number by a preset multiple to obtain a first coding array includes:
step S11, obtaining the sign bit of the first floating point number, the exponent bit of the first floating point number and the base bit of the first floating point number;
step S12, calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and step S13, shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first code array.
Assuming that the first floating-point number is denoted as f, and the byte of f is denoted as fBytes, f needs to be amplified by a preset multiple (a times) and then converted into a large integer. First, the sign bit sign, exponent bit index, and base bit base of f are obtained. Then, the shift direction and shift amount of the base are calculated from the preset multiple a and the exponent bit index. The shift direction includes a left shift or a right shift. And finally, shifting the base to the left (or to the right) by the shift amount to obtain a first coding array.
The process of converting the second floating-point number to the second encoding array is similar. Specifically, a sign bit of the second floating point number, an exponent bit of the second floating point number, and a base bit of the second floating point number are obtained; calculating the shift direction and the shift amount of the base digit of the second floating point number according to the preset multiple and the exponent digit of the second floating point number; and shifting the base number of the second floating point number by the shift amount according to the shift direction to obtain a second coding array.
The float type and the double type correspond to floating point data of different lengths, the float type is 32 bits, and the double type is 64 bits. Referring to fig. 2, a schematic diagram of encoding rules of the float type and the double type is shown. For example, as shown in fig. 2, the floating point number of the double type is 64 bits, the most significant bit (63 rd bit) is the sign bit, the 0 th bit to 51 th bit are the base bits, and the 52 th bit to 62 th bit are the exponent bits.
In one example, taking the double type in the java programming language as an example, assuming that the preset multiple is 2^40, the first floating point number and the second floating point number of the double type need to be converted into 128-bit signed integers. It should be noted that the embodiment of the present invention is not limited to the java programming language, and the data processing method of the present invention can be applied to any programming language as long as the definition of the floating point number meets the IEEE (Institute of Electrical and Electronics Engineers) binary floating point number arithmetic standard (IEEE 754).
As shown in fig. 2 for a double type floating point number, the most significant bit is the sign bit, the following 11 bits are the digits, the exponent is an unsigned number, and the exponent is the actual exponent plus 1023 bits (plus 128 if of float type). Plus 1023 is added for conversion to a positive number. The 52 th bit is a base bit, which is also an unsigned number.
It should be noted that, by performing steps S11 to S13, any floating point number can be amplified by a predetermined multiple and converted into a byte array (e.g., 128-bit encoding array) of a large integer (big integer) type.
Taking the floating point number-123.625 as an example, the floating point number is a negative number of double type. The sign bit of the negative number is 1, so the sign bit (most significant bit) of floating point number-123.625 is 1, translating floating point number-123.625 to a binary representation as: 1111011.101, the conversion to scientific notation is: 1.111011101 x 2^ 6. The exponent bit of the floating-point binary is the actual exponent bit plus 1023. For the floating-point number-123.625, the actual exponent bit is 6, and 1023 needs to be added to get a binary exponent bit of 1029. Denote 1029 as binary: 10000000101. since the integer bit is always 1, no writing can be omitted. The binary representation of the base digit is: 111011101, and the remainder are 0's compliments, the floating point number-123.625 is stored in memory in the form: 1100000001011110111010000000000000000000000000000000000000000000.
in a specific implementation, the sign bit, the exponent bit, and the base bit of a floating point number may be obtained by using three masks, 0x800000000000, 0x7ff0000000000000, and 0x000 fffffffffffffffffffffL.
For floating point number-123.625, the sign bit sign of-123.625 can be obtained with three masks, 0x8000000000000000, 0x7ff0000000000000, and 0x000fffffffffffffL, is 1, the exponent bit index is 10000000101, and the base bit base is 1110111010000000000000000000000000000000000000000000. It should be noted that, for a double type floating-point number, the sign bit needs to be right-shifted by 63 bits, the exponent bit needs to be right-shifted by 52 bits, and 1023 is subtracted from the shifted exponent bit to obtain the actual exponent bit. The sign bit is shifted to the right by 63 bits, and the exponent bit is shifted to the right by 52 bits because the sign bit is leftmost, and the sign bit is shifted to the rightmost end in order to allow the sign bit to be intuitively understood as 0 or 1. The exponent is the same.
After the sign bit, exponent bit, and base bit of the floating point-123.625 are obtained, a shift direction and a shift amount of the base bit base of the floating point-123.625 are calculated according to the preset multiple (e.g., 2^40 times) and the exponent bit (e.g., 10000000101) of the floating point-123.625.
Since the base digit of the double-type floating point number refers to a decimal part under the scientific notation, 1 needs to be supplemented before the highest digit, the actual base digit can be obtained by taking a complement code according to the positive and negative of the data to be encrypted and then right shifting the base digit by 52 digits, and therefore the shift amount of the base digit base of the floating point number-123.625 is 40+ index-52 by combining the exponent digit index and the preset multiple 2^ 40. The shift direction is left-shifted if the shift amount is a positive number, and right-shifted if the shift amount is a negative number. Since the shift amount is 40+ index-52=40+6-52= -6, which is a negative number, the shift direction is right shift and the shift amount is 6 bits.
And finally, moving the bottom number of the floating point number-123.625 by the shift amount according to the shift direction to obtain an encoding array of the floating point number-123.625.
For the data to be encrypted of the floating point type, after determining the first floating point number and the second floating point number corresponding to the data to be encrypted, the method may be adopted to amplify the first floating point number by the preset multiple and convert the first floating point number into a byte array (e.g., a 128-bit first encoding array) of the large integer (big integer) type, and amplify the second floating point number by the preset multiple and convert the second floating point number into a byte array (e.g., a 128-bit second encoding array) of the large integer (big integer) type.
In the embodiment of the invention, for data d to be encrypted of a floating point type, a first floating point number x with the order of magnitude equivalent to (or higher than) d is randomly generated; then calculating y = d-x to obtain a second floating point number y; then respectively converting the first floating point number x and the second floating point number y into byte coding arrays (a first coding array and a second coding array) of a large integer type according to the method; and finally, respectively sending the first coding array obtained by converting the first floating point number x and the second coding array obtained by converting the second floating point number y to an arithmetic party, so that secret sharing of the floating point type data d to be encrypted can be realized, and the error is controlled within a controllable range.
It is understood that d, x, y may represent any floating point number, and the invention is not limited in this regard.
In an optional embodiment of the present invention, the shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain the first coding array may include:
step S21, performing modulus calculation on the shift quantity to obtain a remainder r and a quotient q;
step S22, shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
step S23, converting the alignment data into bytes to obtain an alignment array;
step S24, the high positions of the aligned arrays are filled up to obtain a middle array with a preset length;
and step S25, moving the middle array by q bytes integrally according to the shift direction to obtain a first coding array.
After the shift direction and the shift amount of the base digit base of the first floating point number are calculated, steps S21 to S25 may be performed to shift the base digit base of the first floating point number. It should be noted that, by executing steps S21 to S25, the base digit of an arbitrary floating point number can be shifted in the shift direction and the shift amount.
Firstly, performing modulus calculation on the shift quantity to obtain a remainder and a quotient, wherein the remainder is represented by r, and the quotient is represented by q. Specifically, the shift amount is modulo-8 calculated, taking the remainder r and the quotient q. And then, moving the base bit base of the first floating point number by r bits according to the shift direction to obtain aligned data base _ align, wherein the step is to perform byte alignment on the base number, and the byte alignment can be realized by integrally moving the byte array by r bits. Since the alignment data base _ align is of int64 type, the first coding array to be converted is a int 128-bit byte array, and therefore, the alignment data is converted into bytes to obtain an alignment array, and the high bits of the alignment array are filled to obtain a middle array with a preset length (128 bits). And finally, moving the middle array by q bytes integrally according to the shift direction to obtain a first coding array. And (3) shifting the bytes of the int 128-bit middle array by q bytes to the left, and throwing out the out-of-range exception if the high bit of the array is out-of-range (the right bit is not needed if the low bit is shifted out-of-range, and the right bit is directly discarded). The shifted array is the coding array.
Still taking the floating point-123.625 as an example, the shift amount of the base bit base of the floating point-123.625 is calculated to be 40+ index-52= -6, that is, it needs to be shifted to the right by 6 bits. The shift amount is modulo 8, resulting in a remainder r =6 and a quotient q = 0. The bottom digit of the floating point number 123.625 is first shifted to the right by r bits to get the aligned data, denoted 11111111100001000110000000000000000000000000000000000000. The alignment data is converted into bytes, resulting in an alignment array, denoted as [0, 0, 0, 0, 96, -124, -1] (low order bits in front and high order bits behind). The high order bits of the aligned array are then filled and concatenated into a 128-bit middle array, denoted as [0, 0, 0, 0, 96, -124, -1, -1, -1, -1, -1, -1, -1, -1. Finally, the whole intermediate array is shifted to the right by q bytes, so that an encoded array of the floating point number-123.625 can be obtained, and the encoded array is represented as [0, 0, 0, 0, 96, -124, -1, -1, -1, -1, -1, -1, -1, -1 ].
By adopting the method, for the first floating point number and the second floating point number corresponding to the data to be encrypted, the first floating point number can be encoded into the first encoding array, and the second floating point number can be encoded into the second encoding array.
In an optional embodiment of the invention, the method may further comprise:
step S31, summing the first coding array and the second coding array to obtain a result array;
and step S32, reducing the result array by preset times and converting the result array into a floating point type to obtain the data to be encrypted.
In the embodiment of the present invention, a process of encoding data to be encrypted (floating point number d) into a first encoding array and a second encoding array is referred to as an encoding process, and may also be referred to as an encryption process, where the first encoding array and the second encoding array are secret sharing results of the floating point number d. In addition, the first encoding array and the second encoding array may be recovered to obtain the plaintext of the floating point number d, and this process is referred to as a decoding process, and may also be referred to as a decryption process.
Suppose that the first encoding array is denoted as xBytes and the second encoding array is denoted as yBytes. If the first coding array and the second coding array are respectively reduced by preset multiples and then converted into the floating point type, and then summed to obtain the plaintext of the data to be encrypted, not only is the operation amount large due to the fact that repeated operation is required to be performed twice, but also the process may cause the loss of the plaintext precision of the finally recovered data to be encrypted.
In order to reduce the amount of operations and avoid the loss of precision, the embodiment of the present invention sums the first coding array and the second coding array to obtain a result array, where the precision of the result array is not lost. And then reducing the result array by preset times and converting the result array into a floating point type to obtain the plaintext of the data to be encrypted. The process only needs to carry out operation of reducing the preset multiple and converting the preset multiple into a floating point type once, and the operation amount can be greatly reduced.
In an optional embodiment of the present invention, the summing the first coding array and the second coding array to obtain a result array may include:
step S41: initializing carry =0, array pointer i =0, and setting each element in result array resBytes to 0;
step S42: if i > = n, jumping to step S47, where n is the length of the first coding array and the second coding array;
step S43: acquiring the ith element x of the first coding array and the ith element y of the second coding array;
step S44: if x or y is less than 0, converting x or y to a positive number;
step S45: summing the x, y and carry to obtain sum, and setting the ith element of resBytes according to the value of sum;
step S46: i is increased by 1, and the step S42 is skipped;
step S47: and outputting a result array rebytes.
In the embodiment of the present invention, the first code array and the second code array are equal in length, for example, 128 bits.
Taking the floating-point type data to be encrypted as-123.625 as an example, assume that the first coding array xBytes obtained by coding is [0, -61, 46, 79, -61, -102, 0, 0, 0, 0, 0, 0, 0, 0, 0], and the second coding array yBytes is [ -1, 60, -47, -80, -100, -23, -2, -1, -1, -1, -1, -1, -1, -1, -1.
Carry =0 is initialized first, array pointer i =0 is initialized, and each element in result array resBytes is initialized to 0.
In the first round loop, the i (i = 1) th element x of the first coding array xBytes and the i (i = 1) th element y of the second coding array yBytes are obtained, and then x =0 and y = -1. Since y is less than 0, y is converted to a positive number, resulting in x =0 and y = 255. Summing x, y, and carry results in sum =0+255+0= 255. The ith element of resBytes is set according to the value of sum. Since carry is the quotient of sum and 256, i.e., the carry, if sum is greater than or equal to 128 at this time, sum is decremented by 256 (since byte data type is treated as a signed number within java) and the ith element of resBytes is set to current sum. In this example, sum = x + y + carry =0+255+0=255, where sum is greater than 128, so that sum =255 = -1 by subtracting 256 from sum, and then the i (i = 1) th element of resBytes is set as the current sum, that is, the 1 st element of resBytes is set as-1. resBytes = [ -1, 0, 0, 0, 0, 0, 0, 0, 0, 0] is obtained in the first round of the cycle.
In the second round, the 2 nd element x of the first coding array xBytes and the 2 nd element y of the second coding array yBytes are obtained, so that x = -61, y = 60. Since x is less than 0, x is converted to a positive number, resulting in x =195 and y = 60. Further, sum =195+60+0-256= -1, and carry =0 is obtained. resBytes = [ -1, -1, 0, 0, 0, 0, 0, 0, 0, 0] is obtained in the second round of the cycle.
And so on until i =16, the final resBytes can be obtained as [ -1, -1, -1, -1, 95, -124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1.
After the first coding array xBytes and the second coding array yBytes are summed to obtain a result array resBytes, the result array resBytes is reduced by preset multiples and then converted into a floating point type, and the plaintext of the floating point type data to be encrypted can be obtained.
In an optional embodiment of the present invention, the reducing the result array by a preset multiple and then converting the result array into a floating point type to obtain the data to be encrypted may include:
step S41, determining the sign bit of the data to be encrypted according to the first bit of the result array;
step S42, converting the effective bit segment in the result array into a preset type integer and taking an absolute value to obtain a target bit segment;
step S43, determining a first subscript according to the valid bit segment, and determining a second subscript according to the target bit segment;
step S44, determining exponent bits of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
step S45, determining a left shift amount according to the length of the effective bit segment and the second subscript;
step S46, moving the target bit segment to the left by the left shift amount to obtain the bottom digit of the data to be encrypted;
step S47, combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted, and the base bit of the data to be encrypted to obtain the data to be encrypted.
Specifically, the positive and negative are judged according to the first bit of the result array rebytes, and the sign bit of the data to be encrypted, which needs to be recovered, can be determined.
Because the result array resBytes is a higher-order integer, and the accuracy is generally higher than float or double, the accuracy of resBytes needs to be corrected, the lower order bits are discarded, and the higher order bits are reserved, so as to obtain the valid bit segment in the result array. Specifically, it is possible to find the least significant bit that is not zero starting from the least significant bit of the result array rebytes and the most significant bit that is not 0 (negative number-1) starting from the most significant bit, get the valid bit segment, and obtain the length of the valid bit segment, baselen. And converting the effective bit segment into a preset type integer and taking an absolute value to obtain a target bit segment. In one example, the preset type is a long type.
Taking the example of a result array resBytes of [ -1, -1, -1, -1, 95, -124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] the valid bit field of the result array is [ -1, -1, -1, -1, 95, -124 ]. As another example, for another result array [0, -61, 46, 79, -61, -102, 0, 0, 0, 0, 0, 0] the valid bit field is [ -61, 46, 79, -61, -102 ].
Taking the result array [ -1, -1, -1, -1, 95, -124, -1, -1, -1, -1, -1, -1] as an example, the valid bit segment is [ -1, -1, -1, -1, 95, -124 ]. And converting the effective bit segment into a long type integer and taking an absolute value to obtain a target bit segment. Specifically, the valid bit segment [ -1, -1, -1, -1, 95, -124] is converted into a long type integer [ -1, -1, -1, -1, 95, -124, -1, -1], and an absolute value of the long type integer is obtained to obtain a target bit segment of [1, 0, 0, 0, -96, 123, 0, 0 ]. The target bit segment is a storage form of the long type integer in the memory.
A first index is then determined from the valid bit segment and a second index is determined from the target bit segment. Wherein the first subscript (i) is the highest-order subscript of the valid bit segment. In this example, the most significant bit of the significant bit segment [ -1, -1, -1, -1, 95, -124] is-124, and thus, the first index i (most significant bit index) is 5.
Further, the determining the second index according to the target bit segment may include: obtaining the byte of the effective highest bit of the target bit segment; circularly right-shifting the bytes until the value after right-shifting is 0 to obtain the right-shifting times at the moment; subtracting the number of right shifts by 1 to obtain a second subscript.
For example, in this example, the target bit segment is [1, 0, 0, 0, -96, 123, 0, 0], and the byte that takes the most significant bit of the target bit segment is 123. Shifting the byte to the right 7 times in a cycle causes the value of 123 to become 0, and thus, the second index (denoted as k) can be determined to be k =7-1= 6.
According to the first subscript, the second subscript and the preset multiple, the exponent number of the data to be encrypted can be determined.
Specifically, the exponent bits of the data to be encrypted =8 ⨉ i + k-40+ 1023. In this example, i =5, k =6, and therefore, the exponent bit of the data to be encrypted =8 ⨉ 5+6-40+1023= 1029.
The amount of left shift can be determined from the length of the active bit segment, baselen, and the second index k. Specifically, the amount of left shift = (8-k) +8 ⨉ (8-baselen) -12. In this example, baselen =6, k =6, and therefore, the amount of left shift = (8-6) +8 ⨉ (8-6) -12= 6. Wherein, the 12-bit subtraction is caused by the 12-bit difference of the most significant bit of the base number of the double type relative to the length 64 thereof.
And moving the target bit segment to the left by the left shift amount to obtain the bottom digit of the data to be encrypted. In this example, shifting the target bit segment [1, 0, 0, 0, -96, 123, 0, 0] left by 6 bits can result in 8699335998963776 being the bottom digit.
After determining the sign bit, the exponent bit and the bottom bit of the data to be encrypted, combining the sign bit, the exponent bit and the bottom bit of the data to be encrypted to obtain the plaintext of the data to be encrypted.
In this example, the leading bit of the result array [ -1, -1, -1, -1, 95, -124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] is negative, and thus, the data to be encrypted is a negative number, and the sign bit of the data to be encrypted can be determined to be 1. The exponent bit of the data to be encrypted is determined to be 1029, and the conversion to binary is 10000000101; having determined that the base digit of the data to be encrypted is 8699335998963776, the conversion to binary is 11110111010000000000000000000000000000000000001000000. The sign bit, the exponent bit and the base bit are spliced to obtain a binary representation of the data to be encrypted, the binary representation is converted into a double type of-123.62500000000091, the value is the plaintext of the data to be encrypted, and the error is within an allowable range.
In the embodiment of the present invention, a double-type floating point number is mainly used as an example for description, and the processing procedures of a float-type floating point number are similar and are referred to each other.
In summary, the embodiment of the present invention provides a data processing method for secret sharing of floating-point type data to be encrypted, and the method can be applied to a data provider. And the data provider randomly generates a first floating point number according to the order of magnitude of the data to be encrypted, and a second floating point number can be obtained according to the difference between the data to be encrypted and the first floating point number. And converting the first floating point number into a first encoding array of an integer type, converting the second floating point number into a second encoding array of the integer type, and sending the obtained first encoding array and the obtained second encoding array to an operator for participating in operation as a secret sharing result of the data to be encrypted. The embodiment of the invention can expand the application scene of the secret sharing algorithm. In addition, the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted, so that the precision of the generated secret sharing result can be ensured. In addition, in the embodiment of the invention, except for result output, only a constant number of times of new memories are required, so that the memory occupancy rate can be saved, the efficiency of encoding and decoding the floating-point type data to be encrypted can be effectively improved, the load of a data provider system can be reduced, and the resources and the cost can be saved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Device embodiment
Referring to fig. 3, a block diagram of a data processing apparatus according to an embodiment of the present invention is shown, where the apparatus is applicable to a data provider, and the apparatus may specifically include:
a first floating point number generating module 301, configured to randomly generate a first floating point number according to an order of magnitude of data to be encrypted, where the order of magnitude of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
a second floating point number generation module 302, configured to determine a second floating point number, where a sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
a floating-point number encoding module 303, configured to convert the first floating-point number into a first encoding array of an integer type, and convert the second floating-point number into a second encoding array of an integer type;
a result sending module 304, configured to send the first coding array and the second coding array to an operator for participating in an arithmetic operation.
Optionally, the floating-point number encoding module is specifically configured to amplify the first floating-point number by a preset multiple and convert the first floating-point number into an integer type to obtain a first encoding array, and amplify the second floating-point number by the preset multiple and convert the second floating-point number into the integer type to obtain a second encoding array.
Optionally, the floating-point number encoding module includes:
a parameter obtaining submodule, configured to obtain a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
the shift determining submodule is used for calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and the shifting submodule is used for shifting the base number of the first floating point number by the shifting amount according to the shifting direction to obtain a first coding array.
Optionally, the shift submodule includes:
the module calculation unit is used for carrying out module calculation on the shift quantity to obtain a remainder r and a quotient q;
the alignment unit is used for shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
the conversion unit is used for converting the alignment data into bytes to obtain an alignment array;
the completion unit is used for completing the high positions of the aligned arrays to obtain a middle array with a preset length;
and the moving unit is used for moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
Optionally, the apparatus further comprises:
the array summing module is used for summing the first coding array and the second coding array to obtain a result array;
and the data reduction module is used for reducing the result array by preset times and then converting the result array into a floating point type to obtain the data to be encrypted.
Optionally, the data restoring module includes:
the sign determining submodule is used for determining the sign bit of the data to be encrypted according to the first bit of the result array;
the target determination submodule is used for converting the effective bit segments in the result array into preset type integers and taking absolute values to obtain target bit segments;
the subscript determining submodule is used for determining a first subscript according to the valid bit segment and determining a second subscript according to the target bit segment;
the exponent determining submodule is used for determining exponent bits of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
the left shift amount determining submodule is used for determining a left shift amount according to the length of the effective bit section and the second subscript;
the base number determining submodule is used for moving the target bit segment to the left by the left shift amount to obtain a base number of the data to be encrypted;
and the data splicing submodule is used for combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
Optionally, the array summing module is specifically configured to perform the following steps:
step 1: initializing carry =0, array pointer i =0, and setting each element in result array resBytes to 0;
step 2: if i > = n, jumping to step 7, wherein n is the length of the first coding array and the second coding array;
and step 3: acquiring the ith element x of the first coding array and the ith element y of the second coding array;
and 4, step 4: if x or y is less than 0, converting x or y to a positive number;
and 5: summing the x, y and carry to obtain sum, and setting the ith element of resBytes according to the value of sum;
step 6: i is increased by 1, and the step 2 is skipped;
and 7: and outputting a result array rebytes.
The embodiment of the invention provides a data processing method for secretly sharing floating-point type data to be encrypted. And the data provider randomly generates a first floating point number according to the order of magnitude of the data to be encrypted, and a second floating point number can be obtained according to the difference between the data to be encrypted and the first floating point number. And converting the first floating point number into a first encoding array of an integer type, converting the second floating point number into a second encoding array of the integer type, and sending the obtained first encoding array and the obtained second encoding array to an operator for participating in operation as a secret sharing result of the data to be encrypted. The embodiment of the invention can expand the application scene of the secret sharing algorithm. In addition, the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted, so that the precision of the generated secret sharing result can be ensured. In addition, in the embodiment of the invention, except for result output, only a constant number of times of new memories are required, so that the memory occupancy rate can be saved, the efficiency of encoding and decoding the floating-point type data to be encrypted can be effectively improved, the load of a data provider system can be reduced, and the resources and the cost can be saved.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present invention provides an apparatus for data processing, applied to a data provider, the apparatus including a memory, and one or more programs, wherein the one or more programs are stored in the memory, and configured to be executed by the one or more processors includes instructions for:
randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
converting the first floating point number to a first encoding array of an integer type and the second floating point number to a second encoding array of an integer type;
and sending the first coding array and the second coding array to an operator for participating in an operation.
Optionally, the converting the first floating point number into a first coding array of an integer type and the converting the second floating point number into a second coding array of an integer type includes:
and amplifying the first floating point number by a preset multiple and converting the first floating point number into an integer type to obtain a first coding array, and amplifying the second floating point number by a preset multiple and converting the second floating point number into an integer type to obtain a second coding array.
Optionally, the converting the first floating-point number after being amplified by a preset multiple into an integer type to obtain a first coding array includes:
obtaining a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first coding array.
Optionally, the shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first coding array includes:
performing modulus calculation on the shift quantity to obtain a remainder r and a quotient q;
shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
converting the alignment data into bytes to obtain an alignment array;
filling the high positions of the aligned arrays to obtain a middle array with a preset length;
and moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
Optionally, the device is also configured to execute the one or more programs by one or more processors including instructions for:
summing the first coding array and the second coding array to obtain a result array;
and reducing the result array by preset times and converting the result array into a floating point type to obtain the data to be encrypted.
Optionally, the reducing the result array by a preset multiple and then converting the result array into a floating point type to obtain the data to be encrypted includes:
determining the sign bit of the data to be encrypted according to the first bit of the result array;
converting the effective bit segment in the result array into a preset type integer and taking an absolute value to obtain a target bit segment;
determining a first subscript according to the valid bit segment, and determining a second subscript according to the target bit segment;
determining the exponent number of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
determining a left shift amount according to the length of the effective bit section and the second subscript;
moving the target bit segment to the left by the left shift amount to obtain a bottom digit of the data to be encrypted;
and combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
Optionally, the summing the first coding array and the second coding array to obtain a result array includes:
step 1: initializing carry =0, array pointer i =0, and setting each element in result array resBytes to 0;
step 2: if i > = n, jumping to step 7, wherein n is the length of the first coding array and the second coding array;
and step 3: acquiring the ith element x of the first coding array and the ith element y of the second coding array;
and 4, step 4: if x or y is less than 0, converting x or y to a positive number;
and 5: summing the x, y and carry to obtain sum, and setting the ith element of resBytes according to the value of sum;
step 6: i is increased by 1, and the step 2 is skipped;
and 7: and outputting a result array rebytes.
Fig. 4 is a block diagram illustrating an apparatus 800 for data processing in accordance with an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 4, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 5 is a schematic diagram of a server in some embodiments of the invention. The server 1900 may vary widely by configuration or performance and may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a series of instructions operating on a server. Still further, a central processor 1922 may be provided in communication with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input-output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform the data processing method shown in fig. 1.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform a data processing method, the method comprising: randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted; determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted; converting the first floating point number to a first encoding array of an integer type and the second floating point number to a second encoding array of an integer type; and sending the first coding array and the second coding array to an operator for participating in an operation.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
The data processing method, the data processing apparatus and the apparatus for data processing provided by the present invention are described in detail above, and specific examples are applied herein to illustrate the principles and embodiments of the present invention, and the description of the above embodiments is only used to help understand the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (11)

1. A data processing method applied to a data provider, the method comprising:
randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the number of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
determining a second floating point number, wherein the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
converting the first floating point number to a first encoding array of an integer type and the second floating point number to a second encoding array of an integer type;
sending the first coding array and the second coding array to an operator for participating in an operation;
the method further comprises the following steps:
summing the first coding array and the second coding array to obtain a result array;
determining the sign bit of the data to be encrypted according to the first bit of the result array;
converting the effective bit segment in the result array into a preset type integer and taking an absolute value to obtain a target bit segment;
determining a first subscript according to the valid bit segment, and determining a second subscript according to the target bit segment;
determining the exponent number of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
determining a left shift amount according to the length of the effective bit section and the second subscript;
moving the target bit segment to the left by the left shift amount to obtain a bottom digit of the data to be encrypted;
and combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
2. The method of claim 1, wherein converting the first floating point number to a first encoded array of integer type and the second floating point number to a second encoded array of integer type comprises:
and amplifying the first floating point number by a preset multiple and converting the first floating point number into an integer type to obtain a first coding array, and amplifying the second floating point number by a preset multiple and converting the second floating point number into an integer type to obtain a second coding array.
3. The method of claim 2, wherein the amplifying the first floating-point number by a predetermined factor and converting the first floating-point number into an integer type to obtain a first coding array comprises:
obtaining a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and shifting the base number of the first floating point number by the shift amount according to the shift direction to obtain a first coding array.
4. The method of claim 3, wherein said shifting the base of the first floating point number by the shift amount in the shift direction to obtain a first coding array comprises:
performing modulus calculation on the shift quantity to obtain a remainder r and a quotient q;
shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
converting the alignment data into bytes to obtain an alignment array;
filling the high positions of the aligned arrays to obtain a middle array with a preset length;
and moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
5. The method of claim 1, wherein summing the first coding array and the second coding array to obtain a result array comprises:
step 1: initializing carry =0, array pointer i =0, and setting each element in result array resBytes to 0;
step 2: if i > = n, jumping to step 7, wherein n is the length of the first coding array and the second coding array;
and step 3: acquiring the ith element x of the first coding array and the ith element y of the second coding array;
and 4, step 4: if x or y is less than 0, converting x or y to a positive number;
and 5: summing the x, y and carry to obtain sum, and setting the ith element of resBytes according to the value of sum;
step 6: i is increased by 1, and the step 2 is skipped;
and 7: and outputting a result array rebytes.
6. A data processing apparatus, applied to a data provider, the apparatus comprising:
the first floating point number generation module is used for randomly generating a first floating point number according to the order of magnitude of data to be encrypted, wherein the order of magnitude of the first floating point number is higher than or equal to the order of magnitude of the data to be encrypted;
the second floating point number generation module is used for determining a second floating point number, and the sum of the first floating point number and the second floating point number is equal to the data to be encrypted;
a floating point number encoding module for converting the first floating point number into a first encoding array of an integer type and converting the second floating point number into a second encoding array of an integer type;
the result sending module is used for sending the first coding array and the second coding array to an operator for participating in operation;
the device further comprises:
the array summing module is used for summing the first coding array and the second coding array to obtain a result array;
the data reduction module is used for reducing the result array by preset times and then converting the result array into a floating point type to obtain the data to be encrypted; the data restoration module comprises:
the sign determining submodule is used for determining the sign bit of the data to be encrypted according to the first bit of the result array;
the target determination submodule is used for converting the effective bit segments in the result array into preset type integers and taking absolute values to obtain target bit segments;
the subscript determining submodule is used for determining a first subscript according to the valid bit segment and determining a second subscript according to the target bit segment;
the exponent determining submodule is used for determining exponent bits of the data to be encrypted according to the first subscript, the second subscript and the preset multiple;
the left shift amount determining submodule is used for determining a left shift amount according to the length of the effective bit section and the second subscript;
the base number determining submodule is used for moving the target bit segment to the left by the left shift amount to obtain a base number of the data to be encrypted;
and the data splicing submodule is used for combining the sign bit of the data to be encrypted, the exponent bit of the data to be encrypted and the base digit of the data to be encrypted to obtain the data to be encrypted.
7. The apparatus of claim 6, wherein the floating-point number encoding module is specifically configured to amplify the first floating-point number by a predetermined multiple and convert the first floating-point number into an integer type to obtain a first encoded array, and amplify the second floating-point number by the predetermined multiple and convert the second floating-point number into the integer type to obtain a second encoded array.
8. The apparatus of claim 7, wherein the floating-point number encoding module comprises:
a parameter obtaining submodule, configured to obtain a sign bit of the first floating point number, an exponent bit of the first floating point number, and a base bit of the first floating point number;
the shift determining submodule is used for calculating the shift direction and the shift amount of the base digit of the first floating point number according to the preset multiple and the exponent digit of the first floating point number;
and the shifting submodule is used for shifting the base number of the first floating point number by the shifting amount according to the shifting direction to obtain a first coding array.
9. The apparatus of claim 8, wherein the shift submodule comprises:
the module calculation unit is used for carrying out module calculation on the shift quantity to obtain a remainder r and a quotient q;
the alignment unit is used for shifting the base number of the first floating point number by r bits according to the shifting direction to obtain alignment data;
the conversion unit is used for converting the alignment data into bytes to obtain an alignment array;
the completion unit is used for completing the high positions of the aligned arrays to obtain a middle array with a preset length;
and the moving unit is used for moving the middle array by q bytes integrally according to the shifting direction to obtain a first coding array.
10. An apparatus for data processing, applied to a data provider, the apparatus comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising instructions for performing the data processing method according to any one of claims 1 to 5.
11. A machine-readable medium having stored thereon instructions which, when executed by one or more processors of an apparatus, cause the apparatus to perform the data processing method of any of claims 1 to 5.
CN202110783551.XA 2021-07-12 2021-07-12 Data processing method and device and data processing device Active CN113239389B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110783551.XA CN113239389B (en) 2021-07-12 2021-07-12 Data processing method and device and data processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110783551.XA CN113239389B (en) 2021-07-12 2021-07-12 Data processing method and device and data processing device

Publications (2)

Publication Number Publication Date
CN113239389A CN113239389A (en) 2021-08-10
CN113239389B true CN113239389B (en) 2021-09-17

Family

ID=77135410

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110783551.XA Active CN113239389B (en) 2021-07-12 2021-07-12 Data processing method and device and data processing device

Country Status (1)

Country Link
CN (1) CN113239389B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422116B (en) * 2021-12-14 2023-11-28 阿里巴巴(中国)有限公司 Data processing method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9405728B2 (en) * 2013-09-05 2016-08-02 Altera Corporation Floating-point adder circuitry
US9461667B2 (en) * 2013-12-30 2016-10-04 Samsung Electronics Co., Ltd. Rounding injection scheme for floating-point to integer conversion
CN106131139B (en) * 2016-06-23 2019-07-19 暨南大学 A kind of encryption of the floating data of cloud relational database and querying method
CN111543025A (en) * 2017-08-30 2020-08-14 因福尔公司 High precision privacy preserving real valued function evaluation
US11411724B2 (en) * 2019-08-01 2022-08-09 Ut-Battelle, Llc Continuous variable quantum secret sharing
CN110677411B (en) * 2019-09-27 2022-07-19 浙江宇视科技有限公司 Data sharing method and system based on cloud storage

Also Published As

Publication number Publication date
CN113239389A (en) 2021-08-10

Similar Documents

Publication Publication Date Title
CN111832067B (en) Data processing method and device and data processing device
CN112241250B (en) Data processing method and device and data processing device
CN110543481B (en) Data processing method and device, computer equipment and storage medium
CN114301594B (en) Inadvertent transmission method, multi-party secure computing platform and device for inadvertent transmission
CN113315631B (en) Data processing method and device and data processing device
CN112861175A (en) Data processing method and device and data processing device
CN114969830B (en) Privacy intersection method, system and readable storage medium
CN113254956A (en) Data processing method and device and data processing device
CN113239389B (en) Data processing method and device and data processing device
CN112667674A (en) Data processing method and device and data processing device
CN110365806B (en) Website conversion method and device
CN115085912A (en) Ciphertext computing method and device for ciphertext computing
CN115617897B (en) Data type conversion method and multi-party secure computing system
CN115941181B (en) Out-of-order secret sharing method, system and readable storage medium
CN112269904A (en) Data processing method and device
CN114885038B (en) Encryption protocol conversion method, result acquisition node and privacy calculation node
CN112580064B (en) Data processing method and device and data processing device
CN116305206A (en) Secure multiparty computing method, device, electronic equipment and storage medium
CN112861145B (en) Data processing method and device for data processing
CN107193530B (en) Method and device for generating random number
CN112468290B (en) Data processing method and device and data processing device
CN114996752A (en) Multiparty privacy intersection method and device and multiparty privacy intersection device
CN112583764B (en) Data processing method and device and data processing device
CN112906904B (en) Data processing method and device for data processing
CN112580063B (en) Data processing method and device and data processing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant