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