[][src]Struct xaynet::message::Sum

pub struct Sum {
    pub sum_signature: ParticipantTaskSignature,
    pub ephm_pk: SumParticipantEphemeralPublicKey,
}

A high level representation of a sum message.

These messages are sent by sum participants during the sum phase.

Examples

Decoding a message

let signature = vec![0x11; 64];
let ephm_pk = vec![0x22; 32];
let bytes = [signature.as_slice(), ephm_pk.as_slice()].concat();
let parsed = SumOwned::from_bytes(&bytes).unwrap();
let expected = SumOwned {
    sum_signature: ParticipantTaskSignature::from_slice(&signature[..]).unwrap(),
    ephm_pk: SumParticipantEphemeralPublicKey::from_slice(&ephm_pk[..]).unwrap(),
};
assert_eq!(parsed, expected);

Encoding a message

let sum_signature = ParticipantTaskSignature::from_slice(vec![0x11; 64].as_slice()).unwrap();
let ephm_pk = SumParticipantEphemeralPublicKey::from_slice(vec![0x22; 32].as_slice()).unwrap();
let msg = Sum {
    sum_signature,
    ephm_pk,
};
// we need a 96 bytes long buffer to serialize that message
assert_eq!(msg.buffer_length(), 96);
// create a buffer with enough space and encode the message
let mut buf = vec![0xff; 96];
msg.to_bytes(&mut buf);

assert_eq!(buf, [vec![0x11; 64].as_slice(), vec![0x22; 32].as_slice()].concat());

Fields

sum_signature: ParticipantTaskSignature

The signature of the round seed and the word "sum".

This is used to determine whether a participant is selected for the sum task.

ephm_pk: SumParticipantEphemeralPublicKey

An ephemeral public key generated by a sum participant for the current round.

Trait Implementations

impl Clone for Sum[src]

impl Debug for Sum[src]

impl Eq for Sum[src]

impl<D, M, N> From<Sum> for Payload<D, M, N>[src]

impl PartialEq<Sum> for Sum[src]

impl StructuralEq for Sum[src]

impl StructuralPartialEq for Sum[src]

impl ToBytes for Sum[src]

Auto Trait Implementations

impl RefUnwindSafe for Sum

impl Send for Sum

impl Sync for Sum

impl Unpin for Sum

impl UnwindSafe for Sum

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]