LCOV - code coverage report
Current view: top level - ballet/zksdk/instructions - fd_zksdk_batched_grouped_ciphertext_validity.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 2 2 100.0 %
Date: 2026-03-19 18:19:27 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_ballet_zksdk_instructions_fd_zksdk_batched_grouped_ciphertext_validity_h
       2             : #define HEADER_fd_src_ballet_zksdk_instructions_fd_zksdk_batched_grouped_ciphertext_validity_h
       3             : 
       4             : #include "../fd_zksdk_common.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           6 : #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           6 : #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             : struct __attribute__((packed)) fd_zksdk_grp_ciph_2h_val_context {
      55             :   uchar pubkey1 [ 32 ]; // point
      56             :   uchar pubkey2 [ 32 ]; // point
      57             :   grp_ciph_2h_t grouped_ciphertext[1]; // 3x points
      58             : };
      59             : typedef struct fd_zksdk_grp_ciph_2h_val_context fd_zksdk_grp_ciph_2h_val_context_t;
      60             : 
      61             : struct __attribute__((packed)) fd_zksdk_batched_grp_ciph_2h_val_context {
      62             :   uchar pubkey1 [ 32 ]; // point
      63             :   uchar pubkey2 [ 32 ]; // point
      64             :   grp_ciph_2h_t grouped_ciphertext_lo[1]; // 3x points
      65             :   grp_ciph_2h_t grouped_ciphertext_hi[1]; // 3x points
      66             : };
      67             : typedef struct fd_zksdk_batched_grp_ciph_2h_val_context fd_zksdk_batched_grp_ciph_2h_val_context_t;
      68             : 
      69             : struct __attribute__((packed)) fd_zksdk_grp_ciph_3h_val_context {
      70             :   uchar pubkey1 [ 32 ]; // point
      71             :   uchar pubkey2 [ 32 ]; // point
      72             :   uchar pubkey3 [ 32 ]; // point
      73             :   grp_ciph_3h_t grouped_ciphertext[1]; // 4x points
      74             : };
      75             : typedef struct fd_zksdk_grp_ciph_3h_val_context fd_zksdk_grp_ciph_3h_val_context_t;
      76             : 
      77             : struct __attribute__((packed)) fd_zksdk_batched_grp_ciph_3h_val_context {
      78             :   uchar pubkey1 [ 32 ]; // point
      79             :   uchar pubkey2 [ 32 ]; // point
      80             :   uchar pubkey3 [ 32 ]; // point
      81             :   grp_ciph_3h_t grouped_ciphertext_lo[1]; // 4x points
      82             :   grp_ciph_3h_t grouped_ciphertext_hi[1]; // 4x points
      83             : };
      84             : typedef struct fd_zksdk_batched_grp_ciph_3h_val_context fd_zksdk_batched_grp_ciph_3h_val_context_t;
      85             : 
      86             : int
      87             : fd_zksdk_verify_proof_direct_grouped_ciphertext_2_handles_validity(
      88             :   fd_zksdk_grp_ciph_2h_val_proof_t const * proof,
      89             :   uchar const                              pubkey1    [ 32 ],
      90             :   uchar const                              pubkey2    [ 32 ],
      91             :   uchar const                              comm       [ 32 ],
      92             :   uchar const                              handle1    [ 32 ],
      93             :   uchar const                              handle2    [ 32 ],
      94             :   uchar const                              comm_hi    [ 32 ],
      95             :   uchar const                              handle1_hi [ 32 ],
      96             :   uchar const                              handle2_hi [ 32 ],
      97             :   uchar const                              challenge_t[ 32 ],
      98             :   int   const                              batched,
      99             :   fd_zksdk_transcript_t *                  transcript );
     100             : 
     101             : int
     102             : fd_zksdk_verify_proof_direct_grouped_ciphertext_3_handles_validity(
     103             :   fd_zksdk_grp_ciph_3h_val_proof_t const * proof,
     104             :   uchar const                              pubkey1    [ 32 ],
     105             :   uchar const                              pubkey2    [ 32 ],
     106             :   uchar const                              pubkey3    [ 32 ],
     107             :   uchar const                              comm       [ 32 ],
     108             :   uchar const                              handle1    [ 32 ],
     109             :   uchar const                              handle2    [ 32 ],
     110             :   uchar const                              handle3    [ 32 ],
     111             :   uchar const                              comm_hi    [ 32 ],
     112             :   uchar const                              handle1_hi [ 32 ],
     113             :   uchar const                              handle2_hi [ 32 ],
     114             :   uchar const                              handle3_hi [ 32 ],
     115             :   uchar const                              challenge_t[ 32 ],
     116             :   int  const                               batched,
     117             :   fd_zksdk_transcript_t *                  transcript );
     118             : 
     119             : #endif /* HEADER_fd_src_ballet_zksdk_instructions_fd_zksdk_batched_grouped_ciphertext_validity_h */

Generated by: LCOV version 1.14