【发布时间】:2022-12-04 18:05:57
【问题描述】:
我在 android key store 创建了一个密钥对。现在我有了公钥(DER 格式)并生成了一个签名(DER 格式)。现在我正试图在 ethers 上进行验证。
但我做不到。 (签名生成的公钥不匹配)
我试过像这样从 Der 签名中获取 r,s。
DER Sign (0x30 size 20/21 r size 20/21 v) // strip zeros if 21
和这样的 DER 编码公钥的未压缩公钥。
30 59 # Sequence length 0x59 - 91 bytes long
30 13 # Sequence length 0x13 - 21 bytes long
06 07 2a8648ce3d0201 # Object ID - 7 bytes long - 1.2.840.10045.2.1 (ECC)
06 08 2a8648ce3d030107 # Object ID - 8 bytes long - 1.2.840.10045.3.1.7 (ECDSA P256)
03 42 # Bit stream - 0x42 (66 bytes long)
0004 # Identifies public key
2927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838 # Identifies public key x co-ordinate
c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e # Identifies public key y co-ordinate
现在在以太坊验证
我的标志:r||s||00 或 r||s||01
我的公钥 0x04 || x线|| Y线
但是在以太坊中,根据给定的签名和数据生成的公钥与编码的公钥不匹配。
那我哪里做错了?
【问题讨论】:
标签: cryptography keystore signature ethers.js