39:43Awesome.
39:43So let's shift gears a little bit and
get a little bit more technical since
39:47one ingredient we'll need to make all
of this happen is not just moving data
39:52around, which we've explored in many other
conversations on this podcast so far.
39:57But one particular aspect of that is
also that like, not just two random
40:02devices are exchanging data in a
completely trustless way, but a device
40:07might also be owned by a person who
has a particular identity or might even
40:13on that given device have maybe there
might be multiple identities at play.
40:18And so how do you retain an identity?
40:20How do you, kind of exchange identity
information, that your, I love the way
40:27how you put it, like your device ring,
how all of those devices can trust each
40:31other, how all of that is made work,
how, and I think there's this typical
40:35tension in security where if you want
to make it secure, that often comes at
40:40the cost of convenience and vice versa.
40:43And that's sort of.
40:44Sweet middle ground where it's
both convenient and secure.
40:47I think that's also very tricky.
40:49So this is an area that you've really
deeply explored and you've built a
40:54whole bunch of different projects.
40:56I think one of them is
being the Lofi.ID, project.
41:00You also have another project
on GitHub called Local Vault.
41:03So maybe you want to give us an
introduction to what you've been
41:07working on there, and then we
can take it one step at a time.
41:11Yeah, so big picture overview.
41:13is that if you are going to own data
on your device, and that's going to be
41:19the source of authority for that data,
which is the premise for local-first,
41:24then I believe that you both need to
be able to secure that data, meaning
41:29securing it at rest, which involves
encryption, and you're going to be
41:33able to need to Securely ensure that
data goes only where you want it to go.
41:39Plain text data being sent around
and backed up in other places,
41:43that's not going to cut it.
41:44So we are going to need encryption
to be part of this equation.
41:49And To boil a lot of real complicated
technology down to hopefully
41:54something that just about anybody
can understand, we have this who's
41:58protecting the master key problem.
42:02No matter what encryption scheme you
design, whether it's password based,
42:06where you derive an encryption key from
something that I type in, or whether
42:11it's I've generated a key and I'm going
to Randomly, and that is your encryption
42:15key, no matter which mechanism, or there's
a bunch of other variations thereof,
42:19but no matter which mechanism you have,
you have this kind of encryption upon
42:24encryption upon encryption, but at the
very top of that chain, you have the
42:27master key, the master password, whatever.
42:30And how do you protect that?
42:32That's the common problem.
42:33And in fact, going all the way back
to the work that I did at Hero,
42:37the Web3 company that I worked at,
they had a very similar problem.
42:41They were trying to create smart
contracts around the Bitcoin chain with
42:45the separate blockchain, and they needed
the ability to, you know, to round trip
42:50transactions in a completely trustless
way between one blockchain and the Bitcoin
42:56blockchain, between Stacks and Bitcoin.
42:57And they have this exact same
problem, which is who's going
43:00to hold the master keys?
43:01And how are you going to do
that in the open, but not
43:03let everybody have it, right?
43:04So we always run into this problem of It
all sounds well and great until we get
43:10to the final piece of the puzzle, which
is how do you handle the master password?
43:13I've been banging my head on
this for years, trying to figure
43:16out there's got to be some way.
43:18And the advent of biometric passkeys
was when the lightbulb went off for me.
43:23Because What Passkeys do and what
the biometric subsystems on these
43:28devices do is they offer a, I think,
compelling answer to that question,
43:34which is there is no perfect storage
for the most secure root, master,
43:41passkey, whatever you call it.
43:43There's no perfect solution, but the
best that we can get is dedicated
43:47hardware on the device that is not
Just free and open to any app, right?
43:53If we can have a dedicated hardware
for this purpose, the secure enclave or
43:58whatever it's called, and then we can
have operating systems that are designed
44:01to very strong, strictly control access
to that, and it's designed in like a
44:06write only way, you cannot read from it.
44:08You can write to it once, and
then you can never read from it.
44:11You can send data in and get results
back out, but you can never ask that
44:15thing to give you its private key.
44:17That really offers, I think, the most
compelling answer we've had so far
44:21to where do we store the master key?
44:24But one of the big problems with that,
it's not in and of itself a solution
44:28to this, to this question is because.
44:32I don't have access to that key.
44:34That means I can't use that key
for encryption purposes myself.
44:40I can create a passkey with my thumbprint
or my face or whatever, but I can't
44:45get access to that key material to
use it for my own encryption purposes.
44:49And I couldn't figure out how we were
going Make passkeys work in a zero
44:54server assumption where there's no
servers and in a way that I could
44:58piggyback upon it to create encryption.
45:01And then it occurred to me that we can
actually bury the key material in the
45:06passkey by way of the user ID field,
or there's actually another mechanism
45:11that is coming along that I think
will be even better than the user ID.
45:14But the main point is, we can actually
piggyback on top of these passkeys.
45:18And in this secure part of the
device, store something in a way
45:22that I think is maybe 99 percent
guaranteeable, that's a lot better
45:27than almost 0 percent guaranteeable
with anything that's in userland apps.
45:31Is it perfect?
45:32No.
45:33But it's absolutely a, you know, a
paradigm step up in terms of security.
45:39And so the whole rest of everything
that I'm building is based on that
45:43one assumption, which is where we're
going to solve the master passkey
45:46problem is by basing this on passkeys.
45:50That does have some
questions that it raises.
45:54How are we going to onboard apps?
45:57on devices that do not already
have biometric capabilities.
46:01They don't have these secure hardware.
46:04I think the good news is that more
and more devices are getting that.
46:07And I think that will continue.
46:08I don't think we will see a,
you know, a pullback in that.
46:12I think we will see more and more
devices getting those capabilities.
46:15So over time that becomes less and
less of a problem, but we do need
46:19an exit ramp for not just telling
somebody, sorry, you're out of luck.
46:24So I've been working on some ideas
around creating kind of a secondary
46:29way of doing things that's not
biometrics based, pattern drawing
46:33that's more complicated and can
create more entropy, things like that.
46:37So I think we do need some exit
ramps there, but I'm going to make
46:39the assumption that for the primary
class of devices that we want to
46:44target here, we have the biometrics.
46:47Once we have that, once
we have that capability.
46:49We needed a way to be able to manage
pass keys without relying upon servers.
46:54So the first library that I wrote
was WebAuthn Local Client, which was
46:59designed to wrap around the web API
that exposes the passkey subsystem,
47:04but doesn't make any assumptions
about communicating with the server.
47:07the use cases in local-first don't need
what the server would do anyway, so that's
47:13not a problem, but it's just no other
libraries out there that I had found where
47:17it could work if you didn't have a server.
47:19So I wrote a library that exposed
that API in a way that made the
47:23assumption you weren't going
to communicate with the server.
47:26You were going to store things securely.
47:28You were going to generate
the challenges on device.
47:31You were going to keep track of
the key and verify that was coming
47:35out was not man in the middle.
47:36You were going to do all of that.
47:37on device, not on server.
47:40So that's what WebAuthn local client was.
47:41That was the first little
piece of the puzzle.
47:45Then I said, okay, well now we need a
way to, piggyback on top of the passkey
47:51system and create something that we can
use for encryption purposes so that we can
47:55protect data both at rest and in transit.
47:58we need some keys.
47:59And I did a lot of research in this.
48:01I'm not an expert.
48:02I'm not a mathematician.
48:04But I settled on, this was back when I was
working at Socket, I settled on, Elliptic
48:09Curve keys, specifically the Edwards
key, the ED25519 key pair as the best
48:17master key pair because you can generate,
that can be used for signing, and you
48:21can generate a sub key pair from that.
48:23That's the Curve 25519 keys
for encryption and decryption.
48:28I settled on that as the best, but
that's not the only way of doing it.
48:31And certainly anybody else could
substitute their own encryption,
48:34or maybe we're going to need to
upgrade that encryption in a post
48:38quantum world in some few years.
48:40But, that's where I landed was,
let's use that, because I think
48:43that's good enough and strong enough.
48:45And I found the Libsodium library,
which is big and complex, but it's,
48:49I been ported to tons of platforms
and that was important to me.
48:53And so I based the ideas around securing
our data on that type of key pair.
48:59So we generate a 25519 key pair.
49:03We take the seed of that, or in my
library, I call it an IV, but IV
49:07or seed, we take the seed of that.
49:09And that's what we store in the passkey.
49:11And with that information coming back
out, each time you put your thumbprint
49:14or your face ID in, you can reconstitute
that key pair and then decrypt
49:19whatever data was previously encrypted.
49:21That is how we fix that
master password problem.
49:26So I built a library to help you do that
and that's called local datalock is the
49:30library that wraps around the WebAuthn
local client, but then it does the
49:35generated encryption key, stick the seed
into the passkey, it does all that stuff.
49:41it does not do anything
about storage of it.
49:43Right?
49:44So you might use local data lock when
all you care about was transmitting
49:47secure data, but it does provide
the pieces for the next one.
49:52The next one was we need to figure out
how we're going to store that data in
49:58an encrypted fashion on the device.
50:01And then, so it's encrypted on
write and decrypted on read.
50:05How are we going to do that?
50:06Well, I actually realized I need
two pieces, not only one to manage
50:09the encryption piece, but actually
I needed a library to manage the
50:12storage piece, because there's
a lot of different variations of
50:15storage, as we were just talking
about with OPFS and things like that.
50:19So I built the Two libraries
to help with this piece.
50:22One library is, I've spun out actually,
it's not even local-first really, it's its
50:28own thing, which is just abstracting local
client storage in a key value way across
50:35all the five major storage mechanisms.
50:37So cookies, local storage, session
storage, indexDB, and OPFS.
50:42And technically under OPFS, there's
two different ways of managing it.
50:45One is more device limited, but
it's the in thread communication
50:51that you can do, asynchronously.
50:53But the more broader device support,
basically all devices at this
50:58point, or all modern devices at
this point, is OPFS in a worker.
51:02and if you do OPFs in a worker, which
you're nodding because you've seen
51:06the same problem, but managing workers
and all of that stuff is difficult.
51:09So that's what this library does, is it
abstracts across all of those mechanisms
51:13the exact same asynchronous key value API.
51:17And that library is called Storage.
51:19It's part of my BYOJS Bring
Your Own JavaScript initiative.
51:23so we'll have a link to that.
51:24But that storage library, even if
you didn't do anything local-first,
51:28you just wanted to store data, I
think that would be useful to help.
51:31Think of it as kind of a more
modern Local Forage, maybe.
51:34Local forage has been around for a decade,
but it's not really maintained anymore,
51:38and it didn't support all the mechanisms.
51:41I think storage is a compelling
option to look at if you're sticking
51:47anything on a local device, even in
local storage, maybe have a better
51:50API and a more secure API for that.
51:53So first of all, storage there, that
has nothing to do with encryption.
51:55It's just The raw reading
and writing from a disk.
52:00And then the last piece of the puzzle,
the one you mentioned before, is the
52:03local data vault . So that library is
what takes storage, WebAuthn, local data
52:08lock, and all those pieces together,
and gives you that local vault, which
52:15is a secure, encryption secured, based
on passkeys, encrypt on write, Decrypt
52:20on read key value storage mechanism.
52:23And you can, of course, choose which
of those places you want to store, like
52:27store it in IndexedDB or store it in OPFS.
52:29But it does all the encryption
and decryption stuff for you
52:33based on the passkey subsystem.
52:35So that's what I've built so far.
52:38Where all of that is going
is towards, there's two ways
52:43that I see this happening.
52:44First of all, I think apps can start
to use, web apps can start to use those
52:49libraries, whatever pieces of that makes
sense to you, use all of it, use part of
52:54it, but start to use those pieces to do
some of this stuff yourself in your own
52:58apps, build your own solution if you want.
53:01I also think that we need to
lower the barrier for apps
53:04to do a lot of this stuff.
53:05And I also think that the more
consolidated of approach we get,
53:09the better chance we have of
something like this catching on.
53:12And so instead of just writing like
a standards doc and saying, if you do
53:17it, you have, you must do it this way.
53:19the approach I'm going to take is to
build a companion Wallet app that allows
53:24you to manage as a user, any number
of your own identities, Protected, of
53:29course, through this passkey subsystem.
53:32And apps will have an SDK that they
can interact with the Wallet app,
53:37whether that Wallet app is a browser
extension, like we mentioned a little
53:40while ago, or whether it's a literal
actual side, you know, companion app.
53:44They'll be able to interact
with that app to ask that app,
53:48Hey, tell me who this user is.
53:51Tell me that it's the same
user as they were before.
53:53That's one question.
53:55So instead of them needing to build
their own authentication, they'll
53:57simply make a call to this Wallet and
say, verify for me that this user is
54:01who they say they are and give me back
their identifier, which might be their
54:05key or some other UUID that you specify.
54:08That's one question.
54:09But also I think those apps shouldn't need
to roll their own encrypt all of my data
54:15and decrypt it all and all of that stuff.
54:17So they'll also be able to provide
the data to the Wallet app and ask
54:22it to encrypt it for them through
that SDK and decrypt it for them.
54:26And again, based all
of that around passkey.
54:28So they don't need to
invent any of that stuff.
54:30The Wallet app will just
take care of it for them.
54:33And then the last piece of the puzzle is.
54:35if you build an app, let's say like
it's a, you know, it's a note taking
54:39app, or it's a social media app,
or whatever, and it does need to
54:41communicate with other devices, instead
of you doing your own synchronization
54:46logic, I think we can actually have
the Wallet app built with peer to peer
54:50capabilities so that my Wallet app on
my phone and my Wallet app on my laptop
54:55and on my tablet can synchronize my
identities, but can also synchronize
54:58userland app data through the Wallet.
55:01Use the Wallet as a tunnel
to do synchronization.
55:04when I say synchronization, I do not
mean that I'm solving anything that what,
55:10what the larger local-first community
says when they say synchronization
55:13with all the CRDTs and all the
merging and stuff that I want to
55:17leave open to this community to solve.
55:19You can plug in whatever.
55:21CRDT systems you think make sense and
whatever strategies you make sense.
55:25I'm simply going to provide the transport
layer through peer to peer various peer
55:29to peer technologies in this Wallet app
so that those bits can get from my phone
55:34to my watch, to my laptop, to my tablet.
55:37And then you'll, your app will
decide what do we do with that?
55:40In your own app logic, you'll decide
how do we merge these competing
55:44sets of bits that are coming in.
55:46I just don't want for people to have to
go invent all of their own wheels there.
55:49And I think a single unified Wallet
app will allow people to do that.
55:54there's other things that I want that
Wallet app to do, but that's kind
55:57of the main, starting point, the 1.
55:590 that I want this Wallet app
to do is to give that to the
56:02local-first community and say, please
consider building upon that Lego.
56:07Perfect.
56:07So this was a lot and, kudos to you
for doing such comprehensive research,
56:14deliberating the different options.
56:16There's always like so many different
paths that you could go in regards
56:20to like all of the different
decryption encryption mechanisms, like
56:25choosing, should you use Libsodium?
56:27Should you use WebCrypto?
56:29Should you use other things, for
what it's worth for Overtone?
56:32I've also landed on using
Libsodium, which, I needed to even
56:36compile my own WASM version to
trim it down a little bit more.
56:40but, yeah, so you've covered a
lot of ground there and I have
56:44a few follow up questions where
I would love to learn more.
56:48also one observation that I just,
as someone who appreciates like
56:53good terminologies and clear
concepts, I just love the term Vault.
56:58As something that, both signals like, Hey,
this is something where it can put stuff
57:02in and get stuff out and it is secure.
57:05So a vault being sort of that combination
of your storage mechanism and that
57:11search mechanism has nothing to do
with encryption at that point, but if
57:14you then combine it with encryption
and decryption, that makes a vault.
57:19I think that's a very intuitive concept
that is, that works both as a concept for
57:24developers, as well as even for end users.
57:28like I think this is what also 1Password,
for example, has started to use.
57:33And I think, 1Password users are
familiar with that also, I'm sure
57:37for other password managers as well.
57:40And so that as a concept, I
hope that it's not just a.
57:44a concept that is used within the
local vault and like the stack that
57:49you're exploring here but hopefully
that's something that as a term,
57:53can be useful for others as well.
57:56Yeah, I agree.
57:57I think it does communicate
what it needs to.
57:59I workshopped that with some of my
social media community, by the way.
58:03I had lots of different suggestions and
I, you know, kind of pieced together
58:06various things, but I workshopped
some of the naming of this, you know,
58:10crowdsourced it because I wanted to
make sure I got a name that really
58:13communicated properly, what I was up to.
58:16So to me, it sounds like you've landed
on a great option here and I might
58:20actually steal that for myself and,
the ways how I'm like in my own data
58:25stack, where I have a database right
now, it's not encrypted address,
58:28but I want to encrypt it more.
58:30And so maybe I can also use
for the SQLite database there.
58:35Maybe I can also start calling
that a vault if it's encrypted.
58:38I like that a lot.
58:39and I also like how you've
already thought a step further.
58:43it's not just as that, like as a tech
stack that can be implemented by a
58:48given apps or high level libraries,
but also from a user perspective, if
58:53you're not just going to use one app,
the kind of part of the entire promise
58:57here is that, like here you have data
in one app and data in another app.
59:02That, and maybe those apps want to
work together and that is actually
59:06something that is like really, really
difficult in today's web2 world.
59:12Where like, just think about
like how much of an effort it is.
59:15That's maybe the best we got.
59:16Maybe it's like a Slack, integration
that like Slack is like a little bit more
59:22aware of like what that Figma link means.
59:26And, I can open it all in my browser.
59:29So from my perspective, it kind
of feels like, Oh my gosh, why
59:31don't you have that context?
59:33So if we, embrace a little
bit more of the user.
59:37The identity concepts, and then also let,
that dictate a little bit of the share,
59:43the context sharing and access control.
59:45I think that can lead to
much better user experiences.
59:49there've been many, many years of
attempts to create in the mobile space.
59:54there was like web intents and then
web share and share intents and like
59:58all these other variations and it went
through various different names and
1:00:03standards processes stumbled with it.
1:00:05I don't even know where that currently
stands, but that's exactly where I'm
1:00:08headed is basically, let's just get around
any of those limitations and allow, for
1:00:13example, a use case where, you know, I
might be in a local-first note taking app,
1:00:18and I might have written a note and I want
to, you know, copy a piece of that note,
1:00:22and I want to send that out to one of my
text messaging recipients or one of my
1:00:26chat recipients or whatever, so I can take
that note and I can synchronize, I can
1:00:31share that information to this other app
in a fully secure, end to end secured way.
1:00:36But it ends up in my other app, and
that other app pops up, and there it is,
1:00:40in the exact same way that, you know,
you can currently do sharing intents.
1:00:45Native apps have that, but the web has
always been, you know, a third class
1:00:50citizen at best in that sort of cross
app collaboration and in sharing story.
1:00:57And I think we can make it a
fully first class story this way.
1:01:01And I think that also takes us in
possibly even a step further that
1:01:05goes beyond today's conversation.
1:01:07so far we talked about identity
and also a part of that identity is
1:01:12like authenticating as assuming that
identity or being denied that identity.
1:01:17that's often abbreviated as Auth, but
Auth can also mean another non abbreviated
1:01:24word, which is authorization, which I
think this is not yet covering that,
1:01:29but there, I want to plug another very
interesting project that is more around
1:01:34authorization, which is called Beehive.
1:01:37that's also been published on
the Ink and Switch website.
1:01:41and there's currently,
I think, not yet a full.
1:01:44Inc & Switch style essay about that, but
there are some notes being taken on this.
1:01:50And so this is a project that, Brooklyn
Zelenka and Alex Good is currently
1:01:54working on that is, also ongoing
research in combination with AutoMerge.
1:02:00And Brooklyn has been exploring a lot
of that, as her previous work On vision
1:02:05and related projects, so, and this is
where, the authorization concepts to my
1:02:10understanding is sort of based around
the ideas of capabilities and, that
1:02:17different users can basically, share
capabilities, and privileges basically
1:02:22up to a level that they have themselves,
whether it's read or write and so on.
1:02:27So I'm sure this is like an equally
deep and challenging topic and, but they
1:02:32feel a little bit, complementary to me.
1:02:35So hopefully there's like some
convergence here as all of
1:02:39those are like very deep topics.
1:02:41I did see that Beehive
announcement just recently.
1:02:44I think that's great.
1:02:45I think we need a lot of different
flowers blooming in this field to figure
1:02:49out and find the places where there's
going to be overlap and collaboration.
1:02:53By the way, just as a little bit of a
side note, I literally just yesterday.
1:02:57learned something that maybe everybody
else listening has already known
1:03:00and I didn't know, but just for the
benefit of the audience, the word
1:03:04auth is you, A U T H as you correctly
point out, is a little too ambiguous.
1:03:08It's a little too shortened
because we don't know, do you mean
1:03:11authentication or authorization
1:03:13but I saw somebody do auth
Z for authorization versus
1:03:17auth n for authentication.
1:03:19So if we just add on that one extra
letter to that shortened word auth,
1:03:23n or auth z then we know maybe
better what we're talking about.
1:03:28So I learned that yesterday and I'm
going to use that going forward.
1:03:32Amazing.
1:03:32I was not aware of that, what that
little letter N in that context meant.
1:03:38there's also what you've
mentioned, web auth N.
1:03:41Maybe that is what it's already using.
1:03:45Perfect.
1:03:45Well, today I learned, thank you
for sharing that little learning.
1:03:49and kudos to everyone who
was already aware of that.