@@ -37,7 +37,8 @@ import {
3737 generateRandomFieldElement ,
3838 universalAccumulatorCombineMultipleD ,
3939 generateFieldElementFromBytes ,
40- generateFieldElementFromNumber
40+ generateFieldElementFromNumber ,
41+ universalAccumulatorFixedInitialElements
4142} from '@docknetwork/crypto-wasm' ;
4243import { MembershipWitness , NonMembershipWitness } from './accumulatorWitness' ;
4344import { getUint8ArraysFromObject } from '../util' ;
@@ -620,15 +621,26 @@ export class UniversalAccumulator extends Accumulator {
620621 initialElementsStore ?: IInitialElementsStore ,
621622 batchSize = 100
622623 ) : Promise < UniversalAccumulator > {
623- // store a batch of generated elements and take the product once the batch is full
624- let currentBatch = [ ] ;
624+ const storePresent = initialElementsStore !== undefined ;
625+
625626 // store the products of each batch
626627 const products : Uint8Array [ ] = [ ] ;
628+ // The first batch of products is the elements fixed for each curve, in this case it's for BLS12-381
629+ const fixed = universalAccumulatorFixedInitialElements ( ) ;
630+ if ( storePresent ) {
631+ for ( const i of fixed ) {
632+ await initialElementsStore . add ( i ) ;
633+ }
634+ }
635+ products . push ( universalAccumulatorComputeInitialFv ( fixed , secretKey ) ) ;
636+
637+ // store a batch of generated elements and take the product once the batch is full
638+ let currentBatch = [ ] ;
627639 // Accumulate 1 more than the maximum number of allowed members as specified in the paper
628640 for ( let i = 0 ; i <= maxSize ; i ++ ) {
629641 const e = generateRandomFieldElement ( ) ;
630642 currentBatch . push ( e ) ;
631- if ( initialElementsStore !== undefined ) {
643+ if ( storePresent ) {
632644 await initialElementsStore . add ( e ) ;
633645 }
634646 if ( currentBatch . length == batchSize ) {
0 commit comments