SDK
Overview
The OPEQ SDK puts quantum-resistant accounts into your own code. An OPEQ account is controlled by one-time hash-based keys (WOTS+ in a Merkle tree of 1024 keys) instead of an elliptic-curve key, so a quantum computer that breaks Ed25519 or secp256k1 does not break it.
It is the same code the OPEQ wallet runs. The library is copied byte for byte from the wallet, and the test suite fails if the two ever differ. It has no dependencies and is open source under the Apache 2.0 license.
- Networks
- Solana, Ethereum, Base, Arbitrum, Robinhood Chain and Elysium
- Accounts
- Create, recover from 24 words, activate or set up, send, run any transaction, rekey
- Verification
- Check any OPEQ signature offline, with no network calls
- Runs in
- Node.js 20 or later, and any current browser
Install
npm install @opeqlabs/sdk
In Node, keep the wallet in a FileStore. In a browser, use IdbStore. Both refuse to move a key counter backwards.
The npm scope is @opeqlabs. Packages under any other name are not ours.
The one rule
A one-time key must never sign twice. The SDK enforces this for you:
- Every store refuses to move a key counter backwards.
FileStorelocks its folder, so two processes cannot use the same wallet at once. Keep the folder on a local disk, owned by you and closed to other users. A shared, network or synced folder defeats the lock.- Signing jobs inside one process run one at a time.
The SDK cannot see a second copy somewhere else. If the same 24 words are used on another device, that device must call useHere() first. It moves the account to a fresh key tree, and the old copy stops signing. Never restore a store from a backup to keep signing: recover from the words and call useHere() instead.
Solana
import { Vault } from "@opeqlabs/sdk";
import { FileStore } from "@opeqlabs/sdk/filestore";
const store = await FileStore.open("./opeq-wallet");
const vault = new Vault({
rpcUrl: "https://your-solana-rpc",
checkRpcUrl: "https://a-second-provider",
network: "mainnet",
store,
});
const { id, words } = await vault.create(password);
const acct = await vault.open(id, password);
await acct.feeKey();
await acct.activate();
await acct.send(to, 1_000_000n);
await acct.execute([instruction]);
await acct.rekey();
acct.close();
await store.close();
acct.addressis the quantum-resistant account. Keep funds there.feeKey()returns the fee key's address. It only pays Solana network fees, signs with Ed25519 and is not quantum-safe, so keep only a little SOL on it.activate()writes the account's key root on chain once. The fee key pays for it.execute()takes web3.js-style instructions. The account signs as the wallet address.- Amounts are whole numbers in base units (lamports, wei) as bigint, integer or digit string.
status()reports how many one-time keys are left. Callrekey()before they run out.
EVM
const acct = await vault.open(id, password);
const base = await acct.evm(8453, {
rpcUrl: "https://your-base-rpc",
checkUrl: "https://a-second-base-rpc",
});
await base.setup();
await base.send(to, 10n ** 16n);
await base.execute([{ to: token, value: 0n, data: "0xa9059cbb..." }]);
acct.close();
- 1
- Ethereum
- 8453
- Base
- 42161
- Arbitrum
- 4663
- Robinhood Chain
- 99901
- Elysium, gas in HYPE
- The same words give the same account address on every chain.
checkUrlmust be a second, independent RPC. Before signing, the SDK checks the account state on both and refuses if they disagree.- The fee key (
feeAddress) pays gas. It is an ordinary secp256k1 key, so keep only gas money on it. setup()deploys the account contract and moves it to a key tree only this device knows.
Verify offline
import { verifySolanaInstruction, verifyEvmExecute } from "@opeqlabs/sdk";
verifySolanaInstruction(data, accountKeys, { pubSeed, root, aid, epoch });
verifyEvmExecute(calldata, { chainId, account, epoch, pubSeed, root });
Both return the one-time key index, or null if the signature does not match or the input is malformed. They make no network calls, so anyone can check that a transaction was signed by an OPEQ account without trusting OPEQ, an RPC or a block explorer.
Speed
Building a key tree takes about 2 seconds on Solana and about 10 seconds on EVM in Node on a laptop. Signing takes under a second. EVM setup() builds three trees, so it takes about a minute. In a browser, hand the work to a Web Worker with @opeqlabs/sdk/compute so the page does not freeze.
RPC
Bring your own: two per network, from different providers, over https. rpc.opeq.io only serves the OPEQ apps.
Status
- Beta, not yet externally audited. The audits planned for the wallet will cover the SDK too.
- The Solana program can still be upgraded by the OPEQ team, as described in the docs. The program cannot move funds on its own: every transfer needs a one-time signature from the account's own key tree. The EVM contracts cannot be upgraded by anyone.
- On EVM, take over an account from one device at a time, and never restore a store from a backup.
Tests
The JavaScript code is checked against vectors from an independent Python implementation, and every result must be byte-identical. End-to-end tests run full accounts on a local EVM chain and on Solana devnet, and an attack suite replays the issues found in the security review before release. The commands are in the README.