Documentation
¶
Index ¶
- func BitIndex(v byte) (out uint64)
- func BitlistCheck(b []byte, limit uint64) error
- func BitlistCheckByteLen(byteLen uint64, bitLimit uint64) error
- func BitlistCheckLastByte(last byte, limit uint64) error
- func BitlistLen(b []byte) uint64
- func BitlistOnesCount(v []byte) uint64
- func BitvectorCheck(b []byte, n uint64) error
- func BitvectorCheckByteLen(byteLen uint64, bitLength uint64) error
- func BitvectorCheckLastByte(last byte, n uint64) error
- func BitvectorOnesCount(v []byte) uint64
- func Covers(af []byte, bf []byte) (bool, error)
- func GetBit(b []byte, i uint64) bool
- func IsZeroBitlist(b []byte) bool
- func SetBit(b []byte, i uint64, v bool)
- type Bitfield
- type CheckedBitfield
- type SizedBits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitlistCheck ¶
Helper function to implement Bitlist with. It checks if:
- the raw bitlist is not empty, there must be a 1 bit to determine the length.
- the bitlist has a leading 1 bit in the last byte to determine the length with.
- if b has no more than given limit in bits.
func BitlistCheckByteLen ¶
func BitlistCheckLastByte ¶
func BitlistLen ¶
Returns the length of the bitlist. And although strictly speaking invalid. a sane default is returned for:
- an empty raw bitlist: a default 0 bitlist will be of length 0 too.
- a bitlist with a leading 0 byte: return the bitlist raw bit length, excluding the last byte (As if it was full 0 padding).
func BitlistOnesCount ¶ added in v0.1.3
Counts the bits set to 1, excluding the delimiter bit.
func BitvectorCheck ¶
Helper function to implement Bitvector with. It checks if:
- b has the same amount of bytes as necessary for n bits.
- unused bits in b are 0
func BitvectorCheckByteLen ¶
func BitvectorCheckLastByte ¶
func BitvectorOnesCount ¶ added in v0.1.3
Counts the bits set to 1. Assumes the bitvector with length not a multiple of 8 has trailing zero bits.
func Covers ¶ added in v0.1.3
Returns true if bf only has bits set to 1 that bitfield af also has set to 1 For bitlists and bitvectors, the trailing part is always the same if the bitlength is the same. So the result is independent of having a delimiting bit or not.
func GetBit ¶
Helper function to implement Bitfields with. Assumes i is a valid bit-index to retrieve a bit from bytes b.
func IsZeroBitlist ¶
Checks if the bitList is fully zeroed (except the leading bit)
Types ¶
type Bitfield ¶
General base interface for Bitlists and Bitvectors Note for Bitfields to work with the SSZ functionality:
- Bitlists need to be of kind []byte (packed bits, incl delimiter bit)
- Bitvectors need to be of kind [N]byte (packed bits)
type CheckedBitfield ¶
type CheckedBitfield interface {
Check() error
}
bitfields implementing this can be checked to be of a valid or not. Useful for untrusted bitfields. See BitlistCheck and BitvectorCheck to easily implement the validity checks.