key: cord-0476138-z5fh9uob authors: Zhao, Lianna; Ferraro, Pietro; Shorten, Robert title: A DLT enabled smart mask system to enable social compliance date: 2022-05-26 journal: nan DOI: nan sha: 3ef70a32d97e67bbfca44843a9df9fbd89314e4d doc_id: 476138 cord_uid: z5fh9uob As Covid-19 remains a cause of concern, especially due to its mutations, wearing masks correctly and efficiently remains a priority in order to limit the spread of the disease. In this paper we present a wearable smart-mask prototype using concepts from Internet of Things, Control Theory and Distributed Ledger Technologies. Its purpose is to encourage people to comply with social distancing norms, through the use of incentives. The smart mask is designed to monitor Carbon Dioxide and Total Volatile Organic Compounds concentrations. The detected data is appended to a DAG-based DLT, named the IOTA Tangle. The IOTA Tangle ensures that the data is secure and immutable and acts as a communication backbone for the incentive mechanism. A hardware-in-the-loop simulation, based on indoor positioning, is developed to validate the effectiveness of the designed prototype. Due to the emergence of Covid-19 and its mutations, it is reasonable to expect that masks and social distancing norms will still play a significant role in many societies across the globe. According to European Centre for Disease Prevention and Control, from 31 December 2019 to 17 March 2022, 458 179 120 cases of Covid-19 (in accordance with the applied case definitions and testing strategies in the affected countries) have been reported, including 6 058 022 deaths. If not properly controlled, the virus might once again spread across the population, leading to high mortality rates and hospitalizations, even with possible sequelae 1 . Even as the amount of infected people abates in some areas, the need to wear face-masks remains in many aspects of daily life, for example, in passenger planes, buses and trains. In such situations, enforcement of mask wearing is the responsibility of observers, such as flight attendants, rather than the mask wearer. Often, this leads to situations where either compliance is not enforced, or where an unreasonable burden is placed on these observers. In this paper we explore ways to encourage people to wear masks properly, especially in confined and crowded spaces, such as supermarkets, tubes and airplanes. Importantly, we wish to design mechanisms where compliance with mask wearing remains with the mask wearer -rather than with observers. To do this we build on our previous work done in [1] . Here the authors discuss a general framework, based on control theory, with the aim of regulating compliance to social contracts 2 in the sharing economy domain. The objective of this paper is to present a Proof-of-Concept (PoC) of a smart mask prototype that can detect people's mask-wearing status, and then incentivise people's behaviour with a token-bond mechanism to wear masks efficiently in confined and crowded spaces. By wearing masks correctly, we mean that people use mask to cover both their mouth and nose at the same time as shown in Figure 1 (a), while Figure 1 (b) and (c) are illustrations of not proper mask wearing. While there are some algorithms that address the compliance issue, such as game theoretic framework ( trying to design an equilibrium which encourages people's good behaviour), there are still some limitations within these works, for example, they are centralised; they are vulnerable to resource-rich attackers; they are often not anonymous because of unencrypted user address; fairness is not preserved as they are not tailored according to the individual situation. Our work also builds on the idea of a personalised dynamic pricing strategy. For completeness, we note that there are many paper on this topic; for example -see [2] - [4] . Specifically, our work is based on [1] , which differs from the works mentioned above along various dimensions. In [1] , the authors propose a personalised feedback control based on distributed ledger technology (DLT) system to enforce people's compliance and furthermore provide a theoretical analysis on the designed system's convergence. Here, DLT structure provides a more secure and privacypreserving structure than its centralised alternatives, to create a personalised economic commitment algorithm and then to enforce compliance. For the convenience of further discussing, we refer to the designed algorithm in [1] as Personalised Feedback Control Algorithm (PFCA). The idea of incentives is also being explored in the circular economy and this concept has already been explored in various applications (although, not in a theoretical manner), such as Kupcrush. Kupcrush uses DLTs to make cups into their own economic agents through the use of Digital Twins. Each cup is associated with a digital identity and a wallet and their aim is to incentivise the consumer who is using the cup to recycle it correctly by 'rewarding every actor in the circular economy with a micro-reward as the cup moves through the recycling chain until it is ultimately recycled into a new cup' 3 . In this paper, we are proposing a variation on the same idea. We present a smart mask, in which we make use of a DLT structure to design a compliance strategy and enforce social contracts. Our proposal is to use digital tokens as a bond to encourage people's compliance: if people remain in compliance, they will get tokens back to their account [5] - [7] , otherwise they will lose it. Accordingly, the main contributions of this paper are: • A smart mask with sensors is designed to detect people's mask wearing status. The recorded data is used to encourage compliance through a bond-deposit scheme implemented on the IOTA Tangle. • A prototype based on a Raspberry Pi 3B [8] , [9] hardware platform is presented. • A hardware-in-the-loop simulation, based on indoor positioning, with ultra-wide band (UWB) is designed to validate the effectiveness of the proposed algorithm and the mask design. The remainder of this paper is organised as follows: In Section II, we give a brief description of DLT and provide a brief summary of the personalised feedback control Algorithm (PFCA) [1] . In Section III, the mask design is introduced and the procedure of data analysis is described briefly. In Section IV we illustrate the efficacy of proposed approach through hardware-in-the-loop simulation based on indoor positioning. Finally, in section V, we summarise the presented results and discuss future lines of research. In essence, DLT refers to digital ledgers shared across multiple nodes in a peer-to-peer network [10] . It has recently gained popularity in both industry and academic communities; for example, in smart cities [6] , supply chain and health-care. DLTs hold great potential in these sectors because of their desirable properties, such as decentralization, immutability, consistency, and transparency. Although blockchain provides a decentralized architecture to overcome the shortcomings of the centralized architecture, several limitations in blockchain hinder its widespread application. For example, the inherent sequential structure in blockchain to add new transactions gives rise to its low scalability and the heavy cryptography Proof-of-Work (PoW) consensus leads to expensive computation power expenses and high transaction fees. As an alternative, the IOTA DLT, whose structure is Directed Acyclic Graph, is proposed in [11] [12] . Instead of using a chain, every new incoming transaction can freely reference existing transactions in a graph structure, without being subject to the restrictions as imposed by the blockchain. This means many transactions are verified in a parallel fashion. Every new transaction must approve two previous transactions. In the IOTA Tangle, there is no Proof-of-work and no transaction fees required. This later feature makes the IOTA DLT attractive for appliance applications. Our work builds on [1] . The main idea in [1] is to use digital tokens to encourage people to comply with a social contract. By social contract, we mean a set of guidelines that must be followed to ensure the proper utilization of a resource or object. For example, the agreement of wearing a mask correctly, in the context of Covid-19, is a social contract. The basic idea is that agents deposit tokens as a bond when they put on a mask, in areas where it is expected for them to wear one (e.g., an airplane). These tokens are then returned in full if the person does not remove the mask. A pricing algorithm is used to determine the number of tokens that are deposited (based on the level of previous compliance). The architecture for realising this system in [1] is depicted in Figure 2 . The algorithm in [1] is organized around three functional components: the distributed ledger is used as a communication layer (i.e., to record the deposit and the withdrawal of the tokens); the physical layer represents the agents interaction in engaging with the social contract; the controller is used to adjust the amount of tokens deposited and achieve expected compliance level. By adopting smart contracts, the whole process including deposit and return of the tokens can be automatically operated. All operations are recorded on a DLT which is immutable and data are shared anonymously among agents (since, each agent's identity is represented by an encrypted address). There are four policies that could be adopted in this context: • Fixed penalty policy: Before participating in the social scheme each agent deposits a certain amount of tokens, the amount being set by the controller. When the action is completed or when the agent exits the scheme, all tokens are returned in the event that they complied with rule E; otherwise no tokens are returned to the agent. In the latter case the pricing algorithm continues to adjust the price based on both the agents' level of compliance and that of the network. • Adaptive penalty policies: Initially each agent deposits a certain amount of tokens, the amount being set by the controller. The contract is reissued at every time-step. At each time step, compliant agents retrieve their tokens, and stake new ones to continue the activity. Distributed Ledger Compliance Policy Non-compliant agents lose all their tokens every time they do not comply. At all time steps, the pricing algorithm continues to adjust the price based on both the agents' level of compliance and that of the network. • Adaptive penalty policies with return: Initially each agent deposits a certain amount of tokens, the amount being set by the controller. The contract is reissued at every time-step. At each time step, compliant agents retrieve their tokens, and stake new ones to continue the activity. Non-compliant agents lose all their tokens every time they do not comply. If an agent that previously lost a token starts complying again, they will retrieve a portion of the lost tokens. At all time steps, the pricing algorithm continues to adjust the price based on both the agents' level of compliance and that of the network. • Event driven policies: Initially each agent deposits a certain amount of tokens. Whenever the agent fails to comply with rule E the tokens are lost; in order to keep participating in the scheme the agent needs to deposit more tokens. In this version of the scheme the amount of tokens that are required varies as a bond changes value over time (again a smart contract can easily take care of the update process). A feedback mechanism for designing a proper value of the bond can be constructed as follows. For each agent i, we define a binary random variable for discrete values k as: Moreover, we assume that the probability of these events is entirely dependant on a constant q i , which represents the proclivity of each agent to comply with rules, and two control variables, C(k), c i (k). The variable C(k) + c i (k) represents the value of the token bond staked by agent i at time-step k. The combination q i + C(k) + c i (k) determines the likelihood that agent i will comply with the rule at time-step k +1. Then, (6) can be expressed as ¶(M i (k + 1) = 1) = p (q i + C(k) + c i (k)) with p : R −→ [0, 1] being a monotone increasing function (which is used to bind the probability between 0 and 1). C(k) and c i (k) represent, respectively, a global and an individual feedback signal whose purpose is to regulate the behaviour of each agent so as to achieve the desired level of compliance. Accordingly, we consider the following control laws, ∀k ∈ N and ∀i ∈ {1, . . . , n}: where α > 0 and β > 0 are two constants, ∀k ∈ N and ∀i ∈ {1, . . . , n}, Q * ∈ [0, 1] is the desired level of compliance,and M i (k) is a windowed time average of the compliance of agent i, which is defined as where (1 − γ) −1 is the length of the window for the average, with γ < 1. Intuitively, this means that the value of the bond staked by agent i depends on the overall compliance of all agents and on how agent i behaved in the past. The use of both a global and an individual control signal brings several advantages, such as Fairness, Distributed trading of compliance levels and resiliency from Pricing attacks. The interested reader can refer to [1] . Given the general background described above, we consider scenarios where agents move within a confined and/or crowded space where the use of mask and social distancing norms is mandatory, such as buses, the tube or airplanes. The following steps are performed to encourage social compliance and the structure of the network is depicted in Figure 3 . • When an agent wants to go into confined or crowded space, he must use a disposable mask with detachable integrated chip 4 connected to his phone or computer. This chip is connected to the customer's wallet. • Each mask has a unique identifier, a detachable sensor and is connected to a Raspberry Pi which acts as the main computing unit (in a more realistic setting, the role of the Raspberry Pi would be carried out by other smaller computing units). • Immediately after an agent enters a confined or crowded space, he has to deposit a stake a certain amount of tokens (determined by the PFCA), through a smart contract (this might be based on the past level of compliance of the agent and on the current average level of compliance ). • The sensor chip monitors equivalent calculated Carbon-dioxide (eCO2) and Total Volatile Organic Compounds (TVOC), whereas the Raspberry Pi performs computations and uploads data to the IOTA Tangle in real time. • If the customer wore the mask properly, they might either receive a portion of their tokens back or, depending on the specific policy employed (as mentioned in Section II.A), they have to stake more tokens and the process is repeated until they leave the confined or crowded space. We now provide a brief description about the hardware and software used for the smart mask prototype: • The Firefly Wallet 5 is used as the customer's account and the tool to interact with the IOTA Tangle. • A Raspberry Pi is used as the main board to collect sensor data and act as a node to send and publish data to IOTA Tangle. Remark: As this is a PoC, we use a Raspberry Pi as part of the prototype mainly for convenience. In an actual implementation, one would use a small chip integrated into the mask for detecting data (to be mounted on the mask) and another computing units (such as a phone, a computer, etc.) for collecting and analysing data. The network flow to upload data to the IOTA Tangle is depicted in Figure 4 . The data is collected from the CJMCU-811 sensor which is connected to the Raspberry Pi 3B. As the most common communication protocol in IoT systems, a lightweight open source Message Queuing Telemetry Transport (MQTT) [13] , [14] is adopted to transfer data in the network. MQTT works in a publish and subscribe model, in which some devices publish messages on a topic, while some devices which have subscribed to this topic receive this message. After the Raspberry Pi gathers eCo2 and TVOC data from the sensor, it publishes these data to a specific topic 6 [15] . The module depicted in Figure 4 named Node.js is set as the back-end server to subscribe to this specific topic and publish contained data in this topic to the IOTA Tangle though a lightweight data transmission protocol -Masked Authenticated Messaging (MAM) [16] , [17] . The MAM is an important method for securing the transfer or access of the data stored in the IOTA Tangle. Nodes or devices, which are connected to the IOTA Tangle acting as publishers, broadcast their encrypted messages into Fig. 4 . Implementation Architecture a specified channel, while nodes which are interested in receiving the published messages can subscribe to the same channel [16] . There are three modes within MAM, including Public mode, Private mode, Restricted mode. For public MAM mode, it employs the address of transaction which is same as Merkle Tree's root [18] . For private MAM mode, it employs the addresses of transactions which is gained by hashing the root of the Merkle Tree, which means the message can be known only if the root of the Merkle Tree is obtained. For restricted MAM mode, it employs the address of transaction which is obtained by the hash of the root of the Merkle tree and a side key, which means the message can be known only if both the key and the root are known [19] . To showcase the functioning of the mask prototype we set up a hardware-in-the-loop kind of simulation based on the structure depicted in Figure 5 . The simulation is divided into the following components: • Agent-based Simulator: an agent-based simulation is employed to mimic the presence of multiple agent within a room. Each agent behaves according to the equations described in Section II. • Smark mask prototype: a user wears the mask prototype and its position and mask wearing status are respectively recorded to the IOTA Tangle and sent to the agent-based Simulator in real time, as if the user was one of the agents of the simulations. In what follows, we provide a detailed description of each component used to perform this simulation. To illustrate the effectiveness of wearing masks in confined and crowded spaces, we perform simulations in a similar way to the ones in [1] . We make use of an agent-based model to simulate the spread of covid-19 within a confined space. In this experiment, we assume the number of agents is 500 and the age of these people is following a normal distribution 7 . Whenever agent i gets in close range with agent j, i.e. when ||x i − x j || 2 ≤ , there is a positive chance that agent i might get infected (given that agent j is positive). This chance is defined as where the base infection rate is denoted by P 0 (the chance of getting infected with no social distancing and mask wearing), m i ∈ [0, 1] is the effectiveness of the mask worn by agent i and M i (k) ∈ {0, 1} is a binary random variable that indicates whether agent i is wearing a mask at time k. Simulations show the following results: 7 https://www.trustforlondon.org.uk/data/population-age-groups/ • When no masks are worn the infection rate increases very quickly. As shown in Figure 6 (a), we set up the model with a single infected individual, marked as the red dot. As depicted in Figures 6(b) -6(h) virus spreads very quickly: at time 30, depicted in Figure 6 (e), nearly half people get infected and nearly all agents get infected at time 55 as depicted in Figure 6 (h). • When people, including healthy people and infected people wear masks effectively, the infection rate and serious infection rate increases at a slower rate. As depicted in Figure 7 (a), when 20%-30% people wear masks, the proportion of infected people is almost 100% around 50 seconds; As depicted in Figure 7 (b), when 30%-40% people wearing masks, the maximum percentage people get infected is also around 60%; While as depicted in 7(c), when 50%-60% people are wearing masks, the maximum percentage of infected people is only around 10% at time 50. Finally, Figure ? ? shows that the amount of infected people is even lower if 70%-80% people are wearing masks. These simulations show, qualitatively, that high levels of compliance with social distancing norms lead to lower infection rates overall. This is the rationale behind the employment of the control laws described in Section II. In, fact as depicted in Figure 9 , with PFCA including both a global and an individual cost signal, the desired level of compliance is achieved and the fairness of cost among all individuals is also ensured (as each individual will comply equally, regarding of their initial proclivity q i ). We want to emphasize that, the agent model used in this paper does not intend to be a realistic simulation of the dynamics of how Covid-19 spreads across a given population. Rather it is intended as a toy model, to showcase how the control algorithm and the smart mask would work in a similar scenario. In the previous section, we showed that with the proposed control strategy, the desired compliance is achieved and the probability of people getting infected is reduced. In order to show the way the mask would implement this control strategy we consider a hardware-in-the-loop simulation based on indoor positioning. As shown in Figure 5 , the hardware-in-the-loop simulation is used for monitoring smart mask wearing position and status for real agent. The position and the status of the mask are sent both to the IOTA Tangle and the python simulation in which a number of virtual agents are simulated. Furthermore, the mask status from the simulated agents are appended on the IOTA Tangle, from which are read by the FPCA to generate the cost signals. To detect the smart mask position we make use of indoor positioning. Although there are multiple viable methods, such as Bluetooth, WiFi (Wireless local area network ) [20] , BLE (Bluetooth low energy) [21] , RFID (Radio Frequency Identification) [22] , either their accuracy is too low or the computational complexity is too high for an IoT application. To achieve better accuracy, our method of choice is Ultra-Wide Band (UWB) due to its better performances for indoor localization, (i.e., high precision and reliable ranging with up to 10 cm accuracy), and large bandwidth with 1 kHz refresh rate [23] . The equipment used in this experiment to perform indoor positioning is the DW1001-DEV 8 . We introduce, the concepts of 'Anchor' and 'Tag' to denote different UWB nodes in the system. 'Anchor' represents a fixed node whose position is known. Anchors use wireless signals from tags to determine the position of movable tags whose position is unknown. In this experiment, the architecture for indoor positioning is depicted in Figure 11 . We set four DWM1001 modules as Anchors and one DWM1001 module as tag (representing the customer moving withing a closed space). Embedded firmware which provides two-way ranging (TWR) and real time location system (RTLS) functionality are pre-loaded in DWM1001 module [24] . We adopt TWR method which is based on time of flight (ToF) [25] , [26] to get the ranging measurements. The distance measurement behind this method is that it takes the product of a measured time and the speed of light. The measured time is the radio signal travels between an emitter and a receiver. The principle behind this method is depicted in Figure 11 . To measure distance, three messages named Poll, Response and Final need to be exchanged between anchors and tag. Anchor timestamps including T SP , T SR , T RF and tag timestamps including T SP , T RP , T SF are recorded to calculate the distance. Based on these timestamps, the distance named Dis between the tag and anchor can be computed by the following equation: where c is the speed of light expressed in m/s. The experiment is performed in a 20 by 10 m room at Imperial College London. There are four anchors named as DW4105, DW9B10, DW4A2F (as initiator), DW4C15 and one Tag named as DW181C. In Figure 10 (a) and 10(b), the triangle depicts the position of the Tag (i.e., the PoC-based mask), while other dots to denote other agents generated by simulator. Figure 10 (c) depicts the data collected by the gas sensor. We average data samples over a fixed time window to detect, whether or not eCo2 and TVOC are above a certain threshold or not. More specifically, we set the time window, to be ten samples and we set the thresholds, for the two quantities, respectively, to 500 ppm for eCo2 and 50 ppb for TVOC. According to the designed control algorithm, if the people's mask wearing data can meet for this requirement, which means for agent i M i (k) = 1 all staked tokens will be returned. Otherwise when M i (k) = 0, all tokens will be deducted. Remark: This experiment that we have described is designed to illustrate the main features of the operation of the system. In particular, the eCO2 and TVOC thresholds Fig. 8 . 70%-80% mask wearing are chosen empirically. Any practical implementation of the system would require these factors to selected in a more rigorous manner by considering factors such as the mask wearers age, health, and factors such as local weather. During the middle of the time scale when people wear a mask on, the value for all variables are increasing dramatically compared to the rest of value when people do not wear a mask. Figure 10 (d) depicts the changing of individual cost according to the compliance of the social contract -when wearing masks correctly. V. CONCLUSION In this paper, a smart mask prototype is designed to monitor people's mask wearing status. The use of DLT -IOTA Tangle, severs as both a communication layer for the control algorithm as well as ledger ensuring the security and immutability of data. The designed mechanism is validated through extensive simulations including a python-based one and a hardware-inthe-loop one. Personalised feedback control, social contracts, and compliance strategies for ensembles Dynamic traffic congestion pricing mechanism with user-centric considerations A model-based dynamic toll pricing strategy for controlling highway traffic iparker-a new smart car-parking system based on dynamic resource allocation and pricing Decentralized assignment of electric vehicles at charging stations based on personalized cost functions and distributed ledger technologies Distributed ledger technology for smart cities, the sharing economy, and social compliance On the stability of unverified transactions in a dag-based distributed ledger Air quality monitoring system based on iot using raspberry pi Smart healthcare monitoring system using raspberry pi on iot platform Rethinking distributed ledger technology Distributed ledger technology: Blockchain compared to directed acyclic graph The tangle. White paper Investigating messaging protocols for the internet of things (iot) Latency evaluation for mqtt and websocket protocols: an industry 4.0 perspective On m2m micropayments: a case study of electric autonomous vehicles Authenticating health activity data using distributed ledger technologies. Computational and structural biotechnology journal Accelerating health data sharing: A solution based on the internet of things and distributed ledger technologies Blockchain and internet of things data provider for smart applications A blockchain solution based on directed acyclic graph for iot data security using iota tangle Application of wifi-based indoor positioning system for labor tracking at construction sites: A case study in guangzhou mtr Smartphone-based indoor positioning using ble ibeacon and reliable lightweight fingerprint map Robot-based indoor positioning of uhf-rfid tags: The sar method with multiple trajectories Adapted error map based mobile robot uwb indoor positioning An analytical study of time of flight error estimation in two-way ranging methods Numerical and experimental evaluation of error estimation for two-way ranging methods ACKNOWLEDGEMENT Thanks for the support from DecaWave company to supply DecaWave DWM1001-DEV.