Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEntropyLengthInvalid = errors.New("entropy length must be [128, 256] and a multiple of 32") ErrBitsChecksumLength = errors.New("bits and checksum length error") )
Functions ¶
func Random ¶
Random creates a random entropy of the given length 助记词长度和随机值位数之间的关系 -----|----------|---------------|-------| bits | checksum | bits+checksum | words | -----|----------|---------------|-------| 128 | 4 | 132 | 12 | -----|----------|---------------|-------| 160 | 5 | 165 | 15 | -----|----------|---------------|-------| 192 | 6 | 198 | 18 | -----|----------|---------------|-------| 224 | 7 | 231 | 21 | -----|----------|---------------|-------| 256 | 8 | 264 | 24 | -----|----------|---------------|-------|
Types ¶
type Bits ¶
type Bits []byte
Bits represents a byte slice of individual bits
func BitsToBytes ¶
助记词长度和随机值位数之间的关系 -----|----------|---------------|-------| bits | checksum | bits+checksum | words | -----|----------|---------------|-------| 128 | 4 | 132 | 12 | -----|----------|---------------|-------| 160 | 5 | 165 | 15 | -----|----------|---------------|-------| 192 | 6 | 198 | 18 | -----|----------|---------------|-------| 224 | 7 | 231 | 21 | -----|----------|---------------|-------| 256 | 8 | 264 | 24 | -----|----------|---------------|-------| length := len(bits) // bits+checksum chks := length / 32 // checksum bits bitsLen := length - chks // bits length
func CheckSummed ¶
CheckSummed returns a bit slice of entropy with an appended check sum