Ejemplo n.º 1
0
    def get_random(valid: bool = True) -> dict:
        """Returns a random Appeal with it's corresponding private key"""

        id_info = ID.get_random(valid=valid)
        key, userid = id_info["private_key"], id_info["id"]
        verdict = Verdict.get_random(valid=valid)["verdict"]

        appeal = Appeal(userid, verdict)

        appeal.sign(import_key(key))

        return {"private_key": key, "appeal": appeal}
Ejemplo n.º 2
0
    def get_random(valid: bool = True) -> dict:
        """Returns a random Accusation with it's corresponding private key"""

        id_info = ID.get_random(valid=valid)
        key, userid = id_info["private_key"], id_info["id"]

        accusation = Accusation(userid,
                                ID.get_random()["id"],
                                Contract.get_random()["contract"])

        accusation.sign(import_key(key))

        return {"private_key": key, "accusation": accusation}
Ejemplo n.º 3
0
    def get_random(valid: bool = True) -> dict:
        """Returns a random Verdict with it's corresponding private key"""

        id_info = ID.get_random(valid=valid)
        key, userid = id_info["private_key"], id_info["id"]
        accusation = Accusation.get_random(valid=valid)["accusation"]

        verdict = Verdict(
            userid, accusation,
            random_word(random.randint(1, SENTECE_CHAR_LIMIT)),
            random_word(random.randint(1, DESCRIPTION_CHAR_LIMIT)))

        verdict.sign(import_key(key))

        return {"private_key": key, "verdict": verdict}
Ejemplo n.º 4
0
    except Exception as e:
        await ctx.send(e)

@client.command()
async def showchamp(ctx, member: typing.Optional[discord.Member], champion_name):
    if member == None:
        await displayChampion(ctx, ctx.author.id, champion_name)
    else:
        await displayChampion(ctx, member.id, champion_name)


@client.command()
async def show(ctx, *, arg):
    try:
        account = await requests.get_summoner_info(arg)
        previous_match_id = await requests.get_previous_match_id(account['accountId'])
        game_mode, match_data = await requests.get_match_data(previous_match_id, account['accountId'])
        await displayPreviousGame(ctx, game_mode, match_data)
    except Exception as e:
        await ctx.send(e)



@client.event
async def on_ready():
    print("Ready")

if __name__ == '__main__':
    load_dotenv()
    client.run(import_key())
Ejemplo n.º 5
0
MIN_JUDGES = contract_config["minimum_judges"]
MAX_JUDGES = contract_config["maximum_judges"]
MIN_RULES = contract_config["minimum_rules"]
MAX_RULES = contract_config["maximum_rules"]
SENDER_CAN_JUDGE = contract_config["allow_sender_to_judge"]

SENTECE_CHAR_LIMIT = verdict_config["sentence_char_limit"]
DESCRIPTION_CHAR_LIMIT = verdict_config["description_char_limit"]

HASH_DIFFICULTY = id_config["hash_difficulty"]
NONCE_LIMIT = id_config["nonce_limit"]
USERNAME_LIMIT = id_config["username_char_limit"]

valid_id = ID.get_random()
userid = valid_id["id"]
key = import_key(valid_id["private_key"])
public_key = key.publickey()
parsed_pubkey = parse_key(public_key)


def test_contract():

    # Valid random contract
    c = Contract.get_random()["contract"]
    assert c.is_valid() == True

    # Invalid random contract
    c = Contract.get_random(valid=False)["contract"]
    assert c.is_valid() == False

    judges = [ID("Agatha Christie", parsed_pubkey) for _ in range(MIN_JUDGES)]
