Line data Source code
1 : #include "../fd_zksdk_private.h" 2 : 3 : static inline int 4 : fd_zksdk_verify_proof_range_u128( 5 : fd_zksdk_range_proof_u128_proof_t const * proof, 6 : uchar const commitments [ 32 ], 7 : uchar const bit_lengths [ 1 ], 8 : uchar const batch_len, 9 51 : fd_zksdk_transcript_t * transcript ) { 10 : 11 51 : const fd_rangeproofs_ipp_proof_t ipp_proof = { 12 51 : 7, 13 51 : proof->ipp_lr_vec, 14 51 : proof->ipp_a, 15 51 : proof->ipp_b, 16 51 : }; 17 51 : int res = fd_rangeproofs_verify( 18 51 : &proof->range_proof, 19 51 : &ipp_proof, 20 51 : commitments, 21 51 : bit_lengths, 22 51 : batch_len, 23 51 : transcript 24 51 : ); 25 : 26 51 : if( FD_LIKELY( res == FD_RANGEPROOFS_SUCCESS ) ) { 27 27 : return FD_EXECUTOR_INSTR_SUCCESS; 28 27 : } 29 24 : return FD_ZKSDK_VERIFY_PROOF_ERROR; 30 51 : } 31 : 32 : int 33 51 : fd_zksdk_instr_verify_proof_batched_range_proof_u128( void const * _context, void const * _proof ) { 34 51 : fd_zksdk_transcript_t transcript[1]; 35 51 : fd_zksdk_batched_range_proof_context_t const * context = _context; 36 51 : fd_zksdk_range_proof_u128_proof_t const * proof = _proof; 37 : 38 51 : 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 51 : int val = batched_range_proof_init_and_validate( &batch_len, context, transcript ); 41 51 : 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 51 : return fd_zksdk_verify_proof_range_u128( proof, context->commitments, context->bit_lengths, batch_len, transcript ); 47 51 : }