def getHForCT(): return "8b655970153799af2aeadc9ff1add0ea6c7251d54154cfa92c173a0dd39c1f94" A = MiniNero.publicFromInt(1) H = MiniNero.hashToPoint_ct(A) Translator.hexToC(H) print(H) return H
def LLW_Sig(pk, xx, index): n = len(pk) print("Generating LLW sig of length ", n) L = [None] * n R = [None] * n c = [None] * n s = [PaperWallet.skGen() for i in range(0, n)] HP = [MiniNero.hashToPoint_ct(i) for i in pk] pj = ''.join(pk) keyimage = keyImage(xx) #ok s[index] = MiniNero.mul_8(s[index]) L[index] = MiniNero.scalarmultBase(s[index]) R[index] = MiniNero.scalarmultKey(HP[index], s[index]) #aH j = (index + 1) % n c[j] = MiniNero.cn_fast_hash(pj + L[index] + R[index]) while j != index: L[j] = MiniNero.addKeys(MiniNero.scalarmultBase(s[j]), MiniNero.scalarmultKey(pk[j], c[j])) #Lj = sG + cxG R[j] = MiniNero.addKeys(MiniNero.scalarmultKey(HP[j], s[j]), MiniNero.scalarmultKey(keyimage, c[j])) #Rj = sH + cxH cj = (j + 1) % n c[cj] = MiniNero.cn_fast_hash(pj + L[j] + R[j]) #c j+1 = H(pk + Lj + Rj j = cj #increment j s[index] = MiniNero.sc_mulsub_keys(s[index], c[index], xx) #si = a - c x so a = s + c x print("sigma = ", keyimage, c[0], s[:]) return keyimage, c[0], s[:]
def getH2ForCT(): A = MiniNero.publicFromInt(1) HPow2 = MiniNero.hashToPoint_ct(A) two = MiniNero.intToHex(2) H2 = [None] * 64 for i in range(0, 64): Translator.hexToCComma(HPow2) H2[i] = HPow2 HPow2 = MiniNero.scalarmultKey(HPow2, two) return H2
def getH2ForCT(): A = MiniNero.publicFromInt(1) HPow2 = MiniNero.hashToPoint_ct(A) two = MiniNero.intToHex(2) H2 = [None] * ATOMS for i in range(0, ATOMS): #Translator.hexToCComma(HPow2) H2[i] = HPow2 HPow2 = MiniNero.scalarmultKey(HPow2, two) return H2
def LLW_Ver(pk, keyimage, c1, s): n= len(pk) #ok print("verifying LLW sig of length", n) L = [None]*n R = [None]*n c= [None]*(n+1) pj = ''.join(pk) HP = [MiniNero.hashToPoint_ct(i) for i in pk] c[0] = c1 j = 0 while j < n: L[j] = MiniNero.addKeys(MiniNero.scalarmultBase(s[j]), MiniNero.scalarmultKey(pk[j], c[j])) R[j] = MiniNero.addKeys(MiniNero.scalarmultKey(HP[j], s[j]), MiniNero.scalarmultKey(keyimage, c[j])) cj = j + 1 c[cj] = MiniNero.cn_fast_hash(pj + L[j] + R[j]) j = cj rv = (c[0] == c[n]) print("sig verifies complete", rv) print("c", c) print("L", L) print("R", R) return rv
def LLW_Sig(pk, xx, index ): n = len(pk) print("Generating LLW sig of length ", n) L = [None] * n R = [None] * n c= [None] * n s = [PaperWallet.skGen() for i in range(0, n)] HP = [MiniNero.hashToPoint_ct(i) for i in pk] pj = ''.join(pk) keyimage = keyImage(xx) #ok s[index] = MiniNero.mul_8(s[index]) L[index] = MiniNero.scalarmultBase(s[index]) R[index] = MiniNero.scalarmultKey(HP[index], s[index]) #aH j = (index + 1) % n c[j] = MiniNero.cn_fast_hash(pj+L[index]+R[index]) while j != index: L[j] = MiniNero.addKeys(MiniNero.scalarmultBase(s[j]), MiniNero.scalarmultKey(pk[j], c[j])) #Lj = sG + cxG R[j] = MiniNero.addKeys(MiniNero.scalarmultKey(HP[j], s[j]), MiniNero.scalarmultKey(keyimage, c[j])) #Rj = sH + cxH cj = (j + 1) % n c[cj] = MiniNero.cn_fast_hash(pj + L[j] + R[j]) #c j+1 = H(pk + Lj + Rj j = cj #increment j s[index] = MiniNero.sc_mulsub_keys(s[index], c[index], xx) #si = a - c x so a = s + c x print("sigma = ", keyimage, c[0], s[:]) return keyimage, c[0], s[:]
def LLW_Ver(pk, keyimage, c1, s): n = len(pk) #ok print("verifying LLW sig of length", n) L = [None] * n R = [None] * n c = [None] * (n + 1) pj = ''.join(pk) HP = [MiniNero.hashToPoint_ct(i) for i in pk] c[0] = c1 j = 0 while j < n: L[j] = MiniNero.addKeys(MiniNero.scalarmultBase(s[j]), MiniNero.scalarmultKey(pk[j], c[j])) R[j] = MiniNero.addKeys(MiniNero.scalarmultKey(HP[j], s[j]), MiniNero.scalarmultKey(keyimage, c[j])) cj = j + 1 c[cj] = MiniNero.cn_fast_hash(pj + L[j] + R[j]) j = cj rv = (c[0] == c[n]) print("sig verifies complete", rv) print("c", c) print("L", L) print("R", R) return rv
def keyImage(x): HP = MiniNero.hashToPoint_ct(MiniNero.scalarmultBase(x)) return MiniNero.scalarmultKey(HP, x)
def getHForCT(): A = MiniNero.publicFromInt(123456) return MiniNero.hashToPoint_ct(A)
a = MiniNero.electrumChecksum(t) print(a) if sys.argv[1] == "1224": #sohuld turn 12 word key to 24 print("tbd") sk = "536313cc0a88457e3d3e5aadda8d204af20e480416cc522ebd5a67df00ce2503" print(MiniNero.getAddr(sk)) if sys.argv[1] == "seed": seed = "3c817618dcbfed122a64e592bb441d73300da9123686224a84e0eab1f075117e"; a = MiniNero.hexToInt(seed) b = a // l print(b) if sys.argv[1] == "HCT": for i in [1, 12, 123, 1234, 12345, 123456]: A = MiniNero.publicFromInt(i) print(i, MiniNero.hashToPoint_ct(A)) if sys.argv[1] == "RingCTSimple": #see below for ring ct with sliding exponents exponent = 9 H_ct = RingCT.getHForCT() print("H", H_ct) sr, Pr = PaperWallet.skpkGen() #receivers private/ public se, pe, ss1, ss2 = Ecdh.ecdhGen(Pr) #compute shared secret ss digits = 32 #in practice it could will be 32 (from .0001 monero to ~400k monero) all other amounts can be represented by full 64 if necessary, otherwise you can use the sliding implementation of RingCT given below. print("inputs") a = 10000 Cia, L1a, s2a, sa, ska = RingCT.genRangeProof(10000, digits) print("outputs") b = 7000 Cib, L1b, s2b, sb, skb = RingCT.genRangeProof(7000, digits) c = 3000
a = MiniNero.electrumChecksum(t) print(a) if sys.argv[1] == "1224": #sohuld turn 12 word key to 24 print("tbd") sk = "536313cc0a88457e3d3e5aadda8d204af20e480416cc522ebd5a67df00ce2503" print(MiniNero.getAddr(sk)) if sys.argv[1] == "seed": seed = "3c817618dcbfed122a64e592bb441d73300da9123686224a84e0eab1f075117e" a = MiniNero.hexToInt(seed) b = a // l print(b) if sys.argv[1] == "HCT": for i in [1, 12, 123, 1234, 12345, 123456]: A = MiniNero.publicFromInt(i) print(i, MiniNero.hashToPoint_ct(A)) if sys.argv[1] == "RingCTSimple": #see below for ring ct with sliding exponents exponent = 9 H_ct = RingCT.getHForCT() print("H", H_ct) sr, Pr = PaperWallet.skpkGen() #receivers private/ public se, pe, ss1, ss2 = Ecdh.ecdhGen(Pr) #compute shared secret ss digits = 32 #in practice it could will be 32 (from .0001 byterub to ~400k byterub) all other amounts can be represented by full 64 if necessary, otherwise you can use the sliding implementation of RingCT given below. print("inputs") a = 10000 Cia, L1a, s2a, sa, ska = RingCT.genRangeProof(10000, digits) print("outputs") b = 7000 Cib, L1b, s2b, sb, skb = RingCT.genRangeProof(7000, digits) c = 3000