@rubric-protocol/sdk 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -100
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,107 +1,109 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @rubric-protocol/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Post-quantum AI attestation with ZK inclusion proofs.
|
|
4
|
+
|
|
5
|
+
Rubric Protocol is the independent witness layer for the AI economy - providing tamper-evident, independently verifiable audit trails for AI decisions, anchored to Hedera Consensus Service.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
npm install @rubric-protocol/sdk
|
|
4
10
|
|
|
5
11
|
## Quick Start
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
import { RubricClient } from "@rubric-protocol/sdk";
|
|
14
|
+
const client = new RubricClient({
|
|
15
|
+
baseUrl: "https://rubric-protocol.com/verify",
|
|
16
|
+
apiKey: "your-api-key",
|
|
17
|
+
});
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
const task = await tempus.tasks.submit({ type: 'compute', description: 'VWAP for HBAR/USD' });
|
|
12
|
-
const proof = await tempus.proof.get(task.attestation?.hcs_sequence!);
|
|
13
|
-
\`\`\`
|
|
19
|
+
Get an API key at https://rubric-protocol.com
|
|
14
20
|
|
|
15
|
-
##
|
|
21
|
+
## Core Concepts
|
|
22
|
+
|
|
23
|
+
Every AI decision submitted to Rubric receives:
|
|
24
|
+
|
|
25
|
+
1. An attestation record - signed with ML-DSA-65 (NIST FIPS 204 post-quantum signature)
|
|
26
|
+
2. A Merkle inclusion - aggregated into a cryptographic tree and anchored to Hedera Consensus Service
|
|
27
|
+
3. A ZK inclusion proof - independently verifiable proof your record was included in the anchored tree
|
|
28
|
+
|
|
29
|
+
The ZK proof means you hold cryptographic evidence of your record that does not require Rubric to verify.
|
|
30
|
+
|
|
31
|
+
## Submitting Attestations
|
|
32
|
+
|
|
33
|
+
const result = await client.attestations.tieredAttest({
|
|
34
|
+
data: { model: "gpt-4o", decision: "approved", confidence: 0.94 },
|
|
35
|
+
sourceId: "your-system-id",
|
|
36
|
+
pipelineId: "my-pipeline",
|
|
37
|
+
});
|
|
38
|
+
console.log(result.attestationId); // retain this
|
|
39
|
+
console.log(result.status); // buffered
|
|
40
|
+
|
|
41
|
+
## Retrieving ZK Inclusion Proofs
|
|
42
|
+
|
|
43
|
+
The proof generates asynchronously after the ~30s Merkle flush. Use the built-in polling helper:
|
|
44
|
+
|
|
45
|
+
const proof = await client.attestations.getZkProof(result.attestationId, {
|
|
46
|
+
timeoutMs: 120_000, // default 120s
|
|
47
|
+
intervalMs: 10_000, // default 10s
|
|
48
|
+
});
|
|
49
|
+
console.log(proof.status); // ready
|
|
50
|
+
console.log(proof.proof.zkRoot); // Poseidon2 Merkle root
|
|
51
|
+
console.log(proof.proof.zkPath); // 20-level inclusion path
|
|
52
|
+
console.log(proof.proof.zkLeaf); // your record leaf hash
|
|
53
|
+
console.log(proof.hcsSeqNum); // HCS sequence number
|
|
54
|
+
console.log(proof.verifyEndpoint); // endpoint to verify this proof
|
|
55
|
+
|
|
56
|
+
HTTP status codes: 202 = pending (retry), 200 = ready, 404 = not found
|
|
57
|
+
|
|
58
|
+
## ZK Proof Response Fields
|
|
59
|
+
|
|
60
|
+
status ready or pending
|
|
61
|
+
attestationId your record ID
|
|
62
|
+
flushId Merkle batch ID
|
|
63
|
+
hcsSeqNum HCS sequence number (populated ~60s after submission)
|
|
64
|
+
hcsExplorerUrl Hashscan link for on-chain verification
|
|
65
|
+
proof.zkLeaf BN254 field element - your record leaf hash
|
|
66
|
+
proof.zkRoot Poseidon2 Merkle root - matches HCS anchor
|
|
67
|
+
proof.zkPath 20-element sibling path
|
|
68
|
+
proof.zkIndices left/right indices per level
|
|
69
|
+
proof.leafIndex your position in the Merkle tree
|
|
70
|
+
circuitVersion noir-beta19-poseidon2-depth20
|
|
71
|
+
|
|
72
|
+
## Full Example
|
|
73
|
+
|
|
74
|
+
import { RubricClient } from "@rubric-protocol/sdk";
|
|
75
|
+
const client = new RubricClient({
|
|
76
|
+
baseUrl: "https://rubric-protocol.com/verify",
|
|
77
|
+
apiKey: process.env.RUBRIC_API_KEY,
|
|
78
|
+
});
|
|
79
|
+
const attest = await client.attestations.tieredAttest({
|
|
80
|
+
data: { model: "claude-3-5-sonnet", action: "content_moderation", result: "approved" },
|
|
81
|
+
sourceId: "my-ai-system",
|
|
82
|
+
});
|
|
83
|
+
const proof = await client.attestations.getZkProof(attest.attestationId);
|
|
84
|
+
console.log("zkRoot: ", proof.proof.zkRoot);
|
|
85
|
+
console.log("leafIndex:", proof.proof.leafIndex);
|
|
86
|
+
console.log("hcsSeqNum:", proof.hcsSeqNum ?? "pending");
|
|
87
|
+
|
|
88
|
+
## EU AI Act Article 12 Compliance
|
|
89
|
+
|
|
90
|
+
Rubric satisfies the tamper-evident logging requirements of EU AI Act Article 12 for high-risk AI systems.
|
|
91
|
+
|
|
92
|
+
- Timestamp independence: consensus timestamps generated by Hedera network, not Rubric
|
|
93
|
+
- Structural immutability: HCS has no DELETE or UPDATE operation by design
|
|
94
|
+
- Third-party verifiability: records verifiable against Hedera public mirror nodes without Rubric
|
|
95
|
+
- Post-quantum integrity: ML-DSA-65 signatures valid against quantum adversaries
|
|
96
|
+
- ZK inclusion proofs: customers hold independent cryptographic evidence of inclusion
|
|
97
|
+
|
|
98
|
+
## Framework Integrations
|
|
99
|
+
|
|
100
|
+
pip install autogen-rubric
|
|
101
|
+
|
|
102
|
+
Supports AutoGen, LlamaIndex, CrewAI, LangGraph, OpenAI Agents SDK, Google ADK, and more.
|
|
103
|
+
|
|
104
|
+
## Support
|
|
105
|
+
|
|
106
|
+
Website: https://rubric-protocol.com
|
|
107
|
+
Email: scott@rubric-protocol.com
|
|
16
108
|
|
|
17
|
-
|
|
18
|
-
npm install @tempus-protocol/sdk
|
|
19
|
-
\`\`\`
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### Submit a task and get attestation
|
|
24
|
-
|
|
25
|
-
\`\`\`typescript
|
|
26
|
-
const task = await tempus.tasks.submit({
|
|
27
|
-
type: 'compute',
|
|
28
|
-
description: 'HBAR/USD volume-weighted average',
|
|
29
|
-
priority: 'high',
|
|
30
|
-
capabilities_required: ['price-feed', 'aggregation'],
|
|
31
|
-
parameters: {
|
|
32
|
-
pair: 'HBAR/USD',
|
|
33
|
-
sources: ['binance', 'coinbase', 'kraken'],
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Poll for completion
|
|
38
|
-
const detail = await tempus.tasks.get(task.id);
|
|
39
|
-
console.log(detail.result);
|
|
40
|
-
console.log(detail.attestation);
|
|
41
|
-
\`\`\`
|
|
42
|
-
|
|
43
|
-
### Register an agent
|
|
44
|
-
|
|
45
|
-
\`\`\`typescript
|
|
46
|
-
const agent = await tempus.agents.register({
|
|
47
|
-
name: 'My Price Agent',
|
|
48
|
-
capabilities: ['price-feed', 'aggregation'],
|
|
49
|
-
description: 'Fetches and aggregates crypto prices',
|
|
50
|
-
version: '1.0.0',
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Heartbeat loop
|
|
54
|
-
setInterval(() => {
|
|
55
|
-
tempus.agents.heartbeat(agent.id, { status: 'idle', max_concurrent: 3 });
|
|
56
|
-
}, 30000);
|
|
57
|
-
\`\`\`
|
|
58
|
-
|
|
59
|
-
### Verify an attestation
|
|
60
|
-
|
|
61
|
-
\`\`\`typescript
|
|
62
|
-
// Public — no API key required
|
|
63
|
-
const proof = await tempus.proof.get(73);
|
|
64
|
-
console.log(proof.verification.is_valid);
|
|
65
|
-
console.log(proof.verification.hedera_explorer_url);
|
|
66
|
-
\`\`\`
|
|
67
|
-
|
|
68
|
-
### Create a pipeline
|
|
69
|
-
|
|
70
|
-
\`\`\`typescript
|
|
71
|
-
const pipeline = await tempus.pipelines.create({
|
|
72
|
-
name: 'HBAR Price Oracle',
|
|
73
|
-
steps: [
|
|
74
|
-
{ name: 'fetch', type: 'fetch', capabilities_required: ['price-feed'] },
|
|
75
|
-
{ name: 'aggregate', type: 'compute', input_from: 'fetch' },
|
|
76
|
-
{ name: 'attest', type: 'attest', input_from: 'aggregate' },
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
await tempus.pipelines.start(pipeline.id);
|
|
80
|
-
\`\`\`
|
|
81
|
-
|
|
82
|
-
### Browse marketplace
|
|
83
|
-
|
|
84
|
-
\`\`\`typescript
|
|
85
|
-
const { agents } = await tempus.marketplace.browse({
|
|
86
|
-
capability: 'price-feed',
|
|
87
|
-
min_reputation: 70,
|
|
88
|
-
sort: 'reputation',
|
|
89
|
-
});
|
|
90
|
-
\`\`\`
|
|
91
|
-
|
|
92
|
-
## All Services
|
|
93
|
-
|
|
94
|
-
| Service | Methods |
|
|
95
|
-
|---------|---------|
|
|
96
|
-
| \`tempus.health\` | \`check()\`, \`protocol()\`, \`stats()\` |
|
|
97
|
-
| \`tempus.tasks\` | \`list()\`, \`submit()\`, \`batch()\`, \`get()\`, \`bid()\`, \`assign()\`, \`submitResult()\`, \`cancel()\` |
|
|
98
|
-
| \`tempus.agents\` | \`list()\`, \`register()\`, \`get()\`, \`update()\`, \`delete()\`, \`heartbeat()\`, \`reputation()\` |
|
|
99
|
-
| \`tempus.proof\` | \`get()\` |
|
|
100
|
-
| \`tempus.pipelines\` | \`list()\`, \`create()\`, \`get()\`, \`start()\`, \`submitStepResult()\` |
|
|
101
|
-
| \`tempus.marketplace\` | \`browse()\`, \`getAgent()\`, \`getReviews()\`, \`submitReview()\`, \`upsertProfile()\`, \`categories()\`, \`featured()\`, \`stats()\` |
|
|
102
|
-
| \`tempus.analytics\` | \`get()\`, \`economics()\`, \`events()\`, \`leaderboard()\`, \`dashboard()\` |
|
|
103
|
-
| \`tempus.admin\` | \`listKeys()\`, \`createKey()\`, \`revokeKey()\`, \`retryQueue()\`, \`webhooks()\` |
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
MIT — Echelon Intelligence Systems LLC
|
|
109
|
+
Built by Echelon Intelligence Group.
|