Skip to content

Instantly share code, notes, and snippets.

@haadcode
Created September 6, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haadcode/33223ea125d59a9524545aca082ba283 to your computer and use it in GitHub Desktop.
Save haadcode/33223ea125d59a9524545aca082ba283 to your computer and use it in GitHub Desktop.
/* Sketch of how muport identities could be used in OrbitDB */
const identitySignerFn = async (id, data) => {
// One can check here too that identity-to-be-signed is actually
// the same muport identity
if (id !== muport.getDid()) throw new Error("Trying to sign with a different identity!")
return await muport.sign(data)
}
const identityVerifierFn = async (identity) => {
// assuming the verify function signature is verify(signature, data)
return await muport.verify(identity.signatures.publicKey, identity.publicKey + identity.signatures.id)
}
it('identity verifies', async () => {
// generates and hold orbit-db signing keys
const keystore = require('orbit-db-keystore').create('./keys')
// create an identity
const identity = await IdentityProvider.createIdentity(keystore, muport.muport.getDid(), 'DID', identitySignerFn)
// verify the identity
const verified = await IdentityProvider.verifyIdentity(identity, identityVerifierFn)
assert.equal(verified, true)
})
@kesavananbu
Copy link

How can i use this in Orbit-web to generate key pair ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment