- addHexPrefix
- baToJSON
- BN
- bufferToHex
- bufferToInt
- defineProperties
- ecrecover
- ecsign
- fromRpcSig
- fromSigned
- generateAddress
- hashPersonalMessage
- importPublic
- isPrecompiled
- isValidAddress
- isValidChecksumAddress
- isValidPrivate
- isValidPublic
- keccak
- keccak256
- privateToAddress
- pubToAddress
- ripemd160
- rlp
- rlphash
- secp256k1
- setLengthRight
- sha256
- sha3
- toBuffer
- toChecksumAddress
- toRpcSig
- toUnsigned
- unpad
- isValidSignature
- isZeroAddress
- KECCAK256_NULL
- KECCAK256_NULL_S
- KECCAK256_RLP
- KECCAK256_RLP_ARRAY
- KECCAK256_RLP_ARRAY_S
- KECCAK256_RLP_S
- lsetLength
- MAX_INTEGER
- privateToPublic
- TWO_POW256
- zeroAddress
- zeros
Adds "0x" to a given String
if it does not already start with "0x"
Parameters
str
String
Returns String
Converts a Buffer
or Array
to JSON
Parameters
Returns (Array | String | null)
Type: Function
Converts a Buffer
into a hex String
Parameters
buf
Buffer
Returns String
Converts a Buffer
to a Number
Parameters
-
buf
Buffer -
Throws any If the input number exceeds 53 bits.
Returns Number
Defines properties on a Object
. It make the assumption that underlying data is binary.
Parameters
self
Object theObject
to define properties onfields
Array an array fields to define. Fields can contain:-name
- the name of the propertieslength
- the number of bytes the field can haveallowLess
- if the field can be less than the lengthallowEmpty
data
any data to be validated against the definitions
ECDSA public key recovery from signature
Parameters
Returns Buffer publicKey
ECDSA sign
Parameters
Returns Object
Convert signature format of the eth_sign
RPC method to signature parameters
NOTE: all because of a bug in geth: ethereum/go-ethereum#2053
Parameters
sig
String
Returns Object
Interprets a Buffer
as a signed integer and returns a BN
. Assumes 256-bit numbers.
Parameters
num
Buffer
Returns BN
Generates an address of a newly created contract
Parameters
from
Buffer the address which is creating this new addressnonce
Buffer the nonce of the from account
Returns Buffer
Returns the keccak-256 hash of message
, prefixed with the header used by the eth_sign
RPC call.
The output of this function can be fed into ecsign
to produce the same signature as the eth_sign
call for a given message
, or fed to ecrecover
along with a signature to recover the public key
used to produce the signature.
Parameters
message
Returns Buffer hash
Converts a public key to the Ethereum format.
Parameters
publicKey
Buffer
Returns Buffer
Returns true if the supplied address belongs to a precompiled account (Byzantium)
Parameters
Returns Boolean
Checks if the address is a valid. Accepts checksummed addresses too
Parameters
address
String
Returns Boolean
Checks if the address is a valid checksummed address
Parameters
address
Buffer
Returns Boolean
Checks if the private key satisfies the rules of the curve secp256k1.
Parameters
privateKey
Buffer
Returns Boolean
Checks if the public key satisfies the rules of the curve secp256k1 and the requirements of Ethereum.
Parameters
publicKey
Buffer The two points of an uncompressed key, unless sanitize is enabledsanitize
Boolean Accept public keys in other formats (optional, defaultfalse
)
Returns Boolean
Creates Keccak hash of the input
Parameters
a
(Buffer | Array | String | Number) the input databits
Number the Keccak width (optional, default256
)
Returns Buffer
Creates Keccak-256 hash of the input, alias for keccak(a, 256)
Parameters
Returns Buffer
Returns the ethereum address of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer
Returns the ethereum address of a given public key. Accepts "Ethereum public keys" and SEC1 encoded keys.
Parameters
pubKey
Buffer The two points of an uncompressed key, unless sanitize is enabledsanitize
Boolean Accept public keys in other formats (optional, defaultfalse
)
Returns Buffer
Creates RIPEMD160 hash of the input
Parameters
a
(Buffer | Array | String | Number) the input datapadded
Boolean whether it should be padded to 256 bits or not
Returns Buffer
Type: Function
Creates SHA-3 hash of the RLP encoded version of the input
Parameters
Returns Buffer
Type: Object
Right Pads an Array
or Buffer
with leading zeros till it has length
bytes.
Or it truncates the beginning if it exceeds.
Parameters
Creates SHA256 hash of the input
Parameters
Returns Buffer
Creates SHA-3 (Keccak) hash of the input [OBSOLETE]
Parameters
a
(Buffer | Array | String | Number) the input databits
Number the SHA-3 width (optional, default256
)
Returns Buffer
Attempts to turn a value into a Buffer
. As input it supports Buffer
, String
, Number
, null/undefined, BN
and other objects with a toArray()
method.
Parameters
v
any the value
Returns a checksummed address
Parameters
address
String
Returns String
Convert signature parameters into the format of eth_sign
RPC method
Parameters
Returns String sig
Converts a BN
to an unsigned integer and returns it as a Buffer
. Assumes 256-bit numbers.
Parameters
num
BN
Returns Buffer
Trims leading zeros from a Buffer
or an Array
Parameters
Returns (Buffer | Array | String)
Validate ECDSA signature
Parameters
Returns Boolean
Checks if a given address is a zero address
Parameters
address
String
Returns Boolean
Keccak-256 hash of null (a Buffer
)
Type: Buffer
Keccak-256 hash of null (a String
)
Type: String
Keccak-256 hash of the RLP of null (a Buffer
)
Type: Buffer
Keccak-256 of an RLP of an empty array (a Buffer
)
Type: Buffer
Keccak-256 of an RLP of an empty array (a String
)
Type: String
Keccak-256 hash of the RLP of null (a String
)
Type: String
Left Pads an Array
or Buffer
with leading zeros till it has length
bytes.
Or it truncates the beginning if it exceeds.
Parameters
msg
(Buffer | Array) the value to padlength
Number the number of bytes the output should beright
Boolean whether to start padding form the left or right (optional, defaultfalse
)
the max integer that this VM can handle (a BN
)
Type: BN
Returns the ethereum public key of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer
2^256 (a BN
)
Type: BN
Returns a zero address
Returns String
Returns a buffer filled with 0s
Parameters
bytes
Number the number of bytes the buffer should be
Returns Buffer