package zkp import ( "fmt" "math/big" ) type big_Int big.Int func (b big_Int) MarshalJSON() ([]byte, error) { i := big.Int(b) v := fmt.Sprintf("\"%x\"", i.Bytes()) return []byte(v), nil } func (b *big_Int) UnmarshalJSON(p []byte) error { if string(p) == "null" { return nil } var v = []byte{} if _, err := fmt.Sscanf(string(p), "\"%x\"", &v); err != nil { return fmt.Errorf("not a valid big integer: %s", p) } *b = big_Int(*new(big.Int).SetBytes(v)) return nil }