I'm trying to implement the curve25519 algo for pubkey generation. But I got stuck on how to generate pubkey from sha256 encoded string in Go?
I have no problems with generation pubkey from sha256 encoded string via Python:
import hashlib
import x25519
example_string = 'kerielle'
sha = hashlib.sha256(example_string.encode()).hexdigest()
hash_bytes = bytes.fromhex(sha)
public_key = x25519.scalar_base_mult(hash_bytes)
hex_res = public_key.hex()
print(hex_res)
>>> 0fa065fcaedecef9aebb5c79ea1c613e82bc5534c4b139d71f3a1cb0cb956652
But how to do the same in Go? Here basic example:
var publicKey [32]byte
privateKey := (*[32]byte)(bytes.Repeat([]byte("1"), 32))
curve25519.ScalarBaseMult(&publicKey, privateKey)
fmt.Printf("%x\n", publicKey)
>>> 04f5f29162c31a8defa18e6e742224ee806fc1718a278be859ba5620402b8f3a