caver.validator
The caver.validator
package provides validation functions that should be used when implementing applications on Klaytn.
NOTE caver.validator
is supported since caver-js v1.6.3.
validateSignedMessage
Validates a signed message by comparing the public key recovered from the signature with the account key of the Klaytn account.
Parameters
message
string
The raw message string. If this message is hashed with the Klaytn-specific prefix, the third parameter should be passed as true
.
signatures
object | Array
An object in the format of { v, r, s }
, an instance of SignatureData
, or an array of SignatureData
. '[ v, r, s ]' or '[[ v, r, s ]]' array can also be passed as a parameter, and in this case, it is internally converted to SignatureData
type.
address
string
The address of the account that signed the message.
isHashed
boolean
(optional, default: false
) Whether the message passed as a parameter is hashed with the prefix "\x19Klaytn Signed Message:\n" + message.length + message
.
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the signature on the message is valid or not.
Examples
validateTransaction
Validates a transaction. This function compares the public keys from the account key of the Klaytn account with the public keys recovered from signatures
. If the transaction is fee-delegated with the feePayerSignatures
variable inside, this function compares the public keys recovered from feePayerSignatures
with the public keys of the fee payer.
Parameters
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transacion is valid or not.
Examples
validateSender
Validates the sender of the transaction. This function compares the public keys of the account key of the Klaytn account with the public keys recovered from signatures
.
Parameters
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transaction is valid or not.
Examples
validateFeePayer
Validates a fee payer in the transaction. This function compares the public keys of the account key of the fee payer with the public keys recovered from feePayerSignatures
.
Parameters
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transaction is valid or not.
Examples
Last updated