From 409b55ad815c00cba4c47c457b773d19023f672c Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 1 Oct 2021 07:40:09 -0700 Subject: [PATCH] add some comments --- zk-token-sdk/src/encryption/dlog.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zk-token-sdk/src/encryption/dlog.rs b/zk-token-sdk/src/encryption/dlog.rs index f618afc7f..4ee83982b 100644 --- a/zk-token-sdk/src/encryption/dlog.rs +++ b/zk-token-sdk/src/encryption/dlog.rs @@ -25,7 +25,7 @@ pub struct DiscreteLogInstance { pub target: RistrettoPoint, } -/// Solves the discrete log instance using a 18/14 bit offline/online split +/// Solves the discrete log instance using a 16/16 bit offline/online split impl DiscreteLogInstance { /// Solves the discrete log problem under the assumption that the solution /// is a 32-bit number. @@ -34,6 +34,7 @@ impl DiscreteLogInstance { self.decode_u32_online(&hashmap) } + /// Builds a HashMap of 2^16 elements pub fn decode_u32_precomputation(generator: RistrettoPoint) -> HashMap { let mut hashmap = HashMap::new(); @@ -50,6 +51,8 @@ impl DiscreteLogInstance { hashmap } + /// Solves the discrete log instance using the pre-computed HashMap by enumerating through 2^16 + /// possible solutions pub fn decode_u32_online(self, hashmap: &HashMap) -> Option { // iterator for 0G, -1G, -2G, ... let ristretto_iter = RistrettoIterator::new( @@ -77,6 +80,7 @@ impl DiscreteLogInstance { self.decode_u32_online_alt(&hashmap) } + /// Builds a HashMap of 2^18 elements pub fn decode_u32_precomputation_alt( generator: RistrettoPoint, ) -> HashMap { @@ -95,6 +99,8 @@ impl DiscreteLogInstance { hashmap } + /// Solves the discrete log instance using the pre-computed HashMap by enumerating through 2^14 + /// possible solutions pub fn decode_u32_online_alt(self, hashmap: &HashMap) -> Option { // iterator for 0G, -1G, -2G, ... let ristretto_iter = RistrettoIterator::new(