#Create the next Block. block = Block( BlockHeader(0, merit.blockchain.last(), bytes(32), 1, bytes(4), bytes(32), 0, merit.blockchain.blocks[-1].header.time + 1200), BlockBody()) #Claim the new Mint. claim: Claim = Claim([(merit.mints[0].hash, 0)], edPubKey.to_bytes()) claim.amount = 0 transactions.add(claim) #Verify the Claim. verif = SignedVerification(claim.hash) verif.sign(0, blsPrivKey) #Create a Send using the same input as the Claim. send: Send = Send([(merit.mints[0].hash, 0)], [(edPubKey.to_bytes(), 1)]) transactions.add(send) #Verify the Send. competingVerif: SignedVerification = SignedVerification(send.hash) competingVerif.sign(0, blsPrivKey) #Create a MeritRemoval out of the conflicting Verifications. mr: SignedMeritRemoval = SignedMeritRemoval(verif, competingVerif) #Generate a Block containing the MeritRemoval. block = Block( BlockHeader(0, merit.blockchain.last(),
transactions.add(send1) send2: Send = Send( [(claim, 0)], [( edPubKey2.to_bytes(), Claim.fromTransaction(transactions.txs[claim]).amount )] ) send2.sign(edPrivKey1) send2.beat(consensus.sendFilter) transactions.add(send2) #Verify the 1st Send with the 1st key. verif = SignedVerification(send1.hash) verif.sign(blsPrivKey1, len(consensus.holders[blsPubKey1.serialize()])) consensus.add(verif) #Verify the 2nd Send with the 2nd key. verif = SignedVerification(send2.hash) verif.sign(blsPrivKey2, 0) consensus.add(verif) #Archive the Elements and close the Epoch. block = Block( BlockHeader( 14, blockchain.last(), int(time()), consensus.getAggregate([(blsPubKey1, 2, -1), (blsPubKey2, 0, -1)]) ),
packets: List[VerificationPacket] = [] toAggregate: List[Signature] = [] verif: SignedVerification for i in range(2): send: Send = Send( [(claim, 0)], [(edPubKeys[i].to_bytes(), Claim.fromTransaction(transactions.txs[claim]).amount)]) send.sign(edPrivKey) send.beat(sendFilter) transactions.add(send) packets.append(VerificationPacket(send.hash, [i])) verif = SignedVerification(send.hash) verif.sign(i, blsPrivKeys[i]) toAggregate.append(verif.signature) #Archive the Packets and close the Epoch. block = Block( BlockHeader(0, blockchain.last(), BlockHeader.createContents(packets), 1, bytes(4), BlockHeader.createSketchCheck(bytes(4), packets), 0, blockchain.blocks[-1].header.time + 1200), BlockBody(packets, [], Signature.aggregate(toAggregate))) for _ in range(6): #Mine it. block.mine(blsPrivKeys[0], blockchain.difficulty()) #Add it. blockchain.add(block) print("Generated Competing Block " + str(len(blockchain.blocks)) + ".")
print("Generated Claimed Mint Block " + str(block.header.nonce) + ".") #Create the next Block. block = Block(BlockHeader(i, merit.blockchain.last(), int(time())), BlockBody()) #Claim the new Mint. claim: Claim = Claim([merit.mints[0].hash], edPubKey.to_bytes()) claim.amount = merit.mints[0].output[1] claim.sign([blsPrivKey]) claim.verified = True transactions.add(claim) #Verify the Claim.. verif = SignedVerification(claim.hash) verif.sign(blsPrivKey, 1) consensus.add(verif) #Mine one more Block. block = Block( BlockHeader(12, merit.blockchain.last(), int(time()), consensus.getAggregate([(blsPubKey, 1, -1)])), BlockBody([(blsPubKey, 1, consensus.getMerkle(blsPubKey, 1))])) block.mine(merit.blockchain.difficulty()) merit.add(transactions, consensus, block) print("Generated Claimed Mint Block " + str(block.header.nonce) + ".") result: Dict[str, Any] = { "blockchain": merit.blockchain.toJSON(), "transactions": transactions.toJSON(), "consensus": consensus.toJSON()