Live video on the AT Protocol
at eli/node-22 24 lines 597 B view raw
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 publicKeyBytes := elliptic.Marshal(ethcrypto.S256(), ecdsaPub.X, ecdsaPub.Y) 19 atkey, err := atcrypto.ParsePublicUncompressedBytesK256(publicKeyBytes) 20 if err != nil { 21 return nil, err 22 } 23 return atkey, nil 24}