TasQ ZK Layer
TasQ Zero-Knowledge Ledger System
TasQ’s ledger processes and validates tasks without exposing sensitive data. It integrates Groth16 for fast succinct proofs and PlonK for universal circuits. Proofs are generated at the node, verified by the ledger, and anchored to Ethereum for auditability.
Privacy-First Task Flow
Client encrypts payload with a per-session key, uploads chunks, and submits a task commitment.
Scheduler assigns microtasks. Nodes receive only encrypted chunks plus public parameters.
Nodes compute results and generate ZK proofs.
Ledger verifies proofs, aggregates results, and finalizes a Merkle root for the task.
Circuit Definition (Circom example)
pragma circom 2.1.6;
include "circomlib/circuits/poseidon.circom";
// Proves y = H(x) without revealing x
component main {public [y]} = Poseidon(1);
signal input x;
main.inputs[0] <== x;
y <== main.out;
Node-side Proof Generation (TypeScript using snarkjs)
import { groth16 } from "snarkjs";
const { proof, publicSignals } = await groth16.fullProve(
{ x: privInput },
"poseidon_js/poseidon.wasm",
"poseidon_final.zkey"
);
// attach proof with result
submitResult({ taskId, shardId, resultHash, proof, publicSignals });
Verifier Invocation (TypeScript)
import { verify } from "snarkjs";
const ok = await verify(vKey, proof, publicSignals);
if (!ok) throw new Error("invalid proof");
Ledger Entry Schema (JSON)
{
"taskId": "0x...",
"shardId": 12,
"nodeId": "ledger:ed25519:...",
"resultHash": "0x...",
"proofRef": "ipfs://...",
"publicSignals": ["0x..."],
"gasUsed": 142356,
"ts": 1723542334
}
Go Scheduler and Routing
type Node struct { ID string; Score float64; Busy bool }
func assignTask(t Task, pool []Node) Node {
sort.Slice(pool, func(i, j int) bool { return pool[i].Score > pool[j].Score })
for _, n := range pool { if !n.Busy { return n } }
return pool[0]
}
gRPC Interface (proto)
service Worker {
rpc FetchShard(FetchReq) returns (ShardResp);
rpc SubmitProof(ProofReq) returns (Ack);
}
message ProofReq { string task_id = 1; uint32 shard_id = 2; bytes result_hash = 3; bytes proof = 4; repeated bytes public_signals = 5; }
Solidity: Minimal Proof Anchor and Payout Escrow (Ethereum mainnet)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IVerifier { function verifyProof(bytes calldata proof, uint256[] calldata pubSignals) external view returns (bool); }
contract TasqEscrow {
IVerifier public verifier; address public payoutToken; // ERC20
mapping(bytes32 => bool) public finalized; // taskRoot => finalized
event Finalized(bytes32 taskRoot, address[] payees, uint256[] amounts);
constructor(address _verifier, address _token){ verifier = IVerifier(_verifier); payoutToken = _token; }
function finalize(bytes32 taskRoot, bytes calldata proof, uint256[] calldata pubSignals, address[] calldata payees, uint256[] calldata amounts) external {
require(!finalized[taskRoot], "already");
require(verifier.verifyProof(proof, pubSignals), "bad proof");
finalized[taskRoot] = true;
// transfer payouts from contract balance
for (uint i; i < payees.length; i++) {
(bool ok, bytes memory d) = payoutToken.call(abi.encodeWithSignature("transfer(address,uint256)", payees[i], amounts[i]));
require(ok && (d.length == 0 || abi.decode(d,(bool))), "transfer failed");
}
emit Finalized(taskRoot, payees, amounts);
}
}
Optimism Credit Mint (Solidity, ERC-1155 style)
contract TasqCredits is ERC1155 {
address public ledger; modifier onlyLedger(){ require(msg.sender==ledger,"ledger"); _; }
constructor(string memory uri_, address l){ _setURI(uri_); ledger = l; }
function mint(address to, uint256 id, uint256 amt) external onlyLedger { _mint(to, id, amt, ""); }
}
Merkle Aggregation of Shards
import { MerkleTree } from "merkletreejs"; import keccak256 from "keccak256";
const leaves = shardResults.map(r => keccak256(Buffer.from(r.resultHash.slice(2), "hex")));
const tree = new MerkleTree(leaves, keccak256, { sortPairs: true });
const root = tree.getHexRoot();
await escrow.finalize(root, aggProof, aggSignals, payees, amounts);
Security and Transport
TLS 1.3 for all gRPC channels
Ed25519 identities for nodes with BLAKE3 commitments
Nonce-seeded workloads to prevent replay of benchmarks or results
Performance Optimizations
WebAssembly workers for parallel proof generation
Proof batching and single aggregate verification per task
Caching of verification keys and circuit metadata
This end-to-end flow covers circuit design, node proof generation, transport, ledger recording, Merkle aggregation, and Ethereum anchoring with escrow payouts. It keeps data private, results verifiable, and settlements transparent.
Last updated