[−][src]Module solana_libra_crypto::bls12381
This module implements the Verifying/Signing API for signatures on the BLS12-381 curve.
Example
use solana_libra_crypto::hash::{CryptoHasher, TestOnlyHasher}; use solana_libra_crypto::{ bls12381::*, traits::{Signature, SigningKey, Uniform}, }; use rand::{rngs::StdRng, SeedableRng}; let mut hasher = TestOnlyHasher::default(); hasher.write("Test message".as_bytes()); let hashed_message = hasher.finish(); let mut rng: StdRng = SeedableRng::from_seed([0; 32]); let private_key = BLS12381PrivateKey::generate_for_testing(&mut rng); let public_key: BLS12381PublicKey = (&private_key).into(); let signature = private_key.sign_message(&hashed_message); assert!(signature.verify(&hashed_message, &public_key).is_ok());
Note: The above example generates a private key using a private function intended only for testing purposes. Production code should generate the key according to the spec draft-irtf-cfrg-bls-signature-00.
This module is not currently used, but could be included in the future for improved performance in consensus.
Structs
BLS12381PrivateKey | A BLS12-381 private key. |
BLS12381PublicKey | A BLS12-381 public key. |
BLS12381Signature | A BLS12-381 signature. |
Constants
BLS12381_PRIVATE_KEY_LENGTH | The length of the BLS12381PrivateKey. |
BLS12381_PUBLIC_KEY_LENGTH | The length of the BLS12381PublicKey. |
BLS12381_SIGNATURE_LENGTH | The length of the BLS12381Signature. |