def phase_5_winner_decision(self): y = self.auction_contract.functions.elgamalY().call() y = BigNumber.from_sol(y).to_py() jM = self.auction_contract.functions.jM().call() bidA = [self.bids[-1]] for i in reversed(range(len(self.bids) - 1)): bidA = [self.bids[i].mul(bidA[0])] + bidA piM_sols = CtMProof(bidA[jM].c, y, bidA[jM].r, 1).to_sol() tx_hash = self.auction_contract.functions.phase5WinnerDecision( piM_sols).transact({ 'from': self.addr, 'gas': gas_limit }) tx_receipt = self.web3.eth.waitForTransactionReceipt(tx_hash) self.gasUsed += tx_receipt['gasUsed'] tx_print(tx_receipt, "B{}".format(self.index))
def phase_2_bidder_submit_bid(self, bid_price_j, value=10): self.bid_price_j = bid_price_j y = self.auction_contract.functions.elgamalY().call() y = BigNumber.from_sol(y).to_py() price_length = self.auction_contract.functions.priceLength().call() self.bids = [] for j in range(price_length): self.bids.append(Ct.from_vote(j == bid_price_j, y)) bid_pi01_sols = [bid.to_sol_with_01_proof() for bid in self.bids] bid, pi01 = list(map(list, list(zip(*bid_pi01_sols)))) bidProd = functools.reduce(lambda ct1, ct2: ct1.mul(ct2), self.bids) piM = CtMProof(bidProd.c, y, bidProd.r, 1).to_sol() tx_hash = self.auction_contract.functions.phase2BidderSubmitBid( bid, pi01, piM).transact({ 'from': self.addr, 'gas': gas_limit }) tx_receipt = self.web3.eth.waitForTransactionReceipt(tx_hash) self.gasUsed += tx_receipt['gasUsed'] tx_print(tx_receipt, "B{} bid_price_j = {}".format(self.index, bid_price_j))
def from_sol(cls, a): u = BigNumber.from_sol(a[0]).to_py() c = BigNumber.from_sol(a[1]).to_py() return cls(u, c)