Aaryamann Challani 0db7a9bbbf Merge pull request #3 from vacp2p/integrate-secp256k1
feat(curves): add secp256k1
2024-05-21 06:03:26 +05:30
2024-03-12 15:11:09 +05:30
2023-12-20 13:06:51 +05:30
2024-05-21 06:02:00 +05:30
2023-08-16 00:46:00 +05:30
2024-05-21 06:02:00 +05:30
2024-05-21 06:02:00 +05:30
2024-03-02 14:28:01 +05:30
2024-03-02 15:01:52 +05:30

erc-5564-rs

Uses the arkworks-rs suite of libraries, and utilities from rln

Existing Implementations

  1. ark_bn254
  2. ark_bls_12_381
  3. ark_bls_12_377

Usage

Note: this scheme should be used with the fork of circom-rln.

use erc_5564_rs::{StealthAddressOnCurve}; // can use bls12_381_impl or bls12_377_impl too
use ark_bn254::Bn254;

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

  1. Building cargo build --release --features <bn254/bls12_381/bls12_377>

  2. Testing cargo test --release --features <bn254/bls12_381/bls12_377>

FFI Api

The exposed FFI API supports one curve at a time.

Precompiled Libraries

Check out the nightly releases.

Attribution

  • The original circuits for rln are located here, by the PSE group
  • Inspired by the erc-5564 eip and the poc by Nerolation.
Description
No description provided
Readme 9.9 MiB
Latest
2024-06-28 02:39:04 -04:00
Languages
Rust 98.6%
Makefile 1.4%