mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
crypto/secp256k1: add safety comments
This commit is contained in:
parent
6a2c12a2dc
commit
97fcd221f2
2 changed files with 5 additions and 0 deletions
|
|
@ -223,6 +223,7 @@ func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int,
|
||||||
if len(scalar) > 32 {
|
if len(scalar) > 32 {
|
||||||
panic("can't handle scalars > 256 bits")
|
panic("can't handle scalars > 256 bits")
|
||||||
}
|
}
|
||||||
|
// NOTE: potential timing issue
|
||||||
padded := make([]byte, 32)
|
padded := make([]byte, 32)
|
||||||
copy(padded[32-len(scalar):], scalar)
|
copy(padded[32-len(scalar):], scalar)
|
||||||
scalar = padded
|
scalar = padded
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,10 @@ var (
|
||||||
|
|
||||||
// Sign creates a recoverable ECDSA signature.
|
// Sign creates a recoverable ECDSA signature.
|
||||||
// The produced signature is in the 65-byte [R || S || V] format where V is 0 or 1.
|
// The produced signature is in the 65-byte [R || S || V] format where V is 0 or 1.
|
||||||
|
//
|
||||||
|
// The caller is responsible for ensuring that msg cannot be chosen
|
||||||
|
// directly by an attacker. It is usually preferable to use a cryptographic
|
||||||
|
// hash function on any input before handing it to this function.
|
||||||
func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
||||||
if len(msg) != 32 {
|
if len(msg) != 32 {
|
||||||
return nil, ErrInvalidMsgLen
|
return nil, ErrInvalidMsgLen
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue