dusk-blockchain
dusk-blockchain copied to clipboard
Add support in sortition for bls public keys that starts with zeros
Describe the bug
p.MemberAt(i)
in extractCommitteeMember would return nil
member making the sortition panic, when a provisioner public key starts with zeros.
To Reproduce
- Try to generate a valid BLS key where the public key starts with zeros
- Stake with it
- If extractCommitteeMember loop reaches this member, it will panic.
Expected behaviour
As it is an existing item, p.MemberAt(i) should return the real member but not nil. To achieve this, Int.FillBytes
should be used.
Additional context
func TestSetBytes(t *testing.T) {
b1 := decodeString("0000d081884c")
bigInt1 := new(big.Int).SetBytes(b1)
b2 := bigInt1.Bytes()
assert.True(t, bytes.Equal(b1, b2))
// failed
}