git ssb

1+

Dominic / secure-scuttlebutt



Commit 24e39a9f5115748332bf4aa241ddc0ab69d7eca2

Rename as "ssb-db"

Christian Bundy committed on 11/13/2018, 8:31:37 PM
Parent: 6d1deba60c33a9c4674e4efcf36b4a406baff090

Files changed

README.mdchanged
index.jschanged
package.jsonchanged
index.mddeleted
README.mdView
@@ -1,27 +1,27 @@
1-# secure-scuttlebutt
1+# ssb-db
22
33 A database of unforgeable append-only feeds, optimized for efficient replication for peer to peer protocols.
44
55 ## What does it do?
66
7-Secure-scuttlebutt provides tools for dealing with unforgeable append-only message
7+ssb-db provides tools for dealing with unforgeable append-only message
88 feeds. You can create a feed, post messages to that feed, verify a feed created by
99 someone else, stream messages to and from feeds, and more (see [API](#api)).
1010
1111 "Unforgeable" means that only the owner of a feed can modify that feed, as
1212 enforced by digital signing (see [Security properties](#security-properties)).
13-This property makes secure-scuttlebutt useful for peer-to-peer applications.
14-Secure-scuttlebutt also makes it easy to encrypt messages.
13+This property makes ssb-db useful for peer-to-peer applications. ssb-db also
14+makes it easy to encrypt messages.
1515
1616 ## Example
1717
1818 In this example, we create a feed, post a signed message to it, then create a stream
1919 that reads from the feed.
2020
2121 ``` js
2222 /**
23- * create a secure scuttlebutt instance and add a message to it.
23+ * create an ssb-db instance and add a message to it.
2424 */
2525
2626 var pull = require('pull-stream')
2727 var fs = require('fs')
@@ -40,9 +40,9 @@
4040 // create the db instance.
4141 // - uses leveldb.
4242 // - can only open one instance at a time.
4343
44-var ssb = require('secure-scuttlebutt/create')(pathToDB)
44+var ssb = require('ssb-db/create')(pathToDB)
4545
4646 // create a feed.
4747 // - this represents a write access / user.
4848 // - you must pass in keys.
@@ -80,10 +80,10 @@
8080 ```
8181
8282 ## Concepts
8383
84-Building upon secure-scuttlebutt requires understanding a few concepts
85-that it uses to ensure the unforgeability of message feeds.
84+Building upon ssb-db requires understanding a few concepts that it uses to
85+ensure the unforgeability of message feeds.
8686
8787 ### Identities
8888
8989 An identity is simply a public/private key pair.
@@ -103,10 +103,10 @@
103103
104104 Note that append-only really means append-only: you cannot delete an
105105 existing message. If you want to enable entities to be deleted or
106106 modified in your data model, that can be implemented in a layer on top
107-of secure-scuttlebutt using
108-[delta encoding](https://en.wikipedia.org/wiki/Delta_encoding).
107+of ssb-db using
108+[delta encoding](https://en.wikipedia.org/wiki/Delta_encoding).
109109
110110 ### Messages
111111
112112 Each message contains:
@@ -130,38 +130,39 @@
130130 any order after it's been replicated.
131131
132132 ### Object ids
133133
134-The text inside a message can refer to three types of secure-scuttlebutt
134+The text inside a message can refer to three types of ssb-db
135135 entities: messages, feeds, and blobs (i.e. attachments). Messages and
136136 blobs are referred to by their hashes, but a feed is referred to by its
137137 signing public key. Thus, a message within a feed can refer to another
138138 feed, or to a particular point _within_ a feed.
139139
140140 Object ids begin with a sigil `@` `%` and `&` for a `feedId`, `msgId`
141141 and `blobId` respectively.
142142
143-Note that secure-scuttlebutt does not include facilities for retrieving
144-a blob given the hash.
143+Note that ssb-db does not include facilities for retrieving a blob given the
144+hash.
145145
146146 ### Replication
147147
148-It is possible to easily replicate data between two SecureScuttlebutts.
148+It is possible to easily replicate data between two instances of ssb-db.
149149 First, they exchange maps of their newest data. Then, each one downloads
150150 all data newer than its newest data.
151151
152152 [Scuttlebot](https://github.com/ssbc/scuttlebot) is a tool that
153-makes it easy to replicate multiple SecureScuttlebutts using a
153+makes it easy to replicate multiple instances of ssb-db using a
154154 decentralized network.
155155
156156 ### Security properties
157-Secure-scuttlebutt maintains useful security properties even when it is
158-connected to a malicious secure-scuttlebutt database. This makes it ideal
157+
158+ssb-db maintains useful security properties even when it is
159+connected to a malicious ssb-db database. This makes it ideal
159160 as a store for peer-to-peer applications.
160161
161162 Imagine that we want to read from a feed for which we know the identity,
162-but we're connected to a malicious secure-scuttlebutt instance. As
163-long as the malicious database does not have the private key:
163+but we're connected to a malicious ssb-db instance. As long as the malicious
164+database does not have the private key:
164165
165166 - The malicious database cannot create a new feed with the same identifier
166167 - The malicious database cannot write new fake messages to the feed
167168 - The malicious database cannot reorder the messages in the feed
@@ -173,24 +174,23 @@
173174
174175
175176 ## API
176177
177-### ssb = require('secure-scuttlebutt/create')(path)
178+### ssb = require('ssb-db/create')(path)
178179
179-Create a secure-scuttlebutt database at the given path,
180-returns an instance.
180+Create an ssb-db database at the given path, returns an instance.
181181
182-### require('secure-scuttlebutt')(db, opts)
182+### require('ssb-db')(db, opts)
183183
184184 Pass in a [levelup](https://github.com/rvagg/node-levelup) instance
185185 (it must have [sublevel](https://github.com/dominictarr/level-sublevel) installed),
186186 and an options object. The options object provides the crypto
187187 and encoding functions, that are not directly tied into how
188-secure-scuttlebutt works.
188+ssb-db works.
189189
190-The following methods all apply to a `SecureScuttlebutt` instance
190+The following methods all apply to a `ssb-db` instance
191191
192-### SecureScuttlebutt#createFeed (keys?)
192+### SSBdb#createFeed (keys?)
193193
194194 Create a Feed object. A feed is a chain of messages signed
195195 by a single key (the identity of the feed).
196196 This handles the state needed to append valid messages to a feed.
@@ -217,16 +217,16 @@
217217 #### Feed#keys
218218
219219 the key pair for this feed.
220220
221-### SecureScuttlebutt#createFeedStream (opts) -> PullSource
221+### ssbDb#createFeedStream (opts) -> PullSource
222222
223223 Create a [pull-stream](https://github.com/dominictarr/pull-stream)
224224 of all the feeds in the database, ordered by timestamps.
225225 All [pull-level](https://github.com/dominictarr/pull-level) options
226226 are allowed (start, end, reverse, tail)
227227
228-### SecureScuttlebutt#createLogStream({gt: ts, tail: boolean}) -> PullSource
228+### ssbDb#createLogStream({gt: ts, tail: boolean}) -> PullSource
229229
230230 create a stream of the messages that have been written to this instance
231231 in the order they arrived. This is mainly intended for building views.
232232 The objects in this stream will be of the form:
@@ -238,24 +238,24 @@
238238 ```
239239 `timestamp` is generated by
240240 [monotonic-timestamp](https://github.com/dominictarr/monotonic-timestamp)
241241
242-### SecureScuttlebutt#createHistoryStream ({id: feedId, seq: int?, live: bool?, limit: int?, keys: bool?, values: bool?}) -> PullSource
242+### ssbDb#createHistoryStream ({id: feedId, seq: int?, live: bool?, limit: int?, keys: bool?, values: bool?}) -> PullSource
243243
244244 Create a stream of the history of `id`. If `seq > 0`, then
245245 only stream messages with sequence numbers greater than `seq`.
246246 if `live` is true, the stream will be a
247247 [live mode](https://github.com/dominictarr/pull-level#example---reading)
248248
249-### SecureScuttlebutt#messagesByType ({type: string, live: bool?}) -> PullSource
249+### ssbDb#messagesByType ({type: string, live: bool?}) -> PullSource
250250
251251 retrieve messages with a given type. All messages must have a type,
252252 so this is a good way to select messages that an application might use.
253253 Returns a source pull-stream. This function takes all the options from [pull-level#read](https://github.com/dominictarr/pull-level#example---reading)
254254 (gt, lt, gte, lte, limit, reverse, live)
255255
256256
257-### SecureScuttlebutt#links ({source: feedId?, dest: feedId|msgId|blobId?, rel: string?, meta: true?, keys: true?, values: false?, live:false?, reverse: false?}) -> PullSource
257+### ssbDb#links ({source: feedId?, dest: feedId|msgId|blobId?, rel: string?, meta: true?, keys: true?, values: false?, live:false?, reverse: false?}) -> PullSource
258258
259259 Get a stream of links from a feed to a blob/msg/feed id.
260260
261261 The objects in this stream will be of the form:
@@ -276,9 +276,9 @@
276276 > Note: if `source`, and `dest` is provided, but not `rel`, ssb will
277277 > have to scan all the links from source, and then filter by dest.
278278 > your query will be more efficient if you also provide `rel`.
279279
280-### SecureScuttlebutt#addMap (fn)
280+### ssbDb#addMap (fn)
281281
282282 Add a map function to be applied to all messages on *read*. The `fn` function
283283 is should expect `(msg, cb)`, and must eventually call `cb(err, msg)` to finish.
284284
@@ -290,9 +290,9 @@
290290 may only be made *after* the original value is saved in `msg.value.meta.original`.
291291
292292
293293 ```js
294-SecureScuttlebutt.addMap(function (msg, cb) {
294+ssbDb.addMap(function (msg, cb) {
295295 if (!msg.value.meta) {
296296 msg.value.meta = {}
297297 }
298298
@@ -302,11 +302,11 @@
302302 msg.value.meta.buzz = true
303303 cb(null, msg)
304304 })
305305
306-const metaBackup = require('secure-scuttlebutt/util').metaBackup
306+const metaBackup = require('ssb-db/util').metaBackup
307307
308-SecureScuttlebutt.addMap(function (msg, cb) {
308+ssbDb.addMap(function (msg, cb) {
309309 // This could instead go in the first map function, but it's added as a second
310310 // function for demonstration purposes to show that `msg` is passed serially.
311311 if (msg.value.meta.fizz && msg.value.meta.buzz) {
312312 msg.meta = metaBackup(msg.value, 'content')
@@ -327,7 +327,4 @@
327327 ## License
328328
329329 MIT
330330
331-
332-
333-
index.jsView
@@ -100,9 +100,9 @@
100100 }, cb)
101101 } else if (Number.isInteger(key)) {
102102 _get(key, cb) // seq
103103 } else {
104- throw new Error('secure-scuttlebutt.get: key *must* be a ssb message id or a flume offset')
104+ throw new Error('ssb-db.get: key *must* be a ssb message id or a flume offset')
105105 }
106106 }
107107
108108 db.add = function (msg, cb) {
package.jsonView
@@ -1,12 +1,12 @@
11 {
2- "name": "secure-scuttlebutt",
2+ "name": "ssb-db",
33 "description": "a secure, replicatable database",
44 "version": "18.6.0",
5- "homepage": "https://github.com/ssbc/secure-scuttlebutt",
5+ "homepage": "https://github.com/ssbc/ssb-db",
66 "repository": {
77 "type": "git",
8- "url": "git://github.com/ssbc/secure-scuttlebutt.git"
8+ "url": "git://github.com/ssbc/ssb-db.git"
99 },
1010 "dependencies": {
1111 "async-write": "^2.1.0",
1212 "cont": "~1.0.0",
index.mdView
@@ -1,135 +1,0 @@
1-# Secure Scuttlebutt
2-
3-Secure Scuttlebutt is a database protocol for unforgeable append-only message feeds.
4-
5-"Unforgeable" means that only the owner of a feed can update that feed, as enforced by digital signing (see [Security properties](#security-properties)).
6-This property makes Secure Scuttlebutt useful for peer-to-peer applications.
7-Secure Scuttlebutt also makes it easy to encrypt messages.
8-
9-## Concepts
10-
11-Building upon Secure Scuttlebutt requires understanding a few concepts that it uses to ensure the unforgeability of message feeds.
12-
13-### Identities
14-
15-An identity is simply a [ed25519 key pair](http://ed25519.cr.yp.to/).
16-The public key is used as the identifier.
17-
18-There is no worldwide store of identities.
19-Users must exchange pubkeys, either by publishing them on their feeds, or out-of-band.
20-
21-### Feeds
22-
23-A feed is a signed append-only sequence of messages.
24-Each identity has exactly one feed.
25-
26-Note that append-only means you cannot delete an existing message, or change your history.
27-This is enforced by a per-feed blockchain.
28-This is to ensure the entire network converges on the same state.
29-
30-### Messages
31-
32-Each message contains:
33-
34-- A signature
35-- The signing public key
36-- A content-hash of the previous message
37-- A sequence number
38-- A timestamp
39-- An identifier of the hashing algorithm in use (currently only "sha256" is supported)
40-- A content object
41-
42-Here's an example message:
43-
44-```js
45-{
46- "previous": "%26AC+gU0t74jRGVeDY013cVghlZRc0nfUAnMnutGGHM=.sha256",
47- "author": "@hxGxqPrplLjRG2vtjQL87abX4QKqeLgCwQpS730nNwE=.ed25519",
48- "sequence": 216,
49- "timestamp": 1442590513298,
50- "hash": "sha256",
51- "content": {
52- "type": "vote",
53- "vote": {
54- "link": "%WbQ4dq0m/zu5jxll9zUbe0iGmDOajCx1ZkLKjZ80JvI=.sha256",
55- "value": 1
56- }
57- },
58- "signature": "Sjq1C3yiKdmi1TWvNqxIk1ZQBf4pPJYl0HHRDVf/xjm5tWJHBaW4kXo6mHPcUMbJYUtc03IvPwVqB+BMnBgmAQ==.sig.ed25519"
59-}
60-```
61-
62-### Entity References (Links)
63-
64-Messages can reference three types of Secure Scuttlebutt entities: messages, feeds, and blobs (i.e. files).
65-Messages and blobs are referred to by their hashes, but a feed is referred to by its signing public key.
66-
67-[» Content-Hash Links](https://ssbc.github.io/docs/ssb/linking.html)
68-
69-### Confidentiality
70-
71-For private sharing, Scuttlebot uses [libsodium](http://doc.libsodium.org/) to encrypt confidential log-entries.
72-Feed IDs are public keys, and so once two feeds are mutually following each other, they can exchange confidential data freely.
73-
74-[» Private Box](https://ssbc.github.io/docs/ssb/end-to-end-encryption.html)
75-
76-### Following
77-
78-Users choose which feeds to synchronize by following them.
79-Presently, [Scuttlebot's replicate plugin](https://ssbc.github.io/scuttlebot/plugins/replicate.html), which is enabled by default, looks on the master user's feed for [type: contact](https://ssbc.github.io/ssb-msg-schemas) messages to know which users are currently followed.
80-
81-### Replication
82-
83-Since feeds are append-only, replication is simple: request all messages in the feed that are newer than the latest message you know about.
84-Scuttlebot maintains a table of known peers, which it cycles through, asking for updates for all followed feeds.
85-
86-### Gossip
87-
88-The protocol creates a [global gossip network](https://en.wikipedia.org/wiki/Gossip_protocol).
89-This means that information is able to distribute across multiple machines, without requiring direct connections between them.
90-
91-![Gossip graph](https://ssbc.github.io/docs/gossip-graph1.png)
92-
93-Even though Alice and Dan lack a direct connection, they can still exchange feeds:
94-
95-![Gossip graph 2](https://ssbc.github.io/docs/gossip-graph2.png)
96-
97-This is because gossip creates "transitive" connections between computers.
98-Dan's messages travel through Carla and the Pub to reach Alice, and visa-versa.
99-
100-### LAN connectivity
101-
102-SSB is hostless: each computer installs the same copy of software and has equal rights in the network.
103-Devices discover each other over the LAN with multicast UDP and sync automatically.
104-
105-### Pub Servers
106-
107-To sync across the Internet, "Pub" nodes run at public IPs and follow users.
108-They are essentially mail-bots which improve uptime and availability.
109-Users generate invite-codes to command Pubs to follow their friends.
110-The SSB team runs some Pubs, but anybody can create and introduce their own.
111-
112-## Security properties
113-
114-Secure Scuttlebutt maintains useful security properties even when it is connected to a malicious Secure Scuttlebutt database.
115-This makes it ideal as a store for peer-to-peer applications.
116-
117-Imagine that we want to read from a feed for which we know the identity, but we're connected to a malicious Secure Scuttlebutt instance.
118-As long as the malicious database does not have the private key:
119-
120-- The malicious database cannot create a new feed with the same identifier
121-- The malicious database cannot write new fake messages to the feed
122-- The malicious database cannot reorder the messages in the feed
123-- The malicious database cannot send us a new copy of the feed that omits messages from the middle
124-- The malicious database *can* refuse to send us the feed, or only send us the first *N* messages in the feed
125-- Messages may optionally be encrypted
126-
127-Additionally there is a protection from the feed owner, through the blockchain.
128-The `previous` content-hash prevents them from changing the feed history after publishing, as a newly-created message wouldn't match the hash of later messages which were already replicated.
129-This ensures the append-only constraint, and thus safe network convergence.
130-
131-## Further Reading
132-
133-- [Design Challenge: Avoid Centralization and Singletons](https://ssbc.github.io/docs/articles/design-challenge-avoid-centralization-and-singletons.html)
134-- [Design Challenge: Sybil Attacks](https://ssbc.github.io/docs/articles/design-challenge-sybil-attack.html)
135-- [Using Trust in Open Networks](https://ssbc.github.io/docs/articles/using-trust-in-open-networks.html)

Built with git-ssb-web