Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(vanity): verify a receipt under the difficulty model it was issued with
nirholas6f328c4d17e3
diff --git a/scripts/verify-vanity-receipt.mjs b/scripts/verify-vanity-receipt.mjsindex e06cc6700..363c670fa 100644--- a/scripts/verify-vanity-receipt.mjs+++ b/scripts/verify-vanity-receipt.mjs@@ -35,6 +35,7 @@ import { hmac } from '@noble/hashes/hmac';import { hkdf } from '@noble/hashes/hkdf';import { gcm } from '@noble/ciphers/aes.js';import { bytesToHex, hexToBytes, concatBytes } from '@noble/hashes/utils';+import { difficultyModel, DIFFICULTY_MODEL_V1 } from '../src/solana/vanity/validation.js';const PROTOCOL_VERSION = 'three-vanity/v1';const WELL_KNOWN = 'https://three.ws/.well-known/three-vanity.json';@@ -90,15 +91,16 @@ function addressMatchesPattern(address, { prefix = '', suffix = '', ignoreCase =if (s && !a.endsWith(s)) return false;return true;}-function expectedAttempts(prefix = '', suffix = '', ignoreCase = false) {- const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';- let attempts = 1;- for (const ch of (prefix || '') + (suffix || '')) {- const lower = ch.toLowerCase(), upper = ch.toUpperCase();- const two = ignoreCase && lower !== upper && alphabet.includes(lower) && alphabet.includes(upper);- attempts *= 58 / (two ? 2 : 1);- }- return attempts;+/**+ * Expected attempts under the model a receipt was ISSUED under, named in its+ * own signed `difficulty.model`. The leading Base58 character is not uniform,+ * so `base58-exact/v2` scores it from the real distribution while `v1`+ * receipts keep verifying against the flat 58^n model they were issued under.+ * An absent field means v1, matching `verifyVanityReceipt` in the module the+ * page and SDK share.+ */+function expectedAttemptsForModel(model, prefix = '', suffix = '', ignoreCase = false) {+ return difficultyModel(model || DIFFICULTY_MODEL_V1)(prefix, suffix, ignoreCase);}const SIGNED_FIELDS = ['protocol', 'receiptType', 'address', 'pattern', 'commitment', 'serverSeed', 'clientSeed', 'requestNonce', 'winningIndex', 'attempts', 'durationMs', 'difficulty', 'sealed', 'sealedScheme', 'sealedRecipient', 'sealedEpk', 'network', 'ts'];function projectSignedCore(obj) {@@ -222,10 +224,12 @@ function runChecks(receipt, { servicePublicKey, openedSecretSeed }) {}{const p = receipt.pattern || {};- const expected = Math.round(expectedAttempts(p.prefix || '', p.suffix || '', !!p.ignoreCase));+ const model = receipt.difficulty?.model || DIFFICULTY_MODEL_V1;+ const expected = Math.round(expectedAttemptsForModel(model, p.prefix || '', p.suffix || '', !!p.ignoreCase));const ok = Number(receipt.difficulty?.expectedAttempts) === expected;add('difficulty', 'Difficulty matches the honest model', ok,- ok ? `expectedAttempts = ${expected}` : `claims ${receipt.difficulty?.expectedAttempts}, model = ${expected}`);+ ok ? `expectedAttempts = ${expected} under ${model}`+ : `claims ${receipt.difficulty?.expectedAttempts}, ${model} model = ${expected}`);}{const sigOk = verifySignature(receipt, servicePublicKey);