Ejemplo n.º 6
0
def generate_genesis(flag=None):
    from_key = "144959022183304207468958131697142040059685853910948370524055564863719555283656859186375447995417957983453833952656919196271479681665018951250898357522909362517891278036311430628171184759058303336530617416715708111617780953697249287964666986731323402836786402481384568501204667928860502693417545842840162066479,188548854434954848512890870714483229539469410811792636070940724848111582521963874676118894241935351431720871624429937491372255124590541392456507290206583489676023773434470547015189064027541103264065649503783858616955433262940351439671834218128389766832554950492134737158914724776025890501004088719937594999,11207454335053488687826015123587685161038987828113104738711126864382907490310385476976176811580430007452816304841944163518586500860496636370074201375297329017532269288951544769939601973249371523325093989406015609332175393150267941248752351501848612110654113287995979327676720217243658350726100869682837486508,110926808386026644342446691260230356187577335215683128433297398082106363031292827588223785686630731323607064060082372711800195071784058826628416528453174816446625095794412437928717557053882327859514303929734928272297265800212871653679911838540631633006151944629851115503497218733326502102022316508670724832873"
    to_key = "129007787299136025904994120015423214458402017278189927455721509946613613371759918809892683242436185202242780144741446060454905083301024137166388270435508673765159863572933907131052385589219829571211822820478435287467659647573336309016186090376384062782587703890857980040812238476428796813159139144631735811167,18036667493436683186281965268161327276194410371342915267286965082681310688928951965397731977554442489357986959732809976837907538057577467019379820342184425188240565259406249472870656543586299655465129403609782306073211386904010771500402174589391749351830409079811059867868371066214294349033637935809686124610,14361218684856120777117758320050044433386800560864012367227493350610807717769946767891002432118544676002750979118019443116013783124634108262262064313491992323880514096872968553385930094267880820415784839702378387067640695975551774781460297735546088577291601245598593240020974668342752730176715415618456814189,27803928587795936572834506673786619019137281923541646481735768253454481653258934954956960566294145859977329772452076284425816861006770682736474923204007934246351424656406539825511369971156884395969587116062661475820123585141787584773816207259149861637391248495662604205174123292251608585080025271691410939651"

    from_key = import_key(from_key)
    if flag:
        s = flag.encode()
        print(from_key.sign(sha256(s).digest().encode(), K=12312351235))
        exit(0)
    to_key = import_key(to_key)
    from_pubkey = export_key(from_key.publickey())
    to_pubkey = export_key(to_key.publickey())
    timestamp = 0
    amount = 5000000000

    signer = from_key

    t = '1:%s:%s:%s:%s' % (from_pubkey, to_pubkey, amount, timestamp)
    digest = sha256(t.encode()).digest()

    while 1:
        k = randint(1, signer.p - 1)
        if GCD(k, signer.p - 1) == 1:
            break

    signature = "%s,%s" % signer.sign(digest, K=k)

    payload = b64encode(
        json_encode([{
            'type': 1,  # транзакция
            'from_pubkey': from_pubkey,  # откуда берем коины
            'to_pubkey': to_pubkey,  # куда переводим коины
            'signature':
            signature,  # сигнатура транзакции, к тому же являеется уникальным идентификатором каждой транзакции
            'amount': amount,  # количество коинов
            'timestamp':
            timestamp,  # время создания транзакции, чтобы не было коллизий
        }]).encode()).decode()
    pub_key = 0
    magic = 0
    prev_block_id = 0
    prev_block_hash = 0
    pub_key = 0
    block_id = 0

    t = "%s:%s:%s:%s:%s:%s" % (str(pub_key), str(block_id), str(prev_block_id),
                               str(prev_block_hash), sha256(
                                   payload.encode()).hexdigest(), str(magic))
    print(t)
    proof = sha256(t.encode()).hexdigest()
    print(proof)
    block = {
        'pub_key': pub_key,  # кому переводим награду (если она будет вообще)
        'block_id': block_id,  # id текущего блока
        'prev_block_id': prev_block_id,  # id предыдущего блока
        'prev_block_hash': prev_block_hash,  # хэш предыдущего блока
        'payload': payload,  # содержимое блока
        'magic': magic,  # число для майнинга
        'proof': proof  # PoW Hash (sha256)
    }
    print(b64encode(json_encode(block).encode()))