mirror of
https://github.com/vacp2p/stealth-address-kit.git
synced 2026-01-09 14:48:08 -05:00
0cdb9d4f01353d95d1b3547be715c2e7b7dace33
erc-5564-rs
Uses the arkworks-rs suite of libraries, and utilities from rln
Existing Implementations
ark_bn254ark_bls_12_381ark_bls_12_377secp256k1
Usage
use erc_5564_rs::{StealthAddressOnCurve};
use ark_bn254::Bn254; // or ark_bls_12_381::Bls12_381 or ark_bls_12_377::Bls12_377, or erc_5564_rs::Secp256k1
fn main() {
let (spending_key, spending_public_key) = Bn254::random_keypair();
let (viewing_key, viewing_public_key) = Bn254::random_keypair();
// generate ephemeral keypair
let (ephemeral_private_key, ephemeral_public_key) = Bn254::random_keypair();
let (stealth_commitment, view_tag) = Bn254::generate_stealth_commitment(viewing_public_key, spending_public_key, ephemeral_private_key);
let stealth_private_key_opt = Bn254::generate_stealth_private_key(ephemeral_public_key, viewing_key, spending_key, view_tag);
if stealth_private_key_opt.is_none() {
panic!("View tags did not match");
}
let derived_commitment = Bn254::derive_public_key(stealth_private_key_opt.unwrap());
assert_eq!(derived_commitment, stealth_commitment);
}
Building and Testing
-
Building
cargo build --release --features <bn254/bls12_381/bls12_377/secp256k1> -
Testing
cargo test --release --features <bn254/bls12_381/bls12_377/secp256k1>
FFI Api
The exposed FFI API supports one curve at a time.
Precompiled Libraries
Check out the nightly releases.
Attribution
Description
Languages
Rust
98.6%
Makefile
1.4%