LCOV - code coverage report
Current view: top level - flamenco/runtime/program/zksdk/instructions - fd_zksdk_batched_grouped_ciphertext_validity.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 2 2 100.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_zksdk_batched_grouped_ciphertext_validity_h
       2             : #define HEADER_fd_zksdk_batched_grouped_ciphertext_validity_h
       3             : 
       4             : #include "../../../../fd_flamenco_base.h"
       5             : 
       6             : /*
       7             :  * Proof
       8             :  */
       9             : 
      10             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/sigma_proofs/grouped_ciphertext_validity/handles_2.rs */
      11             : struct __attribute__((packed)) fd_zksdk_grp_ciph_2h_val_proof {
      12             :   uchar y0[ 32 ]; // point
      13             :   uchar y1[ 32 ]; // point
      14             :   uchar y2[ 32 ]; // point
      15             :   uchar zr[ 32 ]; // scalar
      16             :   uchar zx[ 32 ]; // scalar
      17             : };
      18             : typedef struct fd_zksdk_grp_ciph_2h_val_proof fd_zksdk_grp_ciph_2h_val_proof_t;
      19          39 : #define fd_zksdk_batched_grp_ciph_2h_val_proof_t fd_zksdk_grp_ciph_2h_val_proof_t
      20             : 
      21             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/sigma_proofs/grouped_ciphertext_validity/handles_3.rs#L46 */
      22             : struct __attribute__((packed)) fd_zksdk_grp_ciph_3h_val_proof {
      23             :   uchar y0[ 32 ]; // point
      24             :   uchar y1[ 32 ]; // point
      25             :   uchar y2[ 32 ]; // point
      26             :   uchar y3[ 32 ]; // point
      27             :   uchar zr[ 32 ]; // scalar
      28             :   uchar zx[ 32 ]; // scalar
      29             : };
      30             : typedef struct fd_zksdk_grp_ciph_3h_val_proof fd_zksdk_grp_ciph_3h_val_proof_t;
      31          33 : #define fd_zksdk_batched_grp_ciph_3h_val_proof_t fd_zksdk_grp_ciph_3h_val_proof_t
      32             : 
      33             : /*
      34             :  * Context
      35             :  */
      36             : 
      37             : struct __attribute__((packed)) grp_ciph_handle {
      38             :   uchar handle [ 32 ]; // point
      39             : };
      40             : typedef struct grp_ciph_handle grp_ciph_handle_t;
      41             : 
      42             : struct __attribute__((packed)) grp_ciph_2h {
      43             :   uchar commitment         [ 32 ]; // point
      44             :   grp_ciph_handle_t handles [ 2 ]; // 2x points
      45             : };
      46             : typedef struct grp_ciph_2h grp_ciph_2h_t;
      47             : 
      48             : struct __attribute__((packed)) grp_ciph_3h {
      49             :   uchar commitment         [ 32 ]; // point
      50             :   grp_ciph_handle_t handles [ 3 ]; // 3x points
      51             : };
      52             : typedef struct grp_ciph_3h grp_ciph_3h_t;
      53             : 
      54             : 
      55             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/zk_elgamal_proof_program/proof_data/grouped_ciphertext_validity/handles_2.rs */
      56             : struct __attribute__((packed)) fd_zksdk_grp_ciph_2h_val_context {
      57             :   uchar pubkey1 [ 32 ]; // point
      58             :   uchar pubkey2 [ 32 ]; // point
      59             :   grp_ciph_2h_t grouped_ciphertext; // 3x points
      60             : };
      61             : typedef struct fd_zksdk_grp_ciph_2h_val_context fd_zksdk_grp_ciph_2h_val_context_t;
      62             : 
      63             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_grouped_ciphertext_validity/handles_2.rs#L47 */
      64             : struct __attribute__((packed)) fd_zksdk_batched_grp_ciph_2h_val_context {
      65             :   uchar pubkey1 [ 32 ]; // point
      66             :   uchar pubkey2 [ 32 ]; // point
      67             :   grp_ciph_2h_t grouped_ciphertext_lo; // 3x points
      68             :   grp_ciph_2h_t grouped_ciphertext_hi; // 3x points
      69             : };
      70             : typedef struct fd_zksdk_batched_grp_ciph_2h_val_context fd_zksdk_batched_grp_ciph_2h_val_context_t;
      71             : 
      72             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/zk_elgamal_proof_program/proof_data/grouped_ciphertext_validity/handles_3.rs#L47 */
      73             : struct __attribute__((packed)) fd_zksdk_grp_ciph_3h_val_context {
      74             :   uchar pubkey1 [ 32 ]; // point
      75             :   uchar pubkey2 [ 32 ]; // point
      76             :   uchar pubkey3 [ 32 ]; // point
      77             :   grp_ciph_3h_t grouped_ciphertext; // 4x points
      78             : };
      79             : typedef struct fd_zksdk_grp_ciph_3h_val_context fd_zksdk_grp_ciph_3h_val_context_t;
      80             : 
      81             : /* https://github.com/anza-xyz/agave/blob/master/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_grouped_ciphertext_validity/handles_3.rs */
      82             : struct __attribute__((packed)) fd_zksdk_batched_grp_ciph_3h_val_context {
      83             :   uchar pubkey1 [ 32 ]; // point
      84             :   uchar pubkey2 [ 32 ]; // point
      85             :   uchar pubkey3 [ 32 ]; // point
      86             :   grp_ciph_3h_t grouped_ciphertext_lo; // 4x points
      87             :   grp_ciph_3h_t grouped_ciphertext_hi; // 4x points
      88             : };
      89             : typedef struct fd_zksdk_batched_grp_ciph_3h_val_context fd_zksdk_batched_grp_ciph_3h_val_context_t;
      90             : 
      91             : int
      92             : fd_zksdk_verify_proof_batched_grouped_ciphertext_2_handles_validity(
      93             :   fd_zksdk_grp_ciph_2h_val_proof_t const * proof,
      94             :   uchar const                              pubkey1    [ 32 ],
      95             :   uchar const                              pubkey2    [ 32 ],
      96             :   uchar const                              comm       [ 32 ],
      97             :   uchar const                              handle1    [ 32 ],
      98             :   uchar const                              handle2    [ 32 ],
      99             :   uchar const                              comm_hi    [ 32 ],
     100             :   uchar const                              handle1_hi [ 32 ],
     101             :   uchar const                              handle2_hi [ 32 ],
     102             :   bool const                               batched,
     103             :   fd_zksdk_transcript_t *                  transcript );
     104             : 
     105             : int
     106             : fd_zksdk_verify_proof_batched_grouped_ciphertext_3_handles_validity(
     107             :   fd_zksdk_grp_ciph_3h_val_proof_t const * proof,
     108             :   uchar const                              pubkey1    [ 32 ],
     109             :   uchar const                              pubkey2    [ 32 ],
     110             :   uchar const                              pubkey3    [ 32 ],
     111             :   uchar const                              comm       [ 32 ],
     112             :   uchar const                              handle1    [ 32 ],
     113             :   uchar const                              handle2    [ 32 ],
     114             :   uchar const                              handle3    [ 32 ],
     115             :   uchar const                              comm_hi    [ 32 ],
     116             :   uchar const                              handle1_hi [ 32 ],
     117             :   uchar const                              handle2_hi [ 32 ],
     118             :   uchar const                              handle3_hi [ 32 ],
     119             :   bool const                               batched,
     120             :   fd_zksdk_transcript_t *                  transcript );
     121             : 
     122             : #endif /* HEADER_fd_zksdk_batched_grouped_ciphertext_validity_h */

Generated by: LCOV version 1.14