Typescript SDK for connecting with ZKWASM cloud.
Introduction
zkWasm-service-helper(https://github.com/DelphinusLab/zkWasm-service-helper) is a typscript library to help communicate with zkwasm cloud service. It provides common APIS for ZKWASM application developers to use the cloud proving service to generate ZKWASM proofs.
How to use it
The default RPC point for ZKWASM cloud is "https://rpc.zkwasmhub.com:8090". This lib main provide a ZkWasmServiceHelper class to help user to communicate to this RPC endpoint. It mainly provides the following APIs to perform proving tasks and query informations about submitted tasks.
Example APIs:
async queryImage(md5: string);
async loadTasks(query: QueryParams);
async addNewWasmImage(task: WithSignature);
async addProvingTask(task: WithSignature);
A example to add new wasm image
This example typescript code will add the wasm image to the zkwasm service.
import {
AddImageParams,
WithSignature,
ZkWasmUtil,
zkWasmServiceHelper
} from "zkwasm-service-helper";
const endpoint = ""https://rpc.zkwasmhub.com:8090";
let helper = new ZkWasmServiceHelper(endpoint, "", "");
let imagePath = "/home/user/a.wasm";
let fileSelected: Buffer = fs.readFileSync(imagePath);
let md5 = ZkWasmUtil.convertToMd5(
fileSelected as Uint8Array
);
let info: AddImageParams = {
name: fileSelected.name,
image_md5: md5,
image: fileSelected,
user_address: account!.address.toLowerCase(),
description_url: "",
avator_url: "",
circuit_size: circuitSize,
};
let msg = ZkWasmUtil.createAddImageSignMessage(info);
let signature: string = await ZkWasmUtil.signMessage(msgString, priv); //Need user private key to sign the msg
let task: WithSignature<AddImageParams> = {
...info,
signature,
};
let response = await helper.addNewWasmImage(task);
A example to add proving tasks
This example typescript code will add proving tasks to the zkwasm service.
A example to query task details
This example typescript code will query task details:
Notes:
md5 is case insensitive when communicate with our zkwasm service
Last updated