mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-08 23:17:54 -05:00
41 lines
1.3 KiB
Cheetah
41 lines
1.3 KiB
Cheetah
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
core "github.com/ingonyama-zk/icicle/v2/wrappers/golang/core"
|
|
cr "github.com/ingonyama-zk/icicle/v2/wrappers/golang/cuda_runtime"
|
|
{{.Field}} "github.com/ingonyama-zk/icicle/v2/wrappers/golang/{{.BaseImportPath}}"
|
|
poseidon "github.com/ingonyama-zk/icicle/v2/wrappers/golang/{{.BaseImportPath}}/poseidon"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPoseidon(t *testing.T) {
|
|
|
|
arity := 2
|
|
numberOfStates := 1
|
|
|
|
ctx, _ := cr.GetDefaultDeviceContext()
|
|
p, err := poseidon.Load(uint32(arity), &ctx)
|
|
assert.Equal(t, core.IcicleSuccess, err.IcicleErrorCode)
|
|
|
|
cfg := p.GetDefaultHashConfig()
|
|
|
|
scalars := {{.Field}}.GenerateScalars(numberOfStates * arity)
|
|
scalars[0] = scalars[0].Zero()
|
|
scalars[1] = scalars[0].Zero()
|
|
|
|
scalarsCopy := core.HostSliceFromElements(scalars[:numberOfStates*arity])
|
|
|
|
var deviceInput core.DeviceSlice
|
|
scalarsCopy.CopyToDevice(&deviceInput, true)
|
|
var deviceOutput core.DeviceSlice
|
|
deviceOutput.Malloc(numberOfStates*scalarsCopy.SizeOfElement(), scalarsCopy.SizeOfElement())
|
|
|
|
err = p.HashMany(deviceInput, deviceOutput, uint32(numberOfStates), 1, 1, &cfg) //run Hash function
|
|
assert.Equal(t, core.IcicleSuccess, err.IcicleErrorCode)
|
|
|
|
output := make(core.HostSlice[{{.Field}}.ScalarField], numberOfStates)
|
|
output.CopyFromDevice(&deviceOutput)
|
|
}
|