pub struct Bls12381PrivateKey { /* private fields */ }bls only.Expand description
A BLS12-381 private key.
Implementations§
Source§impl Bls12381PrivateKey
impl Bls12381PrivateKey
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generates a new random BLS12-381 private key.
§Panics
This function will not panic in normal operation. The internal expect
is a defensive check for the blst library’s key generation, which only
fails if the input keying material (IKM) is less than 32 bytes. Since
we always provide exactly 32 bytes of random data, this cannot fail.
Sourcepub fn from_seed(seed: &[u8]) -> AptosResult<Self>
pub fn from_seed(seed: &[u8]) -> AptosResult<Self>
Creates a private key from a 32-byte seed.
This uses the BLS key derivation function to derive a key from the seed.
§Errors
Returns an error if the seed is less than 32 bytes or if key derivation fails.
Sourcepub fn from_bytes(bytes: &[u8]) -> AptosResult<Self>
pub fn from_bytes(bytes: &[u8]) -> AptosResult<Self>
Creates a private key from raw bytes.
§Errors
Returns an error if the bytes length is not 32 bytes or if the key deserialization fails.
Sourcepub fn from_hex(hex_str: &str) -> AptosResult<Self>
pub fn from_hex(hex_str: &str) -> AptosResult<Self>
Creates a private key from a hex string.
§Errors
Returns an error if hex decoding fails or if the resulting bytes are invalid.
Sourcepub fn public_key(&self) -> Bls12381PublicKey
pub fn public_key(&self) -> Bls12381PublicKey
Returns the corresponding public key.
Sourcepub fn sign(&self, message: &[u8]) -> Bls12381Signature
pub fn sign(&self, message: &[u8]) -> Bls12381Signature
Signs a message and returns the signature.
Sourcepub fn create_proof_of_possession(&self) -> Bls12381ProofOfPossession
pub fn create_proof_of_possession(&self) -> Bls12381ProofOfPossession
Creates a proof of possession for this key pair.
A proof of possession (PoP) proves ownership of the private key
and prevents rogue key attacks in aggregate signature schemes.
Trait Implementations§
Source§impl Clone for Bls12381PrivateKey
impl Clone for Bls12381PrivateKey
Source§fn clone(&self) -> Bls12381PrivateKey
fn clone(&self) -> Bls12381PrivateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more