4JWXOJIPJAOL6FZMQENB2ZUTWEFXNB7VU2NHYDNT4T45ESSCSUPQC
Version uint64
Message string
Description string
Timestamp time.Time
Authors []map[string]string
Version uint64
Message string
Description string
Timestamp time.Time
Authors []map[string]string
Dependencies []Hash
ExtraKnown []Hash
Metadata []byte
}
type Hash [32]byte
var base32Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
func (h Hash) String() string {
return base32Encoding.EncodeToString(append(h[:], 1))
func HashFromBase32(b32 string) (Hash, error) {
b, err := base32Encoding.DecodeString(b32)
if err != nil {
return Hash{}, err
}
if len(b) != 33 {
return Hash{}, fmt.Errorf("expected 33 bytes, got %d", len(b))
}
if b[32] != 1 {
return Hash{}, fmt.Errorf("expected Blake3 hash, got type %d", b[32])
}
return Hash(b[:32]), nil
}
func deserializeHash(data []byte) ([]byte, Hash, error) {
data, tag, err := uint32LE(data)
if err != nil {
return data, Hash{}, err
}
if tag == 0 {
return data, Hash{}, nil
}
if tag != 1 {
return data, Hash{}, fmt.Errorf("bad tag for Hash, expected 0 or 1, got %d", tag)
}
data, b, err := take(32)(data)
if err != nil {
return data, Hash{}, err
}
return data, Hash(b), nil
}