1 of 56

EE 629 �Internet of Things �Lesson 10: Blockchain

Kevin W. Lu

2021-10-16

2 of 56

Lesson 10: Blockchain

  • Introduction to blockchains
  • Build a blockchain using Python on Raspberry Pi
  • A blockchain course
  • R3 Corda blockchain platform
  • The Linux Foundation Hyperledger project
  • Trusted IoT Alliance
  • The Mobility Open Blockchain Initiative (MOBI)
  • Quorum
  • Diem blockchain and protocol (rebranded from Libra in December 2020)
  • Government cryptocurrency
  • IoT blockchain examples
  • IOTA, Tangle, and Masked Authentication Messaging (MAM)
  • RuuviTag
  • InterPlanetary File System (IPFS), Filecoin, and OrbitDB
  • Blockchain-based IoT standards

2

3 of 56

Lab 10A — Blockchain

  • Run hash_value.py and snakecoin.py

$ cd iot/lesson10

$ python3 hash_value.py

$ python3 snakecoin.py

$ python3 snakecoin-server-full-code.py

$ cd

  • Terminal 1: node_server.py

$ git clone https://github.com/satwikkansal/python_blockchain_app.git

$ export FLASK_APP=node_server.py

$ cd python_blockchain_app

$ flask run --port 8000

* Serving Flask app "node_server"

* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)

  • Terminal 2: run_app.py

$ cd python_blockchain_app

$ python3 run_app.py

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

* Restarting with inotify reloader

* Debugger is active!

* Debugger PIN: 184-619-943

3

4 of 56

Lab 10B — IOTA

Install PyOTA and connect to an IRI node

$ sudo pip3 install pyota[ccurl]

$ cd ~/iot/lesson10

$ python3 iri_node_info.py

$ cd

Send DHT11 sensor data to the IOTA Tangle using MAM (by Robert Lie)

  • Download and build the C library for BCM2835

$ wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz

$ tar zxvf bcm2835-1.60.tar.gz

$ cd bcm2835-1.60

$ ./configure

$ make

$ sudo make check

$ sudo make install

$ cd

  • Clone the code repository

$ git clone https://github.com/robertlie/dht11-raspi3.git

$ cd dht11-raspi3

$ npm install

4

5 of 56

Lab 10B — IOTA

  • Change nodes.testnet.iota.org to nodes.devnet.iota.org

$ nano mam_publish.js

$ nano mam_receive.js

$ nano mam_sensor.js

  • Ctrl+W to search mwm (minimum weight magnitude) and change it from 14 to 9

$ cd lib

$ nano mam.client.js

  • Terminal 1: Run mam_publish.js (Press Ctrl+Z to stop)

$ node mam_publish.js

  • Terminal 2: Run mam_receive.js (Press Ctrl+Z to stop)

$ node mam_receive.js YOUR_ROOT

  • Change sensor type to DHT22 and GPIO pin to 24 (The sensor is required)

$ nano sensor.js

$ nano mam_sensor.js

$ node sensor.js

  • Terminal 1: Run mam_sensor.js (Press Ctrl+Z to stop)

$ node mam_sensor.js

  • Terminal 2: Run mam_receive.js (Press Ctrl+Z to stop)

$ node mam_receive.js YOUR_ROOT

5

6 of 56

Distributed Ledger Technology

  • A distributed ledger technology (DLT) is a consensus of replicated, shared, and synchronized digital data geographically spread across multiple sites, countries, or institutions
  • There is no central administrator or centralized data storage
  • A peer-to-peer network is required as well as consensus algorithms to ensure replication across nodes is undertaken
    • Could be used to track and verify any kind of digital exchange
    • Provides a way to track the unique history of individual devices, by recording a ledger of data exchanges between it and other devices, web services, and human users
    • Enables smart devices to become independent agents, autonomously conducting a variety of transactions, e.g., an autonomous vehicle that can diagnose, schedule, and pay for its own maintenance
  • One form of distributed ledger design is the blockchain system, which can be either public or private

6

7 of 56

Transparency and Traceability

  • Transparency refers to the capture and transference of high-level information along the supply chain that is specific and accurate, relating to the components of a product, the names of suppliers, the location of facilities, associated certificates, etc.
  • The information captured during traceability is more granular, relating to individual ingredients or components such as batch-lot data (catch/harvest date, field data, etc.), purchase order (PO) data, and other operational information
  • Whereas transparency focuses on mapping the whole supply chain, traceability looks at individual batches of components or purchase orders as they progress through the supply chain

7

8 of 56

Blockchain

  • A blockchain [GitHub] is an open, distributed ledger that can record transactions between two parties in a verifiable way against a double-spending problem
  • Don Tapscott and Alex Tapscott, Blockchain Revolution: How the Technology behind Bitcoin Is Changing Money, Business, and the World, 2018
  • NIST NISTIR 8202, Blockchain Technology Overview
  • IBM Blockchain
  • McKinsey strategic business value of blockchain
  • List of blockchain uses

8

9 of 56

Blockchain Technology Key Forces

9

10 of 56

Blockchain of Things

10

11 of 56

Blockchain and Cryptocurrency

11

12 of 56

Non-Fungible Tokens (NFTs)

  • In economics, fungibility is the property of a good or a commodity whose individual units are essentially interchangeable, and each of its parts is indistinguishable from another part, e.g., gold, sweet crude oil, company shares, bonds, other precious metals, and currencies
  • Fungibility refers only to the equivalence and indistinguishability of each unit of a commodity with other units of the same commodity, and not to the exchange of one commodity for another
  • A non-fungible token (NFT) is a special type of cryptographic token that represents something unique and not mutually interchangeable like bitcoin
  • NFTs are used to create verifiable digital scarcity, ownership, and asset interoperability across multiple platforms in several specific applications that require unique digital items like crypto art, digital collectibles, and online gaming
  • Art was an early use case for NFTs, and blockchain in general, because of its ability to provide proof of authenticity and ownership of digital art that has otherwise had to contend with the potential for mass reproduction and unauthorized distribution of art through the internet

12

13 of 56

Hash Functions

  • A hash function is any function that can be used to map data of arbitrary size to data of a fixed size

pi@piot4:~/iot/lesson10 $ python3 hash_value.py

  • Hans Peter Luhn 1896—1964 of IBM appears to have been the first to use the concept of a hash function in a memo dated January 1953
  • SHA-2 (Secure Hash Algorithm 2) is a set of cryptographic hash functions with hash values (or digests) that are 224, 256, 384 or 512 bits (28, 32, 48, or 64 bytes)
  • Each hexadecimal digit represents four binary digits, a nibble, which is half a byte

pi@piot4:~$ python3

>>> import hashlib; m=hashlib.sha256(b"hello, world")

>>> m.hexdigest()

'09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b'

>>> m.digest_size

32

>>> m.block_size

64

>>> exit()

pi@piot4:~$

13

14 of 56

Hash Trees

  • A hash tree or Merkle tree named after Ralph Merkle [1979 patent] is a tree in which every leaf node is labeled with the hash of a data block, and every non-leaf node is labeled with the cryptographic hash of the labels of its child nodes

14

15 of 56

Bitcoin Transactions

  • Without a trusted party, transactions must be publicly announced as a chain of digital signatures, and need a system for participants to agree on a single history of the order in which they were received

15

16 of 56

Timestamp Server

  • A timestamp server works by taking a hash of a block of items to be time stamped and widely publishing the hash
  • The timestamp proves that the data must have existed at the time in order to get into the hash
  • Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it

16

17 of 56

Proof-of-Work

  • The proof-of-work is one-CPU-one-vote that involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits
  • The average work required is exponential in the number of zero bits required and can be verified by executing a single hash
  • The proof-of-work is implemented by incrementing a nonce in the block until a value is found that gives the block's hash the required zero bits
  • The proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour
  • If they're generated too fast, the difficulty increases

17

18 of 56

Peer-to-Peer Network

  • Nodes always consider the longest chain to be the correct one and will keep working on extending it as follows:
  • New transactions are broadcast to all nodes
  • Each node collects new transactions into a block
  • Each node works on finding a difficult proof-of-work for its block
  • When a node finds a proof-of-work, it broadcasts the block to all nodes
  • Nodes accept the block only if all transactions in it are valid and not already spent
  • Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash
  • New transaction broadcasts do not necessarily need to reach all nodes
  • As long as they reach many nodes, they will get into a block before long
  • Block broadcasts are also tolerant of dropped messages
  • If a node does not receive a block, it will request it when it receives the next block and realizes it missed one

18

19 of 56

