]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - src/js/fio-util.js
Merge pull request #466 from RitoProject/ritocoin
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / fio-util.js
1 function FIObufferToPublic(pubBuf) {
2 const Buffer = libs.buffer.Buffer;
3 const FIO_PUBLIC_PREFIX = "FIO";
4
5 let checksum = libs.createHash("rmd160").update(pubBuf).digest("hex").slice(0, 8);
6 pubBuf = Buffer.concat([pubBuf, Buffer.from(checksum, "hex")]);
7 return FIO_PUBLIC_PREFIX.concat(libs.bs58.encode(pubBuf));
8 }
9
10 function FIObufferToPrivate(privBuf) {
11 const Buffer = libs.buffer.Buffer;
12 const FIO_PRIVATE_PREFIX = "80";
13
14 privBuf = Buffer.concat([Buffer.from(FIO_PRIVATE_PREFIX, "hex"), privBuf]);
15 let tmp = libs.createHash("sha256").update(privBuf).digest();
16 let checksum = libs.createHash("sha256").update(tmp).digest("hex").slice(0, 8);
17 privBuf = Buffer.concat([privBuf, Buffer.from(checksum, "hex")]);
18 return libs.bs58.encode(privBuf);
19 }