コード例 #1
0
    async def submit_request(self,
                             req_json: str,
                             signed: bool = False,
                             apply_taa=False):
        try:
            if signed:
                if not self._did:
                    raise AnchorException("Cannot sign request: no DID")
                req = json.loads(req_json)
                if apply_taa and self._taa_accept:
                    req["taaAcceptance"] = self._taa_accept
                signer = SimpleSigner(self._did, self._seed)
                req["signature"] = signer.sign(req)
                req_json = json.dumps(req)
            rv_json = await ledger.submit_request(self._pool, req_json)
            await asyncio.sleep(0)
        except IndyError as e:
            raise AnchorException(
                "Error submitting ledger transaction request") from e

        resp = json.loads(rv_json)
        if resp.get("op", "") in ("REQNACK", "REJECT"):
            raise AnchorException(
                "Ledger rejected transaction request: {}".format(
                    resp["reason"]))

        return resp
コード例 #2
0
def test_authenticate_raises_correct_exception():
    msg = dict(myMsg=msg_str)
    simple_signer = SimpleSigner()
    identifier = simple_signer.identifier
    signature = simple_signer.sign(msg)
    verkey = simple_signer.verkey
    dummyAr = DummyAuthenticator()
    dummyAr.addIdr(identifier, verkey)
    pytest.raises(CouldNotAuthenticate, dummyAr.authenticate, msg, identifier,
                  signature)
コード例 #3
0
def testReconstitutedClientCreatesTheSameSig(cli, sig, msg):
    cli2 = SimpleSigner(idr, seed=cli.seed)
    sig2 = cli2.sign(msg)
    assert sig == sig2
コード例 #4
0
def testReconstitutedClientCreatesTheSameSig(signer, sig, msg):
    signer2 = SimpleSigner(idr, seed=signer.seed)
    sig2 = signer2.sign(msg)
    assert sig == sig2
コード例 #5
0
ファイル: test_client_authn.py プロジェクト: evernym/plenum
def testReconstitutedClientCreatesTheSameSig(cli, sig, msg):
    cli2 = SimpleSigner(idr, seed=cli.seed)
    sig2 = cli2.sign(msg)
    assert sig == sig2