func bigIntMarshalledSize(i *big.Int) uint64 { intd, err := i.GobEncode() if err != nil { return 0 } return uint64(1 + len(intd)) }
func bigIntMarshalBinary(i *big.Int) (data []byte, err error) { intd, err := i.GobEncode() if err != nil { return } size := len(intd) if size > 255 { return nil, errors.New("Big int is too big") } data = make([]byte, size+1) data[0] = byte(size) copy(data[1:], intd) return }