Skip to content

Commit

Permalink
core/vm: Fixed error in bn256Add
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Jun 20, 2017
1 parent 7f6688f commit ec8ff51
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ func (c *bn256Add) Run(in []byte) ([]byte, error) {
return nil, errInvalidCurvePoint
}

y, onCurve := new(bn256.G1).Unmarshal(in[:64])
y, onCurve := new(bn256.G1).Unmarshal(in[64:128])
if !onCurve {
return nil, errNotOnCurve
}
gx, gy, _, _ = x.CurvePoints()
gx, gy, _, _ = y.CurvePoints()
if gx.Cmp(bn256.P) >= 0 || gy.Cmp(bn256.P) >= 0 {
return nil, errInvalidCurvePoint
}
Expand Down Expand Up @@ -278,7 +278,8 @@ type pairing struct{}
// This method does not require any overflow checking as the input size gas costs
// required for anything significant is so high it's impossible to pay for.
func (c *pairing) RequiredGas(input []byte) uint64 {
return 0 // TODO
//return 0 // TODO
return uint64(60000*len(input) + 40000)
}

const pairSize = 192
Expand Down

0 comments on commit ec8ff51

Please sign in to comment.