Method and device for creating layout file by block chain, electronic equipment and storage medium

文档序号:68867 发布日期:2021-10-01 浏览:28次 中文

阅读说明:本技术 区块链创建版式文件的方法、装置、电子设备及存储介质 (Method and device for creating layout file by block chain, electronic equipment and storage medium ) 是由 青龙生 龙玲 刘明霞 于 2021-07-08 设计创作,主要内容包括:本发明公开了区块链创建版式文件的方法、装置、电子设备及存储介质,方法包括S1,区块链节点接收版式文件生成指示,包括版式文件内容信息和设置参数;S2,区块链节点根据版式文件生成指示,触发智能合约;S3,智能合约根据设置参数设置文档属性,将版式文件内容信息写入设置属性的文档中,生成版式文件,包括如下步骤:S4,对版式文件进行编码;S5,将编码后的版式文件,进行存储;装置包括依次连接的收发单元、处理单元、加密单元、存储单元;电子设备包括:处理器,用于存储处理器可执行指令的存储器;处理器运行所述方法的可执行指令;存储介质,其上存储有计算机指令,计算机指令被处理器执行时,实现所述方法的步骤。(The invention discloses a method and a device for creating a format file by a block chain, electronic equipment and a storage medium, wherein the method comprises S1, a block chain link receives a format file generation instruction, and the format file generation instruction comprises format file content information and setting parameters; s2, generating an instruction according to the format file by the block link points, and triggering an intelligent contract; s3, the intelligent contract sets the document attribute according to the setting parameter, writes the format file content information into the document with the setting attribute, generates the format file, including the following steps: s4, encoding the layout file; s5, storing the coded layout file; the device comprises a transmitting-receiving unit, a processing unit, an encryption unit and a storage unit which are connected in sequence; the electronic device includes: a processor, a memory for storing processor-executable instructions; the processor executes the executable instructions of the method; a storage medium having stored thereon computer instructions which, when executed by a processor, perform the steps of the method.)

1. The method for creating the layout file by the block chain is characterized by comprising the following steps:

s1, receiving a format file generation instruction by the block chain link point, wherein the format file generation instruction comprises format file content information and setting parameters;

s2, generating an instruction according to the format file by the block link points, and triggering an intelligent contract;

s3, the intelligent contract sets the document attribute according to the setting parameter, writes the format file content information into the document with the setting attribute, generates the format file, including the following steps:

s311, calling a creating unit of the intelligent contract by the intelligent contract, and receiving format file content information and setting parameters;

s312, the intelligent contract calls a verification unit of the intelligent contract to verify the legality of the format file content information and the setting parameters;

s313, if the validity check is passed, the intelligent contract calls a setting unit of the intelligent contract, and the attribute of the format file is set according to the setting parameter;

s314, the intelligent contract calls the conversion logic of the intelligent contract, and the content information of the layout file is converted into the layout file according to the set attribute;

s4, encoding the layout file;

and S5, storing the coded layout file.

2. The method for creating a layout file according to claim 1, wherein the blockchain node directly obtains a set of documents, and generates the layout file by converting the intelligent contracts on the blockchain node; the generation of the layout file comprises the following steps:

s321, the intelligent contract calls the uploading unit of the intelligent contract to receive the document, wherein the information of the document is the content after being coded;

s322, the intelligent contract calls the verification unit of the intelligent contract to verify the coded document, and the document information is verified for validity by converting the document content into a byte array;

and S323, if the validity check is passed, the intelligent contract calls a conversion unit of the intelligent contract to convert the document into a format file.

3. The method for creating a layout file according to the blockchain of claim 1 or 2, wherein the intelligent contract calls a storage unit of the intelligent contract, encodes the layout file, and writes the encoded layout file into an account book of the blockchain node.

4. The method of claim 1, wherein the setting parameters are preset on the nodes of the blockchain by a smart contract, and the preset setting parameters are read when the layout file is generated.

5. The method of claim 1, wherein in step S5, the encoded layout file is divided into data, the size of a single transaction in the blockchain is controlled, and the divided subsets are stored in the ledger of blockchain link points.

