@@ -524,6 +524,7 @@ where
524524 RingVerifierKeyBuilder { partial, raw_vk }
525525 }
526526
527+ /// Free public key slots.
527528 #[ inline( always) ]
528529 pub fn free_slots ( & self ) -> usize {
529530 self . partial . max_keys - self . partial . curr_keys
@@ -533,6 +534,11 @@ where
533534 ///
534535 /// If the `pks` length is greater than the number of available slots in the ring
535536 /// then an error is returned with the available slots count.
537+ ///
538+ /// If the available free slots are not sufficient to append `pks` sequence, the
539+ /// number of available slots are returned in the error variant.
540+ /// If the supplied loader returns `None`, then an error with `usize::MAX` is
541+ /// returned.
536542 pub fn append (
537543 & mut self ,
538544 pks : & [ AffinePoint < S > ] ,
@@ -543,12 +549,20 @@ where
543549 return Err ( avail_slots) ;
544550 }
545551 let pks = TEMapping :: to_te_slice ( pks) ;
546- let srs_loader = |range : Range < usize > | srs_loader. load ( range) . ok_or ( ( ) ) ;
552+ // Currently ring_proof backend panics if `srs_loader` fails.
553+ // As it stands, this workaround prevents it (but requires a clone).
554+ let segment = srs_loader
555+ . load ( self . partial . curr_keys ..self . partial . curr_keys + pks. len ( ) )
556+ . ok_or ( usize:: MAX ) ?;
557+ let srs_loader = |range : Range < usize > | {
558+ debug_assert_eq ! ( segment. len( ) , range. len( ) ) ;
559+ Ok ( segment. clone ( ) )
560+ } ;
547561 self . partial . append ( & pks, srs_loader) ;
548562 Ok ( ( ) )
549563 }
550564
551- /// Finalize and build verifier key.
565+ /// Build verifier key.
552566 pub fn finalize ( self ) -> RingVerifierKey < S > {
553567 RingVerifierKey :: < S > :: from_ring_and_kzg_vk ( & self . partial , self . raw_vk )
554568 }
0 commit comments