@@ -7,16 +7,6 @@ import (
77 "github.com/scroll-tech/go-ethereum/common"
88)
99
10- // RespStatus represents status code from prover to scroll
11- type RespStatus uint32
12-
13- const (
14- // StatusOk means generate proof success
15- StatusOk RespStatus = iota
16- // StatusProofError means generate proof failed
17- StatusProofError
18- )
19-
2010// ProofType represents the type of task.
2111type ProofType uint8
2212
@@ -51,15 +41,15 @@ type ChunkTaskDetail struct {
5141
5242// BatchTaskDetail is a type containing BatchTask detail.
5343type BatchTaskDetail struct {
54- ChunkInfos []* ChunkInfo `json:"chunk_infos"`
55- ChunkProofs []* ChunkProof `json:"chunk_proofs"`
56- BatchHeader interface {} `json:"batch_header"`
57- BlobBytes []byte `json:"blob_bytes"`
44+ ChunkInfos []* ChunkInfo `json:"chunk_infos"`
45+ ChunkProofs []ChunkProof `json:"chunk_proofs"`
46+ BatchHeader interface {} `json:"batch_header"`
47+ BlobBytes []byte `json:"blob_bytes"`
5848}
5949
6050// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
6151type BundleTaskDetail struct {
62- BatchProofs []* BatchProof `json:"batch_proofs"`
52+ BatchProofs []BatchProof `json:"batch_proofs"`
6353}
6454
6555// ChunkInfo is for calculating pi_hash for chunk
@@ -79,11 +69,24 @@ type SubCircuitRowUsage struct {
7969 RowNumber uint64 `json:"row_number"`
8070}
8171
82- // ChunkProof includes the proof info that are required for chunk verification and rollup.
83- type ChunkProof struct {
72+ // ChunkProof
73+ type ChunkProof interface {
74+ Proof () []byte
75+ }
76+
77+ // NewChunkProof creates a new ChunkProof instance.
78+ func NewChunkProof (hardForkName string ) ChunkProof {
79+ switch hardForkName {
80+ default :
81+ return & Halo2ChunkProof {}
82+ }
83+ }
84+
85+ // Halo2ChunkProof includes the proof info that are required for chunk verification and rollup.
86+ type Halo2ChunkProof struct {
8487 StorageTrace []byte `json:"storage_trace,omitempty"`
8588 Protocol []byte `json:"protocol"`
86- Proof []byte `json:"proof"`
89+ RawProof []byte `json:"proof"`
8790 Instances []byte `json:"instances"`
8891 Vk []byte `json:"vk"`
8992 // cross-reference between cooridinator computation and prover compution
@@ -92,29 +95,53 @@ type ChunkProof struct {
9295 RowUsages []SubCircuitRowUsage `json:"row_usages,omitempty"`
9396}
9497
95- // BatchProof includes the proof info that are required for batch verification and rollup.
96- type BatchProof struct {
98+ // Proof returns the proof bytes of a ChunkProof
99+ func (ap * Halo2ChunkProof ) Proof () []byte {
100+ return ap .RawProof
101+ }
102+
103+ // BatchProof
104+ type BatchProof interface {
105+ SanityCheck () error
106+ Proof () []byte
107+ }
108+
109+ // NewBatchProof creates a new BatchProof instance.
110+ func NewBatchProof (hardForkName string ) BatchProof {
111+ switch hardForkName {
112+ default :
113+ return & Halo2BatchProof {}
114+ }
115+ }
116+
117+ // Halo2BatchProof includes the proof info that are required for batch verification and rollup.
118+ type Halo2BatchProof struct {
97119 Protocol []byte `json:"protocol"`
98- Proof []byte `json:"proof"`
120+ RawProof []byte `json:"proof"`
99121 Instances []byte `json:"instances"`
100122 Vk []byte `json:"vk"`
101123 // cross-reference between cooridinator computation and prover compution
102124 BatchHash common.Hash `json:"batch_hash"`
103125 GitVersion string `json:"git_version,omitempty"`
104126}
105127
128+ // Proof returns the proof bytes of a BatchProof
129+ func (ap * Halo2BatchProof ) Proof () []byte {
130+ return ap .RawProof
131+ }
132+
106133// SanityCheck checks whether a BatchProof is in a legal format
107- func (ap * BatchProof ) SanityCheck () error {
134+ func (ap * Halo2BatchProof ) SanityCheck () error {
108135 if ap == nil {
109136 return errors .New ("agg_proof is nil" )
110137 }
111138
112- if len (ap .Proof ) == 0 {
139+ if len (ap .RawProof ) == 0 {
113140 return errors .New ("proof not ready" )
114141 }
115142
116- if len (ap .Proof )% 32 != 0 {
117- return fmt .Errorf ("proof buffer length must be a multiple of 32, got: %d" , len (ap .Proof ))
143+ if len (ap .RawProof )% 32 != 0 {
144+ return fmt .Errorf ("proof buffer length must be a multiple of 32, got: %d" , len (ap .RawProof ))
118145 }
119146
120147 if len (ap .Instances ) == 0 {
@@ -128,27 +155,46 @@ func (ap *BatchProof) SanityCheck() error {
128155 return nil
129156}
130157
158+ // BundleProof
159+ type BundleProof interface {
160+ SanityCheck () error
161+ Proof () []byte
162+ }
163+
164+ // NewBundleProof creates a new BundleProof instance.
165+ func NewBundleProof (hardForkName string ) BundleProof {
166+ switch hardForkName {
167+ default :
168+ return & Halo2BundleProof {}
169+ }
170+ }
171+
131172// BundleProof includes the proof info that are required for verification of a bundle of batch proofs.
132- type BundleProof struct {
133- Proof []byte `json:"proof"`
173+ type Halo2BundleProof struct {
174+ RawProof []byte `json:"proof"`
134175 Instances []byte `json:"instances"`
135176 Vk []byte `json:"vk"`
136177 // cross-reference between cooridinator computation and prover compution
137178 GitVersion string `json:"git_version,omitempty"`
138179}
139180
181+ // Proof returns the proof bytes of a BundleProof
182+ func (ap * Halo2BundleProof ) Proof () []byte {
183+ return ap .RawProof
184+ }
185+
140186// SanityCheck checks whether a BundleProof is in a legal format
141- func (ap * BundleProof ) SanityCheck () error {
187+ func (ap * Halo2BundleProof ) SanityCheck () error {
142188 if ap == nil {
143189 return errors .New ("agg_proof is nil" )
144190 }
145191
146- if len (ap .Proof ) == 0 {
192+ if len (ap .RawProof ) == 0 {
147193 return errors .New ("proof not ready" )
148194 }
149195
150- if len (ap .Proof )% 32 != 0 {
151- return fmt .Errorf ("proof buffer length must be a multiple of 32, got: %d" , len (ap .Proof ))
196+ if len (ap .RawProof )% 32 != 0 {
197+ return fmt .Errorf ("proof buffer length must be a multiple of 32, got: %d" , len (ap .RawProof ))
152198 }
153199
154200 if len (ap .Instances ) == 0 {
0 commit comments