secp256k1: Allow code generation to compile again.

This updates the static generation code so that it compiles as intended
by locally calculating the curve byte size based on its bit size since
that value was removed from the curve definition.
This commit is contained in:
Dave Collins 2021-07-28 04:39:14 -05:00
parent df2e172ee8
commit aae4e07cf0
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014-2015 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Copyright (c) 2015-2021 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
@ -45,11 +45,12 @@ func (curve *KoblitzCurve) SerializedBytePoints() []byte {
doublingPoints := curve.getDoublingPoints()
// Segregate the bits into byte-sized windows
serialized := make([]byte, curve.byteSize*256*3*10*4)
curveByteSize := curve.BitSize / 8
serialized := make([]byte, curveByteSize*256*3*10*4)
offset := 0
for byteNum := 0; byteNum < curve.byteSize; byteNum++ {
for byteNum := 0; byteNum < curveByteSize; byteNum++ {
// Grab the 8 bits that make up this byte from doublingPoints.
startingBit := 8 * (curve.byteSize - byteNum - 1)
startingBit := 8 * (curveByteSize - byteNum - 1)
computingPoints := doublingPoints[startingBit : startingBit+8]
// Compute all points in this window and serialize them.