// hash_sha3x.go package sha3x /* #cgo CFLAGS : -I../include #cgo LDFLAGS: -L../lib -lsha3x #include #include #include "sha3xapi.h" */ import "C" import ( //"encoding/hex" //"log" "unsafe" ) func BuildPowHash(h Sha3xBlockHeader) []byte { outputs := make([]byte, 32) inb := Sha3xBlockHeaderToBytes(h) //log.Println("[sha3x]in", hex.EncodeToString(inb)) in := (*C.uchar)(C.CBytes(inb)) output := (*C.uchar)(C.malloc(32)) C.sha3x_hash(output, in) p := uintptr(unsafe.Pointer(output)) for i := 0; i < 32; i++ { j := *(*byte)(unsafe.Pointer(p)) outputs[i] = j p += unsafe.Sizeof(j) } C.free(unsafe.Pointer(output)) C.free(unsafe.Pointer(in)) outputs32 := make([]byte, 32) for i := 0; i < 32; i++ { outputs32[i] = outputs[i] } return outputs32 }