Skip to content

Commit

Permalink
fix: ECDSA HashToInt bytes-bits mismatch (#428)
Browse files Browse the repository at this point in the history
* fix: bytes-bits mismatch when masking excess bits in ecdsa

* chore: go generate
  • Loading branch information
ivokub committed Jul 11, 2023
1 parent f93a56c commit 9c18d5e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ecc/bls12-377/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bls12-378/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bls12-381/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bls24-315/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bls24-317/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bn254/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bw6-633/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bw6-756/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/bw6-761/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/secp256k1/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/stark-curve/ecdsa/ecdsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/generator/ecdsa/template/ecdsa.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

const (
sizeFr = fr.Bytes
sizeFrBits = fr.Bits
sizeFp = fp.Bytes
{{- if eq .Name "secp256k1"}}
sizePublicKey = 2 * sizeFp
Expand Down Expand Up @@ -94,7 +95,7 @@ func HashToInt(hash []byte) *big.Int {
hash = hash[:sizeFr]
}
ret := new(big.Int).SetBytes(hash)
excess := len(hash)*8 - sizeFr
excess := ret.BitLen() - sizeFrBits
if excess > 0 {
ret.Rsh(ret, uint(excess))
}
Expand Down

0 comments on commit 9c18d5e

Please sign in to comment.