Reclaiming Disk Space

  • Once the latest transaction in a bitcoin is buried under enough blocks, the spent transactions before it can be discarded to save disk space
  • To facilitate this without breaking the block's hash, transactions are hashed in a Merkle Tree, with only the root included in the block's hash

19

20 of 56

Simplified Payment Verification

  • To verify payments without running a full network node, a user only needs to keep a copy of the block headers of the longest proof-of-work chain

20

21 of 56

Combining and Splitting Value

  • To allow value to be split and combined, transactions contain multiple inputs and outputs
  • Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender

21

22 of 56

Privacy

  • Privacy can still be maintained by breaking the flow of information in another place by keeping public keys anonymous
  • As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner

22

23 of 56

Bitcoin Blocks

  • Click any block on a block list since 2009-01-03 to view its summary where 0x is a prefix for hexadecimal
  • List of bitcoin companies by services such as miners, e.g.,
    • Poolin
    • F2Pool
    • BTC.com
    • AntPool
  • List of bitcoin mining application-specific integrated circuits (ASICs), e.g.,

23

24 of 56

Bitcoin Electricity Consumption

  • Given that the exact electricity load and consumption of the Bitcoin network cannot be determined, the Cambridge Bitcoin Electricity Consumption Index (CBECI) provides a range of possibilities consisting of a lower bound and an upper bound estimates corresponding to
    • The absolute minimum total electricity expenditure based on the best case assumption that all miners always use the most energy-efficient equipment available on the market
    • The absolute maximum total electricity expenditure based on the worst case assumption that all miners always use the least energy-efficient equipment available on the market as long as running the equipment is still profitable in electricity terms
  • Within the boundaries of this range, a best-guess estimate is calculated to provide a more realistic figure that comes closest to Bitcoin’s real annual electricity consumption
  • The best-guess estimate is based on the assumption that miners use a basket of profitable hardware rather than a single model

24

25 of 56

Aluminum Smelting

  • Aluminum smelting is the process of extracting aluminum from aluminum oxide (commonly called alumina extracted from the ore bauxite) by the Hall-Héroult electrolytic process that uses huge amounts of electricity
  • About eight percent of global electric power is lost in transmission and distribution
  • Smelters tend to be located close to large power stations, often hydro-electric ones, where electricity is abundant, and where the local consumers may not be able to absorb all that capacity, e.g., Plattsburgh, New York
  • Smelters are often located near ports, since many smelters use imported alumina
  • This led to an Icelandic economist stating that Iceland exports energy in the form of aluminum, and hoping it can replicate this model to exports energy as data
  • Smelters have been converted into Bitcoin mines, e.g., Coinmint operates a digital currency data center at a former Alcoa Aluminum smelter in Massena, New York

25

26 of 56

Natural Gas Flaring

  • Routine flaring, also known as production flaring, is a method and current practice of disposing of large unwanted amounts of associated petroleum gas (APG) during crude oil extraction
  • The gas is first separated from the liquids and solids downstream of the wellhead, then released into a flare stack and combusted into earth's atmosphere (usually in an open diffusion flame)
  • Where performed, the unwanted gas (mostly natural gas dominated by methane) has been deemed unprofitable, and may be referred to as stranded gas, flare gas, or simply as "waste gas"
  • Routine flaring is not to be confused with safety flaring, maintenance flaring, or other flaring practices characterized by shorter durations or smaller volumes of gas disposal
  • Instead of wasting the excess natural gas, companies (e.g., Crusoe Energy Systems) convert it to electricity, and transfers the power to servers at the data center on the well site for computing tasks such as Bitcoin mining
  • Using satellite internet, these companies digitally transfer the output product

26

27 of 56

Smart Contracts and Ethereum

  • Decentralized finance (commonly referred to as DeFi) is a blockchain-based form of finance that does not rely on central financial intermediaries such as brokerages, exchanges, or banks to offer traditional financial instruments, and instead utilizes smart contracts on blockchains
  • A smart contract is a computer protocol which facilitates the negotiation of a contract and allows for the performance of credible transactions without third parties
  • Utilizing blockchain technology as a tool of distributed consensus, Ethereum [site, repo, whitepaper] provides a built-in programming language such as Solidity and Remix that can be used to create these smart contracts
  • However, blockchains are unable to communicate with external systems and the potentials of smart contracts have been limited by this fact
  • The key to resolving this issue is an oracle that brings real-world data into the blockchain, or sends data from the blockchain into the real world
  • As of today, oracle services are provided by centralized companies, which nullifies the security and reliability obtained from using blockchain

