def test_sign_verify_random(self):
     for l in range(1, 300):
         sk = ed25519.generate_secret()
         pk = ed25519.publickey(sk)
         msg = random.bytes(l)
         sig = ed25519.sign(sk, msg)
         self.assertTrue(ed25519.verify(pk, sig, msg))
    def test_cosi(self):

        for N in range(1, 11):

            # generate random message to be signed
            msg = random.bytes(128)

            # phase 0: create priv/pubkeys and combine pubkeys
            keys = [None] * N
            pubkeys = [None] * N
            for j in range(N):
                keys[j] = ed25519.generate_secret()
                pubkeys[j] = ed25519.publickey(keys[j])

            pubkey = ed25519.cosi_combine_publickeys(pubkeys)

            # phase 1: create nonces, commitments (R values) and combine commitments
            nonces = [None] * N
            Rs = [None] * N
            for j in range(N):
                nonces[j] = ed25519.generate_secret()
                Rs[j] = ed25519.publickey(nonces[j])

            R = ed25519.cosi_combine_publickeys(Rs)

            # phase 2: sign and combine signatures
            sigs = [None] * N
            for j in range(N):
                sigs[j] = ed25519.cosi_sign(keys[j], msg, nonces[j], R, pubkey)

            sig = ed25519.cosi_combine_signatures(R, sigs)

            # check signature using normal ed25519.verify
            res = ed25519.verify(pubkey, sig, msg)
            self.assertTrue(res)
async def lisk_verify_message(ctx, msg):
    digest = message_digest(msg.message)
    verified = ed25519.verify(msg.public_key, msg.signature, digest)
    if not verified:
        raise wire.ProcessError('Invalid signature')

    address = get_address_from_public_key(msg.public_key)
    await require_confirm_verify_message(ctx, address, msg.message)

    return Success(message='Message verified')
Esempio n. 4
0
async def verify_message(ctx, msg):
    digest = message_digest(msg.message)
    verified = ed25519.verify(msg.public_key, msg.signature, digest)
    if not verified:
        raise wire.ProcessError("Invalid signature")

    address = get_address_from_public_key(msg.public_key)
    await confirm_signverify(ctx,
                             "Lisk",
                             decode_message(msg.message),
                             address=address)

    return Success(message="Message verified")
 def test_verify(self):
     for sk, pk, sig in self.vectors:
         # msg = pk
         self.assertTrue(ed25519.verify(unhexlify(pk), unhexlify(sig), unhexlify(pk)))
         pass
Esempio n. 6
0
def _verify_message(public_key: bytes, signature: bytes, message: str):
    return ed25519.verify(public_key, signature, message)