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

          Line data    Source code
       1             : #include "../fd_zksdk_private.h"
       2             : 
       3             : static inline int
       4             : fd_zksdk_verify_proof_range_u64(
       5             :   fd_zksdk_range_proof_u64_proof_t const * proof,
       6             :   uchar const                               commitments [ 32 ],
       7             :   uchar const                               bit_lengths [ 1 ],
       8             :   uchar const                               batch_len,
       9          48 :   fd_zksdk_transcript_t *                   transcript ) {
      10             : 
      11          48 :   const fd_rangeproofs_ipp_proof_t ipp_proof = {
      12          48 :     6,
      13          48 :     proof->ipp_lr_vec,
      14          48 :     proof->ipp_a,
      15          48 :     proof->ipp_b,
      16          48 :   };
      17          48 :   int res = fd_rangeproofs_verify(
      18          48 :     &proof->range_proof,
      19          48 :     &ipp_proof,
      20          48 :     commitments,
      21          48 :     bit_lengths,
      22          48 :     batch_len,
      23          48 :     transcript
      24          48 :   );
      25             : 
      26          48 :   if( FD_LIKELY( res == FD_RANGEPROOFS_SUCCESS ) ) {
      27          24 :     return FD_EXECUTOR_INSTR_SUCCESS;
      28          24 :   }
      29          24 :   return FD_ZKSDK_VERIFY_PROOF_ERROR;
      30          48 : }
      31             : 
      32             : int
      33          48 : fd_zksdk_instr_verify_proof_batched_range_proof_u64( void const * _context, void const * _proof ) {
      34          48 :   fd_zksdk_transcript_t transcript[1];
      35          48 :   fd_zksdk_batched_range_proof_context_t const * context = _context;
      36          48 :   fd_zksdk_range_proof_u64_proof_t const *       proof   = _proof;
      37             : 
      38          48 :   uchar batch_len = 0;
      39             :   /* https://github.com/anza-xyz/agave/blob/v2.0.1/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u64.rs#L82-L91 */
      40          48 :   int val = batched_range_proof_init_and_validate( &batch_len, context, transcript );
      41          48 :   if( FD_UNLIKELY( val != FD_EXECUTOR_INSTR_SUCCESS ) ) {
      42           0 :     return val;
      43           0 :   }
      44             : 
      45             :   /* https://github.com/anza-xyz/agave/blob/v2.0.1/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u64.rs#L93-L95 */
      46          48 :   return fd_zksdk_verify_proof_range_u64( proof, context->commitments, context->bit_lengths, batch_len, transcript );
      47          48 : }

Generated by: LCOV version 1.14