Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions dcrec/secp256k1/ecdsa/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
// https://www.secg.org/sec1-v2.pdf

var (
// zero32 is an array of 32 bytes used for the purposes of zeroing and is
// defined here to avoid extra allocations.
zero32 = [32]byte{}

// orderAsFieldVal is the order of the secp256k1 curve group stored as a
// field value. It is provided here to avoid the need to create it multiple
// times.
Expand Down Expand Up @@ -140,7 +136,7 @@ func (sig *Signature) Serialize() []byte {

// zeroArray32 zeroes the provided 32-byte buffer.
func zeroArray32(b *[32]byte) {
copy(b[:], zero32[:])
*b = [32]byte{}
}

// fieldToModNScalar converts a field value to scalar modulo the group order and
Expand Down
11 changes: 1 addition & 10 deletions dcrec/secp256k1/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,7 @@ func (f FieldVal) String() string {
// Output Normalized: Yes
// Output Max Magnitude: 1
func (f *FieldVal) Zero() {
f.n[0] = 0
f.n[1] = 0
f.n[2] = 0
f.n[3] = 0
f.n[4] = 0
f.n[5] = 0
f.n[6] = 0
f.n[7] = 0
f.n[8] = 0
f.n[9] = 0
f.n = [10]uint32{}
}

// Set sets the field value equal to the passed value in constant time. The
Expand Down
17 changes: 2 additions & 15 deletions dcrec/secp256k1/modnscalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ const (
uint32Mask = 0xffffffff
)

var (
// zero32 is an array of 32 bytes used for the purposes of zeroing and is
// defined here to avoid extra allocations.
zero32 = [32]byte{}
)

// ModNScalar implements optimized 256-bit constant-time fixed-precision
// arithmetic over the secp256k1 group order. This means all arithmetic is
// performed modulo:
Expand Down Expand Up @@ -169,14 +163,7 @@ func (s *ModNScalar) Set(val *ModNScalar) *ModNScalar {
// already set to zero. This function can be useful to clear an existing scalar
// for reuse.
func (s *ModNScalar) Zero() {
s.n[0] = 0
s.n[1] = 0
s.n[2] = 0
s.n[3] = 0
s.n[4] = 0
s.n[5] = 0
s.n[6] = 0
s.n[7] = 0
s.n = [8]uint32{}
}

// IsZeroBit returns 1 when the scalar is equal to zero or 0 otherwise in
Expand Down Expand Up @@ -309,7 +296,7 @@ func (s *ModNScalar) SetBytes(b *[32]byte) uint32 {

// zeroArray32 zeroes the provided 32-byte buffer.
func zeroArray32(b *[32]byte) {
copy(b[:], zero32[:])
*b = [32]byte{}
}

// SetByteSlice interprets the provided slice as a 256-bit big-endian unsigned
Expand Down
4 changes: 1 addition & 3 deletions dcrec/secp256k1/schnorr/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ func (sig *Signature) Verify(hash []byte, pubKey *secp256k1.PublicKey) bool {

// zeroArray zeroes the memory of a scalar array.
func zeroArray(a *[scalarSize]byte) {
for i := 0; i < scalarSize; i++ {
a[i] = 0x00
}
*a = [scalarSize]byte{}
}

// schnorrSign generates an EC-Schnorr-DCRv0 signature over the secp256k1 curve
Expand Down