Beispiel #1
0
    def test_cosi_sign(self):
        self.setup_mnemonic_pin_passphrase()

        digest = sha256(b"this is a message").digest()

        c0 = cosi.commit(self.client, parse_path("10018'/0'"), digest)
        c1 = cosi.commit(self.client, parse_path("10018'/1'"), digest)
        c2 = cosi.commit(self.client, parse_path("10018'/2'"), digest)

        global_pk = cosi.combine_keys([c0.pubkey, c1.pubkey, c2.pubkey])
        global_R = cosi.combine_keys(
            [c0.commitment, c1.commitment, c2.commitment])

        # fmt: off
        sig0 = cosi.sign(self.client, parse_path("10018'/0'"), digest,
                         global_R, global_pk)
        sig1 = cosi.sign(self.client, parse_path("10018'/1'"), digest,
                         global_R, global_pk)
        sig2 = cosi.sign(self.client, parse_path("10018'/2'"), digest,
                         global_R, global_pk)
        # fmt: on

        sig = cosi.combine_sig(
            global_R, [sig0.signature, sig1.signature, sig2.signature])

        cosi.verify(sig, digest, global_pk)
Beispiel #2
0
    def test_cosi_sign(self):
        self.setup_mnemonic_pin_passphrase()

        digest = sha256(b"this is a message").digest()

        c0 = cosi.commit(self.client, parse_path("10018'/0'"), digest)
        c1 = cosi.commit(self.client, parse_path("10018'/1'"), digest)
        c2 = cosi.commit(self.client, parse_path("10018'/2'"), digest)

        global_pk = cosi.combine_keys([c0.pubkey, c1.pubkey, c2.pubkey])
        global_R = cosi.combine_keys([c0.commitment, c1.commitment, c2.commitment])

        # fmt: off
        sig0 = cosi.sign(self.client, parse_path("10018'/0'"), digest, global_R, global_pk)
        sig1 = cosi.sign(self.client, parse_path("10018'/1'"), digest, global_R, global_pk)
        sig2 = cosi.sign(self.client, parse_path("10018'/2'"), digest, global_R, global_pk)
        # fmt: on

        sig = cosi.combine_sig(
            global_R, [sig0.signature, sig1.signature, sig2.signature]
        )

        cosi.verify(sig, digest, global_pk)
Beispiel #3
0
def test_cosi_sign(client):
    digest = sha256(b"this is a message").digest()

    c0 = cosi.commit(client, parse_path("10018'/0'"), digest)
    c1 = cosi.commit(client, parse_path("10018'/1'"), digest)
    c2 = cosi.commit(client, parse_path("10018'/2'"), digest)

    global_pk = cosi.combine_keys([c0.pubkey, c1.pubkey, c2.pubkey])
    global_R = cosi.combine_keys([c0.commitment, c1.commitment, c2.commitment])

    # fmt: off
    sig0 = cosi.sign(client, parse_path("10018'/0'"), digest, global_R,
                     global_pk)
    sig1 = cosi.sign(client, parse_path("10018'/1'"), digest, global_R,
                     global_pk)
    sig2 = cosi.sign(client, parse_path("10018'/2'"), digest, global_R,
                     global_pk)
    # fmt: on

    sig = cosi.combine_sig(global_R,
                           [sig0.signature, sig1.signature, sig2.signature])

    cosi.verify_combined(sig, digest, global_pk)
Beispiel #4
0
def test_cosi_compat(client):
    digest = sha256(b"this is not a pipe").digest()
    remote_commit = cosi.commit(client, parse_path("10018'/0'"), digest)

    local_privkey = sha256(b"private key").digest()[:32]
    local_pubkey = cosi.pubkey_from_privkey(local_privkey)
    local_nonce, local_commitment = cosi.get_nonce(local_privkey, digest, 42)

    global_pk = cosi.combine_keys([remote_commit.pubkey, local_pubkey])
    global_R = cosi.combine_keys([remote_commit.commitment, local_commitment])

    remote_sig = cosi.sign(client, parse_path("10018'/0'"), digest, global_R,
                           global_pk)
    local_sig = cosi.sign_with_privkey(digest, local_privkey, global_pk,
                                       local_nonce, global_R)
    sig = cosi.combine_sig(global_R, [remote_sig.signature, local_sig])

    cosi.verify_combined(sig, digest, global_pk)
Beispiel #5
0
    def test_cosi_compat(self):
        self.setup_mnemonic_pin_passphrase()

        digest = sha256(b"this is not a pipe").digest()
        remote_commit = cosi.commit(self.client, parse_path("10018'/0'"), digest)

        local_privkey = sha256(b"private key").digest()[:32]
        local_pubkey = cosi.pubkey_from_privkey(local_privkey)
        local_nonce, local_commitment = cosi.get_nonce(local_privkey, digest, 42)

        global_pk = cosi.combine_keys([remote_commit.pubkey, local_pubkey])
        global_R = cosi.combine_keys([remote_commit.commitment, local_commitment])

        remote_sig = cosi.sign(
            self.client, parse_path("10018'/0'"), digest, global_R, global_pk
        )
        local_sig = cosi.sign_with_privkey(
            digest, local_privkey, global_pk, local_nonce, global_R
        )
        sig = cosi.combine_sig(global_R, [remote_sig.signature, local_sig])

        cosi.verify(sig, digest, global_pk)