Created
September 6, 2018 14:22
-
-
Save haadcode/33223ea125d59a9524545aca082ba283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can i use this in Orbit-web to generate key pair ?