@@ -223,30 +223,14 @@ func (ap *Halo2BundleProof) SanityCheck() error {
223223
224224// Proof for flatten VM proof
225225type OpenVMProof struct {
226- Proof interface {} `json:"proofs"`
227- PublicValues []uint32 `json:"public_values"`
228- }
229-
230- type ByteArray []byte
231-
232- // MarshalJSON marshals a ByteArray to JSON
233- func (b ByteArray ) MarshalJSON () ([]byte , error ) {
234- builder := strings.Builder {}
235- builder .WriteString ("[" )
236- for i , v := range b {
237- builder .WriteString (fmt .Sprintf ("%d" , v ))
238- if i != len (b )- 1 {
239- builder .WriteString ("," )
240- }
241- }
242- builder .WriteString ("]" )
243- return []byte (builder .String ()), nil
226+ Proof []byte `json:"proofs"`
227+ PublicValues []byte `json:"public_values"`
244228}
245229
246230// Proof for flatten EVM proof
247231type OpenVMEvmProof struct {
248- Proof ByteArray `json:"proof"`
249- Instances [][] string `json:"instances"`
232+ Proof [] byte `json:"proof"`
233+ Instances []byte `json:"instances"`
250234}
251235
252236// OpenVMChunkProof includes the proof info that are required for chunk verification and rollup.
@@ -350,8 +334,21 @@ type OpenVMBundleProof struct {
350334 GitVersion string `json:"git_version,omitempty"`
351335}
352336
337+ // Proof returns the proof bytes that are eventually passed as calldata for on-chain bundle proof verification.
338+ //
339+ // There are 12 accumulators for a SNARK proof. The accumulators are the first 12 elements of the EvmProof's
340+ // Instances field. The remaining items in Instances are supplied on-chain by the ScrollChain contract.
341+ //
342+ // The structure of these bytes is:
343+ // | byte index start | byte length | value | description |
344+ // |------------------|----------------|----------|---------------------|
345+ // | 0 | 32 | accs[0] | accumulator 1 |
346+ // | 32 | 32 | accs[1] | accumulator 2 |
347+ // | 32*i ... | 32 | accs[i] | accumulator i ... |
348+ // | 352 | 32 | accs[11] | accumulator 12 |
349+ // | 384 | dynamic | proof | proof bytes |
353350func (p * OpenVMBundleProof ) Proof () []byte {
354- return p .EvmProof .Proof
351+ append ( p . EvmProof . Instances [ 0 : 384 ], p .EvmProof .Proof )
355352}
356353
357354// SanityCheck checks whether a BundleProof is in a legal format
0 commit comments