27

28 of 56

Chainlink

  • To solve the oracle dilemma, Chainlink was developed as the first decentralized oracle service
  • Now anyone can run a Chainlink node and provide external data directly to smart contracts
  • Developers can obtain real-word data from Chainlink nodes and utilize that data to create their contracts
  • Running a Chainlink node provides external data directly to smart contracts
  • Click here to configure a Chainlink node and become a node operator

28

Contribution by Aldin Llolla, 2019 Fall

29 of 56

Build a Blockchain 0/3

  • Antony Lewis, "Bits on blocks — Thoughts on blockchain technology" [Site]
  • Arjuna Sky Kok, "Building a simple blockchain data structure with Python" [Site]
  • Tom Cusack, "Blockchain explained in seven Python functions" [Site]
  • Eric Munsing, "Build your own blockchain: a Python tutorial" [Site, GitHub]
  • Gerald Nash, "Let's build the tiniest blockchain in less than 50 lines of Python" [Site, GitHub], 2017-07-16

pi@piot4:~/iot/lesson10 $ python3 snakecoin.py

  • Gerald Nash, "Let’s Make the Tiniest Blockchain Bigger Part 2: With More Lines of Python " [Site, GitHub], 2017-07-23

pi@piot4:~/iot/lesson10 $ python3 snakecoin-server-full-code.py

  • Adil Moujahid, "A practical introduction to blockchain with Python" [Site, GitHub]
  • Daniel van Flymen, "Learn blockchain by building one" [Site, GitHub]

29

30 of 56

Build a Blockchain 1/3

  • Satwik Kansal, python_blockchain_app
  • Terminal 1

$ git clone https://github.com/satwikkansal/python_blockchain_app.git

$ export FLASK_APP=node_server.py

$ cd python_blockchain_app

$ flask run --port 8000

* Serving Flask app "node_server"

* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)

  • Terminal 2

$ cd python_blockchain_app

$ python3 run_app.py

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

* Restarting with inotify reloader

* Debugger is active!

* Debugger PIN: 184-619-943

30

31 of 56

Build a Blockchain 2/3

31

32 of 56

Build a Blockchain 3/3

32

33 of 56

Blockchain Classes

  • Princeton University textbook and video lectures: Arvind Narayanan, Joseph Bonneau, Edward Felten, Andrew Miller, Steven Goldfeder, Bitcoin and Cryptocurrency Technologies: A Comprehensive Introduction, 2016
  • Harvard University, Introduction to Blockchain and Bitcoin
  • Columbia University COMS W4995-013: Blockchain and Applications
  • Columbia Business School B8462-001: An Introduction to Blockchain and Cryptocurrencies
  • Nakamoto & Turing Labs (N&T Labs) offers blockchain classes, formerly, Columbia University ELEN E6883 "Introduction to Blockchain Technology"
  • Duke Blockchain Lab
  • Blockchain at Berkeley

33

34 of 56

Enterprise Blockchain

  • The R3 consortium started from nine financial companies on 2015-09-15 to an ecosystem of more than 300
  • R3 made its Corda blockchain platform open source on 2016-11-30
  • Energy Web Foundation (EWF) launched in early 2017 has 17 decentralized applications (dApps) on its enterprise-grade public blockchain
  • The B3i blockchain consortium focused on the insurance industry since 2018 launched its first live product on the R3 Corda platform
  • Global Shipping Business Network (GSBN) was created on 2019-07-12 as a not-for-profit joint venture to accelerate the digital transformation of the shipping industry

34

35 of 56

Hyperledger

  • In December 2015, the Linux Foundation announced the creation of the Hyperledger Project to improve the performance and reliability of blockchains and distributed ledgers
  • The Hyperledger project integrates independent open protocols and standards by means of a framework or codebase for use-specific modules, including blockchains with their own consensus and storage routines, services for identity, access control, and smart contracts

35

36 of 56

Trusted IoT Alliance

  • The Trusted IoT Alliance (TIoTA) started in 2016 is a open-source software foundation to support the creation of a secure, scalable, interoperable, and trusted IoT ecosystems
  • On 2020-01-03, the Industrial Internet Consortium (IIC) and the Trusted IoT Alliance (TIoTA) announced they are combining their memberships

