-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor into 2 crates, example and sdk
- Loading branch information
Showing
21 changed files
with
127 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,7 @@ | ||
[package] | ||
name = "stealth_address_kit" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "Stealth Address Kit: A Rust library for generating stealth addresses." | ||
license = "MIT" | ||
homepage = "https://vac.dev" | ||
[workspace] | ||
|
||
[lib] | ||
name = "stealth_address_kit" | ||
path = "src/lib.rs" | ||
crate-type = ["staticlib"] | ||
|
||
[features] | ||
ffi = [] | ||
bls12_381 = [] | ||
bls12_377 = [] | ||
secp256k1 = [] | ||
secp256r1 = [] | ||
bn254 = [] | ||
pallas = [] | ||
vesta = [] | ||
bw6_761 = [] | ||
default = ["all"] | ||
all = ["ffi", "secp256k1", "bls12_381", "bls12_377", "bn254", "secp256r1", "pallas", "vesta", "bw6_761"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rln = "0.3.4" | ||
ark-std = "0.4.0" | ||
num-bigint = "0.4.3" | ||
num-traits = "0.2.15" | ||
ark-ff = "0.4.1" | ||
ark-bn254 = "0.4.0" | ||
ark-bls12-381 = "0.4.0" | ||
ark-bls12-377 = "0.4.0" | ||
ark-secp256k1 = "0.4.0" | ||
ark-secp256r1 = "0.4.0" | ||
ark-pallas = "0.4.0" | ||
ark-vesta = "0.4.0" | ||
ark-bw6-761 = "0.4.0" | ||
tiny-keccak = { version = "=2.0.2", features = ["keccak"] } | ||
ark-ec = "0.4.1" | ||
ark-serialize = "0.4.1" | ||
cfg-if = "1.0.0" | ||
paste = "1.0.0" | ||
|
||
[dev-dependencies] | ||
serde_json = "1.0.96" | ||
color-eyre = "0.6.2" | ||
members = [ | ||
"sdk", | ||
"example" | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "stealth_address_kit_example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
stealth_address_kit = { path = "../sdk", default-features = false, features = ["secp256r1"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Example | ||
|
||
Feel free to play around with the `curves` that are exported by the `stealth_address_kit` crate. The following example demonstrates how to generate a stealth address using the `secp256r1` curve. | ||
|
||
Update the `Cargo.toml` file to include the features/curves that you would like to use. | ||
|
||
Supported Curves: [here](../README.md#Existing-Implementations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use stealth_address_kit::Secp256r1; | ||
use stealth_address_kit::StealthAddressOnCurve; | ||
|
||
type Curve = Secp256r1; | ||
|
||
fn main() { | ||
let (spending_key, spending_public_key) = Curve::random_keypair(); | ||
let (viewing_key, viewing_public_key) = Curve::random_keypair(); | ||
|
||
// generate ephemeral keypair | ||
let (ephemeral_private_key, ephemeral_public_key) = Curve::random_keypair(); | ||
|
||
let (stealth_address, view_tag) = Curve::generate_stealth_address( | ||
viewing_public_key, | ||
spending_public_key, | ||
ephemeral_private_key, | ||
); | ||
|
||
let stealth_private_key_opt = Curve::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_stealth_address = Curve::derive_public_key(&stealth_private_key_opt.unwrap()); | ||
assert_eq!(derived_stealth_address, stealth_address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[package] | ||
name = "stealth_address_kit" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "Stealth Address Kit: A Rust library for generating stealth addresses." | ||
license = "MIT" | ||
homepage = "https://vac.dev" | ||
|
||
[lib] | ||
name = "stealth_address_kit" | ||
path = "src/lib.rs" | ||
crate-type = ["staticlib", "rlib"] | ||
|
||
[features] | ||
ffi = [] | ||
bls12_381 = [] | ||
bls12_377 = [] | ||
secp256k1 = [] | ||
secp256r1 = [] | ||
bn254 = [] | ||
pallas = [] | ||
vesta = [] | ||
bw6_761 = [] | ||
default = ["secp256k1", "ffi"] | ||
all = ["ffi", "secp256k1", "bls12_381", "bls12_377", "bn254", "secp256r1", "pallas", "vesta", "bw6_761"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rln = "0.3.4" | ||
ark-std = "0.4.0" | ||
num-bigint = "0.4.3" | ||
num-traits = "0.2.15" | ||
ark-ff = "0.4.1" | ||
ark-bn254 = "0.4.0" | ||
ark-bls12-381 = "0.4.0" | ||
ark-bls12-377 = "0.4.0" | ||
ark-secp256k1 = "0.4.0" | ||
ark-secp256r1 = "0.4.0" | ||
ark-pallas = "0.4.0" | ||
ark-vesta = "0.4.0" | ||
ark-bw6-761 = "0.4.0" | ||
tiny-keccak = { version = "=2.0.2", features = ["keccak"] } | ||
ark-ec = "0.4.1" | ||
ark-serialize = "0.4.1" | ||
cfg-if = "1.0.0" | ||
paste = "1.0.0" | ||
|
||
[dev-dependencies] | ||
serde_json = "1.0.96" | ||
color-eyre = "0.6.2" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.