LevelDB & Crypto

LevelDB & Crypto Hyperkv and Hyperlog-sodium

Check out a free preview of the full LevelDB & Crypto course:
The "Hyperkv and Hyperlog-sodium" Lesson is part of the full, LevelDB & Crypto course featured in this preview video. Here's what you'd learn in this lesson:

James 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.

Get Unlimited Access Now

Transcript from the "Hyperkv and Hyperlog-sodium" Lesson

[00:00:00]
>> If you don't wanna have to build your own indexes, there aren't actually I don't think too many different kinds of indexes that you would actually want to run. Things like counters are so difficult to do, but things like key/value stores are actually extremely simple. I've got a package to do that that's being used in that offline peer-to-peer mapping project as well, called hyperkv.

[00:00:22] So with hyperkv, you kind of get a key/value store view on top of a log of edits. So key/value stores are really handy, we use them all the time. The important thing to note is if you call get in this key/value store, if you do kv.get, you're going to get back possibly many documents, not just a single one.

[00:00:49] So here's how that would look. So instead of a single value, you get back an object. The keys are the hashes and then the values are whatever the document value is for that hash. So but this is just what's true about that log. And I think hiding from the truth is a bad idea in technology.

[00:01:12] So I take a principled stand [LAUGH] for the truth of the immutable log in this case. So if you want to play around with doing building something like a peer-to-peer distributed wiki, you could do that with hyperkv. I think we'll have some time, so I might try to build one of those on top of a hyperlog.

[00:01:40] There's also a package called hyperlog-sodium that I wrote a while ago. It's kind of a lot of boilerplate. It's quite difficult to set up the sodium hooks for doing signing and verification correctly. So this package does all that for you. You can just drop it into your hyperlog, like I can show you right really quick what that would look like.

[00:02:00] So in the part of hyperlog where you have like the valueEncoding and whatever, that's where you can require hsodium, which is hyperlog-sodium. And you can do hsodium of a key pair and then whatever other stuff you want to put. So the key pair would be from libsodium. If you require chloride, Chloride, then you do chloride.crypto_sign_keypair, like that.

[00:02:34] So this is all that it takes to get a signed log instead of just something that's going to be unsigned, but have a Merkle DAG.