package keys import ( "errors" "fmt" "math/big" "github.com/sonr-io/crypto/core/curves" ) // getEcdsaPoint builds an elliptic curve point from a compressed byte slice func getEcdsaPoint(pubKey []byte) (*curves.EcPoint, error) { crv := curves.K256() x := new(big.Int).SetBytes(pubKey[1:33]) y := new(big.Int).SetBytes(pubKey[33:]) ecCurve, err := crv.ToEllipticCurve() if err != nil { return nil, fmt.Errorf("error converting curve: %v", err) } return &curves.EcPoint{X: x, Y: y, Curve: ecCurve}, nil } // DeserializeSecp256k1Signature deserializes an ECDSA signature from a byte slice func deserializeSignature(sigBytes []byte) (*curves.EcdsaSignature, error) { if len(sigBytes) != 66 { return nil, errors.New("malformed signature: not the correct size") } sig := &curves.EcdsaSignature{ V: int(sigBytes[0]), R: new(big.Int).SetBytes(sigBytes[1:33]), S: new(big.Int).SetBytes(sigBytes[33:66]), } return sig, nil }