[−][src]Struct bls_signature_aggregator::signature_aggregator::SignatureAggregator
Accumulator for signature shares for arbitrary payloads.
This accumulator allows to collect BLS signature shares for some payload one by one until enough of them are collected. At that point it combines them into a full BLS signature of the given payload. It also automatically rejects invalid signature shares and expires entries that did not collect enough signature shares within a given time.
The accumulated payload needs to implement Serialize
which is used in two ways:
- to calculate a cryptographic hash of the payload which is then used to compute the accumulation key. This means that two signature shares with payloads that serialize into the same byte sequence are accumulated together.
- to verify the signature share - the serialized payload is what is passed to the
verify
function.
The serialization is performed using bincode::serialize
which also needs to be used to
create the signature share.
This accumulator also handles the case when the same payload is signed with a signature share corresponding to a different BLS public key. In that case, the payloads will be accumulated separately. This avoids mixing signature shares created from different curves which would otherwise lead to invalid signature to be produced even though all the shares are valid.
Implementations
impl<T> SignatureAggregator<T> where
T: Debug + Serialize,
[src]
T: Debug + Serialize,
pub fn new() -> Self
[src]
Create new accumulator with default expiration.
pub fn with_expiration(expiration: Duration) -> Self
[src]
Create new accumulator with the given expiration.
pub fn add(
&mut self,
payload: T,
proof_share: ProofShare
) -> Result<(T, Proof), AccumulationError>
[src]
&mut self,
payload: T,
proof_share: ProofShare
) -> Result<(T, Proof), AccumulationError>
Add new share into the accumulator. If enough valid signature shares were collected, returns
the payload and its corresponding Proof
(signature + public key). Otherwise returns error
which details why the accumulation did not succeed yet.
Note: returned AccumulationError::NotEnoughShares
does not indicate a failure. It simply
means more shares still need to be added for that particular payload. Similarly,
AccumulationError::AlreadyAccumulated
means the signature was already accumulated and
adding more shares has no effect. These two errors could be safely ignored (they might
still be useful perhaps for debugging). The other error variants, however, indicate
failures and should be treated a such. See AccumulationError
for more info.
Note: the signature_share
field in the proof_share
must be created by serializing the
payload
with bincode::serialize
and signing the resulting bytes. Other serialization
formats are not currently supported.
Trait Implementations
impl<T> Default for SignatureAggregator<T> where
T: Debug + Serialize,
[src]
T: Debug + Serialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for SignatureAggregator<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SignatureAggregator<T> where
T: Send,
T: Send,
impl<T> Sync for SignatureAggregator<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SignatureAggregator<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SignatureAggregator<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,