Documentation
¶
Index ¶
- Constants
- Variables
- func Checksum(ingest []byte) []byte
- func FromUvarint(buf []byte) (uint64, int, error)
- func GenerateAssetId(assetKey string) crypto.Hash
- func PutUvarint(buf []byte, x uint64) int
- func ReadUvarint(r io.ByteReader) (uint64, error)
- func ToUvarint(num uint64) []byte
- func UvarintSize(num uint64) int
- func ValidateChecksum(ingest, expect []byte) bool
- func VerifyAddress(addr string) error
- func VerifyAssetKey(assetKey string) error
- func VerifyTransactionHash(hash string) error
- type Address
- type Network
- type Protocol
Constants ¶
const ( // MaxLenUvarint63 is the maximum number of bytes representing an uvarint in // this encoding, supporting a maximum value of 2^63 (uint63), aka // MaxValueUvarint63. MaxLenUvarint63 = 9 // MaxValueUvarint63 is the maximum encodable uint63 value. MaxValueUvarint63 = (1 << 63) - 1 )
const BlsPrivateKeyBytes = 32
BlsPrivateKeyBytes is the length of a BLS private key
const BlsPublicKeyBytes = 48
BlsPublicKeyBytes is the length of a BLS public key
const ChecksumHashLength = 4
ChecksumHashLength defines the hash length used for calculating address checksums.
const MainnetPrefix = "f"
MainnetPrefix is the main network prefix.
const MaxAddressStringLength = 2 + 84
MaxAddressStringLength is the max length of an address encoded as a string it include the network prefx, protocol, and bls publickey
const PayloadHashLength = 20
PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols.
Variables ¶
var ( // ErrUnknownNetwork is returned when encountering an unknown network in an address. ErrUnknownNetwork = errors.New("unknown address network") // ErrUnknownProtocol is returned when encountering an unknown protocol in an address. ErrUnknownProtocol = errors.New("unknown address protocol") // ErrInvalidPayload is returned when encountering an invalid address payload. ErrInvalidPayload = errors.New("invalid address payload") // ErrInvalidLength is returned when encountering an address of invalid length. ErrInvalidLength = errors.New("invalid address length") // ErrInvalidChecksum is returned when encountering an invalid address checksum. ErrInvalidChecksum = errors.New("invalid address checksum") )
var ( FilecoinChainBase string FilecoinChainId crypto.Hash )
var ( ErrOverflow = errors.New("varints larger than uint63 not supported") ErrUnderflow = errors.New("varints malformed, could not reach the end") ErrNotMinimal = errors.New("varint not minimally encoded") )
var AddressEncoding = base32.NewEncoding(encodeStd)
AddressEncoding defines the base32 config used for address encoding and decoding.
var CurrentNetwork = Mainnet
CurrentNetwork specifies which network the address belongs to
var Undef = Address{}
Undef is the type that represents an undefined address.
var UndefAddressString = "<empty>"
UndefAddressString is the string used to represent an empty address when encoded to a string.
Functions ¶
func FromUvarint ¶ added in v0.13.6
FromUvarint reads an unsigned varint from the beginning of buf, returns the varint, and the number of bytes read.
func GenerateAssetId ¶
func PutUvarint ¶ added in v0.13.6
PutUvarint is an alias for binary.PutUvarint.
This is provided for convenience so users of this library can avoid built-in varint functions and easily audit code for uses of those functions.
Make sure that x is smaller or equal to MaxValueUvarint63, otherwise this function will produce values that may be rejected by readers.
func ReadUvarint ¶ added in v0.13.6
func ReadUvarint(r io.ByteReader) (uint64, error)
ReadUvarint reads a unsigned varint from the given reader.
func UvarintSize ¶ added in v0.13.6
UvarintSize returns the size (in bytes) of `num` encoded as a unsigned varint.
This may return a size greater than MaxUvarintLen63, which would be an illegal value, and would be rejected by readers.
func ValidateChecksum ¶ added in v0.13.6
ValidateChecksum returns true if the checksum of `ingest` is equal to `expected`>
func VerifyAddress ¶
func VerifyAssetKey ¶
func VerifyTransactionHash ¶
Types ¶
type Address ¶ added in v0.13.6
type Address struct {
// contains filtered or unexported fields
}
Address is the go type that represents an address in the filecoin network.
func NewBLSAddress ¶ added in v0.13.6
NewBLSAddress returns an address using the BLS protocol.
func NewFromBytes ¶ added in v0.13.6
NewFromBytes return the address represented by the bytes `addr`.
func NewFromString ¶ added in v0.13.6
NewFromString returns the address represented by the string `addr`.
func NewSecp256k1Address ¶ added in v0.13.6
NewSecp256k1Address returns an address using the SECP256K1 protocol.
func (Address) Empty ¶ added in v0.13.6
Empty returns true if the address is empty, false otherwise.
type Network ¶ added in v0.13.6
type Network = byte
Network represents which network an address belongs to.