6. The method of claim 5, wherein the encoded layout file is divided into equal ratios, the total size is X units, the equal ratios are divided into Y transactions for storage, the size of each transaction is Z units, wherein Y ≦ X, Z = X/Y, when X/Y is not an integer, Z is rounded up, i.e. the storage size of the 1 st to Y-1 st transactions is Z, and the storage size of the Y transaction is X-Z (Y-1), and the divided subsets are stored in the book of the link points of the block.

7. The method for creating a layout file according to claim 1, wherein the layout file content information in S1 is a markup language generated by a rich text editor.

8. Apparatus for blockchain creation of layout files for blockchain nodes, the apparatus comprising:

the receiving and sending unit comprises a sending and receiving unit, and the sending unit is used for sending format file generation instructions to the block chain nodes, wherein the format file generation instructions comprise format file content information and setting parameters; the receiving unit is used for receiving a format file generation instruction;

the processing unit is used for setting the attribute of the document through setting parameters according to the received format file generation instruction, writing the content information of the format file into the attribute-set document and generating a format file;

the encryption unit encrypts the layout file by adopting codes;

and the storage unit is used for storing the coded layout file.

9. The electronic device of claim 1, comprising: a processor, a memory for storing processor-executable instructions; wherein the processor implements the method of the first aspect by executing executable instructions of the method.

10. The computer-readable storage medium of claim 1, having stored thereon computer instructions, wherein the computer instructions, when executed by a processor, perform the steps of the method.

Technical Field

The present invention relates to the field of blockchain technologies, and in particular, to a method and an apparatus for creating a layout file in a blockchain, an electronic device, and a storage medium.

Background

The block chain technology, also called distributed ledger technology, is an emerging technology in which several computing devices participate in "accounting" together, and a complete distributed database is maintained together. The blockchain technology has been widely used in many fields due to its characteristics of decentralization, transparency, participation of each computing device in database records, and rapid data synchronization between computing devices.

With the development of cloud computing, big data and artificial intelligence, a few of software vendors with monopoly status provide a format file creating service for users, and collect behavior habits and even privacy data of the users to describe so-called user portrayal.

Contracts in civil activities or documents such as other documents, documents and the like are increasingly displayed, exchanged and stored by data telegraph texts. However, due to the high requirements on legibility, reliability and safety of electronic contracts, invoices, insurance policies, medical records, receipt, bills, notifications and the like, the reliability of electronic documents becomes very important. How to reliably ensure that the content of the electronic document remains intact and unchanged since the electronic document is finally formed becomes a key problem to be solved.

In real life, a share of an electronic contract generally requires the following operations:

downloading, installing and starting client software such as Microsoft Word or WPS Office;

step two, creating a streaming document through the client software, and editing text contents on an interface of the streaming document;

step three, converting the streaming document into a format document in a PDF or OFD format;

and fourthly, uploading the format document in the PDF or OFD format to a third party signing platform for electronic signature.

In the whole process, multi-party operation is involved, the intermediate process is complicated, and the result content is returned to the user after the interaction between the partial operation environment and the server is separated from the user operation, so that the information safety of the document is difficult to ensure.

Based on this, users need a technology with higher efficiency, lower cost, and higher safety and reliability, and a trusted environment for an electronic document is established from the time when the user has edited a content initiation request to the time when the electronic document is finally formed.

Disclosure of Invention

In order to solve the defects of the prior art, realize the purposes of improving the reliability of the electronic document and ensuring that the content is completely operated and not changed when the electronic document is finally formed from the initiation request, the invention adopts the following technical scheme:

the method for creating the layout file by the block chain comprises the following steps:

s1, the block chain link point receives a format file generation instruction sent to the block chain link point by the user authorized application end, wherein the format file generation instruction comprises format file content information and setting parameters;

s2, generating an instruction according to the format file by the block link points, and triggering an intelligent contract; the block chain node triggers different creating units in the intelligent contract according to different types of the received format file content information;

