Any explanation for the signature format conversion in Klaytn Doc?

I have a raw signature in DER format which is signed externally by HSM by secp256k1. How do I convert it to the format [v,r,s] for Klaytn? I tried and found out it is similar to EIP-155 which the value of [v] is the chaid-id*2+35+orig.v.slice(64,). If [v] is incorrect, the system will show Invalid chainId error message so I think value of [v] might be correct. However, I am not sure how to compose the value of [r,s] since I have retrieved them by [orig.r.slice(0,32), orig.s.slice(32,64)] but got an error of Returned error: invalid transaction v, r, s values of the sender.

Any detailed explanation for converting the signature from DER format to [v,r,s]? I have read Klaytn doc and only RLP encoding related functions are found from the website.

Hi, thanks for filing a question on KlaytnForum.

I’m not sure how DER format works exactly, but it seems that it should work similarly on Ethereum except that the chain ID will be one of 1001 (Baobab) and 8217 (Cypress).

I hope this source code might be helpful.