diff --git a/API.md b/API.md index cd675c5..f1b11c6 100644 --- a/API.md +++ b/API.md @@ -374,7 +374,23 @@ await db.drop() #### key -The [keypair]([orbit-db-keystore]()) used to access the database. +The [keypair](https://github.com/orbitdb/orbit-db/blob/master/GUIDE.md#keys) used to access the database. + +``` +const key = db.key +console.log(key) +// > +``` + +The key contains the keypair used to sign the database entries. The public key can be retrieved with: +``` +console.log(db.key.getPublic('hex')) +// 04d009bd530f2fa0cda29202e1b15e97247893cb1e88601968abfe787f7ea03828fdb7624a618fd67c4c437ad7f48e670cc5a6ea2340b896e42b0c8a3e4d54aebe +``` + +The key can also be accessed from the [OrbitDB](#orbitdb) instance: `orbitdb.key.getPublic('hex')`. #### type diff --git a/GUIDE.md b/GUIDE.md index 3be03e4..e2b5602 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -132,13 +132,19 @@ The database manifest can be fetched from IPFS and it looks like this: ### Keys Each entry in a database is signed by who created that entry. The signing key, the key that a peer uses to sign entries, can be accessed as a member variable of the database instance: + ``` -db.key +const key = db.key +console.log(key) +// > ``` The key contains the keypair used to sign the database entries. The public key can be retrieved with: ``` -db.key.getPublic('hex') +console.log(db.key.getPublic('hex')) +// 04d009bd530f2fa0cda29202e1b15e97247893cb1e88601968abfe787f7ea03828fdb7624a618fd67c4c437ad7f48e670cc5a6ea2340b896e42b0c8a3e4d54aebe ``` The key can also be accessed from the OrbitDB instance: `orbitdb.key.getPublic('hex')`.