A wallet is mostly a chain of small, well-specified steps. Twelve words become a seed (BIP-39). The seed becomes a tree of keys (BIP-32). A key becomes an address, in one of several encodings. A transaction is serialized, hashed and signed with secp256k1. Each step has a public specification and public test vectors.
In a Dart app, these steps can end up spread over several dependencies: a general crypto library, a web3 client, a mnemonic package. The more packages touch your private keys, the more code someone has to read before trusting the signing path.
crypto_wallet_core puts the whole chain in one small package: mnemonics, HD key derivation, addresses, secp256k1 signing and Ethereum transaction signing. Its only runtime dependency is package:crypto, and it does not use web3dart.
Before anything else, the warning from the top of the README: it is not audited, private keys must be handled with care, and pure Dart gives no constant-time guarantees. Elliptic-curve maths runs on Dart BigInt, whose timing depends on the values it handles. Keys and seeds sit in ordinary garbage-collected memory and cannot be reliably wiped. Every algorithm is checked against official test vectors, but no one has reviewed the code for side channels. Before you protect real funds with it, get an independent review, or use a hardware wallet or an audited native library for signing.
What it does
Hashes. Keccak-256 (the Ethereum variant, not FIPS-202 SHA3-256), RIPEMD-160, HASH160, double SHA-256, HMAC-SHA512 and PBKDF2-HMAC-SHA512. SHA-2 and HMAC come from package:crypto. The rest is implemented in the package using 32-bit operations only, so results are the same on the Dart VM and on the web.
BIP-39. The official English wordlist, mnemonic generation from entropy (with Random.secure() by default), checksum validation, and seed derivation with a passphrase.
BIP-32. Master key from seed, CKDpriv and CKDpub, hardened and non-hardened children, and path parsing such as m/84'/0'/0'/0/0, with ', h or H. It serializes and strictly parses xprv/xpub, tprv/tpub, and the SLIP-132 variants yprv/ypub, uprv/upub (BIP-49) and zprv/zpub, vprv/vpub (BIP-84).
Bitcoin addresses. BIP-44 legacy P2PKH (Base58Check), BIP-49 P2SH-P2WPKH and BIP-84 P2WPKH (bech32), for mainnet, testnet/signet and regtest. WIF private keys. Generic Bech32 and Bech32m encoding and decoding, and SegWit v0 to v16 address decoding to scriptPubKey.
secp256k1 ECDSA. RFC 6979 deterministic nonces, low-s normalisation, public key recovery with the recovery id, and verification.
Ethereum. EIP-55 checksummed addresses, strict RLP encoding and decoding, legacy transactions with EIP-155 replay protection, EIP-1559 (type 2) transactions with access lists, EIP-191 personal_sign with ecrecover-based verification, and EIP-712 typed-data hashing and signing.
How to use it
Add it from GitHub:
dependencies:
crypto_wallet_core:
git: https://github.com/AbdeldjalilChougui/crypto_wallet_core
The README example goes from a mnemonic to a Bitcoin address and a signed Ethereum transaction:
import 'dart:convert';
import 'package:crypto_wallet_core/crypto_wallet_core.dart';
void main() {
// The public BIP-39 test mnemonic. Never use it for real funds.
const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon '
'abandon abandon abandon abandon about';
if (!Bip39.validateMnemonic(mnemonic)) throw StateError('bad mnemonic');
final seed = Bip39.mnemonicToSeed(mnemonic, passphrase: '');
// Bitcoin, BIP-84 native SegWit.
final root = HDKey.fromSeed(seed, version: ExtendedKeyVersion.zpub);
final account = root.derivePath("m/84'/0'/0'");
print(account.neuter().toExtendedPublicKey()); // zpub6rFR7y4Q2Aij...
final key = account.derivePath('0/0');
print(BitcoinAddress.p2wpkh(key.publicKey)); // bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu
print(Wif.encode(key.privateKey!));
// Ethereum, m/44'/60'/0'/0/0.
final ethKey = root.derivePath("m/44'/60'/0'/0/0").privateKey!;
final from = EthereumAddress.fromPrivateKey(ethKey);
final signed = Eip1559Transaction(
chainId: BigInt.one,
nonce: BigInt.zero,
maxPriorityFeePerGas: BigInt.from(1500000000),
maxFeePerGas: BigInt.from(30000000000),
gasLimit: BigInt.from(21000),
to: '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed',
value: BigInt.from(10).pow(16),
).sign(ethKey);
print(signed.rawHex); // for eth_sendRawTransaction
final message = utf8.encode('Sign in to example.org');
final sig = PersonalSign.sign(message, ethKey);
print(PersonalSign.verify(message, sig, from)); // true
}
The package signs. It does not talk to a node: signed.rawHex is what you hand to eth_sendRawTransaction with your own HTTP client.
The lower-level pieces are public too: Secp256k1.sign, Secp256k1.verify, Secp256k1.recoverPublicKey, Secp256k1.rfc6979Nonce, Rlp.encode and Rlp.decode, Bech32, SegwitAddress, Base58, keccak256, ripemd160 and pbkdf2HmacSha512. example/main.dart is a runnable tour.
How it was checked
The package ships one dataset, the BIP-39 English wordlist, copied verbatim from the bitcoin/bips repository. A test recomputes its SHA-256 and compares it with the published value.
Everything else is test vectors, and the README lists each file with its source and license: the BIP-32 vectors 1 to 5, the Trezor python-mnemonic vectors for BIP-39, the vectors in the BIP-49, BIP-84, BIP-173 and BIP-350 texts, Bitcoin Core's Base58 and key I/O data, the Keccak team's known-answer tests, the official RIPEMD-160 values, RFC 6979 nonces from Trezor and bitcoinjs-lib fixtures, the ethereum/tests RLP tests, the examples in EIP-55, EIP-155 and EIP-712, and Hyperledger Besu's EIP-1559 vectors.
Two sets were cross-checked before they were committed: the RFC 6979 sets were recomputed with python-ecdsa, and all ten EIP-1559 raw transactions were re-signed with eth-account 0.14. Both matched.
Things to know
- Security. Not audited, no constant-time guarantees, and secrets are not zeroised.
-
Speed. Point arithmetic uses
BigIntwith Jacobian coordinates. A signature or public key costs milliseconds, not microseconds. That is fine for a wallet, but not for bulk work. -
BIP-39 normalisation. BIP-39 requires NFKD, and Dart has no built-in Unicode normalisation. ASCII input works as is. A non-ASCII mnemonic or passphrase throws unless you normalise it yourself and pass
inputIsNfkd: true. Only the English wordlist is bundled. -
EIP-712 arrays. Array member types such as
uint256[]orPerson[]throwUnsupportedError. The EIP's own example has no arrays, so there is no official vector to check them against, and they are left out instead of guessed. Atomic types other thanstring,addressanduint256follow the encoding rules in the EIP text and were cross-checked againsteth-account, but the EIP publishes no vector for them. - Not included. Taproot (BIP-86) key tweaking, Schnorr (BIP-340), PSBT and Bitcoin transaction signing, EIP-2930 type 1 transactions, EIP-4844 blob transactions, ABI encoding and networking. Bech32m and SegWit v1+ are supported for addresses only.
-
Two paths without a direct vector. BIP-32 says to move to the next index when a child key is invalid (probability below 2^-127). The package does that, but no vector exercises it. BIP-44 publishes no address vectors, so P2PKH is tested as the composition of the BIP-49
HASH160vector and the Bitcoin Core Base58 vectors.
Why I built it
The README's "Dependencies" section gives the reason. The package does not use pointycastle: its last release, 4.0.0, came out in February 2025, and its repository has had no commits since then. Keccak, RIPEMD-160, PBKDF2 and secp256k1 are small enough to implement and check against the published vectors, and doing so keeps everything security-relevant in one package.
That is the idea behind "small and auditable". It does not mean audited, and the README says so in its first lines. It means that someone who wants to review the signing path has one package and one dependency to read, and that every algorithm in it points to the vector file that tests it.
Get the code
The source, the standards table, the vector sources and the tests are on GitHub: https://github.com/AbdeldjalilChougui/crypto_wallet_core. It is MIT licensed. If you plan to hold real funds, read the warning again first.
Originally published at abdeldjalilchougui.biz.
Top comments (0)