36

37 of 56

MOBI

  • The Mobility Open Blockchain Initiative (MOBI) launched on 2018-05-02 is a consortium for blockchain innovation in the mobility industry
  • The first project is to build a vehicle digital identity prototype or car passport that can track and secure odometer and relevant data of a vehicle on distributed ledgers that helps car dealerships and insurers to accurately underwrite the vehicle history for warranties and insurance policies

37

38 of 56

Quorum

  • Quorum is an Ethereum-based distributed ledger protocol and a fork of Go Ethereum, the Go implementation of the Ethereum protocol, with enhancements in transaction/contract privacy, alternative consensus mechanisms, peer permissioning, and high performance

38

39 of 56

Diem Blockchain and Protocol

  • On 2019-06-18, the Diem Association (formerly Libra Association), a Swiss consortium of Facebook and its subsidiary Novi (formerly Calibra) with initial partners unveiled a low-volatility cryptocurrency, Diem [GitHub repository], to have a stable value backed up by traditional bank accounts and currencies
  • On 2020-03-03, Facebook has decided to offer its users digital versions of government-backed currencies in addition to the proposed Diem token [Source]
  • In contrast to Bitcoin that is capped at 21 million and requires proof-of-work, an unlimited number of Diem can be generated with high transaction throughput, low latency, and more energy-efficient approach to consensus
  • The Diem currency is built on the Diem Blockchain, a decentralized, programmable database implemented by the open-source Diem protocol with
    • The Move programming language for transaction logic and smart contracts
    • The Byzantine Fault Tolerant (BFT) consensus protocol, DiemBFT
    • The Blockchain data structures

39

40 of 56

Government Cryptocurrency

  • A central bank can issue a government-backed cryptocurrency and disperse it to spenders via trusted institutions, e.g., Digital Currency Electronic Payment (DCEP) is a central bank digital currency (CBDC) of China, pegged 1:1 to the renminbi (RMB) [Source]
  • A number of central banks could create a "synthetic hegemonic currency" (SHC) from a network of digital central-bank currencies as a global, virtual reserve currency

40

41 of 56

IoT Blockchain Examples

  • Helium is a decentralized machine network using blockchain to connect low-power IoT machines such as routers and microchips to the internet
  • Chronicled combines blockchain and IoT-enabled shipping containers and sensors to provide real-time updates on shipping processes
  • ArcTouch builds personalized, blockchain-based, decentralized apps (DApps) that connect to IoT devices
  • Filament Blocklet USB Enclave can plug into any USB port to launch projects on a blockchain
  • NetObjex blockchain-enabled IoToken provides a secure digital platform for smart devices in the same ecosystem to interact and communicate
  • HYPR stores biometric logins for IoT devices on blockchain, securing and decentralizing important information
  • Xage blockchain-protected security platform enables IoT devices to be tamper proof and have access to secure lines of communication between smart objects
  • Grid+ Lattice1 uses Ethereum to identify fluctuations in the energy market and determine the most efficient price point in real-time

41

42 of 56

IOTA Foundation

  • The IOTA ledger was created in 2015 by David Sønstebø (Drammen, Buskerud, Norway), Dominik Schiener (Berlin, Germany), Sergey Ivancheglo (bio, a.k.a. Come-from-Beyond, Minsk, Belarus), and Prof. Serguei Popov (University of Porto, Campinas, São Paulo, Brazil)
  • The IOTA network went live in 2016
  • In 2017, early IOTA token investors donated 5% of the total token supply for continued development and to endow what became later the IOTA Foundation
  • In 2018, the IOTA Foundation was chartered as a Stiftung in Berlin, with the goal to assist in the research and development, education, and standardization of IOTA technology
  • The IOTA Foundation is a board member of International Association for Trusted Blockchain Applications (INATBA), and founding member of the Trusted-IoT Alliance (TIoTA) and Mobility Open Blockchain Initiative (MOBI), to promote blockchain and distributed ledgers in regulatory approaches, the IoT ecosystem and mobility

42

43 of 56

