Struct iop_keyvault::secp256k1::Secp256k1
source · [−]pub struct Secp256k1;
Expand description
This elliptic curve cryptography implements both the AsymmetricCrypto and KeyDerivationCrypto traits so for BTC, ETH and IOP as examples.
Trait Implementations
sourceimpl AsymmetricCrypto for Secp256k1
impl AsymmetricCrypto for Secp256k1
type KeyId = SecpKeyId
type KeyId = SecpKeyId
The ID (also called fingerprint or address in some literature) of the public key. See
PublicKey::key_id
for more details. Read more
type PublicKey = SecpPublicKey
type PublicKey = SecpPublicKey
type PrivateKey = SecpPrivateKey
type PrivateKey = SecpPrivateKey
See PrivateKey
for more details. Read more
type Signature = SecpSignature
type Signature = SecpSignature
The signature of a given message with a given private key. Its size and representation is up to the implementation. Read more
sourceimpl ExtendedPrivateKey<Secp256k1> for SecpExtPrivateKey
impl ExtendedPrivateKey<Secp256k1> for SecpExtPrivateKey
sourcefn derive_normal_child(&self, idx: i32) -> Result<SecpExtPrivateKey>
fn derive_normal_child(&self, idx: i32) -> Result<SecpExtPrivateKey>
Normal derivation allows the neutered extended public key to calculate child extended public keys without revealing any private keys. Read more
sourcefn derive_hardened_child(&self, idx: i32) -> Result<SecpExtPrivateKey>
fn derive_hardened_child(&self, idx: i32) -> Result<SecpExtPrivateKey>
Hardened derivation makes it impossible to the neutered extended public key to calculate children. It uses a different derivation algorithm. Read more
sourcefn neuter(&self) -> SecpExtPublicKey
fn neuter(&self) -> SecpExtPublicKey
Neutering an extended private key gives an extended public key that contains the private key neutered, plus the chain code. It is useless to reveal the chain code when hardened derivation is used. Read more
sourcefn private_key(&self) -> SecpPrivateKey
fn private_key(&self) -> SecpPrivateKey
Throws away the chain code and gives back only the private key from the extended private key.
sourceimpl ExtendedPublicKey<Secp256k1> for SecpExtPublicKey
impl ExtendedPublicKey<Secp256k1> for SecpExtPublicKey
sourcefn derive_normal_child(&self, idx: i32) -> Result<SecpExtPublicKey>
fn derive_normal_child(&self, idx: i32) -> Result<SecpExtPublicKey>
Derive child extended public keys. Useful for auditing hierarchical deterministic wallets, or generating a new address for each on-chain transaction knowing the owner of the corresponding extended private key can spend the received coins. Read more
sourcefn public_key(&self) -> SecpPublicKey
fn public_key(&self) -> SecpPublicKey
Throws away the chain code and gives back only the public key from the extended public key.
sourceimpl KeyDerivationCrypto for Secp256k1
impl KeyDerivationCrypto for Secp256k1
type ExtendedPrivateKey = SecpExtPrivateKey
type ExtendedPrivateKey = SecpExtPrivateKey
See ExtendedPrivateKey
for more details. Read more
type ExtendedPublicKey = SecpExtPublicKey
type ExtendedPublicKey = SecpExtPublicKey
See ExtendedPublicKey
for more details. Read more
sourcefn master(seed: &Seed) -> SecpExtPrivateKey
fn master(seed: &Seed) -> SecpExtPrivateKey
Does not seem to completely belong here, but calculates the master extended private key - the root of a hierarchical deterministic wallet - from a given seed. All other keys are derived from this one extended private key. Read more
sourceimpl PrivateKey<Secp256k1> for SecpPrivateKey
impl PrivateKey<Secp256k1> for SecpPrivateKey
sourcefn sign<D: AsRef<[u8]>>(&self, data: D) -> SecpSignature
fn sign<D: AsRef<[u8]>>(&self, data: D) -> SecpSignature
Panics
There is a 2^-256 chance this message cannot be signed by this key. The C implementation in bitcoin does not fail, but this pure rust version does. Then we panic.
sourcefn public_key(&self) -> SecpPublicKey
fn public_key(&self) -> SecpPublicKey
sourceimpl PublicKey<Secp256k1> for SecpPublicKey
impl PublicKey<Secp256k1> for SecpPublicKey
sourcefn key_id(&self) -> SecpKeyId
fn key_id(&self) -> SecpKeyId
Calculates the ID (also called fingerprint or address in some literature) of the public key. In some algorithms the public key is only revealed in point-to-point communications and a keypair is identified only by the digest of the public key in all other channels. Read more
sourcefn validate_id(&self, key_id: &SecpKeyId) -> bool
fn validate_id(&self, key_id: &SecpKeyId) -> bool
We do not have multiple versions of KeyIds for the same multicipher public key, so for now this comparison is trivial. But when we
introduce newer versions, we need to take the version of the key_id
argument into account and calculate that possibly older version
from self
. Read more
sourcefn verify<D: AsRef<[u8]>>(&self, data: D, sig: &SecpSignature) -> bool
fn verify<D: AsRef<[u8]>>(&self, data: D, sig: &SecpSignature) -> bool
This method can be used to verify if a given signature for a message was made using the private
key that belongs to this public key. See also PrivateKey::sign
Read more
Auto Trait Implementations
impl RefUnwindSafe for Secp256k1
impl Send for Secp256k1
impl Sync for Secp256k1
impl Unpin for Secp256k1
impl UnwindSafe for Secp256k1
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more