A commodity delivery recording method and system based on blockchain
By using the RSA asymmetric encryption algorithm and the storage mechanism of blockchain nodes in blockchain technology, the problem of non-tamperability and verifiability of commodity delivery record data is solved, and high security and accuracy of data are achieved.
Patent Information
- Application Number
- CN202410890713.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In the existing technology, it is difficult for commodity delivery records to ensure the non-tamperability and verifiability of data, and there is a lack of effective data storage and verification mechanisms.
Adopt a blockchain-based commodity delivery recording method, generate the private key and public key pair of the RSA asymmetric encryption algorithm through user registration, use a mobile device with a positioning function to take photos to obtain longitude and latitude coordinate information and pictures, calculate the hash value of the picture and use RSA An asymmetric encryption algorithm generates a digital signature, which is uploaded to the blockchain node for storage and verification.
It greatly increases the difficulty of data tampering and ensures the security and accuracy of data. Through blockchain technology, commodity delivery records cannot be tampered with and are easy to verify.
Smart Images

Figure CN118410193B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and more specifically, to a commodity delivery record method and system based on blockchain. Background Art
[0002] Blockchain technology is decentralized and tamper-proof. Its technical feature is that it uses a chain structure with a timestamp to store data, which adds a time dimension to the data record, making it verifiable and traceable. Any slight change in the information in the block will lead to the modification of the data content of all blocks after the block, greatly increasing the difficulty of data tampering, making it very suitable for data storage and verification. Summary of the invention
[0003] The present invention overcomes the shortcomings of the prior art and provides a commodity delivery record method and system based on blockchain, in the hope of solving the problems existing in the prior art.
[0004] In order to solve the above technical problems, one aspect of the present invention provides a commodity delivery record method based on blockchain.
[0005] A commodity delivery recording method based on blockchain, comprising the following steps:
[0006] Upstream and downstream user registration, generating the user's RSA asymmetric encryption algorithm private key and public key pair;
[0007] Create a transaction. The downstream user sets the coordinates of the delivery location. After the upstream user delivers the goods to the delivery location, he / she uses a mobile device with positioning function to take a photo. The photo includes the upstream user and the delivered goods, and obtains the latitude and longitude coordinate information and picture information at the time of taking the photo.
[0008] Calculate the hash value of the image;
[0009] Encrypt the image information using the user private key in the RSA asymmetric encryption algorithm, generate a digital signature of the image, and generate an image with a digital signature, wherein the image information includes a hash value of the image;
[0010] The longitude and latitude coordinate information when taking the photo and the obtained picture with a digital signature are uploaded to the blockchain node, and the transaction information is stored in the transaction, wherein the transaction information includes the longitude and latitude coordinate information of the delivery location and the picture with a digital signature.
[0011] Using blockchain nodes to record transaction information can completely record transaction information, and as new transactions are generated, the ledger is also updated. Any slight change in the information in the block will lead to the modification of the data content of all blocks after the block, which greatly increases the difficulty of data tampering. At the same time, the security and accuracy of the ledger information can be guaranteed by cryptography. Each block corresponds to a hash value, which represents the integrity and consistency of the data, further improving the accuracy of the data.
[0012] A further technical solution is that the calculation of the hash value of the image specifically includes the following steps:
[0013] Use the MD5 hash algorithm to process the entire image file in blocks and calculate the hash value;
[0014] Convert the hash value to hexadecimal format.
[0015] The final hash value is a compact representation of the file, which is easier to read and process.
[0016] A further technical solution is that the picture information also includes EXIF data and coordinate information.
[0017] EXIF (Exchangeable Image File Format) is a metadata standard for digital camera images, which records the attribute information and shooting data of digital images. This information includes:
[0018] Manufacturer and camera model;
[0019] Image orientation, resolution, and units;
[0020] Software, last change time;
[0021] YCbCr position, exposure time, aperture value, shooting mode;
[0022] ISO sensitivity, EXIF information version;
[0023] The time when the image was taken and saved;
[0024] Exposure compensation, metering mode, flash usage;
[0025] Physical focal length of the lens, Flashpix version;
[0026] Image color space and size;
[0027] A further technical solution is that the transaction information is stored in the transaction, and the transaction information also includes the time of taking the photo.
[0028] The photo-taking time information contained in the EXIF information is used to generate a digital signature, which is mainly used to verify the image. The photo-taking time stored in the transaction information is mainly used to record the time.
[0029] A further technical solution is that the hash value of the image information is encrypted using the user private key in the RSA asymmetric encryption algorithm, and generating a digital signature of the image specifically includes the following steps:
[0030] Use OAEP (Optimal Asymmetric Encryption Padding) to pad and select two hash functions;
[0031] Split message m into two parts: message m1 and a random padding string r;
[0032] Apply the hash function to the padding string r and get the result G(r);
[0033] Connect G(r) with message m1 to get the new message m';
[0034] Apply a masking function to m' to convert it to a large integer for RSA encryption;
[0035] Use the RSA public key to encrypt m' to obtain the ciphertext c, which is the digital signature.
[0036] The hash value of the image is encrypted using the user's private key in the RSA asymmetric encryption algorithm to generate a digital signature for the image. This requires generating a fixed-length encrypted ciphertext. The OAEP (Optimal Asymmetric Encryption Padding) padding scheme ensures that sufficient randomness is added during encryption to improve security, so that the ciphertext of the same message is different each time it is encrypted, which increases security and prevents some attacks.
[0037] A further technical solution is that after storing the transaction information in the transaction, the following steps are performed:
[0038] The transaction data is encrypted with the private key to create a transaction signature; other nodes can use the corresponding public key to verify the transaction signature to ensure the legitimacy of the transaction.
[0039] Broadcasting the transaction signature to the blockchain network; broadcasting transactions means sending transactions to other nodes in the network so that they can be verified and included in blocks.
[0040] Other nodes in the blockchain receive the transaction and use the RSA public key to verify the validity of the transaction signature;
[0041] Other nodes in the blockchain extract a fixed-length digital signature from the end of the same-frame image of the transaction data and verify its validity using the RSA public key.
[0042] If the transaction signature passes the verification, the node will persist the new block to the local ledger;
[0043] If the transaction signature fails to pass verification, it means that the transaction is forged or tampered with, and the transaction is canceled.
[0044] Another aspect of the present invention provides a commodity delivery record system based on blockchain, including a server, a mobile device, and a blockchain node;
[0045] The server is used to receive user registration information; generate a private key and a public key pair of the user's RSA asymmetric encryption algorithm;
[0046] The mobile device is used to obtain coordinate information in real time and take photos in the same frame; calculate the hash value of the picture taken by the mobile device; use the user private key in the RSA asymmetric encryption algorithm to encrypt the picture information, generate a digital signature of the picture, and generate a picture with a digital signature; upload the picture with the digital signature to the blockchain node;
[0047] The blockchain node is used to store and manage delivery information; broadcast transaction signatures to the blockchain network; and use RSA public keys to verify the validity of transaction signatures broadcast by other nodes.
[0048] Compared with the prior art, the present invention has at least the following beneficial effects: the present invention sets the delivery location through the downstream user, and the upstream user brings the delivery product to the delivery location to take photos, collects necessary information to prove that the delivery product has been delivered, uploads the taken photos to the server, generates photos with digital signatures by the server, uses blockchain nodes to record transaction information, and broadcasts the transaction signature to the blockchain network, which greatly increases the difficulty of data tampering and uses blockchain technology to make the commodity delivery records tamper-proof and easy to verify. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is a schematic diagram of the steps of Example 1 of the present invention;
[0050] Figure 2 This is a schematic diagram of the structure and information interaction of Example 2 of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0052] Embodiment 1
[0053] A method for recording commodity delivery based on blockchain, such as Figure 1 As shown, the following steps are included:
[0054] S1: Upstream and downstream user registration, generating the private key and public key pair of the user's RSA asymmetric encryption algorithm;
[0055] S2: Create a transaction. The downstream user sets the coordinates of the delivery location. After the upstream user delivers the goods to the delivery location, he uses a mobile device with positioning function to take a photo. The photo includes the upstream user and the delivered goods, and obtains the latitude and longitude coordinate information at the time of taking the photo.
[0056] In this embodiment, the longitude and latitude coordinates are: 116.397128, 39.916527.
[0057] After the downstream user sets the delivery location coordinates, the upstream user must bring the delivery product to the delivery location for photography. If the user fails to arrive at the delivery location set by the downstream user, the location information of the photo taken will be inconsistent with the location set by the user, and the delivery requirements will not be met. The user may not make a record or may record the current coordinates but indicate that the delivery requirements have not been met.
[0058] If the delivery location has been reached, the taken picture will contain the latitude and longitude coordinates when the picture was taken, the upstream user, and the delivered product. Therefore, it can be proved that the delivery product has been delivered by the upstream user.
[0059] S3: Calculate the hash value of the image; the hash calculation may adopt common algorithms such as average hash, block hash, difference hash, etc. In this embodiment, the calculation of the hash value of the image specifically includes the following steps:
[0060] S31: Use the MD5 hash algorithm to process the entire image file in blocks and calculate the hash value;
[0061] S32: Convert the hash value to hexadecimal form to obtain a compact representation.
[0062] In this embodiment, the hash value of the image file is: e31dd395a954d59d6c22f5fc860570c6;
[0063] S4: Encrypt the image information using the user private key in the RSA asymmetric encryption algorithm to generate a digital signature of the image, and generate an image with a digital signature, wherein the image information includes a hash value of the image;
[0064] In a preferred embodiment, the picture information also includes EXIF data and coordinate information.
[0065] The purpose of converting image information into a digital signature is to facilitate the subsequent verification of the image information, thereby ensuring the authenticity of the image. Therefore, when only the image hash value is available, the image can still be verified, thereby further improving the authenticity of the image and preventing subsequent modification.
[0066] The purpose of encrypting the image information other than the hash value and generating a digital signature is to further verify the image with other information to improve the integrity and authenticity of the information.
[0067] The user private key in the RSA asymmetric encryption algorithm is used to encrypt the image information. Taking the image hash value as an example, generating the digital signature of the image specifically includes the following steps:
[0068] S41: Use OAEP padding and select two hash functions; in this embodiment, the hash functions used are SHA-1 and SHA-256.
[0069] S42: Divide the message m into two parts: message m1 and a random padding string r;
[0070] S43: Apply a hash function to the padding string r to obtain a result G(r);
[0071] S44: Connect G(r) with message m1 to obtain a new message m';
[0072] S45: Apply a masking function to m' to convert it into a large integer;
[0073] S46: Encrypt m' using the RSA public key to obtain ciphertext c, which is the digital signature.
[0074] For example, the ciphertext is as follows: 0f6cdfda13f4fe130b817b10e0d9b14fb69a81c9a7920d8ffea87c9064eacf403f534e3ef1df76e969227b00f8aaa8f8e36cadcda3283d5a573b266768cc10bd787a37ed03aa86601ef38b641a4c256d5427a1b3b8b1b30da6f386c896d0ffd7193d218ed976d92c58059c0cb2579cd037579533808f87b3def614058f2 f63b0d780b1fba773a740f263a3649d1658b14a42f5f5227026e4ae43461b8d6f 5599de4542e23631bb46cc25ef7f94d8d22046d82202eb5374d6f510b0136e832 3e3859e2589d3ef690fbdb4a640861c99da51a868089822d1d7e8cbd3169333e0 d2bb85969e4d85c82bb19160fb97dfa5bf117f083910fec6d4dad73ff74f64079a
[0075] S5: Upload the longitude and latitude coordinate information when taking the photo and the obtained digitally signed picture to the blockchain node, and store the transaction information in the transaction, wherein the transaction information includes the longitude and latitude coordinate information of the delivery location and the digitally signed picture. In this embodiment, the transaction information also includes the photo taking time.
[0076] Although the image information already contains the longitude and latitude coordinate information and the EXIF data already contains the shooting time, the longitude and latitude coordinate information in the image information and the shooting time in the EXIF data have been encrypted into a digital signature for verifying the image information. The shooting time uploaded here is saved as transaction information.
[0077] S6: Encrypt the transaction data using the private key and create a transaction signature;
[0078] S7: Broadcast the transaction signature to the blockchain network;
[0079] S8: Other nodes in the blockchain receive the transaction and use the RSA public key to verify the validity of the transaction signature;
[0080] If the transaction signature passes the verification, the node will persist the new block to the local ledger;
[0081] If the transaction signature fails to pass verification, it means that the transaction is forged or tampered with, and the transaction is canceled.
[0082] Embodiment 2
[0083] A commodity delivery record system based on blockchain, such as Figure 2 As shown, it includes, a server, a mobile device, and a blockchain node;
[0084] The server is used to receive user registration information; generate a private key and a public key pair of the user's RSA asymmetric encryption algorithm;
[0085] The mobile device is used to obtain coordinate information in real time and take photos in the same frame; calculate the hash value of the picture taken by the mobile device; use the user private key in the RSA asymmetric encryption algorithm to encrypt the picture information, generate a digital signature of the picture, and generate a picture with a digital signature; upload the picture with the digital signature to the blockchain node;
[0086] The mobile device can be an existing mobile phone terminal or a special anti-counterfeiting collection terminal.
[0087] The blockchain node is used to store and manage delivery information; broadcast transaction signatures to the blockchain network; and use RSA public keys to verify the validity of transaction signatures broadcast by other nodes.
[0088] Although the present invention is described herein with reference to the illustrative embodiments of the present invention, it should be understood that those skilled in the art can design many other modifications and implementations, which will fall within the scope and spirit of the principles disclosed in the present application. More specifically, within the scope disclosed in the present application, multiple variations and improvements can be made to the components and / or layout of the subject combination layout. In addition to the variations and improvements made to the components and / or layout, other uses will also be apparent to those skilled in the art.
Claims
1. A method for recording commodity delivery based on blockchain, It is characterized in that The following steps are involved: Upstream and downstream user registration, generating the user's RSA asymmetric encryption algorithm private key and public key pair; Create a transaction. The downstream user sets the coordinates of the delivery location. After the upstream user delivers the goods to the delivery location, he / she uses a mobile device with positioning function to take a photo. The photo includes the upstream user and the delivered goods, and obtains the latitude and longitude coordinate information and picture information at the time of taking the photo. Calculate the hash value of the image; Encrypt the image information using the user private key in the RSA asymmetric encryption algorithm, generate a digital signature of the image, and generate an image with a digital signature, wherein the image information includes a hash value of the image; The method of encrypting the image information using the user private key in the RSA asymmetric encryption algorithm and generating a digital signature of the image specifically includes the following steps: Use OAEP padding and choose two hash functions; Split message m into two parts: message m1 and a random padding string r; Apply the hash function to the padding string r and get the result G(r); Connect G(r) with message m1 to get the new message m'; Apply a masking function to m' to convert it to a large integer; Encrypt m' using the RSA public key to obtain ciphertext c, which is the digital signature; The longitude and latitude coordinate information when taking the photo and the obtained picture with a digital signature are uploaded to the blockchain node, and the transaction information is stored in the transaction, wherein the transaction information includes the longitude and latitude coordinate information of the delivery location and the picture with a digital signature.
2. A method for recording commodity delivery based on blockchain as claimed in claim 1, It is characterized in that The step of calculating the hash value of the image specifically includes the following steps: Use the MD5 hash algorithm to process the entire image file in blocks and calculate the hash value; Convert the hash value to hexadecimal format.
3. A method for recording commodity delivery based on blockchain as claimed in claim 1, It is characterized in that The picture information also includes EXIF data and coordinate information.
4. A method for recording commodity delivery based on blockchain as claimed in claim 3, It is characterized in that The transaction information is stored in the transaction, and the transaction information also includes the time of taking the photo.
5. A method for recording commodity delivery based on blockchain as claimed in claim 1, It is characterized in that After storing the transaction information in the transaction, perform the following steps: Encrypt transaction data with a private key and create a transaction signature; Broadcast the transaction signature to the blockchain network; Other nodes in the blockchain receive the transaction and use the RSA public key to verify the validity of the transaction signature; If the transaction signature passes the verification, the node will persist the new block to the local ledger; If the transaction signature fails to pass verification, it means that the transaction has been forged or tampered with and the transaction is canceled.
6. A commodity delivery record system based on blockchain, It is characterized in that Including servers, mobile devices, and blockchain nodes; The server is used to receive user registration information; generate a private key and a public key pair of the user's RSA asymmetric encryption algorithm; The mobile device is used to obtain coordinate information in real time and take photos in the same frame; Calculate the hash value of the picture taken by the mobile device; Use the user's private key in the RSA asymmetric encryption algorithm to encrypt the image information, use OAEP padding, select two hash functions, divide the message m into two parts, message m1 and a random padding string r, apply the hash function to the padding string r, and get the result G(r); connect G(r) with the message m1 to get the new message m'; Apply a masking function to m' to convert it into a large integer, encrypt m' using the RSA public key to obtain the ciphertext c, which is the digital signature of the generated image, and generate an image with a digital signature; Upload the digitally signed image to the blockchain node; The blockchain node is used to store and manage delivery information; broadcast transaction signatures to the blockchain network; Use the RSA public key to verify the validity of the transaction signature broadcast by other nodes.
