]>
git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - src/js/eos-util.js
1 function EOSbufferToPublic(pubBuf
) {
2 const Buffer
= libs
.buffer
.Buffer
;
3 const EOS_PUBLIC_PREFIX
= "EOS";
4 let checksum
= libs
.createHash("rmd160").update(pubBuf
).digest("hex").slice(0, 8);
5 pubBuf
= Buffer
.concat([pubBuf
, Buffer
.from(checksum
, "hex")]);
6 return EOS_PUBLIC_PREFIX
.concat(libs
.bs58
.encode(pubBuf
));
9 function EOSbufferToPrivate(privBuf
) {
10 const Buffer
= libs
.buffer
.Buffer
;
11 const EOS_PRIVATE_PREFIX
= "80";
12 privBuf
= Buffer
.concat([Buffer
.from(EOS_PRIVATE_PREFIX
, "hex"), privBuf
]);
13 let tmp
= libs
.createHash("sha256").update(privBuf
).digest();
14 let checksum
= libs
.createHash("sha256").update(tmp
).digest("hex").slice(0, 8);
15 privBuf
= Buffer
.concat([privBuf
, Buffer
.from(checksum
, "hex")]);
16 return libs
.bs58
.encode(privBuf
);