Why does polygon relayer signature is 66 bytes long?

I have created an autotask which signs a hash using a relayer provider and web3js. The autotask returns the signature and when the relayer's network is polygon the signature is 66 bytes (134 chars with 0x included) long, while when using the same relayer in other networks the signature length is 65 bytes 134 chars with 0x included) long as ECDSA is supposed to be.

:computer: Environment
I am using an openzeppelin relayer and an autotask.

:memo:Details
I've tried same code with same relayer in other networks and the signature has the correct length (65 bytes). Also I cannot reproduce this issue locally connecting to different networks and signing the same hash, not even using the yarn.lock file recommended for local development here: https://docs.openzeppelin.com/defender/autotasks#local-development

I've also tried different hash and the result is the same. Does anyone knows what is happening here? Is this a bug?

:1234: Code to reproduce

const Web3 = require('web3');
const { DefenderRelayProvider } = require('defender-relay-client/lib/web3');

exports.handler = async function (event) {
  const provider = new DefenderRelayProvider(event, { speed: 'fast' });
  const web3Signer = new Web3(provider);
  const [from] = await web3Signer.eth.getAccounts();
  const msgHash = "0xf0831194fa59f01077f46bf1e6d2953671e5fca0baa307a1157dd67e3867fe89";
  const web3Signature = await web3Signer.eth.sign(msgHash, from);
  return `Web3 signature: ${web3Signature}`;
}

when using the same relayer in other networks the signature length is 65 bytes 134 chars with 0x included) long as ECDSA is supposed to be.

Hey @Alvaro_Gomez_Haro, ECDSA signatures in Ethereum include a v parameter that depends on the chain id. If the chain identifier is large enough, this can cause the v value to be larger than a single byte.

Thanks @spalladino ! I found something that probably is the answer https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md

But I have tried doing same signature with ethersjs and the result does not match up, the length is still 65 bytes even in polygon which is chainid 137

Both signatures are valid! We just added a note on the docs to clarify.

1 Like