Starting Vector serves as the starting point for GSM (Global State Machine) initialization and also acts as the basis for key generation.
Below is a reference test implementation of the Starting Vector generation.
moduletypeFIELD=sigtypetvalzero: tvalone: tvaladd: t -> t -> tvalmul: t -> t -> tvalsub: t -> t -> tvalinv: t -> tvalrand: unit -> tendmodulePrimeField:FIELDwithtypet=Z.t = structtypet=Z.tletprime=Z.(nextprime (one lsl 1024))letzero=Z.zeroletone=Z.oneletadd=Z.addletmul=Z.mulletsub=Z.subletinvx=Z.invert x primeletrand()=letbits=Z.numbits prime inletrecloop()=letr=Z.(random_bits bits mod prime) inifZ.(r >= prime) then loop ()else rin loop ()endmoduleVector (F:FIELD) =structtypet=F.t listletinitn: t =List.init n (fun_->F.rand ())letmap2fab=List.map2 f a bletreduce=List.fold_left F.add F.zeroendmoduleStartingVector=structmoduleV=Vector(PrimeField)letphiap=letopenPrimeFieldinletr= rand ()in mul (add (mul a a) r) (add a one)letgeneraten:PrimeField.t list=leta=V.init n inletp=V.init n inletphi_applied=List.map2 phi a p inList.map V.reduce (List.map (funx->[x]) phi_applied)end