enclaive/enclaive-docker-nodejs-sgx

WebAssembly can not allocate memory properly

Opened this issue · 0 comments

Problem:

I'm trying to run a simple snarkjs sample in sgx enclave, but process can not start up normally.
It seems that process fail to request WebAssembly memory allocation.
Expanding enclave size to 16G still does't work.
image

CPU:

Intel(R) Xeon(R) Gold 5318Y CPU

Snarkjs Sample:

const snarkjs = require("snarkjs")
const express = require('express')
const morgan = require('morgan')
const fs = require('fs')

const app = express()
const port = 3000

// create a write stream (in append mode)
const accessLogStream = fs.createWriteStream('/data/access.log', { flags: 'a' })

app.use(morgan('combined', { stream: accessLogStream }))

app.get('/hello', (req, res) => {
    res.send(run())
})

app.get('/shutdown', (req, res) => {
    process.exit()
})

app.listen(port, () => {
    console.log(`Example app listening on port ${port}`)
})

async function run() {
    const { proof, publicSignals } = await snarkjs.plonk.fullProve({a: 3, b: 11}, "/app/demo/circuit_js/circuit.wasm", "/app/demo/circuit_final.zkey");

    console.log("Proof: ");
    console.log(JSON.stringify(proof, null, 1));

    const vKey = JSON.parse(fs.readFileSync("/app/demo/verification_key.json"));

    const res = await snarkjs.plonk.verify(vKey, publicSignals, proof);

    if (res === true) {
        console.log("Verification OK");
    } else {
        console.log("Invalid proof");
    }
}