crypto library

Exports low-level cryptographic operations needed to sign Ethereum transactions.

Classes

MsgSignature
Signatures used to sign Ethereum transactions and messages.

Properties

keccakDigest → KeccakDigest
final

Functions

bytesToHex(List<int> bytes, {bool include0x = false, int? forcePadLength, bool padToEvenLength = false}) String
Converts the bytes given as a list of integers into a hexadecimal representation.
bytesToInt(List<int> bytes) BigInt
Converts the bytes from that list (big endian) to a (potentially signed) BigInt.
bytesToUnsignedInt(Uint8List bytes) BigInt
compressPublicKey(Uint8List compressedPubKey) Uint8List
Given a byte array computes its compressed version and returns it as a byte array, including the leading 02 or 03
decompressPublicKey(Uint8List compressedPubKey) Uint8List
Given a byte array computes its expanded version and returns it as a byte array, including the leading 04
ecRecover(Uint8List messageHash, MsgSignature signatureData) Uint8List
Given an arbitrary message hash and an Ethereum message signature encoded in bytes, returns the public key that was used to sign it. https://github.com/web3j/web3j/blob/c0b7b9c2769a466215d416696021aa75127c2ff1/crypto/src/main/java/org/web3j/crypto/Sign.java#L241
generateNewPrivateKey(Random random) BigInt
Generates a new private key using the random instance provided. Please make sure you're using a cryptographically secure generator.
hexToBytes(String hexStr) Uint8List
Converts the hexadecimal string, which can be prefixed with 0x, to a byte sequence.
hexToDartInt(String hex) int
Converts the hexadecimal input and creates an int.
hexToInt(String hex) BigInt
Takes the hexadecimal input and creates a BigInt.
intToBytes(BigInt number) Uint8List
isValidSignature(Uint8List messageHash, MsgSignature signatureData, Uint8List publicKey) bool
Given an arbitrary message hash, an Ethereum message signature encoded in bytes and a public key encoded in bytes, confirms whether that public key was used to sign the message or not.
keccak256(Uint8List input) Uint8List
keccakAscii(String input) Uint8List
keccakUtf8(String input) Uint8List
privateKeyBytesToPublic(Uint8List privateKey) Uint8List
Generates a public key for the given private key using the ecdsa curve which Ethereum uses.
privateKeyToPublic(BigInt privateKey) Uint8List
Generates a public key for the given private key using the ecdsa curve which Ethereum uses.
publicKeyToAddress(Uint8List publicKey) Uint8List
Constructs the Ethereum address associated with the given public key by taking the lower 160 bits of the key's sha3 hash.
sign(Uint8List messageHash, Uint8List privateKey) MsgSignature
Signs the hashed data in messageHash using the given private key.
strip0x(String hex) String
If present, removes the 0x from the start of a hex-string.
unsignedIntToBytes(BigInt number) Uint8List