gridplus-sdk
Advanced tools
Comparing version 0.8.2 to 0.8.3
{ | ||
"name": "gridplus-sdk", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "SDK to interact with GridPlus Lattice1 device", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -49,6 +49,8 @@ // Utils for Ethereum transactions. This is effecitvely a shim of ethereumjs-util, which | ||
Buffer.from(keccak256(Buffer.concat([get_personal_sign_prefix(msg.length), msg])), 'hex'); | ||
// Get recovery param with a `v` value of [27,28] by setting `useEIP155=false` | ||
return addRecoveryParam(hash, sig, signer, { chainId: 1, useEIP155: false }) | ||
} else if (input.protocol === 'eip712') { | ||
const digest = prehash ? prehash : eip712.TypedDataUtils.encodeDigest(req.input.payload); | ||
return addRecoveryParam(digest, sig, signer, { type: 'EIP712_MSG' }) | ||
// Get recovery param with a `v` value of [27,28] by setting `useEIP155=false` | ||
return addRecoveryParam(digest, sig, signer, { useEIP155: false }) | ||
} else { | ||
@@ -410,10 +412,7 @@ throw new Error('Unsupported protocol'); | ||
return ensureHexBuffer(v, true); // 0 or 1, with 0 expected as an empty buffer | ||
} else if (type === 'EIP712_MSG') { | ||
return ensureHexBuffer(v, false); // 0 or 1, with 0 expected as a number | ||
} else if (false === useEIP155 || chainId === null) { | ||
// For ETH messages and non-EIP155 chains the set should be [27, 28] for `v` | ||
return Buffer.from(new BN(v).plus(27).toString(16), 'hex'); | ||
} | ||
// If we are not using EIP155, convert v directly to a buffer and return it | ||
if (false === useEIP155 || chainId === null) | ||
return Buffer.from(new BN(v).plus(27).toString(16), 'hex'); | ||
// We will use EIP155 in most cases. Convert v to a bignum and operate on it. | ||
@@ -420,0 +419,0 @@ // Note that the protocol calls for v = (CHAIN_ID*2) + 35/36, where 35 or 36 |
111801