Closed doitian closed 8 months ago
secp256r1 is not different from other algorithms other than the thing mentioned in https://github.com/nervosnetwork/ckb-auth/pull/29 .
@contrun the openssl command in secp256r1.md generate a signature in DER format, do you know a tool to get the 64 bytes signature from the file?
In my local machine, the signature is saved in a file called signature
, whose hex contents are
xxd signature
00000000: 3044 0220 63bf dc57 257a 6cf6 7393 e4bf 0D. c..W%zl.s...
00000010: 2aa0 af38 f25f a04d ec3d 1428 b83f 9f8c *..8._.M.=.(.?..
00000020: f4d8 050f 0220 2744 17cb 0d9d 625a b0ba ..... 'D....bZ..
00000030: b1c6 11e0 c445 081a 31f6 8266 8c0a bfa0 .....E..1..f....
00000040: 1341 e977 08af
Running the following command will output the R and S value of the signature
openssl asn1parse -dump -inform DER -in signature
0:d=0 hl=2 l= 68 cons: SEQUENCE
2:d=1 hl=2 l= 32 prim: INTEGER :63BFDC57257A6CF67393E4BF2AA0AF38F25FA04DEC3D1428B83F9F8CF4D8050F
36:d=1 hl=2 l= 32 prim: INTEGER :274417CB0D9D625AB0BAB1C611E0C445081A31F682668C0ABFA01341E97708AF
All that we need to do to convert the signature to the 64-bytes form is to concatenate the R and S value in the last two lines. Running the following command suffices
openssl asn1parse -dump -inform DER -in signature | awk -F: '/33 prim: INTEGER/ {print $NF}' | xxd -r -p > signature.raw
I added the this instructions in the PR https://github.com/nervosnetwork/ckb-auth/pull/30
Thanks again.
secp256r1.md refers to auth.md for more details, but auth.md has nothing about secp256r1