[][src]Trait iota_signing_preview::PrivateKey

pub trait PrivateKey {
    type PublicKey: PublicKey;
    type Signature: Signature;
    type Error;
    fn generate_public_key(&self) -> Result<Self::PublicKey, Self::Error>;
fn sign(&mut self, message: &[i8]) -> Result<Self::Signature, Self::Error>; }

Associated Types

type PublicKey: PublicKey

The type of the matching public key

type Signature: Signature

The type of the generated signatures

type Error

Loading content...

Required methods

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

Returns the public counterpart of a private key

Example

    IotaSeed,
    PrivateKeyGenerator,
    Seed,
    WotsPrivateKeyGeneratorBuilder,
    WotsSecurityLevel,
};
use iota_signing_preview::PrivateKey;

    .security_level(WotsSecurityLevel::Medium)
    .build()
    .unwrap();
let public_key = private_key.generate_public_key();

fn sign(&mut self, message: &[i8]) -> Result<Self::Signature, Self::Error>

Generates and returns a signature for a given message

Arguments

  • message A slice that holds a message to be signed

Example

    IotaSeed,
    PrivateKeyGenerator,
    Seed,
    WotsPrivateKeyGeneratorBuilder,
    WotsSecurityLevel,
};
use iota_signing_preview::PrivateKey;
use iota_ternary_preview::{
    T1B1Buf,
    TryteBuf,
};

    .security_level(WotsSecurityLevel::Medium)
    .build()
    .unwrap();
let message = "CHXHLHQLOPYP9NSUXTMWWABIBSBLUFXFRNWOZXJPVJPBCIDI99YBSCFYILCHPXHTSEYSYWIGQFERCRVDD";
let message_trits = TryteBuf::try_from_str(message).unwrap().as_trits().encode::<T1B1Buf>();
let signature = private_key.sign(&message_trits.as_i8_slice());
Loading content...

Implementors

impl<S, K> PrivateKey for MssPrivateKey<S, K> where
    S: Sponge + Default,
    K: PrivateKey,
    <<K as PrivateKey>::PublicKey as PublicKey>::Signature: RecoverableSignature
[src]

type PublicKey = MssPublicKey<S, K::PublicKey>

type Signature = MssSignature<S>

type Error = MssError

impl<S: Sponge + Default> PrivateKey for WotsPrivateKey<S>[src]

type PublicKey = WotsPublicKey<S>

type Signature = WotsSignature<S>

type Error = WotsError

Loading content...