Struct Keyshare

Source
pub struct Keyshare { /* private fields */ }
Expand description

A key share representing a party’s portion of a distributed secret key.

This struct encapsulates all the information needed for a party to participate in distributed key generation and signing protocols. It includes:

  • The party’s secret share
  • Public key components
  • Party ranks and identifiers
  • Oblivious transfer seeds
  • Additional protocol-specific data

The key share is stored in a compact binary format and provides methods for accessing its components and deriving child keys.

Implementations§

Source§

impl Keyshare

Source

pub const MAGIC: [u8; 4]

Magic number identifying valid key share data.

This constant is used to validate that a byte buffer contains a valid key share.

Source§

impl Keyshare

Source

pub fn new(n: u8, t: u8, id: u8, extra: &[u8]) -> Keyshare

Creates a new key share with the specified parameters.

§Arguments
  • n - Total number of parties in the protocol
  • t - Threshold value for the protocol
  • id - ID of this party
  • extra - Additional data to be embedded in the key share
§Panics

Panics if n is less than 2.

Source

pub fn from_bytes(buffer: &[u8]) -> Option<Self>

Creates a key share from a byte slice.

§Arguments
  • buffer - Byte slice containing the key share data
§Returns

Some(Keyshare) if the buffer contains valid key share data, None otherwise.

Source

pub fn from_vec(buffer: Vec<u8>) -> Result<Self, Vec<u8>>

Creates a key share from a vector of bytes.

§Arguments
  • buffer - Vector containing the key share data
§Returns

Ok(Keyshare) if the vector contains valid key share data, Err(buffer) otherwise.

Source

pub fn as_slice(&self) -> &[u8]

Returns the underlying byte slice of the key share.

Source

pub fn public_key(&self) -> ProjectivePoint

Returns the public key as a ProjectivePoint.

Source

pub fn rank_list(&self) -> Vec<u8>

Returns a vector of ranks for all parties.

Source

pub fn x_i_list(&self) -> Vec<NonZeroScalar>

Returns a vector of x-coordinates for all parties.

Source

pub fn zero_ranks(&self) -> bool

Returns true if all parties have rank zero.

Source

pub fn get_rank(&self, party_id: u8) -> u8

Returns the rank of a specific party.

§Arguments
  • party_id - ID of the party
Source

pub fn s_i(&self) -> Scalar

Returns the secret scalar s_i for this party.

Source

pub fn extra_data(&self) -> &[u8]

Returns the user-defined data embedded in the key share.

This data is passed via the setup message during key generation and is immutable.

Source

pub fn big_s(&self, party_id: u8) -> ProjectivePoint

Returns the public key component for a specific party.

§Arguments
  • party_id - ID of the party
Source§

impl Keyshare

Source

pub fn root_chain_code(&self) -> [u8; 32]

Returns the root chain code.

Source

pub fn root_public_key(&self) -> ProjectivePoint

Returns the root public key.

Source§

impl Keyshare

Source

pub fn get_finger_print(&self) -> KeyFingerPrint

Returns the key fingerprint.

Source

pub fn derive_with_offset( &self, chain_path: &DerivationPath, ) -> Result<(Scalar, ProjectivePoint), BIP32Error>

Derives a child key with the given chain path and offset.

§Arguments
  • chain_path - The derivation path to use
§Returns

A tuple containing the derived scalar and public key, or an error if derivation fails.

Source

pub fn derive_child_pubkey( &self, chain_path: &DerivationPath, ) -> Result<ProjectivePoint, BIP32Error>

Derives a child public key with the given chain path.

§Arguments
  • chain_path - The derivation path to use
§Returns

The derived public key, or an error if derivation fails.

Source

pub fn derive_xpub( &self, prefix: Prefix, chain_path: DerivationPath, ) -> Result<XPubKey, BIP32Error>

Derives an extended public key with the given prefix and chain path.

§Arguments
  • prefix - The prefix to use for the extended public key
  • chain_path - The derivation path to use
§Returns

The derived extended public key, or an error if derivation fails.

Trait Implementations§

Source§

impl Clone for Keyshare

Source§

fn clone(&self) -> Keyshare

Returns a copy 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 Deref for Keyshare

Source§

type Target = KeyshareInfo

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Drop for Keyshare

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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, dst: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more