# README
go-circom-witnesscalc
Witness Calculator in go, calling WASM generated from circom.
Example
package main
import (
"encoding/json"
"io/ioutil"
wasm3 "github.com/iden3/go-wasm3"
"github.com/stretchr/testify/assert"
)
func Test(t *testing.T) {
wasmFilename := "test_files/mycircuit.wasm"
inputsFilename := "test_files/mycircuit-input2.json"
runtime := wasm3.NewRuntime(&wasm3.Config{
Environment: wasm3.NewEnvironment(),
StackSize: 64 * 1024,
})
defer runtime.Destroy()
wasmBytes, err := ioutil.ReadFile(wasmFilename)
require.Nil(t, err)
module, err := runtime.ParseModule(wasmBytes)
require.Nil(t, err)
module, err = runtime.LoadModule(module)
require.Nil(t, err)
inputsBytes, err := ioutil.ReadFile(inputsFilename)
require.Nil(t, err)
inputs, err := ParseInputs(inputsBytes)
require.Nil(t, err)
witnessCalculator, err := NewWitnessCalculator(runtime, module)
require.Nil(t, err)
w, err := witnessCalculator.CalculateWitness(inputs, false)
require.Nil(t, err)
wJSON, err := json.Marshal(WitnessJSON(w))
require.Nil(t, err)
fmt.Print(string(wJSON))
}
License
GPLv3
# Functions
No description provided by the author
No description provided by the author
NewCircom2WitnessCalculator creates a new WitnessCalculator from the WitnessCalc loaded WASM module in the runtime.
NewWitnessCalculator creates a new WitnessCalculator from the WitnessCalc loaded WASM module in the runtime.
ParseInputs parses WitnessCalc inputs from JSON that consist of a map of types which contain a recursive combination of: numbers, base-10 encoded numbers in string format, arrays.
# Structs
Circom2WitnessCalculator is the object that allows performing witness calculation from signal inputs using the WitnessCalc WASM module.
WitnessCalculator is the object that allows performing witness calculation from signal inputs using the WitnessCalc WASM module.
# Type aliases
WitnessJSON is a wrapper type to Marshal the Witness in JSON format.