Fix bug in utils.js (#15)

This commit is contained in:
Michał Leszczyński
2023-03-02 02:54:46 +01:00
committed by GitHub
parent 700faade0b
commit 3e4f5dd6c6

View File

@@ -72,7 +72,10 @@ function parseSig(res) {
sn = -sn + curveOrder;
}
return {r: rn.toString(16), s: sn.toString(16)};
return {
r: rn.toString(16).padStart(64, '0'),
s: sn.toString(16).padStart(64, '0')
};
}
function reformatSignature(digest, signature, publicKey) {
@@ -92,8 +95,8 @@ function reformatSignature(digest, signature, publicKey) {
throw new HaloLogicError("Failed to get recovery param.");
}
let finalSig = '0x' + rn.toString(16).padStart(64, '0')
+ sn.toString(16).padStart(64, '0')
let finalSig = '0x' + fixedSig.r
+ fixedSig.s
+ Buffer.from([27 + recoveryParam]).toString('hex');
let pkeyAddress = ethers.utils.computeAddress('0x' + publicKey);