タイトルの通りです。
Go言語でESDSAを使用したいのですが、実現方法がわかりません。
https://pkg.go.dev/crypto/ecdsa
こちらを参照しても、秘密鍵をランダム値から生成するロジックや検証にまつわるものはありますが、
生の秘密鍵の値から公開鍵を生成する方法の情報が見つからず困っています。
Go
1type Keys struct { 2 PrivateKey *big.Int 3 PublicKey struct { 4 X, Y *big.Int 5 } 6 Hsid string 7} 8 9func (k *Keys)GenAllFromPrivKey(in *big.Int) error { 10 priv, err := x509.ParseECPrivateKey(in.Bytes()) 11 if err != nil { 12 return err 13 } 14 k.PrivateKey = priv.D 15 16 return nil 17}
上記のコードを作って試してみましたが、下記のエラーでうまく動きませんでした。
panic: x509: failed to parse EC private key: asn1: structure error: tags don't match (16 vs {class:3 tag:27 length:127 isCompound:false}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} ecPrivateKey @2
ご助言いただけると幸いです。