-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
21 lines (18 loc) · 1009 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const Identities = require('orbit-db-identity-provider')
const Crypto = require('@arkecosystem/crypto');
class CoreIdentityProvider extends Identities.IdentityProvider {
static get type() { return 'CoreIdentityType' } // return type
async getId(options) {
const publicKey = Crypto.Identities.PublicKey.fromPassphrase(options.passphrase);
return publicKey;
} // return identifier of external id (eg. a public key)
async signIdentity(data, options) {
const signed = Crypto.Crypto.Message.sign(data, options.passphrase);
return signed.signature;
} //return a signature of data (signature of the OrbtiDB public key)
static async verifyIdentity(identity) {
const verified = Crypto.Crypto.Message.verify({ message: identity.publicKey + identity.signatures.id, signature: identity.signatures.publicKey, publicKey: identity.id });
return verified;
} //return true if identity.sigantures are valid
}
exports.default = CoreIdentityProvider;