Clean up whitespace in secp256k1.go to improve code readability without altering functionality.
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package p256k1
|
package p256k1
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
// PublicKey represents a parsed and valid public key (64 bytes)
|
// PublicKey represents a parsed and valid public key (64 bytes)
|
||||||
type PublicKey struct {
|
type PublicKey struct {
|
||||||
data [64]byte
|
data [64]byte
|
||||||
@@ -601,36 +599,36 @@ func rfc6979NonceFunction(nonce32 []byte, msg32 []byte, key32 []byte, algo16 []b
|
|||||||
if len(nonce32) != 32 || len(msg32) != 32 || len(key32) != 32 {
|
if len(nonce32) != 32 || len(msg32) != 32 || len(key32) != 32 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build input data for HMAC: key || msg || [extra_data] || [algo]
|
// Build input data for HMAC: key || msg || [extra_data] || [algo]
|
||||||
var keyData []byte
|
var keyData []byte
|
||||||
keyData = append(keyData, key32...)
|
keyData = append(keyData, key32...)
|
||||||
keyData = append(keyData, msg32...)
|
keyData = append(keyData, msg32...)
|
||||||
|
|
||||||
// Add extra entropy if provided
|
// Add extra entropy if provided
|
||||||
if data != nil {
|
if data != nil {
|
||||||
if extraBytes, ok := data.([]byte); ok && len(extraBytes) == 32 {
|
if extraBytes, ok := data.([]byte); ok && len(extraBytes) == 32 {
|
||||||
keyData = append(keyData, extraBytes...)
|
keyData = append(keyData, extraBytes...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add algorithm identifier if provided
|
// Add algorithm identifier if provided
|
||||||
if algo16 != nil && len(algo16) == 16 {
|
if algo16 != nil && len(algo16) == 16 {
|
||||||
keyData = append(keyData, algo16...)
|
keyData = append(keyData, algo16...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize RFC 6979 HMAC
|
// Initialize RFC 6979 HMAC
|
||||||
rng := NewRFC6979HMACSHA256()
|
rng := NewRFC6979HMACSHA256()
|
||||||
rng.Initialize(keyData)
|
rng.Initialize(keyData)
|
||||||
|
|
||||||
// Generate nonces until we get the right attempt
|
// Generate nonces until we get the right attempt
|
||||||
var tempNonce [32]byte
|
var tempNonce [32]byte
|
||||||
for i := uint(0); i <= attempt; i++ {
|
for i := uint(0); i <= attempt; i++ {
|
||||||
rng.Generate(tempNonce[:])
|
rng.Generate(tempNonce[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(nonce32, tempNonce[:])
|
copy(nonce32, tempNonce[:])
|
||||||
rng.Clear()
|
rng.Clear()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user