IOTA, Tangle, and MAM

  • IOTA is a cryptocurrency for the IoT industry without miners and miner fees
  • Instead of a blockchain, IOTA uses a directed acyclic graph (DAG) called the Tangle to store its distributed ledger for scalability, and a gossip (or epidemic) protocol and Masked Authenticated Messaging (MAM) for data flow
  • The Tangle vertices represent transactions and edges represent approvals
  • The first transaction in the Tangle is the genesis
  • A new transaction is added as a new vertex and is attached to two previous transactions by approving its history was verified and found to be valid
  • Two previous transactions (or tips) are chosen by performing a random walk from the genesis towards the transactions with more cumulative weight, i.e., more transactions approving them
  • Cumulative weight corresponds to the amount of proof of work (PoW) that validates a particular transaction
  • Once a transaction has enough cumulative weight, it is included in the consensus
  • The Tangle does not have a built-in maximum throughput

43

Contribution by Ziran Gong, 2018 Fall

44 of 56

Directed Acyclic Graph (DAG)

  • A graph is formed by a collection of vertices and edges
  • A directed graph has each edge with an orientation from one vertex to another
  • A directed acyclic graph (DAG) is a finite directed graph that has a topological ordering without directed cycles, i.e., every edge goes from earlier in the ordering (upper left) to later in the ordering (lower right)

44

45 of 56

PyOTA and IRI

  • PyOTA is the IOTA Python API library including functions such as signing, bundles, utilities, and conversion [GitHub repository]

$ sudo pip3 install pyota[ccurl]

  • Tutorial 1: Integrating devices with IOTA
  • Tutorial 2: Switching a light on with IOTA
  • Tutorial 3: Switching a motor on with IOTA
  • Tutorial 4: Upload images onto the Tangle
  • The IRI (IOTA reference implementation) is open-source Java software for the IOTA protocol, currently running on nodes in the public IOTA networks where clients can transfer the IOTA token among each other

$ cd ~/iot/lesson10

$ python3 iri_node_info.py

$ cd

45

46 of 56

IOTA Ecosystem

  • IOTA Tangle
  • IOTA Version 1.1 getting started
  • IOTA Hornet is a lightweight alternative to the original IRI node software
    • The Ultimate Guide to Pi Hornet by Daniel Stricker, 2020-06-16
  • Trinity Wallet available on mobile and desktop
  • Qubic protocol for oracle machines, smart contracts, outsourced computations
  • Coordicide modules: node identities, auto-peering, spam protection, shimmer, tip selection
  • Roadmap of IOTA research and development
  • IOTA.cafe research discussion forum

46

47 of 56

IOTA MAM Example 0/1

  • Send DHT11 sensor data to the IOTA Tangle using MAM and Raspberry Pi

Tutorial, quick guide, code, and app by Robert Lie of Mobilefish.com

  • Download and build the C library for BCM2835 and clone the code repository

$ wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz

$ tar zxvf bcm2835-1.60.tar.gz

$ cd bcm2835-1.60

$ ./configure

$ make

$ sudo make check

$ sudo make install

$ cd

$ git clone https://github.com/robertlie/dht11-raspi3.git

$ cd dht11-raspi3

$ npm install

  • Change testnet to devnet and minimum weight magnitude (mwm) from 14 to 9

$ nano mam_publish.js

$ nano mam_receive.js

$ nano mam_sensor.js

$ nano ./lib/mam.client.js

47

Contribution by Dhruvil Joshi, 2019 Fall

48 of 56

IOTA MAM Example 1/1

  • Run mam_publish.js on one terminal and copy the ROOT

$ node mam_publish.js

  • Run mam_receive.js on another terminal with the ROOT

$ node mam_receive.js YOUR_ROOT

  • Press control-z to stop each
  • Change sensor type to DHT22 and GPIO pin to 24

nano sensor.js

nano mam_sensor.js

  • Test sensor.js

$ node sensor.js

  • Press control-z to stop
  • Run mam_sensor.js on one terminal and copy the ROOT

$ node mam_sensor.js

  • Run mam_receive.js on another terminal with the ROOT

$ node mam_receive.js YOUR_ROOT

  • Press control-z to stop each

48

Contribution by Dhruvil Joshi, 2019 Fall

49 of 56

RuuviTag

  • RuuviTag is an open-source (repositories) wireless environmental sensor node and platform for measuring temperature, atmospheric pressure, and relative air humidity [specs]
  • Ruuvi Lab tutorials include IOTA
  • Ruuvi is the Finnish word for "screw"

49

50 of 56

