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
ba
Buffer or Array
Returns **Array or String or **
Converts a Buffer
into a hex String
Parameters
buf
Buffer
Returns String
Converts a Buffer
to a Number
Parameters
buf
Buffer
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
msgHash
Bufferv
Numberr
Buffers
Buffer
Returns Buffer publicKey
ECDSA sign
Parameters
msgHash
BufferprivateKey
Buffer
Returns Object
Convert signature format of the wsh_sign
RPC method to signature parameters
NOTE: all because of a bug in gwsh: https://github.com/wiseplat/go-wiseplat/issues/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 wsh_sign
RPC call.
The output of this function can be fed into ecsign
to produce the same signature as the wsh_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 Wiseplat format.
Parameters
publicKey
Buffer
Returns Buffer
Returns true if the supplied address belongs to a precompiled account
Parameters
address
Buffer or String
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 Wiseplat.
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
Validate ECDSA signature
Parameters
v
Bufferr
Buffers
Bufferhomestead
[Boolean] (optional, defaulttrue
)
Returns Boolean
the max integer that this VM can handle (a BN
)
Returns the wiseplat address of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer
Returns the wiseplat address of a given public key. Accepts "Wiseplat 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 or Array or String or Number the input datapadded
Boolean whether it should be padded to 256 bits or not
Returns Buffer
Creates SHA-3 hash of the RLP encoded version of the input
Parameters
a
Buffer or Array or String or Number the input data
Returns Buffer
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 or 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
)
Returns Buffer or Array
Right Pads an Array
or Buffer
with leading zeros till it has length
bytes.
Or it truncates the beginning if it exceeds.
Parameters
msg
Buffer or Array the value to padlength
Number the number of bytes the output should be
Returns Buffer or Array
Creates SHA256 hash of the input
Parameters
a
Buffer or Array or String or Number the input data
Returns Buffer
Creates SHA-3 hash of the input
Parameters
a
Buffer or Array or String or Number the input databits
[Number] the SHA width (optional, default256
)
Returns Buffer
SHA3-256 hash of null (a Buffer
)
SHA3-256 hash of null (a String
)
SHA3-256 hash of the RLP of null (a Buffer
)
SHA3-256 of an RLP of an empty array (a Buffer
)
SHA3-256 of an RLP of an empty array (a String
)
SHA3-256 hash of the RLP of null (a String
)
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 wsh_sign
RPC method
Parameters
v
Numberr
Buffers
Buffer
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
2^256 (a BN
)
Trims leading zeros from a Buffer
or an Array
Parameters
a
Buffer or Array or String
Returns Buffer or Array or String
Returns a buffer filled with 0s
Parameters
bytes
Number the number of bytes the buffer should be
Returns Buffer
Returns the wiseplat public key of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer