Skip to content

Commit 39542d8

Browse files
committed
BLS12-381 circuits with output commitments, ENS source tracking
Circuits: - Compiled from updated Verity compiler (Circom.lean) that makes Poseidon commitments circuit OUTPUTS instead of inputs - Compiled with circom --prime bls12381, vkeys report curve: bls12381 - No JS Poseidon needed (circomlibjs removed from proof pipeline) Frontend: - Spec lookup shows source: "from veryclear.eth" (green) or "static fallback" (amber) so user sees where the spec came from - ENS reader normalizes old format (specName) to new format (spec) - Circuit commitment check uses cached ENS lookup (no redundant RPC) - Removed unused imports
1 parent cb684f2 commit 39542d8

3 files changed

Lines changed: 51 additions & 13 deletions

File tree

src/app/clear-signing/engine/ens.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,18 @@ export async function readSpecFromEns(
9999
}
100100

101101
console.log("[ENS] Found:", value);
102-
const entry = JSON.parse(value) as EnsSpecEntry;
102+
const raw = JSON.parse(value);
103+
// Normalize: support both old format (specName/type/decimals/symbol)
104+
// and new format (spec/deploy/circuits)
105+
const entry: EnsSpecEntry = raw.spec
106+
? raw
107+
: {
108+
spec: raw.specName,
109+
deploy: (raw.decimals || raw.symbol)
110+
? { decimals: raw.decimals, symbol: raw.symbol }
111+
: undefined,
112+
circuits: raw.circuits,
113+
};
103114
ensCache.set(cacheKey, { entry, ts: Date.now() });
104115
return entry;
105116
} catch (e) {

src/app/clear-signing/engine/specs.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,45 @@ export const SPECS = STATIC_SPECS;
5252

5353
// ─── ENS-aware lookup ───────────────────────────────────────────────────────
5454

55+
export type SpecLookupResult = {
56+
spec: IntentSpec;
57+
/** Where the spec was resolved from */
58+
source: "ens" | "static";
59+
/** ENS entry if resolved from ENS */
60+
ensEntry?: EnsSpecEntry;
61+
};
62+
5563
/**
5664
* Find a spec by contract address.
5765
* Tries ENS first (veryclear.eth), falls back to static registry.
66+
* Returns the source so the UI can show where the spec came from.
5867
*/
5968
export async function findSpecFromEns(
6069
contractAddress: string
61-
): Promise<IntentSpec | null> {
70+
): Promise<SpecLookupResult | null> {
71+
// Try ENS (veryclear.eth)
6272
const ensEntry = await readSpecFromEns(contractAddress);
6373
if (ensEntry) {
6474
const json = SPEC_JSONS[ensEntry.spec];
6575
if (json) {
66-
return loadIntentSpec(json, contractAddress, ensEntry);
76+
console.log("[specs] Resolved from ENS:", ensEntry.spec);
77+
return {
78+
spec: loadIntentSpec(json, contractAddress, ensEntry),
79+
source: "ens",
80+
ensEntry,
81+
};
6782
}
83+
console.warn("[specs] ENS entry found but no matching spec JSON:", ensEntry.spec);
6884
}
69-
return STATIC_SPECS[contractAddress.toLowerCase()] ?? null;
85+
86+
// Fall back to static registry
87+
const staticSpec = STATIC_SPECS[contractAddress.toLowerCase()];
88+
if (staticSpec) {
89+
console.log("[specs] Resolved from static fallback");
90+
return { spec: staticSpec, source: "static" };
91+
}
92+
93+
return null;
7094
}
7195

7296
/** Synchronous fallback (for non-async contexts). */

src/app/clear-signing/page.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
getVkeyHash,
1717
type ProofResult,
1818
} from "./engine/prover";
19-
import { readSpecFromEns, type EnsSpecEntry } from "./engine/ens";
2019
import { DEMO_EXAMPLE } from "./engine/examples";
2120
import type {
2221
IntentSpec,
@@ -32,7 +31,7 @@ import type {
3231
// ─── Types ──────────────────────────────────────────────────────────────────
3332

3433
type Step =
35-
| { kind: "spec-match"; spec: IntentSpec | null; address: string }
34+
| { kind: "spec-match"; spec: IntentSpec | null; address: string; source?: "ens" | "static" }
3635
| { kind: "function-id"; binding: Binding | null; selector: string }
3736
| {
3837
kind: "calldata-decode";
@@ -354,7 +353,12 @@ function SpecMatchStep({
354353
</span>{" "}
355354
matches{" "}
356355
<strong className="font-semibold">{step.spec.contractName}</strong>{" "}
357-
spec
356+
spec{" "}
357+
<span className={`text-[12px] font-mono ${
358+
step.source === "ens" ? "text-emerald-600" : "text-amber-500"
359+
}`}>
360+
({step.source === "ens" ? "from veryclear.eth" : "static fallback"})
361+
</span>
358362
</p>
359363
{spec && LEAN_SOURCES[spec.contractName] && (
360364
<details className="mt-2">
@@ -829,11 +833,11 @@ export default function ClearSigningPage() {
829833
try {
830834
// Step 1: Spec lookup
831835
await delay(300);
832-
spec = await findSpecFromEns(contractAddress);
833-
addStep({ kind: "spec-match", spec, address: contractAddress });
836+
const lookup = await findSpecFromEns(contractAddress);
837+
spec = lookup?.spec ?? null;
838+
addStep({ kind: "spec-match", spec, address: contractAddress, source: lookup?.source });
834839
if (spec) setActiveSpec(spec);
835840
if (!spec) {
836-
837841
return;
838842
}
839843

@@ -949,10 +953,9 @@ export default function ClearSigningPage() {
949953

950954
// Verify circuit commitment against ENS registry
951955
let circuitCheck: { ensHash: string | null; localHash: string | null; match: boolean } | undefined;
952-
const ensEntry = await readSpecFromEns(contractAddress);
953956
const localHash = await getVkeyHash(spec.contractName, binding.intentFnName);
954-
if (ensEntry?.circuits && localHash) {
955-
const ensHash = ensEntry.circuits[binding.intentFnName] ?? null;
957+
if (lookup?.ensEntry?.circuits && localHash) {
958+
const ensHash = lookup.ensEntry.circuits[binding.intentFnName] ?? null;
956959
circuitCheck = {
957960
ensHash,
958961
localHash,

0 commit comments

Comments
 (0)