s3, the intelligent contract sets the document attribute according to the setting parameter, writes the format file content information into the document with the setting attribute, and generates the format file; the setting of the parameters includes: the layout file's margins, headers, footers, watermarks, page directions, dimensions, titles, document authors, keywords, metadata, document security settings, etc., such as: printing, annotating, signing, and the like; the layout file is a PDF file;

s4, performing Base64 coding on the format file; the format file is difficult to directly store in the block chain account book, so that the coded content is stored in the block chain account book after being coded by Base64, and meanwhile, the encryption effect is achieved, and the ciphertext of the format file is generated;

and S5, encrypting the coded layout file by using a symmetric encryption method and/or an asymmetric encryption method through the block link point, and storing the encrypted layout file. The data is stored in the blockchain node and/or the distributed storage system and/or returned to the application terminal.

Further, the S3 includes the following steps:

s311, calling a creating unit of the intelligent contract by the intelligent contract, and receiving format file content information and setting parameters;

s312, the intelligent contract calls a verification unit of the intelligent contract to verify the legality of the format file content information and the setting parameters;

s313, if the validity check is passed, the intelligent contract calls a setting unit of the intelligent contract, and the attribute of the format file is set according to the setting parameter;

and S314, calling the conversion logic of the intelligent contract, and converting the content information of the layout file into the layout file according to the set attribute.

The existing format file creation mainly aims at the PDF format, and usually needs to convert the format through PDF, and in software, document formats such as WPS, Word, HTML, Text, Image, RTF, XPS and the like are converted into the format file through a streaming file, but are not performed through a block chain intelligent contract.

Further, the blockchain node directly obtains a set of documents, such as: and converting one or more files of doc/docx, xls/xlsx, ppt/pptx, jpg, tif, PDF, gif, png, cad and html through intelligent contracts on the block link points to generate a format file in a PDF format.

Further, the generation of the layout file comprises the following steps:

s321, calling an uploading unit of the intelligent contract by the intelligent contract, and receiving the document, wherein the information of the document is the content of the file subjected to Base64 encoding by an application end;

s322, the intelligent contract calls a verification unit of the intelligent contract, verifies the document coded by the Base64, and verifies the legality of the document information (format, size and the like) by converting the document content into a byte array;

and S323, if the validity check is passed, the intelligent contract calls a conversion unit of the intelligent contract to convert the document content into a format file.

Further, the intelligent contract calls a storage unit of the intelligent contract, Base64 encoding is carried out on the format file, and the encoded format file is written into an account book of the block chain node.

Furthermore, the setting parameters are preset on the block chain nodes by an intelligent contract, and the preset setting parameters are read when the layout file is generated.

Further, in S5, the encoded layout file is divided into data, the size of a single transaction in the blockchain is controlled, the divided subsets are stored in the ledger of the blockchain nodes, and the file itself or the path and/or identifier (such as transaction Hash, file ID) of the stored file is returned to the requesting party. In actual business, a generated file is usually stored, and currently, the mainstream field is to store the file in a traditional server, such as OSS object storage and NAS file storage, and also explore and research an IPFS distributed file system based on a block chain technology, but the file is not directly stored in a block chain; the following problems exist in storing files directly on the blockchain: the block chain is formed by connecting one block and one block, a plurality of transactions are stored in each block, the number of the transactions and/or the size of the blocks are limited when the block chain is configured, and infinite content storage is not allowed, so that the content to be stored can be better stored according to the setting of the blocks by dividing the content to be stored through a certain rule.

Further, the coded layout file is subjected to geometric partitioning, the total size is X units, the geometric partitioning is performed to Y transactions for storage, the size of each transaction for storage is Z units, wherein Y is less than or equal to X, Z = X/Y, when X/Y is not an integer, Z is rounded up, that is, the storage sizes of the 1 st to Y-1 st transactions are Z, and the storage size of the Y th transaction is X-Z (Y-1), for example: and the total size of the file is X =10, and the file needs to be divided into Y =3 transaction storages, so that Z = X/Y =4 (rounding up), the 1 st storage is 4, the second storage is 4, and the third storage is X-Z (Y-1) =2, and the divided subsets are stored in the account book of the block link points.

