DirtyCoreKeyShare

Struct DirtyCoreKeyShare 

Source
pub struct DirtyCoreKeyShare<E: Curve> {
    pub i: u16,
    pub key_info: DirtyKeyInfo<E>,
    pub x: NonZero<SecretScalar<E>>,
}
Expand description

Dirty (unvalidated) core key share

Key share can be either polynomial or additive:

  • Polynomial key share:

    • Supports any threshold $2 \le t \le n$
    • All signers co-share a secret polynomial $F(x)$ with degree $deg(F) = t-1$
    • Signer with index $i$ (index is in range $0 \le i < n$) holds secret share $x_i = F(I_i)$
    • Shared secret key is $\sk = F(0)$.

    If key share is polynomial, vss_setup fiels should be Some(_).

    $I_j$ mentioned above is defined in VssSetup::I. Reasonable default would be $I_j = j+1$.

  • Additive key share:

    • Always non-threshold (i.e. $t=n$)
    • Signer with index $i$ holds a secret share $x_i$
    • All signers share a secret key that is sum of all secret shares $\sk = \sum_{j \in [n]} x_j$.

    Advantage of additive share is that DKG protocol that yields additive share is a bit more efficient.

§HD wallets support

If hd-wallets feature is enabled, key share provides basic support of deterministic key derivation:

  • chain_code field is added. If it’s Some(_), then the key is HD-capable. (shared_public_key, chain_code) is extended public key of the wallet (can be retrieved via extended_public_key method).
    • Setting chain_code to None disables HD wallets support for the key
  • Convenient methods are provided such as derive_child_public_key

§Serialization format via serde

We make our best effort to keep serialization format the same between the versions (even with breaking changes), and so far we’ve never introduced breaking change into the serialization format. This ensures that newer versions of library are able to deserialize the key shares produced by the old version version of the library.

It’s unlikely, but at some point, we might introduce a breaking change into the serialization format. In this case, we’ll announce it and publish the migration instructions.

Not every serde backend supports features that we use to ensure backwards compatibility. We require that field names are being serialized, that helps us adding new fields as the library grows. We strongly advise using either serde_json, if verbose/human-readable format is needed, or ciborium, if you’d like to opt for binary format. Other serialization backends are not tested and may not work or stop working at some point (like bincode did) or be not backwards compatible between certain versions.

If you need the smallest size of serialized key share, we advise implementing serialization manually (all fields of the key share are public!).

Fields§

§i: u16

Index of local party in key generation protocol

§key_info: DirtyKeyInfo<E>

Public key info

§x: NonZero<SecretScalar<E>>

Secret share $x_i$

Implementations§

Source§

impl<E: Curve> DirtyCoreKeyShare<E>

Source

pub fn is_hd_wallet(&self) -> bool

Available on crate feature hd-wallet only.

Checks whether the key is HD-capable

Source

pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>

Available on crate feature hd-wallet only.

Returns extended public key, if HD support was enabled

Source

pub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>( &self, derivation_path: impl IntoIterator<Item = ChildIndex>, ) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>
where NonHardenedIndex: TryFrom<ChildIndex>,

Available on crate feature hd-wallet only.

Derives child public key, if it’s HD key

Methods from Deref<Target = DirtyKeyInfo<E>>§

Source

pub fn share_preimage(&self, j: u16) -> Option<NonZero<Scalar<E>>>

Returns share preimage associated with j-th signer

  • For additive shares, share preimage is defined as j+1
  • For VSS-shares, share preimage is scalar $I_j$ such that $x_j = F(I_j)$ where $F(x)$ is polynomial co-shared by the signers and $x_j$ is secret share of j-th signer

Note: if you have no idea what it is, probably you don’t need it.

Source

pub fn is_hd_wallet(&self) -> bool

Available on crate feature hd-wallet only.

Checks whether the key is HD-capable

Source

pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>

Available on crate feature hd-wallet only.

Returns extended public key, if HD support was enabled

Source

pub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>( &self, derivation_path: impl IntoIterator<Item = ChildIndex>, ) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>
where NonHardenedIndex: TryFrom<ChildIndex>,

Available on crate feature hd-wallet only.

Derives child public key, if it’s HD key, using HdWallet algorithm

Trait Implementations§

Source§

impl<E: Curve> AsRef<DirtyKeyInfo<E>> for DirtyCoreKeyShare<E>

Source§

fn as_ref(&self) -> &DirtyKeyInfo<E>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<E: Clone + Curve> Clone for DirtyCoreKeyShare<E>

Source§

fn clone(&self) -> DirtyCoreKeyShare<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Curve> Deref for DirtyCoreKeyShare<E>

Source§

type Target = DirtyKeyInfo<E>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de, E: Curve> Deserialize<'de> for DirtyCoreKeyShare<E>

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<E: Curve> Serialize for DirtyCoreKeyShare<E>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<E: Curve> Validate for DirtyCoreKeyShare<E>

Source§

type Error = InvalidCoreShare

Validation error
Source§

fn is_valid(&self) -> Result<(), Self::Error>

Checks whether value is valid Read more
Source§

fn validate(self) -> Result<Valid<Self>, ValidateError<Self, Self::Error>>
where Self: Sized,

Validates the value Read more
Source§

fn validate_ref(&self) -> Result<&Valid<Self>, Self::Error>
where Self: Sized,

Validates the value by reference Read more
Source§

impl<E: Curve> ValidateFromParts<(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>)> for DirtyCoreKeyShare<E>

Source§

fn validate_parts( (i, key_info, x): &(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> Result<(), Self::Error>

Validates parts Read more
Source§

fn from_parts( (i, key_info, x): (u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> Self

Constructs Self from parts

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,