예제 #1
0
    #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 = merit.mints[0].outputs[0][1]
claim.sign([blsPrivKey])
transactions.add(claim)

#Verify the Claim.
verif = SignedVerification(claim.hash)
verif.sign(0, blsPrivKey)

#Mine one more Block.
block = Block(
    BlockHeader(
        0, merit.blockchain.last(),
        BlockHeader.createContents([VerificationPacket(verif.hash, [0])]), 1,
        bytes(4),
        BlockHeader.createSketchCheck(bytes(4),
                                      [VerificationPacket(verif.hash, [0])]),
        0, merit.blockchain.blocks[-1].header.time + 1200),
    BlockBody([VerificationPacket(verif.hash, [0])], [], verif.signature))
block.mine(blsPrivKey, merit.blockchain.difficulty())
merit.add(block)
print("Generated Claimed Mint Block " + str(len(merit.blockchain.blocks) - 1) +
      ".")
예제 #2
0
파일: Competing.py 프로젝트: vporton/Meros
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)) + ".")