I'm rewriting some C code in Go. And in my C code I have stuff like this:
static void sharedb(unsigned char *sharedkey, unsigned char *send,
const unsigned char *received) {
unsigned char krq[96];
unsigned char buf[64];
// rest removed for brevity
indcpa_enc(send, buf, received, krq + 32);
}
Where indcpa_enc
function is defined like this:
static void indcpa_enc(unsigned char *c,
const unsigned char *m,
const unsigned char *pk,
const unsigned char *coins)
So, in my Go code instead of using char
arrays I used byte
arrays. Where I have something like this:
func SharedB(sharedKey, send, received []byte) {
var krq [96]byte
var buf [64]byte
// rest removed for brevity
INDCPAEnc(send[:], buf[:SharedKeyBytes], received[:], krq[32:32+CoinBytes])
}
Where INDCPAEnc
function is defined like this:
func INDCPAEnc(c []byte, m [SharedKeyBytes]byte, pk []byte, coins [CoinBytes]byte)
Though, this function call in Go gives me an array, regarding type mismatch. How can I convert a C code like above to a proper Go code? Also, should I use the pointer notation *
for my Go function parameters as in C?