Further, the layout file content information in S1 is a markup language generated by editing content with a rich text editor provided by SaaS service, for example: code fragments composed of HTML language, XHTML language, and the like.

Apparatus for blockchain creation of layout files for blockchain nodes, the apparatus comprising:

the receiving and sending unit comprises a sending and receiving unit, and the sending unit is used for sending format file generation instructions to the block chain nodes, wherein the format file generation instructions comprise format file content information and setting parameters; the receiving unit is used for receiving the generation instruction of the layout file, and the information of the layout file to be generated comprises one or more of doc/docx, xls/xlsx, ppt/pptx, jpg, tif, pdf, gif, png, cad, html and the like; the information of the layout file to be generated can also be the content combined by non-file lightweight data exchange formats such as JSON, XML and the like;

the processing unit is used for setting the attribute of the document through setting parameters according to the received format file generation instruction, writing the content information of the format file into the attribute-set document and generating a format file;

the encryption unit is used for encrypting the generated layout file, and the encryption processing preferentially adopts Base64 coding to encrypt the layout file; the encryption processing can be further performed by adopting a symmetric and/or asymmetric encryption mode;

and the storage unit is used for storing the coded layout file. The layout file may be stored on the blockchain node; the format file can be stored in a distributed storage system, and the digital abstract of the format file is stored in the account book of the block chain node; the storage unit can also return the format file to an application end requesting transaction, the application end stores the format file for additional storage, and stores the digital abstract and the file storage path of the format file in the account book of the block chain node.

An electronic device for creating a layout file by a blockchain, comprising: a processor, a memory for storing processor-executable instructions; wherein the processor implements the method of the first aspect by executing executable instructions of the method.

A computer readable storage medium having a block chain creating a layout file, having computer instructions stored thereon, wherein the computer instructions, when executed by a processor, implement the steps of the method.

The invention has the advantages and beneficial effects that:

the invention creates the format file through the block chain, expands the creating way for creating the format file such as PDF, performs data leakage prevention processing on the format file through an encryption technology, links the generated file content at the same time, really utilizes the decentralization and tamper resistance of the block chain to protect the content of the format file, and combines the format file creation based on the intelligent contract with the format file link to enable the editable format file based on the block chain to be possible.

Drawings

FIG. 1 is a flow chart of the method of the present invention.

FIG. 2 is a schematic diagram of the apparatus of the present invention.

Detailed Description

The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present invention, are given by way of illustration and explanation only, not limitation.

Blockchains are generally divided into three types: public chain (Public Blockchain), Private chain (Private Blockchain) and alliance chain (Consortium Blockchain). Furthermore, there may be a combination of the above types, such as private chain + federation chain, federation chain + public chain, and so on.

Among them, the most decentralized is the public chain. The public chain is represented by bitcoin and ether house, and participants (also called nodes in the block chain) joining the public chain can read data records on the chain, participate in transactions, compete for accounting rights of new blocks, and the like. Moreover, each node can freely join or leave the network and perform related operations.

Private chains are the opposite, with the network's write rights controlled by an organization or organization and the data read rights specified by the organization. Briefly, a private chain may be a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for use within a particular establishment.

A federation chain is a block chain between a public chain and a private chain, and "partial decentralization" can be achieved. Each node in a federation chain typically has a physical organization or organization corresponding to it; the nodes are authorized to join the network and form a benefit-related alliance, and block chain operation is maintained together.

Based on the basic characteristics of a blockchain, a blockchain is usually composed of several blocks. The time stamps corresponding to the creation time of the block are recorded in the blocks respectively, and all the blocks form a time-ordered data chain according to the time stamps recorded in the blocks strictly.

With the popularization of electronization, taking applications such as electronic contracts, electronic invoices, electronic insurance policies, electronic medical records and the like as examples, more and more information needs to be edited to generate a layout file, wherein the layout file in the PDF format is the most common. However, with the development of digital economy, lawbreakers have privately stored document contents of users and stolen user privacy by using technologies such as big data, artificial intelligence, and the like.

As shown in fig. 1, the present invention provides a method for creating a layout file based on a block chain, which is applied to a block chain node, and enables a user to create a layout file based on a block chain through an application end.

1. Editing document contents through rich texts, such as titles, paragraphs, pictures and other contents;

2. acquiring HTML code segments for editing contents, and initiating a transaction request to the block link points;

3. the block chain node receives the transaction request, triggers the intelligent contract to call the HTML converter, converts the HTML converter into PDF, and comprises the following steps:

(1) initializing a PDF layout file instance;

(2) setting a margin;

(3) adding a new page;

(4) custom examples, including font, color, etc.;

(5) writing the content at the designated location;

(6) saving the electronic document;

4. and encrypting the PDF format file by adopting Base64 coding, and storing the ciphertext coded by the Base64 in an account book of a block chain.

The present invention provides another embodiment, uploading one or more files of doc/docx, xls/xlsxsx, ppt/pptx, jpg, tif, PDF, gif, png, cad, HTML, etc. by an application end, and processing the files through an intelligent contract on the block chain node to generate a format file in PDF format, for example, for an HTML file, including:

(1) creating a new conversion parameter object and instantiating the new conversion parameter object;

(2) creating a font object and instantiating the font object;

(3) setting a font;

(4) reading the content to a character string;

(5) newly building an output stream and instantiating the output stream;

(6) calling an HTML converter to convert into PDF;

(7) and closing.

In general, layout files created by smart contracts are not convenient for direct storage and need to be encrypted using Base64 encoding.

The format file ciphertext coded by the Base64 can be directly compiled into a visual file. Therefore, there is a preferable mode as follows:

and encrypting the layout file by adopting symmetric encryption and/or asymmetric encryption, thereby performing necessary information security protection on the layout file.

As previously described, the resulting layout file needs to be returned to the application for use by the user and/or stored in the blockchain ledger and/or in the distributed storage system.

As described above, when storing the layout file in the blockchain ledger, there is a preferable mode in consideration of the limit of the ledger transaction size, as follows:

and (4) carrying out data segmentation on the format file, and respectively storing the segmented subsets in the account book so as to reduce the size of single transaction in the account book.

In one embodiment, user a needs to sign a purchase contract with user b. For example, if application c provides a text editor based on a block chain, user a directly inputs contract information such as "a purchases 10 computers from b, the total amount is 10 ten thousand yuan RMB", and after user a finishes editing the content, application c initiates a transaction to the block chain, and the block chain creates a layout file through an intelligent contract and returns the content of the layout file encoded by Base64 to application c.

As shown in fig. 2, an apparatus for creating a layout file based on a blockchain, applied to a blockchain node, includes:

the receiving and sending unit is used for sending transaction instructions to the block chain nodes, and the transaction instructions comprise the transaction sent to the block chain nodes; the receiving and sending unit is further configured to receive information of a to-be-generated layout file sent by the application end, where the information of the to-be-generated layout file includes one or more of doc/docx, xls/xlsx, ppt/pptx, jpg, tif, pdf, gif, png, cad, html, and the like; the information of the layout file to be generated can also be the content combined by non-file lightweight data exchange formats such as JSON and XML.

The processing unit is used for generating the format file according to the information of the format file to be generated in the target transaction;

the encryption unit is used for encrypting the generated layout file, and the encryption processing preferentially adopts Base64 coding to encrypt the layout file; the encryption processing can be further performed by adopting a symmetric and/or asymmetric encryption mode;

and the storage unit stores the layout file on the block chain node. The storage unit may further store the format file in a distributed storage system, and store a digital summary of the format file in an account book of the blockchain node; the storage unit can also return the format file to an application end requesting transaction, the application end stores the format file for additional storage, and stores the digital abstract and the file storage path of the format file in the account book of the block chain node.

An electronic device that creates a layout file based on a blockchain, comprising: a processor, a memory for storing processor-executable instructions; wherein the processor implements the method of the first aspect by executing the executable instructions.

A computer-readable storage medium for creating a layout file based on a blockchain, having stored thereon computer instructions which, when executed by a processor, carry out the steps of the method according to the first aspect.

The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:文件校验的方法、装置、电子设备和计算机可读存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!