Post
Topic
Board Announcements (Altcoins)
Re: [ANN][LISK] Lisk | ICO | Decentralized Application & Sidechain Platform
by
rlh
on 19/04/2016, 15:03:35 UTC
Quote from: Github Source
Code:

//Lines 260-265
private.openAccount = function (secret, cb) {
var hash = crypto.createHash('sha256').update(secret, 'utf8').digest();
var keypair = ed.MakeKeypair(hash);

self.setAccountAndGet({publicKey: keypair.publicKey.toString('hex')}, cb);
}


//Lines 268-280
Accounts.prototype.generateAddressByPublicKey = function (publicKey) {
var publicKeyHash = crypto.createHash('sha256').update(publicKey, 'hex').digest();
var temp = new Buffer(8);
for (var i = 0; i < 8; i++) {
temp[i] = publicKeyHash[7 - i];
}

var address = bignum.fromBuffer(temp).toString() + 'L';
if (!address) {
throw Error("wrong publicKey " + publicKey);
}
return address;
}

EDIT:

Please let me know if I'm understanding this correctly.  To get a Lisk address, all I do is take the SHA-256 hash of the secret key, derive the Ed25519 pub/priv-key pair and then convert the first 7 bytes of the pub-key to a long?  What is the "cb" parameter?  I see it passed around everywhere and I also see that some method is named that.  I can't readily find it's definition.