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 BitvectorCheck(b []byte, n uint64) error
- func BitvectorCheckByteLen(byteLen uint64, bitLength uint64) error
- func BitvectorCheckLastByte(last byte, n uint64) error
- func GetBit(b []byte, i uint64) bool
- func IsZeroBitlist(b []byte) bool
- func SetBit(b []byte, i uint64, v bool)
- type Bitfield
- type Bitlist
- type BitlistMeta
- type Bitvector
- type BitvectorMeta
- 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 ¶ added in v0.1.4
func BitlistCheckLastByte ¶ added in v0.1.4
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 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 ¶ added in v0.1.4
func BitvectorCheckLastByte ¶ added in v0.1.4
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 Bitlist ¶
type Bitlist interface {
Bitfield
BitlistMeta
}
type BitlistMeta ¶
type Bitvector ¶
type Bitvector interface {
Bitfield
BitvectorMeta
}
type BitvectorMeta ¶
type BitvectorMeta interface {
SizedBits
}
Bitvectors should have a pointer-receiver BitLen function to derive its fixed bit-length from.
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.