Closed CooleRnax closed 3 years ago
I was coping valid order generated by 1inch.. I implemented sign_hash function part and almost was able to sign it, but the last character is different. What am I doing wrong?
I'm getting signature: 0x1ced85d5cd22c76361e376afb66d2c06dc304bddcd0454d0f9b9a1cba1c93bf082226f26f5e77dfd23k515f91fe0c49n92e80e912bf06247d5b50e61en6493d6c103
But valid signature is: 0x1ced85d5cd22c76361e376afb66d2c06dc304bddcd0454d0f9b9a1cba1c93bf082226f26f5e77dfd23k515f91fe0c49n92e80e912bf06247d5b50e61en6493d6c102
ec_signature = _parse_signature_hex_as_rsv(signature.signature.hex())
if ec_signature["v"] in valid_v_param_values:
signature_as_vrst_hex = (
_convert_ec_signature_to_vrs_hex(ec_signature)
+ _Constants.SignatureType.ETH_SIGN.value.to_bytes(
1, byteorder="big"
).hex()
)
signature_as_vrst_hex
ec_signature = _parse_signature_hex_as_vrs(signature.signature.hex())
if ec_signature["v"] in valid_v_param_values:
signature_as_vrst_hex = (
_convert_ec_signature_to_vrs_hex(ec_signature)
+ _Constants.SignatureType.ETH_SIGN.value.to_bytes(
1, byteorder="big"
).hex()
)
signature_as_vrst_hex
ended with a solution:
signature_as_vrst_hex = (
zero_ex.order_utils._convert_ec_signature_to_vrs_hex(
ec_signature) + '02'
)
Expected Behavior
w3.eth.sign() approach is deprecated, I'm trying to get signature in the new way:
signature = w3.eth.account.sign_message(encode_defunct(hexstr=order_hash_hex), private_key)
but when I post an order api rejects it because of the invalid signature
Steps to Reproduce (for bugs)
Context
I'm trying to sign and send transaction
Your Environment
Windows | python 3.7
| Package | Version | 0x-contract-wrappers | 2.0.0 0x-order_utils | 4.0.0
| Network | mainnet