This guide mirrors the repository tutorial pack for the zkTLS Twitter/X follower-count example. It is intended for developers who want to see how a browser-generated TLSNotary proof becomes a Newton task input.Documentation Index
Fetch the complete documentation index at: https://docs.newton.xyz/llms.txt
Use this file to discover all available pages before exploring further.
The package in this example is
@newton-protocol/zktls-twitter-example. It is an example SDK/demo surface for the zkTLS Twitter flow, not the production Newton SDK package.What you build
The example flow:- Opens a browser demo that talks to the TLSNotary extension.
- Creates an attester WebSocket session through the Newton sidecar.
- Generates a proof for a Twitter/X follower-count response from
api.x.com. - Stores the proof and receives a CID.
- Submits a Newton task with
proofCid,wasmArgs, and a transactionintent. - Evaluates whether the account meets the configured follower threshold.
Prerequisites
- Node.js 20+
- pnpm 9+
- A Newton API key
- A running Newton gateway and zkTLS attester sidecar
- A TLSNotary-compatible browser extension bridge
- A deployed policy client address for the Twitter/X follower policy
This example sub-package is
"private": true in package.json and is not published to npm. To use it, clone the SDK repo and build locally. Production integrations should depend on @magicnewton/newton-protocol-sdk instead.Run the example locally
Clone the SDK repository and build the example workspace:Task payload shape
The demo submits a task with a shallow camelCase client shape. The SDK converts top-level gateway params to snake_case while preserving the nestedintent object in camelCase because the gateway accepts it.
Proof retrieval and integrity
The example proof client retrieves proof bytes by CID and verifies that the returned bytes match the CID multihash before returning them to callers. The same verification runs afterstore(): the SDK re-derives the CID locally from the bytes it sent and rejects any gateway response whose CID does not match. This keeps the client boundary stable while proof storage is still IPFS-backed and prevents a malicious or misconfigured gateway from routing downstream proofCid submissions to content the client never authored.
Verification rejects unknown multihash algorithms — only sha2-256 (multicodec 0x12) is accepted. CIDs using other hash functions throw before any byte comparison runs.
The planned backend migration moves proof persistence to gateway-owned Postgres. The public store/retrieve API should remain the handoff point for the demo even when the storage backend changes.
For the full set of client-side invariants (CID integrity, WebSocket lifecycle, bounded body reads, hex caps), see the SDK Invariants reference.
Identity integration roadmap
Future iterations should bind this proof flow to Newton identity records:- Upload encrypted identity data before proof submission.
- Include identity references alongside
proofCidin policy-specific WASM args. - Validate identity domain, proof freshness, and task chain ID together in the policy.
- Move address fields to checksum-validated branded address types when the SDK adopts them.
More resources
- Repository tutorial pack:
docs/zktls-twitter/ - Example SDK:
examples/zktls-twitter/sdk/ - Browser demo:
examples/zktls-twitter/demo/ - Config fixtures:
examples/zktls-twitter/configs/