InterPlanetary File System (IPFS)

  • Juan Benet started Protocol Labs in May 2014, and published original 2014 papers on the InterPlanetary File System (IPFS) and Filecoin
    • IPFS is a protocol and network designed to create a content-addressable, peer-to-peer method of storing and sharing hypermedia in a distributed file system
    • Juan Benet's 2016 TEDx Talk on the next internet revolution
    • Filecoin is an open-source, public, cryptocurrency and digital payment system intended to be a blockchain-based cooperative digital storage and data retrieval method
  • OrbitDB is a serverless, distributed, peer-to-peer database that uses
    • IPFS as its data storage
    • IPFS Pubsub to automatically sync databases with peers
    • CRDTs (conflict-free replicated data type) for conflict-free database merges

50

Contributions by Anwar Alruwaili and Kyra DiFrancesco, 2019 Spring

51 of 56

Blockchain-based IoT Standards

  • The IEEE Blockchain Standards [Link]
    • P2144.1: Standard for Framework of Blockchain-based Internet of Things (IoT) Data Management
    • P2144.2: Standard for Functional Requirements in Blockchain-based Internet of Things (IoT) Data Management
    • P2144.3: Standard for Assessment of Blockchain-based Internet of Things (IoT) Data Management
    • P2418.1: Standard for the Framework of Blockchain Use in Internet of Things (IoT)
  • Papers by Claudio Lima, founder of the Blockchain Engineering Council (BEC)
    • "Developing Open and Interoperable DLT/Blockchain Standards" [Link]
    • "Distributed Ledger Technology (DLT) Blockchain Interoperability Standards" [Link]
    • "Towards an Open DLT Blockchain Energy Standards for Decentralized Grid Applications" [Link]

51

52 of 56

Lesson 10 Summary

  • Blockchain or distributed ledger technologies drive continuous innovation in IoT systems and services
  • Blockchain-based smart contracts keep security risk to a minimum and eliminate the need for a third-party with fast approval or disapproval of an agreement, saving time and cost
  • IOTA, a cryptocurrency for the IoT industry without fees, uses a directed acyclic graph (DAG) called the Tangle to store its distributed ledger for scalability, and a gossip protocol and Masked Authenticated Messaging (MSM) for data flow
  • Global standards, such as the IEEE Blockchain standards series, are creating generic and interoperable frameworks to serve different industry verticals and use cases

52

53 of 56

IoT Course Summary

  • Since the IoT often communicates data associated with users and their environments, data access shall have differential restrictions
  • Python programming is a common thread through IoT native services, web services, data analysis, and system management
  • IoT communication models
    • Request-response — Django REST framework, Flask, etc.
    • Publish-subscribe — Crossbar.io, Paho, etc.
  • IoT cloud platforms — ThingSpeak, Particle Cloud, etc.
  • Value of the IoT is created by making sense of data, turning it into knowledge and meaningful action
  • NETCONF protocol and YANG data modeling language provide advanced capabilities of automating IoT device configuration and management
  • Cloud native computing, service mesh, and blockchain drive continuous innovation in IoT systems and services

53

54 of 56

IoT Course Takeaways

54

Application

Web App

ThingSpeak, Google Sheet,

Particle Cloud

App Server

Django, Node.js

Database Server

SQLite, MySQL

Management

Services

Security

Device

Management

NETCONF,

YANG, Pyang,

PlantUML,

Docker,

Netopeer2, Kubernates, Istio

Native Services

Python (RPi.GPIO, spidev, os, subprocess, psutil)

Analysis

Python (NumPy, SciPy, Scikit-learn, Matplotlib, Pandas, TensorFlow, Keras)

Web Services

Python (smtplib, requests, json, Django, Flask, gspread)

Authentication

WPA, SSH, VNC, Google 2-Step Verification

Authorization

MySQL

Root User,

Django Superuser, OAuth

Communication

Request and

Respond

Django REST

Publish and

Subscribe

Crossbar.io, Paho

Wireless

Communications

Wi-Fi, Socket, ZigBee, BT

Device

Sensors

BMP, DHT, LDR, PIR, TMP, etc.

Actuators

Relay, Motor Driver

Computing Devices

Raspberry Pi, Arduino, Particle

Contribution by Dler Hasan, 2017 Spring

55 of 56

Course Survey

55

56 of 56

Course Survey Result

56

Response

Weight

Grade

Strongly Agree

4

A

Agree

3

B

Neutral

2

C

Disagree

1

D

Strongly Disagree

0

F