diff --git a/btcec/field.go b/btcec/field.go index 0f2be74c0c..b4f9bf7435 100644 --- a/btcec/field.go +++ b/btcec/field.go @@ -220,6 +220,10 @@ func (f *fieldVal) SetBytes(b *[32]byte) *fieldVal { // The field value is returned to support chaining. This enables syntax like: // f := new(fieldVal).SetByteSlice(byteSlice) func (f *fieldVal) SetByteSlice(b []byte) *fieldVal { + if len(b) > 32 { + b = b[:32] + } + var b32 [32]byte for i := 0; i < len(b); i++ { if i < 32 {