Docs · Build
TypeScript signer
@enquantum/wots is the reference signer. It mirrors the Solidity verifier byte for byte and runs in a browser or in Node.
The package
The signer lives in packages/wots in the repository and is used by the site as a workspace package. It is not published to npm yet, so build it from the repository. Its only dependency is @noble/hashes.
npm install
npm run build -w @enquantum/wots
npm run test -w @enquantum/wots
All byte values are Uint8Array. Use hexToBytes and bytesToHex at the edges.
Seeds and key hashes
32 bytes from the platform's secure random source.
The hash to commit. Use index 0 for a first commitment or install.
import { generateSeed, derivePublicKeyHash, bytesToHex } from "@enquantum/wots";
const seed = generateSeed();
const pqKeyHash = bytesToHex(derivePublicKeyHash(seed, account, 0));
A seed that comes from an elliptic curve key falls with that key. It has to be fresh randomness, stored separately.
Signing a user operation
Derives the key for keyIndex and the one after it, signs keccak256(userOpHash ‖ nextPkHash) and returns the 2,176-byte value for userOp.signature.
import { signUserOp, hexToBytes, bytesToHex } from "@enquantum/wots";
const { signature, nextPkHash } = signUserOp(seed, account, keyIndex, hexToBytes(userOpHash));
userOp.signature = bytesToHex(signature);
// After the operation lands, the account's key hash equals nextPkHash and its index is keyIndex + 1.
Read keyIndex from keyIndexOf(account) on the validator every time.
Verifying locally
Runs the same check as the contract. Useful in tests and before submitting.
import { tweak, verify, vaultDigest } from "@enquantum/wots";
const t = tweak(account, keyIndex);
const message = vaultDigest(userOpHash, nextPkHash);
const ok = verify(t, message, signature.slice(32), currentPkHash);
Lower-level calls
deriveKeyPair(seed, account, keyIndex)returns the secret starts, public values, public key hash and tweak.sign(keyPair, message)signs any 32-byte message and returns 2,144 bytes.recoverPublicKeyHash(tweak, message, signature)returns the hash a signature implies.digits(message)returns the 67 base-16 digits, checksum included.encodeVaultSignature(nextPkHash, signature)joins the two parts of the Vault format.
The scheme itself is described on the signature scheme page.
ABIs and chains
@enquantum/abi exports the three contract ABIs, the recorded deployment addresses and chain details, typed for viem.
import { registryAbi, alarmAbi, vaultValidatorAbi, deployments, robinhoodChain, ENTRYPOINT_V07 } from "@enquantum/abi";
const addresses = deployments[String(robinhoodChain.id)]; // undefined until a deployment is recorded