About the format for testnet address

I’m writing a keypair generator for Libra in JS, and I’m looking for where to find the format of addresses.
Checking the code, I found out that it uses Ed25519 curve and Keccak for hashing.
I tried to port the behavior, but I can’t get expected result from public keys.
Can you please let me know how it will be?

EDIT: this is what I’m working on, and I’m not sure it is correct

1 Like

Hi @nao20010128nao, I’m not proficient with the JavaScript Elliptic package, but I believe you should be hashing the pubBytes of the keypair, i.e. replace line 67 with

return Buffer.from(keccak(this.pub.pubBytes()));

Reference

Not sure if the elliptic package adheres to the ed25519 spec in the same way as curve25519-dalek does, but we did test out a few other libraries like HACL* and the pubkey bytes were canonical.

Let me know if that worked. Happy to look into it a bit more.

Ladi

1 Like

Did you mean

return Buffer.from(keccak(this.getPublicKeyBuffer()))

?

pubBytes doesn’t exist in elliptic’s BasePoint.

I would assume yes. I checked the elliptic github and posted a reference in my original response. You just need to get the serialized bytes (32-bytes) for the Public Key in question.