what is v and how to get it? I'm trying to sign message without web3 library, only with using secp256k1 in python
Dec 26, 2022, 8:54 AM
It's a variable...
Dec 26, 2022, 8:56 AM
I signed message with secp256k1 and sign size is 64 bytes
not 65
Dec 26, 2022, 8:56 AM
How should we know, when we dont see the declaration?
Dec 26, 2022, 8:57 AM
Private key: 255afe3429feae8e28aabfd3f8034991dc9d372af5a4f7f6f7fcf80f2dfd4045
Public key: fae9419dda70480b905289be407089cc5866d9d6c2d2a51fe5db1e0b57d562b1656e35ed48be923a3daddf1a713aa88aa5a06194d8020740509d5eaabd1f8a40
Address: 0x3a2dEa7b74bFDd42b0b5600066B2E4BD89C00711
b'0\xbd\xcf%\x87FK:\xc8\xdf\xff[\x0ccf=\xdcP\x0c\xc72f\x99t\n\x16\xda\x06\xaf`\x01\xad_\x8dZS\xd4.\xe0\xef`oV\xd3\xe6\x83\xab\xff\xd5\xc2C\xee8\xaf\\u\x03\xd3\xdc\xce\xfc\xed/G'
64
Public key: fae9419dda70480b905289be407089cc5866d9d6c2d2a51fe5db1e0b57d562b1656e35ed48be923a3daddf1a713aa88aa5a06194d8020740509d5eaabd1f8a40
Address: 0x3a2dEa7b74bFDd42b0b5600066B2E4BD89C00711
b'0\xbd\xcf%\x87FK:\xc8\xdf\xff[\x0ccf=\xdcP\x0c\xc72f\x99t\n\x16\xda\x06\xaf`\x01\xad_\x8dZS\xd4.\xe0\xef`oV\xd3\xe6\x83\xab\xff\xd5\xc2C\xee8\xaf\\u\x03\xd3\xdc\xce\xfc\xed/G'
64
I want to do ecrecover but this sign is 64 bytes
Dec 26, 2022, 8:59 AM
There is nowhere a "v" defined
I am not sure if you understand what you do?
Dec 26, 2022, 8:59 AM
he's into some dangerous territory
Dec 26, 2022, 9:02 AM
this is just a elliptic curve encryption for Bitcoin, not much todo with solidity?
https://github.com/bitcoin-core/secp256k1
https://github.com/bitcoin-core/secp256k1
Dec 26, 2022, 9:02 AM
ethereum signature has v r s params and it backed by secp256k1
Dec 26, 2022, 9:02 AM
yeah but you can't just invent a "v"
it's then a parametric of the object of the encryption
Dec 26, 2022, 9:03 AM
solidity and eth uses secp256k1 too for private keys
Dec 26, 2022, 9:03 AM
you should use ethers/web3js
Dec 26, 2022, 9:03 AM
if you really want to understand the elliptic curve encryption you can checkout the library for it and read the source from there and implement in on your own.
but this sounds like a massive waste of time.
but this sounds like a massive waste of time.
Dec 26, 2022, 9:04 AM
I want to get rid of any dependencies and implement in in backend
Dec 26, 2022, 9:04 AM
I sent you the link above
this is not really smart.
but yeah, then use the link above and learn the algorithm
but yeah, then use the link above and learn the algorithm
Dec 26, 2022, 9:04 AM
code snippets are also dependencies, u could just copy and paste from their repo
Dec 26, 2022, 9:05 AM
also i want to get rid of \x19Ethereum Signed Message:\n32
just sign it with private key and do ecrecover
Dec 26, 2022, 9:06 AM
are u signing from the backend or frontend/metamask?
Dec 26, 2022, 9:07 AM
backend, it's a py application
probably some hacky script or so to sweep wallets
Dec 26, 2022, 9:07 AM
no
I want to do ECDSA on backend
to pass price into smart contract for example
Dec 26, 2022, 9:08 AM
that doesn't make sense
estimation of gas doesn't happen with the encryption
So what is your actual plan?
Dec 26, 2022, 9:08 AM
First 32 bytes would be r, next 32 would be s. As for v, it should be 27 or 28
Dec 26, 2022, 9:08 AM
idk how to get v
well ofc can just try 27 or 28
Dec 26, 2022, 9:09 AM
If it was on js, after signing you'll get an object as result and v is simply object.recovery + 27
Dec 26, 2022, 9:10 AM
where i can get recovery?
py lib returns just r and s values as 64 bytes
Dec 26, 2022, 9:11 AM
In python library, no clue. In js its used as
var sig = secp256k1.sign(msgHash, privateKey)
var ret = {}
ret.r = sig.signature.slice(0, 32)
ret.s = sig.signature.slice(32, 64)
ret.v = sig.recovery + 27
var sig = secp256k1.sign(msgHash, privateKey)
var ret = {}
ret.r = sig.signature.slice(0, 32)
ret.s = sig.signature.slice(32, 64)
ret.v = sig.recovery + 27
Its from ethereum stack btw, never had to use raw secp256k1 instead of web3 lib
Dec 26, 2022, 9:15 AM
hmm i found this
actually it make sense to check chain id to prevent replay attacks
Dec 26, 2022, 9:18 AM
Can u copy this code to me to try it
Dec 26, 2022, 1:43 PM
https://gist.github.com/BjornvdLaan/e41d292339bbdebb831d0b976e1804e8
I already solved my problem with eth_keys python package
Dec 26, 2022, 1:44 PM
Okay thanks
U need any help
Dec 26, 2022, 1:45 PM