Live video on the AT Protocol
1package atproto 2 3import ( 4 "crypto" 5 "crypto/ecdsa" 6 "crypto/elliptic" 7 "fmt" 8 9 atcrypto "github.com/bluesky-social/indigo/atproto/crypto" 10 ethcrypto "github.com/ethereum/go-ethereum/crypto" 11) 12 13func ParsePubKey(pub crypto.PublicKey) (*atcrypto.PublicKeyK256, error) { 14 ecdsaPub, ok := pub.(*ecdsa.PublicKey) 15 if !ok { 16 return nil, fmt.Errorf("public key is not an ECDSA public key") 17 } 18 19 publicKeyBytes := elliptic.Marshal(ethcrypto.S256(), ecdsaPub.X, ecdsaPub.Y) //nolint:all 20 atkey, err := atcrypto.ParsePublicUncompressedBytesK256(publicKeyBytes) 21 if err != nil { 22 return nil, err 23 } 24 return atkey, nil 25}