Skip to content

Commit

Permalink
Hash ticket before performing arithmetic
Browse files Browse the repository at this point in the history
To ensure no arithmetic properties leak from BLS-G2 affine compressed
representation.

Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
  • Loading branch information
Kubuxu committed Jul 7, 2024
1 parent b5674db commit 49fe9e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gpbft/gpbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-f3/merkle"
"golang.org/x/crypto/blake2b"
"golang.org/x/xerrors"
)

Expand Down Expand Up @@ -1434,7 +1435,8 @@ func (c *convergeState) FindMaxTicketProposal(table PowerTable) ConvergeValue {
for key, value := range c.values {
for _, ticket := range c.tickets[key] {
senderPower, _ := table.Get(ticket.Sender)
ticketAsInt := new(big.Int).SetBytes(ticket.Ticket)
ticketHash := blake2b.Sum256(ticket.Ticket)

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-check / All

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-check / All

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-check / All

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes (compile)

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-check / All

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes (compile)

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-fuzz

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes

Check failure on line 1438 in gpbft/gpbft.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go next)

cannot use ticketHash (variable of type [32]byte) as []byte value in argument to new(big.Int).SetBytes
ticketAsInt := new(big.Int).SetBytes(ticketHash)
weightedTicket := new(big.Int).Mul(ticketAsInt, big.NewInt(int64(senderPower)))
if maxTicket == nil || weightedTicket.Cmp(maxTicket) > 0 {
maxTicket = weightedTicket
Expand Down

0 comments on commit 49fe9e2

Please sign in to comment.