crypto library

package:janzeer_sdk/crypto.dart — the function-style API of the janzeer_crypto.dart module that the Janzeer Flutter wallet used before the SDK existed. Kept so the wallet migrates by changing an import; new code should use Account, TxBuilder and SignedTx from package:janzeer_sdk/janzeer_sdk.dart.

Classes

LegacyAccount
A derived account (legacy shape): private key (hex), compressed public key (hex), address.
TokenOp
Token op codes (legacy constants).

Constants

kNetworkId → const String
ChainSpec.networkId (legacy name).

Functions

accountFromMnemonic(String mnemonic, {String passphrase = ''}) → LegacyAccount
mnemonic → account
accountFromPrivateKey(String privHex) → LegacyAccount
private key (hex) → account
accountFromSeed(Uint8List seed) → LegacyAccount
seed → m/0/0/0 account
buildSignedExitPromoter({String networkId = kNetworkId, required int timestamp, required Object fee, required int nonce, required String senderAddress, required String publicKey, required String promoterKey, required String privHex}) → Map<String, Object?>
Build a signed validator exit body (legacy name).
buildSignedExitPromoterIsolate(Map<String, Object?> a) → Map<String, Object?>
buildSignedExitPromoter from a primitive map.
buildSignedPromoter({String networkId = kNetworkId, required int timestamp, required Object fee, required int nonce, required String senderAddress, required String publicKey, required Object amount, required String promoterKey, required String privHex}) → Map<String, Object?>
Build a signed validator registration body (legacy name).
buildSignedPromoterIsolate(Map<String, Object?> a) → Map<String, Object?>
buildSignedPromoter from a primitive map.
buildSignedTokenTx({String networkId = kNetworkId, required int timestamp, required Object fee, required int nonce, required String senderAddress, required String publicKey, required int op, String tokenId = '', String symbol = '', String name = '', int decimals = 0, String? cap, String? amount, String? recipient, required String privHex}) → Map<String, Object?>
Build a fully-signed TokenTx body. cap/amount are integer base-unit strings.
buildSignedTokenTxIsolate(Map<String, Object?> a) → Map<String, Object?>
buildSignedTokenTx from a primitive map.
buildSignedTransfer({String networkId = kNetworkId, required int timestamp, required Object fee, required int nonce, required String senderAddress, required String publicKey, required String recipientAddress, required Object amount, String? data, required String privHex}) → Map<String, Object?>
Build a fully-signed transfer body (ready to POST).
buildSignedTransferIsolate(Map<String, Object?> a) → Map<String, Object?>
buildSignedTransfer from a primitive map.
bytesToHex(List<int> bytes) → String
bytes → lowercase hex
deriveAccountIsolate(String mnemonic) → Map<String, String>
mnemonic → {priv, pub, address}
exitPromoterPayload({required String promoterKey}) → Uint8List
Validator-exit payload (legacy name).
generateMnemonic({int strength = 128}) → String
Generate a BIP39 mnemonic (12 words by default).
hashBytes(Uint8List bytes) → String
double-SHA256 → hex
hexToBytes(String hex) → Uint8List
Lenient hex → bytes: accepts an optional 0x prefix and either case.
isChecksumValid(String address) → bool
AddressUtils.isChecksumValid: all-lowercase (canonical), all-uppercase, or a correctly cased EIP-55 address.
mnemonicToSeed(String mnemonic, {String passphrase = ''}) → Uint8List
SeedCalculator.calculateSeed — PBKDF2-HMAC-SHA512, 2048 rounds, 64 bytes, salt hdSalt + passphrase. Inputs are used as given (BIP39 English phrases are ASCII; NFKD-normalize non-ASCII passphrases yourself).
promoterPayload({required Object amount, required String promoterKey}) → Uint8List
Validator-registration payload (legacy name).
publicKeyToAddress(Uint8List compressedPublicKey) → String
CANONICAL address = "0x" + lowercase hex of the first 20 bytes of keccak256(compressed public key). This is what the node stores, hashes and expects as senderAddress.
signHash(String hashHex, String privateKeyHex) → String
Sign a 32-byte digest (hex) with a private key (hex): RFC-6979 (HMAC-SHA256 k), low-S, DER, Base64.
toChecksumAddress(String address) → String
EIP-55 mixed-case display form (AddressUtils.toChecksumAddress). Presentation only — never sign or store it.
tokenPayload({required int op, String? tokenId, String? symbol, String? name, int? decimals, String? cap, String? amount, String? recipient}) → Uint8List
Token payload: op(1) ‖ LP(tokenId) ‖ LP(symbol) ‖ LP(name) ‖ int32(decimals) ‖ LP(cap) ‖ LP(amount) ‖ LP(recipient). Token amounts are integer base units as decimal strings; absent fields are empty strings.
toScaledLong(Object amount) → BigInt
ByteUtils.toScaledLong: BigDecimal(amount).setScale(8, HALF_UP) × 10^8 as an integer. Pinned by the scaled table of the conformance vectors.
transactionBytes({String networkId = c.networkId, required int timestamp, required Object fee, required int nonce, required String senderAddress, required Uint8List payload}) → Uint8List
networkId ‖ timestamp(8) ‖ toScaledLong(fee)(8) ‖ nonce(8) ‖ senderAddress ‖ payload.
transferPayload({required Object amount, required String recipientAddress, String? data}) → Uint8List
Transfer payload: toScaledLong(amount)(8) ‖ recipientAddress ‖ (data ?? "").
validateMnemonic(String mnemonic) → bool
Wordlist + checksum check.