coin_walletconnect library

WalletConnect transport cryptography (web-safe).

This barrel exposes the WalletConnect primitives: the v2 envelope crypto (X25519 -> HKDF symKey, SHA-256 topic, ChaCha20-Poly1305 type-0/1 envelopes), the EdDSA relay-auth JWT (did:key), the wc: URI (v1 + v2), and the WC v1 AES-CBC+HMAC cipher - plus the underlying in-house primitives they build on. The higher-level Sign/Auth protocol engine is not part of this build.

Classes

Addr
Bech32
Chain
CodecGate
CryptoVault
CurveGate
Implementations may use pure Dart math or native FFI/WASM bindings.
Denomination
DerivedKey
DerivedKeyMaterial
DerivedPublicKey
DerivedSecretKey
DigestGate
EcdsaSig
Ed25519Gate
Pluggable backend for Ed25519 curve operations (Monero, etc.). All inputs/outputs are byte arrays so native backends avoid BigInt conversion.
ExTx
FundingPlan<T>
HdAccount
An account node m/purpose'/coinType'/account' bound to a ChainParams and a DerivationScheme.
HdWallet
A hierarchical-deterministic wallet root.
InputSig
DER-encoded ECDSA sig + sighash byte.
KeyForge
LegacyAddr
LegacyInput
LegacySigHasher
Legacy sighash (pre-segwit).
Locking
MessageSig
Mnemonic
MultiSig
M-of-N multisig: OP_M <keys...> OP_N OP_CHECKMULTISIG
Op
OpCode
Outpoint
P2pkhAddr
P2pkhInput
scriptSig = sig, pubkey
P2shAddr
P2shMultisigInput
P2wpkhAddr
P2wpkhInput
witness = sig, pubkey
P2wshAddr
PayToPubKeyHash
P2PKH: OP_DUP OP_HASH160 <20> OP_EQUALVERIFY OP_CHECKSIG
PayToScriptHash
P2SH: OP_HASH160 <20> OP_EQUAL
PayToTaproot
P2TR: OP_1 <32>
PayToWitness
Generic witness program (version 0-16).
PayToWitnessPubKey
P2WPKH: OP_0 <20>
PayToWitnessScript
P2WSH: OP_0 <32>
PublicKey
PushData
PushDataMatcher
Matches any push of a given size, for pattern matching against scripts.
RawInput
RawLocking
RecoverableEcdsaSig
SchnorrInputSig
Schnorr sig: 64 bytes, or 65 with non-default sighash.
SchnorrSig
Script
ScriptOp
SecretKey
SegwitAddr
SigHasher
SigHashType
TapBranch
TapLeaf
Taproot
TaprootAddr
Taproot address (bech32m, witness v1).
TaprootKeyInput
Key-path spend; witness = schnorr_sig.
TaprootScriptInput
Script-path spend; witness = ...stack, script, controlBlock.
TaprootSigHasher
BIP-341 taproot sighash.
TapTree
Tx
TxBody
Components of a transaction body (everything after the version word), shared by Tx.fromReader and ExTx.fromReader.
TxInput
TxOutput
UnknownWitnessAddr
For witness versions 2-16 (future soft forks).
VaultKeeper
Call initialize once before using any crypto operations. Defaults to pure Dart backends; register FFI backends with register or registerAsync before calling initialize.
WcAttestationClaims
The decoded claims of a Verify attestation JWT.
WcEnvelope
WalletConnect v2 transport crypto (Reown / WC v2 wire format).
WcLinkModeMessage
A link-mode (deep-link) message: the topic it targets and the out-of-band envelope (a type-2 base64url envelope) it carries.
WcUri
WalletConnect wc: URI parsing/serialization (EIP-1328), v1 and v2.
WcV1Payload
WalletConnect v1 transport crypto.
WcVerify
Stateless Verify helpers: JWT shape, ES256 verification, claim decoding, and the origin/scam decision.
WcVerifyClient
A Verify client that fetches and caches the service public key (until its expiresAt) via an injected WcHttpGet, then validates attestations.
WcVerifyKey
The Verify service's ES256 public key (a JWK), plus its expiresAt.
WireMeasure
Counts serialized size without allocating.
WireReader
WireWriter
WitnessInput
WitnessSigHasher
BIP-143 witness v0 sighash.

Enums

DerivationScheme
BIP standard derivation schemes, each mapping to a single address type.
WcVerifyStatus
The result of validating an attestation against a declared origin.

Functions

aes256CbcDecrypt(Uint8List key32, Uint8List iv16, Uint8List ciphertext) Uint8List
AES-256-CBC decryption with PKCS#7 padding validation.
aes256CbcEncrypt(Uint8List key32, Uint8List iv16, Uint8List plaintext) Uint8List
AES-256-CBC encryption with PKCS#7 padding.
aesEncryptBlock(Uint8List roundKeys, Uint8List block16) Uint8List
Encrypts a single 16-byte block16 under the expanded roundKeys schedule (240 bytes from _expandKey). Returns a new 16-byte block.
base58Decode(String encoded) Uint8List
base58Encode(Uint8List payload) String
bytesEqual(Uint8List a, Uint8List b) bool
chacha20Block(Uint8List key32, int counter, Uint8List nonce12) Uint8List
Generates one 64-byte ChaCha20 keystream block for the given 32-byte key32, 32-bit block counter and 12-byte nonce12.
chacha20Poly1305Decrypt({required Uint8List key32, required Uint8List nonce12, required Uint8List ciphertextWithTag, Uint8List? aad}) Uint8List
Verifies and decrypts ciphertextWithTag (ciphertext || 16-byte tag).
chacha20Poly1305Encrypt({required Uint8List key32, required Uint8List nonce12, required Uint8List plaintext, Uint8List? aad}) Uint8List
Encrypts plaintext with ChaCha20-Poly1305 AEAD (RFC 8439 sec. 2.8).
checkInt32(int i) → void
checkUint16(int i) → void
checkUint32(int i) → void
checkUint64(BigInt i) → void
checkUint8(int i) → void
compareBytes(Uint8List a, Uint8List b) int
concatBytes(List<Uint8List> parts) Uint8List
copyCheckBytes(Uint8List bytes, int length, [String name = 'bytes']) Uint8List
ed25519PublicKeyFromSeed(Uint8List seed32) Uint8List
Returns the 32-byte Ed25519 public key A for the given 32-byte seed32.
ed25519Sign(Uint8List seed32, Uint8List message) Uint8List
Signs message with the Ed25519 key derived from seed32.
ed25519Verify(Uint8List publicKey32, Uint8List message, Uint8List signature64) bool
Verifies a 64-byte Ed25519 signature64 over message under publicKey32.
generateSecureBytes(int n) Uint8List
hash160(Uint8List data) Uint8List
hexDecode(String hex) Uint8List
Accepts optional "0x" prefix.
hexEncode(Uint8List bytes) String
hkdfSha256(Uint8List ikm, {Uint8List? salt, Uint8List? info, required int length}) Uint8List
HKDF-SHA256 (RFC 5869).
hmacSha256(Uint8List key, Uint8List data) Uint8List
hmacSha512(Uint8List key, Uint8List data) Uint8List
initCoin() Future<void>
keccak256(Uint8List data) Uint8List
poly1305Mac(Uint8List oneTimeKey32, Uint8List message) Uint8List
Computes the 16-byte Poly1305 MAC of message under the 32-byte one-time key oneTimeKey32, per RFC 8439 sec. 2.5.
ripemd160(Uint8List data) Uint8List
sha256(Uint8List data) Uint8List
sha256d(Uint8List data) Uint8List
sha512(Uint8List data) Uint8List
taggedHash(String tag, Uint8List data) Uint8List
wcDecodeIss(String iss) Uint8List
Decode a did:key issuer string back to the 32-byte Ed25519 public key.
wcDecodeType2(String encoded) String
Decode a type-2 (link-mode) envelope back to its plaintext message. Tolerates URL-safe alphabet and missing padding (deep links may strip it).
wcDecrypt({required String symKeyHex, required String encoded}) String
Decrypt a base64 WC envelope, returning the plaintext message.
wcDeriveSymKey(String privKeyHex, String pubKeyHex) String
Derive the shared symmetric key from our private key and the peer public key. Returns the 32-byte symKey as hex. symKey = HKDF-SHA256(X25519(priv, pub)).
wcDeserialize(String encoded) WcEnvelope
Parse a base64 WC envelope into its components.
wcEncodeIss(Uint8List publicKey32) String
Encode an Ed25519 public key as a did:key issuer string.
wcEncodeType2({required String message}) String
Encode a type-2 (link-mode) envelope: base64url( 0x02 || plaintext ).
wcEncrypt({required String message, required String symKeyHex, int type = 0, required Uint8List iv, String? senderPublicKeyHex}) String
Encrypt message into a base64 WC envelope.
wcHashKey(String keyHex) String
topic = SHA-256(symKey-bytes), as hex. Also used to hash any hex key.
wcHashMessage(String message) String
SHA-256 of a UTF-8 message, as hex (WC hashMessage).
wcLinkModeUrl(String universalLink, String topic, String envelope) String
Build a link-mode deep link carrying an out-of-band envelope: {universalLink}?wc_ev={envelope}&topic={topic} (reown getLinkModeURL).
wcParseLinkModeUrl(String url) WcLinkModeMessage
Parse the topic + wc_ev (envelope) params out of a link-mode url.
wcSignJwt({required Uint8List seed32, required String sub, required String aud, required int iat, required int ttl}) String
Sign a relay-auth JWT.
wcTopicFromSymKey(String symKeyHex) String
Convenience alias: the pairing/session topic is SHA-256 of the symKey.
wcV1Decrypt(WcV1Payload payload, Uint8List key32) String
Verify HMAC then AES-256-CBC decrypt, returning the UTF-8 plaintext.
wcV1Encrypt({required Uint8List key32, required Uint8List iv16, required String plaintext}) WcV1Payload
Encrypt plaintext (a UTF-8 string, typically JSON) under key32.
wcV1VerifyHmac(WcV1Payload payload, Uint8List key32) bool
Verify the HMAC of a payload (over ciphertext || iv).
wcVerifyJwt(String jwt) bool
Verify a relay-auth JWT against the public key embedded in its iss claim.
wifDecode(String wif, Chain chain) → (Uint8List, bool)
wifEncode(Uint8List privKey, Chain chain, {bool compressed = true}) String
x25519(Uint8List scalar32, Uint8List uCoordinate32) Uint8List
Core X25519 function: computes X25519(k, u) per RFC 7748 sec. 5.
x25519Base(Uint8List scalar32) Uint8List
Computes X25519(k, 9): the public key for private scalar scalar32.

Typedefs

WcHttpGet = Future<String> Function(String url)
WalletConnect Verify API (R26): verify the ES256 attestation JWT the relay attaches to a delivery (WcRelayMessage.attestation) against the Verify service's P-256 public key, decode its claims, and compare the attested origin to the peer's declared origin - yielding VALID / INVALID / SCAM.

Exceptions / Errors

OutOfData