- addHexPrefix
- arrayContainsArray
- baToJSON
- bufferToHex
- bufferToInt
- defineProperties
- ecrecover
- ecsign
- fromAscii
- fromRpcSig
- fromSigned
- fromUtf8
- generateAddress
- getBinarySize
- getKeys
- hashPersonalMessage
- importPublic
- intToBuffer
- intToHex
- isHexString
- isPrecompiled
- isValidAddress
- isValidChecksumAddress
- isValidPrivate
- isValidPublic
- isValidSignature
- isZeroAddress
- keccak
- KECCAK256_NULL
- KECCAK256_NULL_S
- KECCAK256_RLP
- KECCAK256_RLP_ARRAY
- KECCAK256_RLP_ARRAY_S
- KECCAK256_RLP_S
- lsetLength
- MAX_INTEGER
- padToEven
- privateToAddress
- privateToPublic
- publicToAddress
- ripemd160
- rlphash
- setLengthRight
- sha256
- sha3
- stripZeros
- toAscii
- toBuffer
- toChecksumAddress
- toRpcSig
- toUnsigned
- toUtf8
- TWO_POW256
- zeroAddress
- zeros
- zeros
- zeros
- zeros
Adds "0x" to a given String
if it does not already start with "0x"
Parameters
str
String
Returns String
Returns TRUE if the first specified array contains all elements from the second one. FALSE otherwise.
Parameters
Returns boolean
Converts a Buffer
or Array
to JSON
Parameters
Returns (Array | String | null)
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
Should be called to get hex representation (prefixed by 0x) of ascii string
Parameters
Returns String hex representation of input string
Convert signature format of the irc_sign
RPC method to signature parameters
NOTE: all because of a bug in girc: https://github.com/irchain/go-irchain/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
Should be called to get hex representation (prefixed by 0x) of utf8 string
Parameters
Returns String hex representation of input string
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
Get the binary size of a string
Parameters
str
String
Returns Number
getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
Parameters
Returns Array output just a simple array of output keys
Returns the keccak-256 hash of message
, prefixed with the header used by the irc_sign
RPC call.
The output of this function can be fed into ecsign
to produce the same signature as the irc_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 IrChain format.
Parameters
publicKey
Buffer
Returns Buffer
Converts an Number
to a Buffer
Parameters
i
Number
Returns Buffer
Converts a Number
into a hex String
Parameters
i
Number
Returns String
Is the string a hex string.
Parameters
Returns Boolean output the string is a hex string
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 IrChain.
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
Returns Boolean
Checks if a given address is a zero address
Parameters
address
String
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
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
Pads a String
to have an even length
Parameters
value
String
Returns String output
Returns the irchain address of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer
Returns the irchain public key of a given private key
Parameters
privateKey
Buffer A private key must be 256 bits wide
Returns Buffer
Returns the irchain address of a given public key. Accepts "IrChain 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
Creates SHA-3 hash of the RLP encoded version of the input
Parameters
Returns Buffer
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
Trims leading zeros from a Buffer
or an Array
Parameters
Returns (Buffer | Array | String)
Should be called to get ascii from it's hex representation
Parameters
string
String in hex
Returns String ascii string representation of hex value
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 irc_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
Should be called to get utf8 from it's hex representation
Parameters
string
String in hex
Returns String ascii string representation of hex value
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
Type: Object
Parameters
bytes
Type: Function
Parameters
bytes
Type: Function
Parameters
bytes