We currently clone the measurement share inside of Prio3::prepare_init(), out of the input share, to save a copy in the prepare state. If the input share and prepare state structs both used an Arc smart pointer for this, then we could shuffle the ownership around without a copy. This could potentially be a very large allocation, depending on VDAF parameters. See divviup/janus#3285.
Both Prio3InputShare and Prio3PrepareState have all their fields private, so this could be done transparently. However, note that both use prio::vdaf::Share, which is public, and exposes that it contains a Vec<F>. I think the best way to implement this would be to create a new enum similar to Share, but with an Arc<Vec<F>> in one variant, and abandon use of Share for the measurement share fields internally. This would save us from big copies while not adding any allocation or atomic instruction overhead to the helper share case (i.e. from using Arc<Share<F, SEED_SIZE>>).
We currently clone the measurement share inside of
Prio3::prepare_init(), out of the input share, to save a copy in the prepare state. If the input share and prepare state structs both used anArcsmart pointer for this, then we could shuffle the ownership around without a copy. This could potentially be a very large allocation, depending on VDAF parameters. See divviup/janus#3285.Both
Prio3InputShareandPrio3PrepareStatehave all their fields private, so this could be done transparently. However, note that both useprio::vdaf::Share, which is public, and exposes that it contains aVec<F>. I think the best way to implement this would be to create a new enum similar toShare, but with anArc<Vec<F>>in one variant, and abandon use ofSharefor the measurement share fields internally. This would save us from big copies while not adding any allocation or atomic instruction overhead to the helper share case (i.e. from usingArc<Share<F, SEED_SIZE>>).