blockchainethereumsmart-contractssoliditytutorialdappweb3ethtruffleweb3jstransactionsigntransactionsignaturesign-datasignpublickeyprivatekeyethereum-identityencryptioncipher
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
571 B
24 lines
571 B
import { utils as ethersUtils } from 'ethers';
|
|
/**
|
|
* split signature-hex into parts
|
|
* @param {string} hexString
|
|
* @return {{v: string, r: string, s: string}}
|
|
*/
|
|
export function fromString(hexString) {
|
|
var arr = ethersUtils.splitSignature(hexString);
|
|
return {
|
|
// convert "v" to hex
|
|
v: "0x".concat(arr.v.toString(16)),
|
|
r: arr.r,
|
|
s: arr.s
|
|
};
|
|
}
|
|
|
|
/**
|
|
* merge signature-parts to one string
|
|
* @param {{v: string, r: string, s: string}} sig
|
|
* @return {string} hexString
|
|
*/
|
|
export function toString(sig) {
|
|
return ethersUtils.joinSignature(sig);
|
|
} |