Blockchain Certification and Granular Editing Permissions in Document
Management System
Filippo Eros Pani
1
, Giacomo Ibba
2
, Michele Marchesi
2
, Andrea Pinna
3
, Simone Porru
1
,
Roberto Tonelli
2
and Bartolomeo Valcalda
1
1
T Bridge S.p.A., Genova, Italy
2
Department of Mathematics and Computer Science, University of Cagliari, Italy
3
Department of Electrical and Electronic Engineering (DIEE), University of Cagliari, Italy
roberto.tonelli@dsf.unica.it
Keywords:
Document Management, Blockchain, Decentralized Applications, Smart Contract, Collaborative Editing.
Abstract:
Ever-growing digitalization and increasingly competitive markets are driving industry and the public sec-
tor into fast-paced transformation. Competitive advantage is being acquired through technology investments
made possible by previously unavailable resources, freed by process automation, simplification, and rational-
ization. Under these contingencies, we propose an innovative document management platform, featuring a
collaborative document editing technique and a blockchain certification procedure. The two proposing parties
- a private company and an academic organization - mutually agreed on employing open-source technologies
as a strategic means to promote software reuse and developer communities’ support, and consequently reduce
implementation costs and ensure interoperability.
1 INTRODUCTION
Ever-growing digitalization and increasingly compet-
itive markets require companies to adapt at a fast pace.
Technology investments ensure a competitive edge,
and such investments are made possible thanks to the
automation, simplification, and rationalization of pro-
cesses which, in turn, unleashes previously unavail-
able resources. The potential market segment ad-
dressed by document management software offers a
plethora of products and services that support com-
munication and interoperability among different sub-
jects. These products and services usually target busi-
ness users, such as institutions and public administra-
tion. Document management solutions can especially
benefit local public authorities. Public organizations,
usually relatively complex, can leverage such solu-
tions to save on storage space, application servers,
back-office maintenance, and front-office extensions
(Pani et al., 2015) On the other hand, managers are
increasingly interested in analysing how information
is managed within companies, since the associated is-
sues are often at the root of inefficiencies. In fact,
information management issues’ resolution sets the
base for a successful strategy. Documents-related
processes (Mahajan and Banerjee, 2018), in particu-
lar, need to undergo significant transformations in or-
der to increase business productivity and process effi-
ciency and, at the same time, reduce operating costs.
The solution proposed in this paper aims to be a cost-
effective solution for business users, in particular by
exposing features dedicated to information flows and
communications support. In the context of a R&D
project, our aim is to offer an innovative software
platform, to be provided as “software-as-a-service”
(SaaS). The creation of electronic documents, com-
munication management, digital signing and stamp-
ing, document recording protocol, and secure trans-
mission, are all features that will be provided by the
document management platform. Multi-channel com-
munication will be ensured by leveraging mail, e-
mail (also certified email), fax, voice, and text mes-
sages. Storage and archiving processes will fulfill lo-
cal regulations (McHenry and Burt, 2018). We pro-
pose an innovative document management platform
featuring a collaborative document editing technique,
The platform is conceived to be remotely available as
a Rich Internet Application (RIA) (Fraternali et al.,
2010). The platform features include an innovative
blockchain based certification procedure. We decided
to use the Aergo blockchain which was released in
2019 to be ”the blockchain for business” and allows
Pani, F., Ibba, G., Marchesi, M., Pinna, A., Porru, S., Tonelli, R. and Valcalda, B.
Blockchain Certification and Granular Editing Permissions in Document Management System.
DOI: 10.5220/0008349902990306
In Proceedings of the 11th International Joint Conference on Knowledge Discovery, Knowledge Engineering and Knowledge Management (IC3K 2019), pages 299-306
ISBN: 978-989-758-382-7
Copyright
c
2019 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved
299
the development of smart contracts.
In the second section of this paper, we present a
background of related works and our development ap-
proach. The third section describes the proposed sys-
tem. In particular, it first presents the key elements of
our solution (the collaborative editing system and the
blockchain document certification) and then discuss
the main features of this two elements focusing on re-
search questions and technological opportunity. Last
section presents the conclusions about the proposed
project.
2 BACKGROUND
A collaborative editing system is essentially system in
which users can contribute concurrently to the same
document in remote. The design of collaborative
editing platforms must take into account and address
the issues and risks related to this specific typology
of system. The research is very much in line with
the development of new technologies, such as the
blockchain. The new proposals of collaborative edit-
ing systems can refer on studies and results that have
been proposed for some decades. The collaborative
writing and related open questions were the subject of
a review of the 2004 (No
¨
el and Robert, 2004). In this
work the collaborative writing activity was framed in
the Computer Supported Cooperative Work (CSCW)
research field (Bannon and Schmidt, 1989).
The development of the system we proposed in
this paper can be framed in the current research on
decentralized collaborative editing platforms. This re-
search focuses on the development of web based ap-
plications in which RIAs are included. In particular,
technologies like cloud computing and decentralized
system allowed the design of new architecture of edit-
ing platform, studied to work also in mobility (Ahmad
and Imine, 2015) (Resmi and Taiani, 2017). New sys-
tems take into account the need for more efficient edit-
ing algorithms, such as the Commutative Replicated
Data Type (Lv et al., 2018).
The blockchain technology for the decentralized
document management is currently the object of in-
vestigation. This technology is suitable for provid-
ing a verifiable and unchangeable time marking to a
document. First studies proposed to implement time
stamping by using the Bitcoin protocol (Gipp et al.,
2015) (Gao and Nobuhara, 2017). Differently, in our
approach we want to exploit the newest generation
of blockchain system, which provides a smart con-
tract environment. The smart contract allows to im-
plement several features, such as the control of ac-
cessing. In the past, we saw the Ethereum network
as the absolute protagonist in this application field
(Nizamuddin et al., 2019). Ethereum was the first
blockchain studied to develop decentralized applica-
tions. Instead of Ethereum we proposed the use of
the Aergo blockchain network, developed in 2019 and
studied explicitly for business applications.
2.1 Development Approach
For the software development activities related to
the project, the lean-based software development ap-
proach proposed in (Leffingwell, 2010) is being em-
ployed. Such approach was selected not only for the
initial implementation, but also for the maintenance
and evolution phase. More specifically, Kanban, a
tool used in lean methodologies, has been used in
maintenance processes (Anderson, 2012). This flexi-
ble approach has several advantages when compared
to older approaches, especially considering its capa-
bility to meet the actual needs of the IT industry.
Being it considerably different from more common
methodologies used within the IT industry, its impact
at the marketing, organizational, and company level
is still to be fully understood. Nevertheless, leverag-
ing the afore-mentioned approach helps a single de-
veloper team in dealing with the management of con-
current projects - a scenario that is neither ideal nor
uncommon.
3 THE SOLUTION PROPOSED
The proposed document management platform is be-
ing devised to be a set of safe and reliable web-based
RIA tools for both individuals and companies, with
the aim of allowing communication with public in-
stitutions, banks, private companies, freelancers, and
other entities. The solution features two main innova-
tive aspects:
a dedicated collaborative document editing tech-
nique;
a document certification procedure based upon the
blockchain technology.
In fig. 1 the main elements of the proposed solu-
tion are represented. The key aspects of the research
relating to the elements of the proposed system will
be described below.
3.1 Collaborative Document Editing
Research has been conducted on the collaborative cre-
ation of complex documents such as:
invitations to tender;
KMIS 2019 - 11th International Conference on Knowledge Management and Information Systems
300
Figure 1: Conceptual diagram of the main elements of the proposed document management platform.
technical projects;
contracts;
commercial offers;
administrative acts.
The platform allows to support users’ real-time inter-
actions during document drafting. In particular, the
platform structuring the document into separate sec-
tions with a specific type of access and editing. Users’
collaboration and interaction is also eased by dedi-
cated auxiliary features, such as the ability to high-
light the text of each author with a different colour, or
the real-time chat window. The general objectives are
as follows:
simplify and make the preparation of a complex
document more efficient, even in case of multi-
organization editing;
ease management and control of the drafting of a
document while maintaining granular responsibil-
ity levels;
create links and interactions between the docu-
ment and the organization’s processes;
simplify and make document signing processes
more user-friendly;
uncouple, as far as possible, the semantic value
of the information from its representation, and the
medium where it is presented.
As regard the non-functional requirements of the
document platform, each application component, in
addition to ensuring an optimal user experience, must
be available to organizations both on-premise and in
the cloud; among other advantages, this would allow
to maintain direct control of the data that are most
critical. The platform design requires the implemen-
tation of the ECM Enterprise through the CMIS stan-
dard (OASIS Standard, 2015). This will make it pos-
sible to replace the ECM component at any time with-
out any modification to the general architecture. The
interfaces of the various application components en-
sure a modern user experience in order to facilitate
users in completing their tasks. On the other hand, as
for the functional requirements, an innovative feature
is the possibility to structure a document into separate
sections with specific user access and editing permis-
sions, as mentioned before. A user with specific per-
missions must be able to create a new document by
defining its descriptive metadata. Then, the system
automatically assign the role of document responsi-
ble. The user responsible for the document must be
able to define the structure of the document by creat-
ing appropriate independent sections. When first con-
figuring a section, it is possible to associate to the sec-
tion the responsible person, by selecting them from
the users’ system database. The section responsible
can also define the team of users that are involved in
the creation of that specific section. When multiple
users access the section’s editing tools, their presence
and actions are visible to all the other authors, ensur-
ing real-time collaboration editing. The editorial pro-
cess of a section comprises the following steps:
opening of the editing phase;
collaborative editing by users with permission on
the specific section;
request for approval of the product content at any
time;
approval of the changes by the section manager.
Regarding the versioning, each single version created
must be stored in the system’s database and made
accessible to the users. Metadata such as creation
time and date, contributors, as well as the content of
each single version, must be recorded. Each version
must be automatically and sequentially numbered,
and must indicate if it was approved by the section’s
responsible during the approval process. Moreover,
the platform must provide the section’s editors a ded-
icated communication environment for that specific
section. This communication channel must allow to
view all messages sent by the users, and possibly fore-
see the exchange of private messages. The same com-
munication channel must be used by the system to
Blockchain Certification and Granular Editing Permissions in Document Management System
301
provide automatic notifications about the main events
related to the section itself.
3.2 Blockchain Document Certification
Another research activity concerned making the doc-
ument’s main responsible capable of ensuring docu-
ment immutability through blockchain document cer-
tification. To this purpose, the system allows to
publish the document on a blockchain by simply
initiating the blockchain publication process on the
page dedicated to the relevant document’s version.
Once the document is successfully published on the
blockchain, and the mining activities are completed,
the system will allow to visualize the publication
time and date, the transaction ID, and the number of
blockchain confirmations.
3.2.1 Blockchain for Document Management:
An Overview
The use of blockchain technology in document man-
agement presents various advantages coming from
the intrinsic properties of the technology itself, like
documents unalterably, simplification of internal pro-
cesses, managing information confidentiality, cryp-
tography and private key management for accessing
the system. A blockchain is a growing list of records,
called blocks, which are sequentially linked using
cryptography. Each block contains a cryptographic
hash of the previous block, a timestamp, and transac-
tion data. By design, a blockchain is proof tamper to
data modification, indeed is defined as an open, dis-
tributed ledger that can record transactions between
two parties efficiently and in a verifiable and perma-
nent way”(Nakamoto et al., 2008).
Currently, several business enterprises propose
blockchain based solutions in field of document man-
agement. Among these we mention Blocko (https:
//www.blocko.io/platform.html), Storj Labs (https://
storj.io/) and Cryptyk (https://www.cryptyk.io/), three
companies which are trying with their blockchain and
smart contract based solutions to revolutionize the ref-
erence market by proposing more efficient and sus-
tainable solutions(Salmer
´
on-Manzano and Manzano-
Agugliaro, 2019). Fields of application includes:
Distributed Document Management: A docu-
ment is stored on multiple machines perfectly syn-
chronized to work at a specific document at the
same time.
Security: A document can be encrypted so that
the owner of the encryption itself, is the only one
to be able to access to that document.
Multisignature: A document can be owned by a
set of predefined owners who can act upon only
if all the owners or a predefined fraction of them
agree.
Traceability: Could be useful on food industry to
keeping track of the origin and the freshness of a
product and keeping information about transport.
Certification: Blockchain could be useful to
demonstrate authenticity and ownership of a doc-
ument.
Recognition: Blockchain is becoming popular on
the management of documents which allow iden-
tification such as identity cards and passports, so,
because of this, the blockchain could be used to
simplify task as boarding and landing of passen-
gers.
Timestamping: Associating a timestamp to a
document establishes a legally valid date and time
to that document.
The role of the blockchain technology and especially
that of smart contracts is continuously emerging to
support new features of software systems. Many stan-
dard features of software systems can be implemented
within the blockchain which plays the role of decen-
tralized services (also called blockchain as a service
- BaaS)(Daniel and Guida, 2019) or microservices
(Tonelli et al., 2019).
3.3 Document management with Aergo
Aergo (AERGO, 2019) is a blockchain project for
business applications recently launched by the com-
pany Blocko. The first version of the platform was
released on 9 April 2019. Aergo (AERGO, 2019) is
a hybrid blockchain which tries to gather the advan-
tages of private and public blockchains. It is Proof of
Stake (Bitcoinwiki, 2019) based, so every user must
prove that he owns a certain amount of tokens.
Another interesting feature of Aergo is that it uses a
particular protocol of interoperability called Merkle
Bridge to allow more chains to communicate with
each other. Furthermore it implements the possibility
of Merkle proofs usage to create a communication be-
tween Ethereum and Aergo to demonstrate and certifi-
cate the existence of something in another blockchain.
Merkle bridge could be seen as a multi-signature con-
tract which signs the state of the root of a sidechain in-
stead of signing individual transactions, like in other
blockchain implementations. Aergo allows to inter-
act with the blockchain with different programming
languages, in particular Java, Javascript and Python.
For Java there is Heraj, for Javascript Herajs, and the
KMIS 2019 - 11th International Conference on Knowledge Management and Information Systems
302
Python library is called Herapy (AERGO contribu-
tors, 2019) .
We first analyze Heraj which provides fea-
tures and functionality to interact with the Aergo
blockchain and with the development and the execu-
tion of smart contracts. Next we will have a look at
how Heraj could be used to deploy a Lua smart con-
tract.
Aergo Smart Contracts. Aergo allows to develop
and run smart contracts using LUA language and
Athena-Ide, which is an extension of the Atom
text editor. In addition Aergo provides a testnet
blockchain in which it is possible to run and test de-
centralized applications without spending real Aergo.
By following the instructions given by the company
available at (AERGO team, 2019) everyone can ob-
tain an Aergo wallet and an Aergo account. Aergo
provides Aergo Connect, which is a blockchain bridge
that allows to connect to the Aergo blockchain with-
out installing a blockchain node. It is very similar to
the more famous Ethereum’s metamask. Thanks to
Aergo Connect it is possible to chose to work in the
Aergo main net or in the testnet. We worked using
the Aergo test net because it is free. Aergo provides
a tool to require tokens spendable only on the testnet.
This tool provides an amount of ve AERGO, which
is more than necessary to build up our smart contract.
Aergo use a particular set up for Lua language, in-
deed the use of some default libraries like the ”os”
one is not allowed for security purposes, and it pro-
vides a type Map which is not of the original Lua.
This type, is like a Java Hash-Map but keys are al-
lowed to be only strings, while values are allowed to
be of any type.Inside the state.var scope we define
our global variables, and inside the constructor() we
set up variables.
As represented in Fig 2, on the left panel we can
notice the Athena-Ide interface, which is very simi-
lar to Remix environment for Solidity smart contracts
development. Indeed, we can see that is possible to
import an Aergo account, compile contracts and make
the contract deploy to append it on Aergo blockchain;
also, is possible to select if we want to work locally,
on test net or on main net.
3.4 The Document Timestamping
We now describe the implementation of a blockchain
based system for document timestamping we devel-
oped during the Document management project.
Given a document, we want to use the blockchain
to associate a timestamp to this document exploiting
the Aergo blockchain. The timestamp must be im-
mutable, so once the document is timestamped, it can
not be timestamped again.
In the following we describe functions and vari-
ables defined in the implementation. In the Appendix
of this paper we we provide the complete source code
of our smart contract.
Global Variables. We used two global variables,
document prove and document id. document prove
is a Map type, and it stores the document id and the
associate timestamp. document id is an integer which
represents the document id.
Function set time. This functions should work
only if the one to call them is the owner of the con-
tract. Thanks to the ”system” library provided by
Aergo, we can call functions like getCreator() and
getSender() which allows us to make those types of
controls; so, if the contract is called by the owner we
can set a new document id.
As before, we check that owner and sender coincide,
and so if this is the case, we check that for a particular
document id a timestamp has not been associated yet;
if this is the case, then we associate a timestamp to
that document else we return an alert message.
Function get timestamp of a document. As ever
we check that the one which is calling the function is
the owner of the contract. If the owner is calling the
function then the associated timestamp to the docu-
ment id given in input will be returned. Else, if the
function is not called by the owner, an alert message
will be printed.
3.5 System Integration
As we said previously, Aergo provides SDK to inter-
act with the blockchain. Heraj is the library provided
by Aergo for Java language; this library allows to in-
terface Java with Aergo blockchain. This type of in-
teraction with Java and Aergo allows the development
of decentralized applications (dAPPs). Heraj makes
the development and the execution of smart contracts
very simple and efficient. To use the library, we can
take the advantages provided by tools such as Gradle
(https://gradle.org/) or Maven (https://maven.apache.
org/). In the collaborative document management sys-
tem, the platform ALFRESCO is modified to include
the Heraj library. This allows the interfacing of the
software with the Aergo blockchain in order to use
the smart contracts deployed in it such as the times-
tamping one. To given an example, when we want
to modify a document, ALFRESCO could execute a
Blockchain Certification and Granular Editing Permissions in Document Management System
303
Figure 2: The AERGO development platform for smart contracts.
smart contract using Heraj library and then, the con-
tract associate the block timestamp to the document
id to provide an incontrovertible date of the last doc-
ument changes.
By using Heraj it is possible to interact and even
to deploy a smart contract in the Aergo blockchain di-
rectly from the Java application. To connect the Heraj
library to our Aergo account we need all of our cre-
dentials (in particular we need our private key and our
decryption account) and we need an Aergo client in-
stalled.
4 CONCLUSION
In this work, we propose an innovative document
management solution built by using development
tools backed by large developer communities, with
the aim of ensuring the availability of adequate sup-
port during development. The architectural design
is being developed as a modular solution, due to the
need for integrating additional modular, interoperable
components, and built with open standards to make
the system flexible. The prototype will try to effec-
tively tackle the complexities stemming from the in-
teraction of separate, interdependent processes. Spe-
cific services will have to work together with the pro-
posed solution, thus requiring to devise a proper in-
frastructure to meet users’ requirements as seamlessly
as possible. The system will ensure effective integra-
tion, and employ a cloud computing system (Lewis,
2012) (Rehman, 2018). The involved parties will ac-
quire new valuable knowledge on document manage-
ment, thanks to the cooperation network which will
stem from the development activities. The very na-
ture of the project itself is bound to ensure knowl-
edge sharing: being open-source, the project pro-
motes the intervention of external contributors, espe-
cially from individuals and organizations directly in-
terested in tackling their own business challenges with
the proposed solution. Among the innovative features
of the proposed document management solution, are
i) the possibility to assign specific access permissions
to each document section, and ii) document certifica-
tion based on blockchain technology.
ACKNOWLEDGEMENTS
The work presented in this paper has been par-
tially funded by Regione Autonoma della Sardegna,
under projects “Gestione Documentale” - Progetto
PIA, Annualit
`
a 2013”, “Crypto-Trading” - Program-
mazione unitaria 2014-2020 POR FESR Sardegna
2014 - 2020, “Easy Wallet” - Programmazione uni-
taria 2014-2020 POR FESR Sardegna 2014 - 2020,
“SardCoin SardCoin: tecnologie blockchain a sup-
porto del turismo in Sardegna” - TOP-DOWN POR
FESR sardegna 2014 2020 Asse prioritario 1, and
“CAFCha - Certification of AgriFood Chain”- POR
FESR Sardegna 2014 – 2020 Asse 1.
The authors would like to thank Prof. Giovanni
Michele Pinna and Prof. Fabio Zuddas from Depart-
ment of Mathematics and Computer Science, Univer-
sity of Cagliari, Italy, and Prof. Alessandro Spano
from Dipartimento di Scienze Economiche ed Azien-
dali, University of Cagliari, Italy, for their helpful
comments and suggestions.
REFERENCES
AERGO (2019). Aergo the blockchain for business. https:
//www.aergo.io/.
AERGO contributors (2019). Aergo project repository.
https://github.com/aergoio.
KMIS 2019 - 11th International Conference on Knowledge Management and Information Systems
304
AERGO team (2019). Aergo project documentation. https:
//docs.aergo.io.
Ahmad, M. and Imine, A. (2015). Decentralized collabora-
tive editing platform. In 2015 16th IEEE International
Conference on Mobile Data Management, volume 1,
pages 323–326.
Anderson, D. J. (2012). Lessons in agile management: on
the road to Kanban. Blue Hole Press.
Bannon, L. J. and Schmidt, K. (1989). Cscw: Four char-
acters in search of a context. In ECSCW 1989: Pro-
ceedings of the First European Conference on Com-
puter Supported Cooperative Work. Computer Sci-
ences Company, London.
Bitcoinwiki (2019). Proof-of-stake. https://en.bitcoinwiki.
org/wiki/Proof-of-stake.
Daniel, F. and Guida, L. (2019). A service-oriented per-
spective on blockchain smart contracts. IEEE Internet
Computing, 23(1):46–53.
Fraternali, P., Rossi, G., and S
´
anchez-Figueroa, F. (2010).
Rich internet applications. IEEE Internet Computing,
14(3):9–12.
Gao, Y. and Nobuhara, H. (2017). A decentralized trusted
timestamping based on blockchains. IEEJ Journal of
Industry Applications, 6(4):252–257.
Gipp, B., Meuschke, N., and Gernandt, A. (2015). De-
centralized trusted timestamping using the crypto cur-
rency bitcoin. arXiv preprint arXiv:1502.04015.
Leffingwell, D. (2010). Agile software requirements: lean
requirements practices for teams, programs, and the
enterprise. Addison-Wesley Professional.
Lewis, G. (2012). The role of standards in cloud-computing
interoperability. software engineering institute.
Lv, X., He, F., Cai, W., and Cheng, Y. (2018). Supporting
selective undo of string-wise operations for collabo-
rative editing systems. Future Generation Computer
Systems, 82:41 – 62.
Mahajan, K. and Banerjee, P. (2018). A review study on
document management system. Computer Software
and Media Applications.
McHenry, C. A. and Burt, S. W. (2018). Electronic docu-
ment classification. US Patent 9,928,244.
Nakamoto, S. et al. (2008). Bitcoin: A peer-to-peer elec-
tronic cash system.
Nizamuddin, N., Salah, K., Azad, M. A., Arshad, J., and
Rehman, M. (2019). Decentralized document version
control using ethereum blockchain and ipfs. Comput-
ers & Electrical Engineering, 76:183 – 197.
No
¨
el, S. and Robert, J.-M. (2004). Empirical study on
collaborative writing: What do co-authors do, use,
and like? Computer Supported Cooperative Work
(CSCW), 13(1):63–89.
OASIS Standard (2015). Content management interop-
erability services (cmis). http://docs.oasis-open.org/
cmis/CMIS/v1.1/CMIS-v1.1.html.
Pani, F. E., Porru, S., and Ibba, S. (2015). A model for dig-
ital content management. In Proceedings of 4th Inter-
national Conference on Data Management Technolo-
gies and Applications, pages 240–247. SCITEPRESS-
Science and Technology Publications, Lda.
Rehman, T. (2018). Cloud Computing Basics. Stylus Pub-
lishing, LLC.
Resmi, A. C. and Taiani, F. (2017). Filament: A cohort con-
struction service for decentralized collaborative edit-
ing platforms. In IFIP International Conference on
Distributed Applications and Interoperable Systems,
pages 146–160. Springer.
Salmer
´
on-Manzano, E. and Manzano-Agugliaro, F. (2019).
The role of smart contracts in sustainability: World-
wide research trends. Sustainability, 11(11).
Tonelli, R., Lunesu, M. I., Pinna, A., Taibi, D., and March-
esi, M. (2019). Implementing a microservices system
with blockchain smart contracts. In 2019 IEEE Inter-
national Workshop on Blockchain Oriented Software
Engineering (IWBOSE), pages 22–31. IEEE.
Blockchain Certification and Granular Editing Permissions in Document Management System
305
APPENDIX
In this appendix we present the AERGO smart con-
tract source code written in LUA language for docu-
ment time stamping.
1
2 --Defining global variables
3 state.var
4 {
5 --Id of the document and map to
associat timestamp to document
6
7 document_id = state.value(),
8 document_prove = state.map()
9
10 }
11
12 function constructor()
13 --Setting up the constructor
14 --Currently the id 0 is reserved
15 document_id:set(0)
16 document_prove[tostring(document_id)] =
"RESERVED"
17 end
18
19 function change_id(id)
20 --getting owner and sender
21 owner = system.getCreator()
22 sender = system.getSender()
23 --This function is callable only by
the owner of the contract
24 if(owner == sender)
25 then
26 --Changing document
27 document_id:set(id)
28 else
29 system.print("YOU'RE NOT THE OWNER YOU
CAN'T ASSOCIATE TIMESTAMP TO DOCUMENT")
30 end
31 end
32
33 --Function to associate timestamp to a
document
34 function set_time()
35
36 owner = system.getCreator()
37 sender = system.getSender()
38
39 --Same as the previous function. Is
callable only by owner
40 if(owner == sender)
41 then
42 --If document has been already
timestamped is not modifiable
anymore
43 if(document_prove[tostring(document_id)]
== nil)
44 then
45 --Associating timestamp to
document
46 document_prove[tostring(document_id)]
47 = system.getTimestamp()
48 else
49 system.print("ALERT!!! DOCUMENT ALREADY
TIMESTAMPED. YOU CAN'T MODIFY IT")
50 end
51 else
52 system.print("YOU'RE NOT THE OWNER YOU
CAN'T ASSOCIATE TIMESTAMP TO DOCUMENT")
53 end
54 end
55
56 --Function to get timestamp of document
57 function get_timestamp_of_document(id)
58 --Callable only by owner
59 owner = system.getCreator()
60 sender = system.getSender()
61 if(owner == sender)
62 then
63 --Return the timestamp associated to
that document
64 return document_prove[tostring(id)]
65 else
66 system.print("YOU'RE NOT THE OWNER YOU
CAN'T ASSOCIATE TIMESTAMP TO
DOCUMENT")
67 end
68 end
69
70
71 --Setting on the Abi viewable functions
72 abi.register(set_time,change_id,
get_timestamp_of_document)
KMIS 2019 - 11th International Conference on Knowledge Management and Information Systems
306