Mina中的zkApp交易snark

1. 引言

前序博客有:

Mina中的user_command交易目前有:

  • 1)Signed_command交易:
    • 1.1)Payment交易
    • 1.2)Stake_delegation交易
  • 2)Parties交易

2. Parties交易结构

Parties.Stable.V1.t结构为:

	type t =
      { fee_payer : Party.Fee_payer.Stable.V1.t
      ; other_parties :
          ( Party.Stable.V1.t
          , Digest.Party.Stable.V1.t
          , Digest.Forest.Stable.V1.t )
          Call_forest.Stable.V1.t
      ; memo : Signed_command_memo.Stable.V1.t
      }

其中:

  • 1)fee_payer字段,Party.Fee_payer.Stable.V1.t结构为:
    type t =
        { body : Body.Fee_payer.Stable.V1.t
        ; authorization : Signature.Stable.V1.t (* 为Schnorr签名:Field.t * Inner_curve.Scalar.t *)
        }
    
    • 1.1)fee_payer.body字段,Body.Fee_payer.Stable.V1.t结构为:
      (* 《1》 body字段,Body.Fee_payer.Stable.V1.t结构为: *)
         type t =
           { public_key : Public_key.Compressed.Stable.V1.t (* 压缩公钥 *)
           ; update : Update.Stable.V1.t (* 包含app_state、delegate、verification_key、permissions、zkapp_uri、token_symbol、timing、voting_for这8个字段。 *)
           ; fee : Fee.Stable.V1.t (* 为Unsigned.UInt64.t *)
           ; events : Events'.Stable.V1.t (* 为Pickles.Backend.Tick.Field.Stable.V1.t array list *)
           ; sequence_events : Events'.Stable.V1.t (* 为Pickles.Backend.Tick.Field.Stable.V1.t array list *)
           ; protocol_state_precondition :
               Zkapp_precondition.Protocol_state.Stable.V1.t (* 包含snarked_ledger_hash、timestamp、blockchain_length、min_window_density、last_vrf_output、total_currency、global_slot_since_hard_fork、global_slot_since_genesis、staking_epoch_data和next_epoch_data这10个字段。 *)
                 [@name "networkPrecondition"]
           ; nonce : Account_nonce.Stable.V1.t (* 为Unsigned_extended.UInt32.t *)
           }
      (* 《1.1》 body.update字段,Update.Stable.V1.t结构为: *)
       type t =
         { app_state :
             F.Stable.V1.t Set_or_keep.Stable.V1.t Zkapp_state.V.Stable.V1.t (* 为8 fields(Set或Keep类型) of 32 bytes each of arbitrary storage *)
         ; delegate : Public_key.Compressed.Stable.V1.t Set_or_keep.Stable.V1.t (* 为Set或Keep类型的压缩公钥 *)
         ; verification_key :
             ( Pickles.Side_loaded.Verification_key.Stable.V2.t
             , F.Stable.V1.t )
             With_hash.Stable.V1.t
             Set_or_keep.Stable.V1.t (* 为Set或Keep类型,可包含data(包含max_width、wrap_index和wrap_vk三个字段)和hash两个字段。 *)
         ; permissions : Permissions.Stable.V2.t Set_or_keep.Stable.V1.t (* 为Set或Keep类型,包含edit_state、send、receive、set_delegate、set_permissions、set_verification_key、set_zkapp_uri、edit_sequence_state、set_token_symbol、increment_nonce、set_voting_for共11个字段,均为Auth_required枚举类型:None | Either | Proof | Signature | Impossible。 *)
         ; zkapp_uri : string Set_or_keep.Stable.V1.t (* 为Set或Keep类型,string *)
         ; token_symbol :
             Account.Token_symbol.Stable.V1.t Set_or_keep.Stable.V1.t  (* 为Set或Keep类型,string *)
         ; timing : Timing_info.Stable.V1.t Set_or_keep.Stable.V1.t (* 为Set或Keep类型,包含:initial_minimum_balance(为Unsigned.UInt64.t类型)、cliff_time(为global_slot,Unsigned_extended.UInt32.t类型)、cliff_amount(为Unsigned.UInt64.t类型)、vesting_period(为global_slot,Unsigned_extended.UInt32.t类型)、vesting_increment(为Unsigned.UInt64.t类型)这5个字段。
         ; voting_for : State_hash.Stable.V1.t Set_or_keep.Stable.V1.t (* 为Set或Keep类型,Field.t哈希值。 *)
         }
      (* 《1.1.1》body.update.verification_key字段,为With_hash.Stable.V1.t  Set_or_keep.Stable.V1.t,其中With_hash.Stable.V1.t结构为: *)
         type ('a, 'h) t = { data : 'a; hash : 'h } (* hash字段为F.t结构 *)
         (* 其中data字段,为 Side_loaded_verification_key.Stable.V2.t结构为:*)
         type t =
           ( G.Stable.V1.t (* 为曲线上的point。 *)
           , unit )
           Pickles_base.Side_loaded_verification_key.Poly.Stable.V2.t
         type ('g, 'vk) t = (* 其中‘vk为 uint。 *)
             { max_width : Width.Stable.V1.t (* 对应为char类型 *)
             ; wrap_index : 'g Plonk_verification_key_evals.Stable.V2.t (* 包含sigma_comm/coefficients_comm/generic_comm/psm_comm/complete_add_comm/mul_comm/emul_comm/endomul_scalar_comm这8个字段。 *)
             ; wrap_vk : 'vk option (* 其中‘vk为 uint。 *)
             }
         (* wrap_index字段,为Plonk_verification_key_evals.Stable.V2.t结构: *)
         type 'comm t = (* 'comm对应为 G.Stable.V1.t结构 *)
           { sigma_comm : 'comm Plonk_types.Permuts_vec.Stable.V1.t
           ; coefficients_comm : 'comm Plonk_types.Columns_vec.Stable.V1.t
           ; generic_comm : 'comm
           ; psm_comm : 'comm
           ; complete_add_comm : 'comm
           ; mul_comm : 'comm
           ; emul_comm : 'comm
           ; endomul_scalar_comm : 'comm
           }
      (* 《1.1.2》body.update.permissions字段,为 Permissions.Stable.V2.t Set_or_keep.Stable.V1.t结构,其中Permissions.Stable.V2.t 结构为: *)
      type t = Auth_required.Stable.V2.t Poly.Stable.V2.t
      type 'controller t =  (* 此处 'controller 为 Auth_required为枚举类型:None | Either | Proof | Signature | Impossible *)
         { edit_state : 'controller
         ; send : 'controller
         ; receive : 'controller (* TODO: Consider having fee *)
         ; set_delegate : 'controller
         ; set_permissions : 'controller
         ; set_verification_key : 'controller
         ; set_zkapp_uri : 'controller
         ; edit_sequence_state : 'controller
         ; set_token_symbol : 'controller
         ; increment_nonce : 'controller
         ; set_voting_for : 'controller
         }
      (* 《1.2》 body.protocol_state_precondition,为Zkapp_precondition.Protocol_state.Stable.V1.t结构: *)
      type t =
         ( Frozen_ledger_hash.Stable.V1.t Hash.Stable.V1.t (* 哈希值,为Check of Field 或 Ignore类型。 *)
         , Block_time.Stable.V1.t Numeric.Stable.V1.t (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
         , Length.Stable.V1.t Numeric.Stable.V1.t  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
         , unit (* TODO *)
         , Global_slot.Stable.V1.t Numeric.Stable.V1.t  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
         , Currency.Amount.Stable.V1.t Numeric.Stable.V1.t (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
         , Epoch_data.Stable.V1.t ) (* 包含ledger、seed、start_checkpoint、lock_checkpoint、epoch_length这5个字段。 *)
         Poly.Stable.V1.t
      type ( 'snarked_ledger_hash (* 哈希值,为Check of Field 或 Ignore类型。 *)
              , 'time  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
              , 'length  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
              , 'vrf_output (* 为unit *)
              , 'global_slot  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
              , 'amount (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
              , 'epoch_data ) (* 包含ledger、seed、start_checkpoint、lock_checkpoint、epoch_length这5个字段。 *)
              t =
           { (* TODO:
                We should include staged ledger hash again! It only changes once per
                block. *)
             snarked_ledger_hash : 'snarked_ledger_hash (* 哈希值,为Check of Field 或 Ignore类型。 *)
           ; timestamp : 'time  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
           ; blockchain_length : 'length  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
                 (* TODO: This previously had epoch_count but I removed it as I believe it is redundant
                    with global_slot_since_hard_fork.
      
                    epoch_count in [a, b]
      
                    should be equivalent to
      
                    global_slot_since_hard_fork in [slots_per_epoch * a, slots_per_epoch * b]
                 *)
           ; min_window_density : 'length  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
           ; last_vrf_output : 'vrf_output [@skip] (* 为unit *)
           ; total_currency : 'amount  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned.UInt64.t类型 *)
           ; global_slot_since_hard_fork : 'global_slot  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
           ; global_slot_since_genesis : 'global_slot  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
           ; staking_epoch_data : 'epoch_data (* 包含ledger、seed、start_checkpoint、lock_checkpoint、epoch_length这5个字段。 *)
           ; next_epoch_data : 'epoch_data (* 包含ledger、seed、start_checkpoint、lock_checkpoint、epoch_length这5个字段。 *)
           }
      (* 《1.2.1》 staking_epoch_data和next_epoch_data字段,为Epoch_data.Stable.V1.t结构: *)
         type t =
           ( ( Frozen_ledger_hash.Stable.V1.t Hash.Stable.V1.t 
             , Currency.Amount.Stable.V1.t Numeric.Stable.V1.t ) (* 为Check或Ignore类型,为二元结构,分别为Field.t哈希值 和  包含lower和upper字段(均为Unsigned.UInt64.t类型)的Currency.Amount *)
             Epoch_ledger.Poly.Stable.V1.t (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
           , Epoch_seed.Stable.V1.t Hash.Stable.V1.t (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
           , State_hash.Stable.V1.t Hash.Stable.V1.t (* 为Check或Ignore类型,为Field.t *)
           , State_hash.Stable.V1.t Hash.Stable.V1.t (* 为Check或Ignore类型,为Field.t *)
           , Length.Stable.V1.t Numeric.Stable.V1.t ) (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
           Poly.Stable.V1.t
      type ( 'epoch_ledger (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
            , 'epoch_seed (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
            , 'start_checkpoint (* 为Check或Ignore类型,为Field.t *)
            , 'lock_checkpoint (* 为Check或Ignore类型,为Field.t *)
            , 'length )  (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
            t =
         { ledger : 'epoch_ledger (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
         ; seed : 'epoch_seed (* 为Check或Ignore类型,为Snark_params.Tick.Field.t *)
         ; start_checkpoint : 'start_checkpoint (* 为Check或Ignore类型,为Field.t *)
               (* The lock checkpoint is the hash of the latest state in the seed update range, not including
                  the current state. *)
         ; lock_checkpoint : 'lock_checkpoint (* 为Check或Ignore类型,为Field.t *)
         ; epoch_length : 'length (* 为Check或Ignore类型,包含lower和upper字段,均为Unsigned_extended.UInt32.t类型 *)
         }
      
  • 2)other_parties字段,Call_forest.Stable.V1.t结构为:
    other_parties :
          ( Party.Stable.V1.t
          , Digest.Party.Stable.V1.t
          , Digest.Forest.Stable.V1.t )
          Call_forest.Stable.V1.t
    

附录1. Mina系列博客

Mina系列博客有:

猜你喜欢

转载自blog.csdn.net/mutourend/article/details/125805309