LevelDB & Crypto
Table of Contents
Introducing LevelDBJames Halliday introduces and sets up LevelDB, a key-value storage library written at Google that provides an ordered mapping from string keys to string values.
Methods and LexicographicallyAfter James reviews the methods that are available with LevelDB, he notes that LevelDB uses lexicographic sorting, which alphabetical order of string values based on the alphabetical order. J
Organizing KeysWith the LevelDB setup, James demonstrates how to organize keys for different situations such as a simple blog and creates queries against that data.
Secondary IndexesJames introduces how to create multiple keys for each post to create a secondary index.
Inserting DataWith the database set up, James reviews how to build a system to add new data into LevelDB.
Adding and Querying DataJames adds new posts with timestamps to the database. Then James examines different ways to query that data from the LevelDB database.
SubleveldownJames introduces Subleveldown, which a library for LevelDB that creates nested sub-databases with unique namespaces;
Level-LivefeedJames installs Level-Livefeed package that allows for one to subscribe to a live feed of changes to the database.
Designing ModulesTo use LevelDB in the browser, James switches from level package to include level-browserify. This change allows the use of the LevelUP code to be portable making it work with node and in the browser.
Best PracticesAfter reviewing the best use cases for LevelDB, James creates a demo application with LevelDB, node, and IndexedDB.
Q&A: IndexedDB vs. LocalStorageJames takes questions from the students about IndexedDB and LocalStorage, browser support, and more.
HashesJames introduces hashes. While encryption is a two-step process used first to encrypt and then decrypt a message, hashing condenses a message into an irreversible fixed-length value or hash.
Approaches to CryptographyJames discusses approaches to cryptography including random number generators, symmetric ciphers, and asymmetric crypto. Cipher is a shared algorithm for performing encryption or decryption whereas asymmetric crypto uses public and private keys to encrypt and decrypt data. James also notes that is an important tool with cryptography is picking a robust random number generator. Finally, James warns against creating your encryption process.
Sodium and ChlorideJames introduces Sodium, a library for encryption, decryption, signatures, and password hashing. Then James demonstrates how to setup Chloride, which is based on Sodium, and generate key pairs.
Using SodiumJames discusses how to use Sodium cryptography with or without a signature, using a symmetric cipher, and using public key encryption.
Secret-HandshakeJames reviews secret-handshake library, which is used to keep both parties unaware of each other with mutually authenticating key agreement handshake. James takes questions from students.
merkle DAGsJames reviews merkle DAGs, which is a directed acyclic graph whose objects are linked to each other (usually just by their hash), where the hash(object) includes all hash(linked_object).
Working with merkle DAGsJames demonstrates how to use merkle DAGs with node using shasum, which checks for SHA checksums.
Introducing Kappa ArchitectureJames introduces Kappa Architecture, where an immutable and append-only logs are used as the source of truth. To create these append-only logs, James notes that they are built hashes that are then trivial to replicate with concatenation.
Using HyperlogJames reviews hyperlog, which creates append-only merkle DAG log store. Hyperlog also can link to other documents by cryptographic hash and provides hooks for cryptographic signing and verification. Then James shows how to set up hyperlog.
Database Replication and Duplex StreamsJames discusses how to synchronous two databases. James takes questions from students.
Hyperlog-indexJames reviews hyperlog-index, which builds materialized views on top of a hyperlog.
Hyperkv and Hyperlog-sodiumJames shows hyperkv, which provides a p2p key/value store as a materialized view over a hyperlog. Then James discusses hyperlog-sodium, which more easily configures hyperlog for cryptographic signing.
Kappa Architecture ExamplesJames reviews several examples of kappa architecture: P2P social database; map database built on hyperlog, hyperkv, hyperlog-kdb-index; and P2P file sync over an append-only merkle DAG log.
WebRTC Swarm with HyperlogsCreate a swarm of P2P connections using WebRTC and a signalhub.