Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly can not allocate memory properly #1

Open
zcc35357949 opened this issue Sep 2, 2022 · 0 comments
Open

WebAssembly can not allocate memory properly #1

zcc35357949 opened this issue Sep 2, 2022 · 0 comments

Comments

@zcc35357949
Copy link

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");
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant