Skip to main content

SphinxSuite

Trait SphinxSuite 

Source
pub trait SphinxSuite {
    type P: Keypair;
    type E: Scalar + for<'a> From<&'a Self::P>;
    type ExpandedPublic;
    type G: GroupElement<Self::E> + for<'a> From<&'a Self::ExpandedPublic>;
    type PRP: PRP + KeyIvInit;

    // Required method
    fn expand_public(
        public_key: &<Self::P as Keypair>::Public,
    ) -> Result<Self::ExpandedPublic>;

    // Provided methods
    fn expand_path(
        public_keys: &[<Self::P as Keypair>::Public],
    ) -> Result<Vec<Self::ExpandedPublic>> { ... }
    fn new_shared_keys<'a>(
        public_keys: &'a [<Self::P as Keypair>::Public],
    ) -> Result<SharedKeys<Self::E, Self::G>>
       where &'a Array<u8, <Self::G as GroupElement<Self::E>>::AlphaLen>: From<&'a <Self::P as Keypair>::Public> { ... }
    fn new_shared_keys_expanded<'a>(
        public_keys: &'a [Self::ExpandedPublic],
    ) -> Result<SharedKeys<Self::E, Self::G>>
       where &'a Array<u8, <Self::G as GroupElement<Self::E>>::AlphaLen>: From<&'a Self::ExpandedPublic> { ... }
    fn new_prp_init(secret: &SecretKey) -> Result<IvKey<Self::PRP>> { ... }
    fn new_reply_prp_init(
        secret: &SecretKey16,
        salt: &[u8],
    ) -> Result<IvKey<Self::PRP>> { ... }
}
Expand description

Represents an instantiation of the Spinx protocol using the given EC group and corresponding public key object.

Required Associated Types§

Source

type P: Keypair

Keypair corresponding to the EC group

Source

type E: Scalar + for<'a> From<&'a Self::P>

Scalar type supported by the EC group

Source

type ExpandedPublic

Expanded form of Self::P’s public key, suitable for EC computations.

Deriving it from the compact [Keypair::Public] can be CPU-intensive, which is why it is a type of its own: a path can be expanded once and reused across several packets.

Source

type G: GroupElement<Self::E> + for<'a> From<&'a Self::ExpandedPublic>

EC group element

Source

type PRP: PRP + KeyIvInit

Pseudo-Random Permutation used to encrypt and decrypt packet payload

Required Methods§

Source

fn expand_public( public_key: &<Self::P as Keypair>::Public, ) -> Result<Self::ExpandedPublic>

Expands a compact public key into Self::ExpandedPublic.

Can be CPU-intensive. Fails if public_key is not a valid point on the curve.

Provided Methods§

Source

fn expand_path( public_keys: &[<Self::P as Keypair>::Public], ) -> Result<Vec<Self::ExpandedPublic>>

Expands an entire path. See SphinxSuite::expand_public.

Source

fn new_shared_keys<'a>( public_keys: &'a [<Self::P as Keypair>::Public], ) -> Result<SharedKeys<Self::E, Self::G>>
where &'a Array<u8, <Self::G as GroupElement<Self::E>>::AlphaLen>: From<&'a <Self::P as Keypair>::Public>,

Convenience function to generate shared keys from the path of public keys.

Expands every key on the path; use SphinxSuite::new_shared_keys_expanded when the path has already been expanded, so that the cost is not paid once per packet.

Source

fn new_shared_keys_expanded<'a>( public_keys: &'a [Self::ExpandedPublic], ) -> Result<SharedKeys<Self::E, Self::G>>
where &'a Array<u8, <Self::G as GroupElement<Self::E>>::AlphaLen>: From<&'a Self::ExpandedPublic>,

As SphinxSuite::new_shared_keys, but for a path that is already expanded.

Source

fn new_prp_init(secret: &SecretKey) -> Result<IvKey<Self::PRP>>

Instantiates a new Pseudo-Random Permutation IV and key for general packet data.

Source

fn new_reply_prp_init( secret: &SecretKey16, salt: &[u8], ) -> Result<IvKey<Self::PRP>>

Instantiates a new Pseudo-Random Permutation IV and key for reply data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SphinxSuite for Ed25519Suite

Available on crate feature ed25519 only.
Source§

type E = Scalar

Source§

type ExpandedPublic = ExpandedOffchainPublicKey

Source§

type G = EdwardsPoint

Source§

type P = OffchainKeypair

Source§

type PRP = Lioness<Hasher, StreamCipherCoreWrapper<ChaChaCore<R20, Ietf>>, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B1>, B0>, B1>, B1>, B0>, B0>, B0>, B0>>