From 23d3b540a10849446dd03449380735a5b1075e0e Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 1 Oct 2021 08:18:10 -0700 Subject: [PATCH] Avoid explicit curve25519_dalek dependency in demo/ --- zk-token-sdk/src/encryption/dlog.rs | 13 +++++++++++-- zk-token-sdk/src/lib.rs | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/zk-token-sdk/src/encryption/dlog.rs b/zk-token-sdk/src/encryption/dlog.rs index 96bc1f399..0584e4cde 100644 --- a/zk-token-sdk/src/encryption/dlog.rs +++ b/zk-token-sdk/src/encryption/dlog.rs @@ -1,5 +1,8 @@ use { - curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar, traits::Identity}, + curve25519_dalek::{ + constants::RISTRETTO_BASEPOINT_POINT as G, ristretto::RistrettoPoint, scalar::Scalar, + traits::Identity, + }, serde::{Deserialize, Serialize}, std::collections::HashMap, }; @@ -46,6 +49,12 @@ pub fn decode_u32_precomputation(generator: RistrettoPoint) -> HashMap<[u8; 32], hashmap } +/// Pre-compute HashMap needed for decryption. The HashMap is independent of (works for) any key. +#[allow(non_snake_case)] +pub fn decode_u32_precomputation_for_G() -> HashMap<[u8; 32], u32> { + decode_u32_precomputation(G) +} + /// Solves the discrete log instance using a 18/14 bit offline/online split impl DiscreteLogInstance { /// Solves the discrete log problem under the assumption that the solution @@ -100,7 +109,7 @@ impl Iterator for RistrettoIterator { #[cfg(test)] mod tests { - use {super::*, curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT as G}; + use super::*; /// Discrete log test for 16/16 split /// diff --git a/zk-token-sdk/src/lib.rs b/zk-token-sdk/src/lib.rs index d1445a0a3..d1dc4d3d0 100644 --- a/zk-token-sdk/src/lib.rs +++ b/zk-token-sdk/src/lib.rs @@ -17,5 +17,3 @@ mod instruction; pub mod zk_token_elgamal; pub mod zk_token_proof_instruction; pub mod zk_token_proof_program; - -pub use curve25519_dalek;