| Crates.io | spark-cryptography |
| lib.rs | spark-cryptography |
| version | 0.1.11 |
| created_at | 2025-02-27 06:22:33.273489+00 |
| updated_at | 2025-04-27 00:54:59.366793+00 |
| description | Cryptography module for Spark Rust SDK |
| homepage | https://docs.spark.info |
| repository | https://github.com/polarityorg/spark-rs |
| max_upload_size | |
| id | 1571378 |
| size | 171,345 |
Welcome to Spark Cryptography, a Rust library providing cryptographic primitives, signature schemes, secret sharing, and key manipulation utilities for the Spark ecosystem.
Note: This crate is under active development and may not be production-ready.
Spark Cryptography offers a variety of cryptographic operations aimed at supporting more advanced features such as threshold signing (FROST), adaptor signatures, Shamir secret sharing, and more. Highlights include:
The crate is primarily designed to integrate with the broader Spark Rust SDK, but can also be used standalone.
Below are some noteworthy features and their corresponding modules:
Key Arithmetic (optional, enabled via self-signing feature)
src/key_arithmetic.rsAdaptor Signatures
src/adaptor_signature.rsSecret Sharing (optional, enabled via self-signing feature)
src/secret_sharing/FROST (requires the spark-protos dependency and proto-conversion feature)
src/signing.rsUtilities
src/utils.rsAdd spark-cryptography to your Cargo.toml:
[dependencies]
spark-cryptography = { git = "https://github.com/polarity/spark-rust-sdk.git", package = "spark-cryptography" }
(Adjust the Git URL as necessary, or specify a version if/when published to crates.io.)
To enable optional features, do something like:
[dependencies]
spark-cryptography = { git = "https://github.com/polarity/spark-rust-sdk.git", package = "spark-cryptography", features = ["self-signing"] }
use spark_cryptography::key::seed_from_phrase;
use spark_cryptography::key_arithmetic::add_public_keys;
fn main() {
// Example addition of two compressed public keys
let pk1 = [/* 33-byte compressed secp256k1 pubkey */];
let pk2 = [/* 33-byte compressed secp256k1 pubkey */];
#[cfg(feature = "self-signing")]
{
let combined = add_public_keys(&pk1, &pk2).expect("Failed to add pubkeys");
println!("Combined compressed public key: {:?}", combined);
}
}
generate_adaptor_from_signature: produce an adaptor signature that partially hides information until a certain condition is revealed.generate_signature_from_existing_adaptor: finalize an adaptor signature once the secret is known.split_secret_with_proofs: create verifiable shares of a given secret (works with VerifiableSecretShare).recover_secret: rebuild the secret from a sufficient subset of shares.validate_share: ensure a given share is valid via polynomial commitments.src/signing.rs].frost_secp256k1_tr.See the test files for full usage examples. Notable test modules include:
Running tests locally:
cd crates/spark-cryptography
cargo test --features self-signing
Each module contains corresponding unit tests. You can run:
# From the project root
cargo test --workspace --features self-signing
Most core functionalities (secret sharing, key arithmetic, adaptor signatures) are behind the "self-signing" feature. If you need advanced cryptographic features, ensure that feature is enabled.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Spark Cryptography by you shall be dual-licensed as above, without any additional terms or conditions.
Enjoy building secure and private applications with Spark Cryptography! If you have questions, feedback, or issues, please open an issue in the Spark Rust SDK repository.
@spark-cryptography ❤️