@@ -21,21 +21,60 @@ import (
21
21
"embed"
22
22
"errors"
23
23
"hash"
24
+ "reflect"
24
25
"sync/atomic"
26
+
27
+ "github.com/XinFinOrg/XDPoSChain/common/hexutil"
25
28
)
26
29
27
30
//go:embed trusted_setup.json
28
31
var content embed.FS
29
32
33
+ var (
34
+ blobT = reflect .TypeOf (Blob {})
35
+ commitmentT = reflect .TypeOf (Commitment {})
36
+ proofT = reflect .TypeOf (Proof {})
37
+ )
38
+
30
39
// Blob represents a 4844 data blob.
31
40
type Blob [131072 ]byte
32
41
42
+ // UnmarshalJSON parses a blob in hex syntax.
43
+ func (b * Blob ) UnmarshalJSON (input []byte ) error {
44
+ return hexutil .UnmarshalFixedJSON (blobT , input , b [:])
45
+ }
46
+
47
+ // MarshalText returns the hex representation of b.
48
+ func (b Blob ) MarshalText () ([]byte , error ) {
49
+ return hexutil .Bytes (b [:]).MarshalText ()
50
+ }
51
+
33
52
// Commitment is a serialized commitment to a polynomial.
34
53
type Commitment [48 ]byte
35
54
55
+ // UnmarshalJSON parses a commitment in hex syntax.
56
+ func (c * Commitment ) UnmarshalJSON (input []byte ) error {
57
+ return hexutil .UnmarshalFixedJSON (commitmentT , input , c [:])
58
+ }
59
+
60
+ // MarshalText returns the hex representation of c.
61
+ func (c Commitment ) MarshalText () ([]byte , error ) {
62
+ return hexutil .Bytes (c [:]).MarshalText ()
63
+ }
64
+
36
65
// Proof is a serialized commitment to the quotient polynomial.
37
66
type Proof [48 ]byte
38
67
68
+ // UnmarshalJSON parses a proof in hex syntax.
69
+ func (p * Proof ) UnmarshalJSON (input []byte ) error {
70
+ return hexutil .UnmarshalFixedJSON (proofT , input , p [:])
71
+ }
72
+
73
+ // MarshalText returns the hex representation of p.
74
+ func (p Proof ) MarshalText () ([]byte , error ) {
75
+ return hexutil .Bytes (p [:]).MarshalText ()
76
+ }
77
+
39
78
// Point is a BLS field element.
40
79
type Point [32 ]byte
41
80
0 commit comments