Explicit digital signature creation method and device for layout file
By inserting signature values and certificate information into the layout file, the problems of browsers being unable to display and digital signatures being unable to be verified after printing are solved, thus realizing intuitive file display and verification functions after printing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-06
- Publication Date
- 2026-04-03
AI Technical Summary
The digital signatures of existing formatted documents cannot be visually displayed in browsers or after printing, and the digital signatures cannot be verified after printing.
By reading the visible content of the layout file, a hash value is extracted using a hash algorithm, and a digital signature is performed using the signer's private key. The signature value and certificate information are then formatted according to predetermined rules and inserted into the file, supporting browser display and printing, and can be verified via OCR.
It enables the digital signature of layout documents to be displayed intuitively in the browser, and verifies it through OCR after printing to ensure the anti-tampering and non-repudiation functions of the documents.
Smart Images

Figure CN121786800A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of digital signatures, digital certificates, and cryptography, and in particular to a method for creating explicit digital signatures for formatted documents. Background Technology
[0002] Existing methods for creating digital signatures for formatted documents are complex and inconsistent, with the signature value and digital certificate hidden within the file's unique data structure. Common software such as browsers and chat tools often fail to display the digital signature when opening formatted documents with this feature, leaving users unaware of its existence. Furthermore, current digital signature technology for formatted documents can only verify signatures on electronic copies; printed documents cannot be verified. Summary of the Invention
[0003] The purpose of this invention is to at least solve the problems in the prior art where users cannot know whether a document has a digital signature and where the digital signature cannot be verified after the electronic document is printed. This invention provides a method and apparatus for creating a digital signature for a formatted document, thereby solving the problems mentioned in the background art.
[0004] To achieve the above objectives, the present invention provides the following technical solution: First, read the visible content of all pages of the document to be signed, then encode the read content according to predetermined rules and extract the hash value according to predetermined hash algorithm.
[0005] The established encoding rules refer to encoding visible content such as text, tables, and images according to common encoding rules such as UTF8, ASCII, and BASE64.
[0006] Then, the hash value is digitally signed using the signer's private key.
[0007] The digital signature refers to encrypting the data to be signed (original text) using a private key based on an asymmetric encryption algorithm (such as SM2, RSA, ECDSA).
[0008] Finally, the obtained signature value and the signer's X509 digital certificate or DID certificate information are formatted according to the established rules and inserted into a specific page.
[0009] The X509 digital certificate refers to the result containing the certificate holder's real identity information and public key, after being encoded by DER or PEM.
[0010] The DID certificate presentation information includes: the public key of the blockchain DID certificate holder, the certificate information to be presented, the salted hash of other certificate information that does not need to be presented, the verifiable credential issued by the DID certificate issuer, the template ID of the DID certificate, the verification challenge random code, and the digital signature of the DID certificate holder for all presented information.
[0011] After opening a file with a digital signature created using the above methods using a browser or common reading software such as WeChat, users can directly see the signature value and the signer's certificate or DID information. After printing the document, OCR technology can be used to scan and read all visible content on non-signature pages, along with the signature value and certificate content on the signature page, to verify the validity of the digital signature. This ensures that the printed electronic document retains its tamper-proof and non-repudiation capabilities. Attached Figure Description
[0012] The present invention will be further described below with reference to the accompanying drawings and embodiments: Figure 1 A schematic diagram of a method and apparatus for creating a digital signature for a type of document.
[0013] Figure 2 An example diagram of a method and apparatus for creating a digital signature for a type of document. Detailed Implementation
[0014] Please see Figure 1 and Figure 2 This invention provides a technical solution for a method and apparatus for creating digital signatures for formatted documents: Step S101: Read the visible content of all pages of the document to be signed.
[0015] Specifically, it reads all visible content (excluding some file metadata that is not displayed) from the first page to the last page of a PDF or OFD file in sequence.
[0016] Step S102: Encode the read content and extract the hash value according to the predetermined hash algorithm.
[0017] Specifically, the read content is encoded according to common encoding rules such as UTF8, ASCII, and BASE64, and then the hash value is extracted according to hash algorithms such as SM3, SHA256, and SHA1.
[0018] Step S103: Digitally sign the hash value using the signer's private key.
[0019] Specifically, the hash value is digitally signed using the private key (algorithm SM2, SECP256K1, RSA, ECDSA, etc.) corresponding to the X509 digital certificate or blockchain DID certificate held by the signer.
[0020] Step S104: Arrange the signature value and certificate content according to the established rules and insert them into a specific page.
[0021] Specifically, the signature value is a hexadecimal string obtained in step S103.
[0022] The certificate content includes X509 digital certificate or blockchain DID certificate presentation information.
[0023] The X509 digital certificate refers to the result containing the certificate holder's real identity information and public key, after being encoded by DER or PEM.
[0024] The DID certificate presentation information includes: the public key of the blockchain DID certificate holder, the certificate information to be presented, the salted hash of other certificate information that does not need to be presented, the verifiable credential issued by the DID certificate issuer, the template ID of the DID certificate, the verification challenge random code, and the digital signature of the DID certificate holder for all presented information.
[0025] Preferably, the signature value can be compared with the signer's X.509 digital certificate. Figure 2 The rules for formatting are then written to the last page of the layout file.
[0026] After users open the file with the digital signature created through the above steps using a browser or ordinary reading software such as WeChat, they can directly see the signature value and the signer's certificate or DID information. After printing the document, OCR technology can be used to scan and read all visible content on non-signature pages, along with the signature value and certificate content on the signature page, to verify the validity of the digital signature. This ensures that the printed electronic document still possesses tamper-proof and non-repudiation functions.
Claims
1. A method for creating an explicit digital signature for a formatted document, characterized in that: First, read the visible content of all pages of the document to be signed. Then, encode the read content according to the predetermined rules and extract the hash value according to the predetermined hash algorithm. Then, use the signer's private key to digitally sign the hash value. Finally, insert the obtained signature value and the signer's X509 digital certificate or DID certificate information into a specific page after being arranged according to the predetermined rules. The established encoding rules refer to encoding visible content such as text, tables, and images according to common rules such as UTF8, ASCII, and BASE64; The digital signature mentioned refers to encrypting the data to be signed (original text) using a private key based on an asymmetric encryption algorithm (such as SM2, RSA, ECDSA); The X509 digital certificate refers to the result containing the certificate holder's real identity information and public key, after being encoded by DER or PEM. The DID certificate presentation information includes: the public key of the blockchain DID certificate holder, the certificate information to be presented, the salted hash of other certificate information that does not need to be presented, the verifiable credential issued by the DID certificate issuer, the template ID of the DID certificate, the verification challenge random code, and the digital signature of the DID certificate holder for all presented information.
2. An explicit digital signature creation device for formatted documents, characterized in that, include: A storage medium capable of storing the method steps used in claim 1; A computer device capable of storing and executing the method steps used in claim 1.