Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
xmr: bp - deterministic masks optimization, prove_s1 optim
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Aug 17, 2018
1 parent cbf74a7 commit 4c27815
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/apps/monero/xmr/bulletproof.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ def __init__(self):
self.v_sL = None
self.v_sR = None
self.tmp_sc_1 = crypto.new_scalar()
self.tmp_det_buff = bytearray(64 + 1 + 1)
self.tmp_h_buff1 = bytearray(32)
self.gc_fnc = gc.collect
self.gc_trace = None

Expand All @@ -542,7 +544,7 @@ def set_input(self, value=None, mask=None):
self.value_enc = crypto.encodeint(value)
self.gamma = mask
self.gamma_enc = crypto.encodeint(mask)
self.proof_sec = crypto.random_bytes(128)
self.proof_sec = crypto.random_bytes(64)

def aL(self, i, dst=None):
dst = _ensure_dst_key(dst)
Expand All @@ -566,10 +568,12 @@ def aR_vct(self):

def _det_mask(self, i, is_sL=True, dst=None):
dst = _ensure_dst_key(dst)
src = crypto.keccak_2hash(
self.proof_sec + (b"sL" if is_sL else b"sR") + dump_uvarint_b(i)
)
crypto.decodeint_into(self.tmp_sc_1, src)
self.tmp_det_buff[0] = int(is_sL)
memcpy(self.tmp_det_buff, 1, self.proof_sec, 0, len(self.proof_sec))
dump_uvarint_b_into(i, self.tmp_det_buff, 65)
crypto.keccak_hash_into(self.tmp_h_buff1, self.tmp_det_buff)
crypto.keccak_hash_into(self.tmp_h_buff1, self.tmp_h_buff1)
crypto.decodeint_into(self.tmp_sc_1, self.tmp_h_buff1)
crypto.encodeint_into(self.tmp_sc_1, dst)
return dst

Expand Down Expand Up @@ -698,7 +702,8 @@ def prove_s1(self, V, A, S, T1, T2, taux, mu, t, x_ip, y, hash_cache, l, r):
self.gc(7)

# PAPER LINES 54-57
vector_add(aL_vpIz, vector_scalar(self.v_sL, x), l)
vector_scalar(self.v_sL, x, tmp_vct)
vector_add(aL_vpIz, tmp_vct, l)
self.v_sL = None
del aL_vpIz
self.gc(8)
Expand Down

0 comments on commit 4c27815

Please sign in to comment.