Пример #1
0
    def test_1_1_spend(self): # 1 in, 1 out
        # generate a sender and recipient stealth account
        sender_private_key = stealth.gen_private_key()
        sender_public_key = stealth.gen_public_key(sender_private_key)
        recipient_private_key = stealth.gen_private_key()
        recipient_public_key = stealth.gen_public_key(recipient_private_key)

        # generate a ring of one-time accounts addressed to unknown recipients
        accounts_ring = []
        for i in range(account.R - 1): 
            temp_private_key = stealth.gen_private_key()
            temp_public_key = stealth.gen_public_key(temp_private_key)
            temp_ot_account,temp_deposit_key = account.gen_account(temp_public_key,random_scalar())
            accounts_ring.append(temp_ot_account)

        # generate a one-time account addressed to the sender and receive it
        ot_sender,deposit_sender = account.gen_account(sender_public_key,random_scalar())
        withdrawal_key = account.receive(sender_private_key,ot_sender)

        # generate a one-time account addressed to the recipient
        ot_recipient,deposit_recipient = account.gen_account(recipient_public_key,random_scalar())

        # spend the input
        tx = account.Transaction([withdrawal_key.tag],accounts_ring,[ot_recipient])
        account.spend([withdrawal_key],[deposit_recipient],tx,'spend memo')
Пример #2
0
    def test_receive(self):
        # generate a stealth account and a second stealth private key
        stealth_private_key = stealth.gen_private_key()
        stealth_public_key = stealth.gen_public_key(stealth_private_key)
        bad_private_key = stealth.gen_private_key()

        # generate a one-time account and deposit key
        a = random_scalar()
        ot_account,deposit_key = account.gen_account(stealth_public_key,a)

        # we cannot receive someone else's one-time account
        with self.assertRaises(Exception):
            account.receive(bad_private_key,ot_account)

        # we can receive our own one-time account
        account.receive(stealth_private_key,ot_account)
Пример #3
0
    def test_gen_account(self):
        # generate a stealth account
        stealth_private_key = stealth.gen_private_key()
        stealth_public_key = stealth.gen_public_key(stealth_private_key)

        # ensure all properties are set
        self.assertIsNotNone(stealth_private_key.tsk)
        self.assertIsNotNone(stealth_private_key.ssk)
        self.assertIsNotNone(stealth_private_key.x)

        self.assertIsNotNone(stealth_public_key.tpk)
        self.assertIsNotNone(stealth_public_key.spk)
        self.assertIsNotNone(stealth_public_key.X)
Пример #4
0
    def test_gen_account(self):
        # generate a stealth account
        stealth_private_key = stealth.gen_private_key()
        stealth_public_key = stealth.gen_public_key(stealth_private_key)

        # generate a one-time account and deposit key
        a = random_scalar()
        ot_account,deposit_key = account.gen_account(stealth_public_key,a)

        # ensure all properties are set
        self.assertIsNotNone(ot_account.pk)
        self.assertIsNotNone(ot_account.co)
        self.assertIsNotNone(ot_account._ek)
        self.assertIsNotNone(ot_account._a)
        self.assertIsNotNone(ot_account._r)
        self.assertIsNotNone(deposit_key.a)
        self.assertIsNotNone(deposit_key.r)