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
build(vanity): rebuild the grinder wasm bundle from the current crate
nirholas5e48db848c99
diff --git a/crates/vanity-grinder/Cargo.toml b/crates/vanity-grinder/Cargo.tomlindex aef3a3752..544669355 100644--- a/crates/vanity-grinder/Cargo.toml+++ b/crates/vanity-grinder/Cargo.toml@@ -16,6 +16,9 @@ sha2 = { version = "0.10", default-features = false }curve25519-dalek = { version = "4", default-features = false, features = ["alloc", "precomputed-tables"] }bs58 = { version = "0.5", default-features = false, features = ["alloc"] }+[dev-dependencies]+ed25519-dalek = "2"+[profile.release]opt-level = 3lto = "fat"diff --git a/crates/vanity-grinder/src/lib.rs b/crates/vanity-grinder/src/lib.rsindex e4a891184..e0a5df416 100644--- a/crates/vanity-grinder/src/lib.rs+++ b/crates/vanity-grinder/src/lib.rs@@ -12,11 +12,11 @@//! `Keypair.fromSecretKey()` in `@solana/web3.js`.//!//! The hot loop derives each pubkey via raw curve25519-dalek primitives-//! (`SHA-512(seed) → clamp → scalar * G → compress`) — exactly the ed25519+//! (`SHA-512(seed)`, clamp, `scalar * G`, compress): exactly the ed25519//! keypair derivation but without constructing the full `SigningKey` struct//! that ed25519-dalek would normally hand back. The output pubkey is//! bit-for-bit identical to `ed25519_dalek::SigningKey::from_bytes(seed)-//! .verifying_key().to_bytes()`.+//! .verifying_key().to_bytes()`, which the native test suite proves.use curve25519_dalek::edwards::EdwardsPoint;use js_sys::{Object, Reflect, Uint8Array};@@ -33,7 +33,7 @@ fn pubkey_from_seed(seed: &[u8; 32]) -> [u8; 32] {scalar_bytes.copy_from_slice(&digest[..32]);// mul_base_clamped internally applies the ed25519 clamp (clear 3 low bits,- // clear high bit, set 254th bit) and multiplies by the basepoint — exactly+ // clear high bit, set 254th bit) and multiplies by the basepoint, exactly// what `ed25519_dalek::SigningKey::from_bytes(seed).verifying_key()` does,// minus the SigningKey-struct overhead we don't need for grinding.EdwardsPoint::mul_base_clamped(scalar_bytes)@@ -41,18 +41,22 @@ fn pubkey_from_seed(seed: &[u8; 32]) -> [u8; 32] {.to_bytes()}-#[wasm_bindgen]-pub fn grind(+/// A successful grind: the 64-byte Solana secret key (`[seed][pubkey]`) and+/// the base58 address it controls.+struct GrindHit {+ secret_key: [u8; 64],+ public_key: String,+}++/// The batch loop behind `grind`, kept free of wasm-bindgen types so the+/// native test suite can drive it directly.+fn grind_batch(prefix: &str,suffix: &str,ignore_case: bool,batch: u32,- start_seed: &[u8],-) -> JsValue {- if start_seed.len() != 32 {- return JsValue::NULL;- }-+ start_seed: &[u8; 32],+) -> Option<GrindHit> {let want_prefix: Vec<u8> = if ignore_case {prefix.to_lowercase().into_bytes()} else {@@ -66,17 +70,12 @@ pub fn grind(let p_len = want_prefix.len();let s_len = want_suffix.len();- let mut seed = [0u8; 32];- seed.copy_from_slice(start_seed);+ let mut seed = *start_seed;let base_counter = u32::from_le_bytes([seed[0], seed[1], seed[2], seed[3]]);for i in 0..batch {let counter = base_counter.wrapping_add(i);- let bytes = counter.to_le_bytes();- seed[0] = bytes[0];- seed[1] = bytes[1];- seed[2] = bytes[2];- seed[3] = bytes[3];+ seed[..4].copy_from_slice(&counter.to_le_bytes());let pub_bytes = pubkey_from_seed(&seed);@@ -113,22 +112,45 @@ pub fn grind(secret_key[..32].copy_from_slice(&seed);secret_key[32..].copy_from_slice(&pub_bytes);- let secret_array = Uint8Array::new_with_length(64);- secret_array.copy_from(&secret_key);-- let result = Object::new();- Reflect::set(&result, &JsValue::from_str("secretKey"), &secret_array.into())- .expect("set secretKey");- Reflect::set(- &result,- &JsValue::from_str("publicKey"),- &JsValue::from_str(&addr_string),- )- .expect("set publicKey");- return result.into();+ return Some(GrindHit {+ secret_key,+ public_key: addr_string,+ });}- JsValue::NULL+ None+}++#[wasm_bindgen]+pub fn grind(+ prefix: &str,+ suffix: &str,+ ignore_case: bool,+ batch: u32,+ start_seed: &[u8],+) -> JsValue {+ let Ok(seed) = <&[u8; 32]>::try_from(start_seed) else {+ return JsValue::NULL;+ };++ match grind_batch(prefix, suffix, ignore_case, batch, seed) {+ None => JsValue::NULL,+ Some(hit) => {+ let secret_array = Uint8Array::new_with_length(64);+ secret_array.copy_from(&hit.secret_key);++ let result = Object::new();+ Reflect::set(&result, &JsValue::from_str("secretKey"), &secret_array.into())+ .expect("set secretKey");+ Reflect::set(+ &result,+ &JsValue::from_str("publicKey"),+ &JsValue::from_str(&hit.public_key),+ )+ .expect("set publicKey");+ result.into()+ }+ }}fn eq_ignore_ascii_case(a: &[u8], b: &[u8]) -> bool {@@ -139,3 +161,74 @@ fn eq_ignore_ascii_case(a: &[u8], b: &[u8]) -> bool {.zip(b.iter()).all(|(x, y)| x.eq_ignore_ascii_case(y))}++#[cfg(test)]+mod tests {+ use super::*;++ /// Deterministic per-test seeds: SHA-512 of a label, truncated to 32 bytes.+ fn seed_from_label(label: &str) -> [u8; 32] {+ let mut h = Sha512::new();+ h.update(label.as_bytes());+ let digest = h.finalize();+ let mut seed = [0u8; 32];+ seed.copy_from_slice(&digest[..32]);+ seed+ }++ #[test]+ fn pubkey_derivation_is_bit_for_bit_ed25519_dalek() {+ for i in 0..64u32 {+ let seed = seed_from_label(&format!("parity-{i}"));+ let expected = ed25519_dalek::SigningKey::from_bytes(&seed)+ .verifying_key()+ .to_bytes();+ assert_eq!(pubkey_from_seed(&seed), expected, "seed #{i}");+ }+ }++ #[test]+ fn grind_finds_prefix_and_returns_solana_secret_key_layout() {+ // 'A' sits in base58's high-probability leading bucket, so a large+ // deterministic batch always lands a hit.+ let start = seed_from_label("prefix-hunt");+ let hit = grind_batch("A", "", false, 50_000, &start)+ .expect("a 50k batch always finds a leading 'A'");++ assert!(hit.public_key.starts_with('A'), "got {}", hit.public_key);++ // secretKey = [32-byte seed][32-byte pubkey], and the embedded pubkey+ // re-derives from the embedded seed.+ let mut seed = [0u8; 32];+ seed.copy_from_slice(&hit.secret_key[..32]);+ let derived = pubkey_from_seed(&seed);+ assert_eq!(&hit.secret_key[32..], &derived[..]);+ assert_eq!(bs58::encode(&derived).into_string(), hit.public_key);+ }++ #[test]+ fn grind_matches_suffix_and_ignore_case() {+ let start = seed_from_label("suffix-hunt");+ let hit = grind_batch("", "q", true, 200_000, &start)+ .expect("a 200k batch always finds a q/Q suffix");+ let last = hit.public_key.chars().last().unwrap();+ assert!(last.eq_ignore_ascii_case(&'q'), "got {}", hit.public_key);+ }++ #[test]+ fn grind_returns_none_when_batch_misses() {+ let start = seed_from_label("miss");+ // An 8-char prefix has ~1 in 58^8 odds per attempt; a 10-key batch+ // cannot hit it.+ assert!(grind_batch("AAAAAAAA", "", false, 10, &start).is_none());+ }++ #[test]+ fn counter_wraps_without_panicking() {+ let mut start = seed_from_label("wrap");+ start[..4].copy_from_slice(&u32::MAX.to_le_bytes());+ // Just proving the wrapping counter path is exercised; any outcome is+ // fine as long as it does not panic.+ let _ = grind_batch("AAAAAAAA", "", false, 16, &start);+ }+}diff --git a/src/solana/vanity/wasm/README.md b/src/solana/vanity/wasm/README.mdindex 8e8969c31..0d5676918 100644--- a/src/solana/vanity/wasm/README.md+++ b/src/solana/vanity/wasm/README.md@@ -10,15 +10,18 @@ npm run build:wasm```The artifacts are checked into the repo so the app builds without a Rust-toolchain at install time. CI / Vercel only need `npm install` + `npm run build`.+toolchain at install time. CI only needs `npm install` + `npm run build`.+This README and the `.gitignore` are rewritten by+[scripts/build-wasm.mjs](../../../../scripts/build-wasm.mjs) after every+build, because wasm-pack would otherwise clobber them.## Files-- `vanity_grinder.js` — wasm-bindgen glue (default export `init`, named export `grind`)-- `vanity_grinder_bg.wasm` — the compiled WebAssembly module-- `vanity_grinder.d.ts` — TypeScript declarations-- `vanity_grinder_bg.wasm.d.ts` — low-level wasm imports declarations-- `package.json` — generated package metadata (not published)+- `vanity_grinder.js`: wasm-bindgen glue (default export `init`, named exports `grind`, `initSync`)+- `vanity_grinder_bg.wasm`: the compiled WebAssembly module+- `vanity_grinder.d.ts`: TypeScript declarations+- `vanity_grinder_bg.wasm.d.ts`: low-level wasm imports declarations+- `package.json`: generated package metadata (not published)## APIdiff --git a/src/solana/vanity/wasm/package.json b/src/solana/vanity/wasm/package.jsonindex f0d2e1202..2bcc6374e 100644--- a/src/solana/vanity/wasm/package.json+++ b/src/solana/vanity/wasm/package.json@@ -3,7 +3,7 @@"type": "module","description": "WASM-backed Solana ed25519 vanity address grinder","version": "0.1.0",- "license": "SEE LICENSE IN LICENSE",+ "license": "MIT","files": ["vanity_grinder_bg.wasm","vanity_grinder.js",diff --git a/src/solana/vanity/wasm/vanity_grinder.js b/src/solana/vanity/wasm/vanity_grinder.jsindex 09a0a43f7..e8d35c1c7 100644--- a/src/solana/vanity/wasm/vanity_grinder.js+++ b/src/solana/vanity/wasm/vanity_grinder.js@@ -8,7 +8,6 @@* @param {Uint8Array} start_seed* @returns {any}*/-import { log } from '../../../shared/log.js';export function grind(prefix, suffix, ignore_case, batch, start_seed) {const ptr0 = passStringToWasm0(prefix, wasm.__wbindgen_export, wasm.__wbindgen_export2);const len0 = WASM_VECTOR_LEN;@@ -22,35 +21,35 @@ export function grind(prefix, suffix, ignore_case, batch, start_seed) {function __wbg_get_imports() {const import0 = {__proto__: null,- __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {const ret = debugString(getObject(arg1));const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);const len1 = WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);},- __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {throw new Error(getStringFromWasm0(arg0, arg1));},- __wbg_length_56fcd3e2b7e0299d: function(arg0) {+ __wbg_length_36bd29c6848c2144: function(arg0) {const ret = getObject(arg0).length;return ret;},- __wbg_new_02d162bc6cf02f60: function() {+ __wbg_new_ebe3e0f6837f0879: function() {const ret = new Object();return addHeapObject(ret);},- __wbg_new_with_length_99887c91eae4abab: function(arg0) {+ __wbg_new_with_length_3ffc1c56427c525c: function(arg0) {const ret = new Uint8Array(arg0 >>> 0);return addHeapObject(ret);},- __wbg_set_24d0fa9e104112f9: function(arg0, arg1, arg2) {- getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));- },- __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));return ret;}, arguments); },+ __wbg_set_b9b5b5cb7b495037: function(arg0, arg1, arg2) {+ getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));+ },__wbindgen_cast_0000000000000001: function(arg0, arg1) {// Cast intrinsic for `Ref(String) -> Externref`.const ret = getStringFromWasm0(arg0, arg1);@@ -277,14 +276,18 @@ function __wbg_finalize_init(instance, module) {async function __wbg_load(module, imports) {if (typeof Response === 'function' && module instanceof Response) {+ if (!module.ok) {+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);+ }+if (typeof WebAssembly.instantiateStreaming === 'function') {try {return await WebAssembly.instantiateStreaming(module, imports);} catch (e) {- const validResponse = module.ok && expectedResponseType(module.type);+ const validResponse = expectedResponseType(module.type);if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {- log.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);} else { throw e; }}@@ -318,7 +321,7 @@ function initSync(module) {if (Object.getPrototypeOf(module) === Object.prototype) {({module} = module)} else {- log.warn('using deprecated parameters for `initSync()`; pass a single object instead')+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')}}@@ -338,7 +341,7 @@ async function __wbg_init(module_or_path) {if (Object.getPrototypeOf(module_or_path) === Object.prototype) {({module_or_path} = module_or_path)} else {- log.warn('using deprecated parameters for the initialization function; pass a single object instead')+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')}}diff --git a/src/solana/vanity/wasm/vanity_grinder_bg.wasm b/src/solana/vanity/wasm/vanity_grinder_bg.wasmindex 594caf190..a8d74dfcb 100644Binary files a/src/solana/vanity/wasm/vanity_grinder_bg.wasm and b/src/solana/vanity/wasm/vanity_grinder_bg.wasm differ