pub fn build_mapped_parameters(
        param_file: PathBuf,
        checked: bool,
    ) -> io::Result<MappedParameters<E>> {
        let mut offset: usize = 0;
        let params = File::open(&param_file)?;
        let mmap = unsafe { MmapOptions::new().map(&params)? };

        let u32_len = mem::size_of::<u32>();
        let g1_len = mem::size_of::<<E::G1Affine as CurveAffine>::Uncompressed>();
        let g2_len = mem::size_of::<<E::G2Affine as CurveAffine>::Uncompressed>();

        let read_length = |mmap: &Mmap, offset: &mut usize| -> Result<usize, std::io::Error> {
            let mut raw_len = &mmap[*offset..*offset + u32_len];
            *offset += u32_len;

            match raw_len.read_u32::<BigEndian>() {
                Ok(len) => Ok(len as usize),
                Err(err) => Err(err),
            }
        };

        let get_offsets = |mmap: &Mmap,
                           offset: &mut usize,
                           param: &mut Vec<Range<usize>>,
                           range_len: usize|
         -> Result<(), std::io::Error> {
            let len = read_length(&mmap, &mut *offset)?;
            for _ in 0..len {
                (*param).push(Range {
                    start: *offset,
                    end: *offset + range_len,
                });
                *offset += range_len;
            }

            Ok(())
        };

        let vk = VerifyingKey::<E>::read_mmap(&mmap, &mut offset)?;

        let mut h = vec![];
        let mut l = vec![];
        let mut a = vec![];
        let mut b_g1 = vec![];
        let mut b_g2 = vec![];

        get_offsets(&mmap, &mut offset, &mut h, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut l, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut a, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut b_g1, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut b_g2, g2_len)?;

        Ok(MappedParameters {
            param_file,
            vk,
            h,
            l,
            a,
            b_g1,
            b_g2,
            checked,
            _e: Default::default(),
        })
    }
// Quickly iterates through the parameter file, recording all
// parameter offsets and caches the verifying key (vk) for quick
// access via reference.
Quickly iterates through the parameter file, recording all
parameter offsets and caches the verifying key (vk) for quick
access via reference.
Quickly iterates through the parameter file recording all parameter offsets and caches the verifying key ( vk ) for quick access via reference .
pub fn build_mapped_parameters(
        param_file: PathBuf,
        checked: bool,
    ) -> io::Result<MappedParameters<E>> {
        let mut offset: usize = 0;
        let params = File::open(&param_file)?;
        let mmap = unsafe { MmapOptions::new().map(&params)? };
        let u32_len = mem::size_of::<u32>();
        let g1_len = mem::size_of::<<E::G1Affine as CurveAffine>::Uncompressed>();
        let g2_len = mem::size_of::<<E::G2Affine as CurveAffine>::Uncompressed>();
        let read_length = |mmap: &Mmap, offset: &mut usize| -> Result<usize, std::io::Error> {
            let mut raw_len = &mmap[*offset..*offset + u32_len];
            *offset += u32_len;
            match raw_len.read_u32::<BigEndian>() {
                Ok(len) => Ok(len as usize),
                Err(err) => Err(err),
            }
        };
        let get_offsets = |mmap: &Mmap,
                           offset: &mut usize,
                           param: &mut Vec<Range<usize>>,
                           range_len: usize|
         -> Result<(), std::io::Error> {
            let len = read_length(&mmap, &mut *offset)?;
            for _ in 0..len {
                (*param).push(Range {
                    start: *offset,
                    end: *offset + range_len,
                });
                *offset += range_len;
            }
            Ok(())
        };
        let vk = VerifyingKey::<E>::read_mmap(&mmap, &mut offset)?;
        let mut h = vec![];
        let mut l = vec![];
        let mut a = vec![];
        let mut b_g1 = vec![];
        let mut b_g2 = vec![];
        get_offsets(&mmap, &mut offset, &mut h, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut l, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut a, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut b_g1, g1_len)?;
        get_offsets(&mmap, &mut offset, &mut b_g2, g2_len)?;
        Ok(MappedParameters {
            param_file,
            vk,
            h,
            l,
            a,
            b_g1,
            b_g2,
            checked,
            _e: Default::default(),
        })
    }
pub fn build_mapped_parameters ( param_file : PathBuf , checked : bool , ) -> io :: Result < MappedParameters < E > > { let mut offset : usize = 0 ; let params = File :: open ( & param_file ) ? ; let mmap = unsafe { MmapOptions :: new ( ) . map ( & params ) ? } ; let u32_len = mem :: size_of :: < u32 > ( ) ; let g1_len = mem :: size_of :: < < E :: G1Affine as CurveAffine > :: Uncompressed > ( ) ; let g2_len = mem :: size_of :: < < E :: G2Affine as CurveAffine > :: Uncompressed > ( ) ; let read_length = | mmap : & Mmap , offset : & mut usize | -> Result < usize , std :: io :: Error > { let mut raw_len = & mmap [ * offset .. * offset + u32_len ] ; * offset += u32_len ; match raw_len . read_u32 :: < BigEndian > ( ) { Ok ( len ) => Ok ( len as usize ) , Err ( err ) => Err ( err ) , } } ; let get_offsets = | mmap : & Mmap , offset : & mut usize , param : & mut Vec < Range < usize > > , range_len : usize | -> Result < ( ) , std :: io :: Error > { let len = read_length ( & mmap , & mut * offset ) ? ; for _ in 0 .. len { ( * param ) . push ( Range { start : * offset , end : * offset + range_len , } ) ; * offset += range_len ; } Ok ( ( ) ) } ; let vk = VerifyingKey :: < E > :: read_mmap ( & mmap , & mut offset ) ? ; let mut h = vec ! [ ] ; let mut l = vec ! [ ] ; let mut a = vec ! [ ] ; let mut b_g1 = vec ! [ ] ; let mut b_g2 = vec ! [ ] ; get_offsets ( & mmap , & mut offset , & mut h , g1_len ) ? ; get_offsets ( & mmap , & mut offset , & mut l , g1_len ) ? ; get_offsets ( & mmap , & mut offset , & mut a , g1_len ) ? ; get_offsets ( & mmap , & mut offset , & mut b_g1 , g1_len ) ? ; get_offsets ( & mmap , & mut offset , & mut b_g2 , g2_len ) ? ; Ok ( MappedParameters { param_file , vk , h , l , a , b_g1 , b_g2 , checked , _e : Default :: default ( ) , } ) }
Quickly iterates through the parameter file, recording all
parameter offsets and caches the verifying key (vk) for quick
access via reference.
Quickly iterates through the parameter file recording all parameter offsets and caches the verifying key ( vk ) for quick access via reference .
param_file
PathBuf
checked
bool
param_file
PathBuf
checked
bool