Skip to content
Open
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: 3 additions & 3 deletions btcec/schnorr/musig2/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func WithBip86SignTweak() SignOption {
}
}

// computeSigningNonce calculates the final nonce used for signing. This will
// ComputeSigningNonce calculates the final nonce used for signing. This will
// be the R value used in the final signature.
func computeSigningNonce(combinedNonce [PubNonceSize]byte,
func ComputeSigningNonce(combinedNonce [PubNonceSize]byte,
combinedKey *btcec.PublicKey, msg [32]byte) (
*btcec.JacobianPoint, *btcec.ModNScalar, error) {

Expand Down Expand Up @@ -313,7 +313,7 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.PrivateKey,
// We'll now combine both the public nonces, using the blinding factor
// to tweak the second nonce:
// * R = R_1 + b*R_2
nonce, nonceBlinder, err := computeSigningNonce(
nonce, nonceBlinder, err := ComputeSigningNonce(
combinedNonce, combinedKey.FinalKey, msg,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion btcec/schnorr/musig2/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func TestMusig2SignCombine(t *testing.T) {
combinedNonce, err := AggregateNonces(pubNonces)
require.NoError(t, err)

finalNonceJ, _, err := computeSigningNonce(
finalNonceJ, _, err := ComputeSigningNonce(
combinedNonce, combinedKey.FinalKey, msg,
)

Expand Down
18 changes: 9 additions & 9 deletions btcec/schnorr/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const (
// SignatureSize is the size of an encoded Schnorr signature.
SignatureSize = 64

// scalarSize is the size of an encoded big endian scalar.
scalarSize = 32
// ScalarSize is the size of an encoded big endian scalar.
ScalarSize = 32
)

var (
Expand Down Expand Up @@ -132,9 +132,9 @@ func schnorrVerify(sig *Signature, hash []byte, pubKeyBytes []byte) error {
// Step 1.
//
// Fail if m is not 32 bytes
if len(hash) != scalarSize {
if len(hash) != ScalarSize {
str := fmt.Sprintf("wrong size for message (got %v, want %v)",
len(hash), scalarSize)
len(hash), ScalarSize)
return signatureError(ecdsa_schnorr.ErrInvalidHashLen, str)
}

Expand Down Expand Up @@ -234,8 +234,8 @@ func (sig *Signature) Verify(hash []byte, pubKey *btcec.PublicKey) bool {
}

// zeroArray zeroes the memory of a scalar array.
func zeroArray(a *[scalarSize]byte) {
for i := 0; i < scalarSize; i++ {
func zeroArray(a *[ScalarSize]byte) {
for i := 0; i < ScalarSize; i++ {
a[i] = 0x00
}
}
Expand Down Expand Up @@ -444,9 +444,9 @@ func Sign(privKey *btcec.PrivateKey, hash []byte,
// Step 2.
//
// Fail if m is not 32 bytes
if len(hash) != scalarSize {
if len(hash) != ScalarSize {
str := fmt.Sprintf("wrong size for message hash (got %v, want %v)",
len(hash), scalarSize)
len(hash), ScalarSize)
return nil, signatureError(ecdsa_schnorr.ErrInvalidHashLen, str)
}

Expand Down Expand Up @@ -519,7 +519,7 @@ func Sign(privKey *btcec.PrivateKey, hash []byte,
return sig, nil
}

var privKeyBytes [scalarSize]byte
var privKeyBytes [ScalarSize]byte
privKeyScalar.PutBytes(&privKeyBytes)
defer zeroArray(&privKeyBytes)
for iteration := uint32(0); ; iteration++ {
Expand Down
Loading
Loading