func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error) { if len(hash) != 32 { return nil, fmt.Errorf("hash is required to be exactly 32 bytes (%d)", len(hash)) } sig, err = secp256k1.Sign(hash, common.LeftPadBytes(prv.D.Bytes(), prv.Params().BitSize/8)) return }
// NewEcdsaPrivateKey creates a new JWK from a EC-DSA private key func NewEcdsaPrivateKey(pk *ecdsa.PrivateKey) *EcdsaPrivateKey { pubkey := NewEcdsaPublicKey(&pk.PublicKey) privkey := &EcdsaPrivateKey{EcdsaPublicKey: pubkey} privkey.D.SetBytes(i2osp(pk.D, pk.Params().BitSize/8)) return privkey }