Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to match the latest CESR 1.1 changes to KERIpy. #100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def create_agent():
stem=client.ctrl.stem,
pidx=1,
tier=client.ctrl.tier))
print(res.json())

if res.status_code != requests.codes.accepted:
raise kering.AuthNError(f"unable to initialize cloud agent connection, {res.status_code}, {res.text}")
Expand Down
4 changes: 2 additions & 2 deletions scripts/create_new_quartet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import requests
from keri import kering
from keri.core import coring
from keri.core import coring, serdering
from keri.core.coring import Tiers

from signify.app.clienting import SignifyClient
Expand Down Expand Up @@ -131,7 +131,7 @@ def create_aid(client, name, bran, pre):
op = operations.get(op["name"])
sleep(1)

icp = coring.Serder(ked=op["response"])
icp = serdering.SerderKERI(sad=op["response"])
print(icp.pre)
assert icp.pre == pre

Expand Down
2 changes: 1 addition & 1 deletion scripts/create_person_aid.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_aid():
op = operations.get(op["name"])
sleep(1)

icp = coring.Serder(ked=op["response"])
icp = serdering.SerderKERI(sad=op["response"])
assert icp.pre == "EBcIURLpxmVwahksgrsGW6_dUw0zBhyEHYFk17eWrZfk"
print(f"Person AID {icp.pre} created")

Expand Down
2 changes: 1 addition & 1 deletion scripts/init_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create_agent():
stem = "signify:controller"

ims = input("Type of paste controller inception event:")
serder = coring.Serder(raw=ims.encode("utf-8"))
serder = serdering.SerderKERIraw=ims.encode("utf-8"))
siger = coring.Siger(qb64=ims[serder.size:])

res = requests.post(url="http://localhost:3903/boot",
Expand Down
2 changes: 1 addition & 1 deletion scripts/join_new_quadlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def accept_join_request(client, name, group):

embeds = exn['e']
ked = embeds['rot']
rot = coring.Serder(ked=ked)
rot = serdering.SerderKERI(sad=ked)

keeper = client.manager.get(aid=hab)
sigs = keeper.sign(ser=rot.raw, indexed=True, indices=[idx], ondices=[odx])
Expand Down
3 changes: 0 additions & 3 deletions scripts/list_ipex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

Testing clienting with integration tests that require a running KERIA Cloud Agent
"""
import sys

from keri.core.coring import Tiers
from keri.vc.proving import Creder

from signify.app.clienting import SignifyClient

Expand Down
5 changes: 2 additions & 3 deletions scripts/list_person_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

Testing clienting with integration tests that require a running KERIA Cloud Agent
"""

from keri.core import serdering
from keri.core.coring import Tiers
from keri.vc.proving import Creder

from signify.app.clienting import SignifyClient

Expand All @@ -33,7 +32,7 @@ def list_credentials():
print(creds)
assert len(creds) == 1

creder = Creder(ked=creds[0]['sad'])
creder = serdering.SerderACDC(sad=creds[0]['sad'])
print(creder.pretty(size=5000))

# said = creder.said
Expand Down
2 changes: 1 addition & 1 deletion scripts/multisig-create-credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def create_credential():

(_, _, op) = identifiers.create("multisig3", bran="0123456789lmnopqrstuv")
icp = op["response"]
serder = coring.Serder(ked=icp)
serder = serdering.SerderKERI(sad=icp)
assert serder.pre == "EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv"
print(f"created AID {serder.pre}")

Expand Down
6 changes: 3 additions & 3 deletions scripts/multisig-holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def multisig_holder():
op = client1.operations().get(op['name'])
sleep(1)

exn = coring.Serder(ked=op["response"]['exn'])
exn = serdering.SerderKERI(sad=op["response"]['exn'])
print(f"Challenge signed in {exn.said}")
client1.challenges().responded("holder1", holder2['i'], exn.said)

Expand Down Expand Up @@ -171,7 +171,7 @@ def create_aid(client, name, bran, expected):
identifiers = client.identifiers()
(_, _, op) = identifiers.create(name, bran=bran)
icp = op["response"]
serder = coring.Serder(ked=icp)
serder = serdering.SerderKERI(sad=icp)
assert serder.pre == expected
print(f"AID Created: {serder.pre}")

Expand Down Expand Up @@ -220,7 +220,7 @@ def create_admit(client, participant, group, said, recp):
ipex = client.ipex()

res = exchanges.get(said)
grant = coring.Serder(ked=res['exn'])
grant = serdering.SerderKERI(sad=res['exn'])
ghab = get_aid(client, group)
mhab = get_aid(client, participant)

Expand Down
8 changes: 4 additions & 4 deletions scripts/multisig-kli-rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_multisig():

(_, _, op) = identifiers.create("multisig3", bran="0123456789lmnopqrstuv")
icp = op["response"]
serder = coring.Serder(ked=icp)
serder = serdering.SerderKERI(sad=icp)
assert serder.pre == "EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv"
print(f"created AID {serder.pre}")

Expand Down Expand Up @@ -124,17 +124,17 @@ def create_multisig():
op = operations.get(op["name"])
sleep(1)

ixn = coring.Serder(ked=op["response"])
ixn = serdering.SerderKERI(sad=op["response"])
events = client.keyEvents()
log = events.get(pre=ixn.pre)
assert len(log) == 2

for event in log:
print(coring.Serder(ked=event).pretty())
print(serdering.SerderKERI(sad=event).pretty())

(_, _, op2) = identifiers.rotate("multisig3")
rot = op2["response"]
serder = coring.Serder(ked=rot)
serder = serdering.SerderKERI(sad=rot)
print(f"rotated multisig3 to {serder.sn}")

input("hit any key when other two participants have rotated their AIDs")
Expand Down
5 changes: 2 additions & 3 deletions scripts/single-issuer-holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from requests import post
from pysodium import randombytes, crypto_sign_SEEDBYTES
from keri.app import signing
from keri.core import coring, eventing
from keri.core import coring, eventing, serdering
from keri.core.coring import Tiers
from keri.help import helping
from keri.vc.proving import Creder
from signify.app.clienting import SignifyClient

URL = 'http://127.0.0.1:3901'
Expand Down Expand Up @@ -184,7 +183,7 @@ def run():
credentials = holder_client.credentials().list('holder', filtr={})

print('Succeeded')
creder = Creder(ked=credentials[0]['sad'])
creder = serdering.SerderACDC(sad=credentials[0]['sad'])
print(creder.pretty(size=5000))


Expand Down
6 changes: 3 additions & 3 deletions src/signify/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_from_events(self, hab, registryName, vcp, ixn, sigs):
@staticmethod
def serialize(serder, anc):
seqner = coring.Seqner(sn=anc.sn)
couple = seqner.qb64b + anc.saider.qb64b
couple = seqner.qb64b + anc.said.encode("utf-8")
atc = bytearray()
atc.extend(coring.Counter(code=coring.CtrDex.SealSourceCouples,
count=1).qb64b)
Expand Down Expand Up @@ -197,7 +197,7 @@ def create(self, hab, registry, data, schema, recipient=None, edges=None, rules=
rules=rules,
status=regk)

dt = creder.subject["dt"] if "dt" in creder.subject else helping.nowIso8601()
dt = creder.attrib["dt"] if "dt" in creder.attrib else helping.nowIso8601()
noBackers = 'NB' in registry['state']['c']
if noBackers:
iserder = eventing.issue(vcdig=creder.said, regk=regk, dt=dt)
Expand All @@ -221,7 +221,7 @@ def create(self, hab, registry, data, schema, recipient=None, edges=None, rules=
keeper = self.client.manager.get(aid=hab)
sigs = keeper.sign(ser=anc.raw)

res = self.create_from_events(hab=hab, creder=creder.ked, iss=iserder.ked, anc=anc.ked,
res = self.create_from_events(hab=hab, creder=creder.sad, iss=iserder.sad, anc=anc.sad,
sigs=sigs)

return creder, iserder, anc, sigs, res.json()
Expand Down
4 changes: 2 additions & 2 deletions src/signify/core/authing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from keri import kering
from keri.app import keeping
from keri.core import coring, eventing
from keri.core import coring, eventing, serdering

from keri.end import ending
from signify.signifying import State
Expand Down Expand Up @@ -74,7 +74,7 @@ def derive(self, state):
toad="0",
wits=[])
elif type(state) is State:
return coring.Serder(ked=state.controller['ee'])
return serdering.SerderKERI(sad=state.controller['ee'])

def approveDelegation(self, agent):
seqner = coring.Seqner(sn=agent.sn)
Expand Down
46 changes: 30 additions & 16 deletions tests/app/test_credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from keri.peer import exchanging
from keri.vdr import eventing as veventing
from keri.core import eventing
from keri.core import eventing, coring
from mockito import mock, unstub, verify, verifyNoUnwantedInteractions, expect, ANY

from signify.app import credentialing
Expand All @@ -26,7 +26,8 @@ def test_registries():

from requests import Response
mock_response = mock({'json': lambda: {}}, spec=Response, strict=True)
mock_hab = {'prefix': 'a_prefix', 'name': 'aid1', 'state': {'s': '1', 'd': "ABCDEFG"}}
mock_hab = {'prefix': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose',
'name': 'aid1', 'state': {'s': '1', 'd': "ABCDEFG"}}
name = "aid1"
regName = "reg1"

Expand Down Expand Up @@ -109,8 +110,10 @@ def test_credentials_create():
mock_manager = mock(spec=keeping.Manager, strict=True)
mock_client.manager = mock_manager # type: ignore

mock_hab = {'prefix': 'a_prefix', 'name': 'aid1', 'state': {'s': '1', 'd': "ABCDEFG"}}
mock_registry = {'regk': "a_regk", 'pre': 'a_prefix', 'state': {'c': ['NB']}}
mock_hab = {'prefix': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose', 'name': 'aid1',
'state': {'s': '1', 'd': "ABCDEFG"}}
mock_registry = {'regk': "EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF",
'pre': 'EHpwssa6tmD2U5W7-aogym-r1NobKBNXydP4MmaebA4O', 'state': {'c': ['NB']}}
data = dict(dt="2023-09-27T16:27:14.376928+00:00", LEI="ABC1234567890AD4456")
schema = "EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao"
recp = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose"
Expand All @@ -122,28 +125,39 @@ def test_credentials_create():
mock_response = mock({}, spec=Response, strict=True)
expect(mock_response, times=1).json().thenReturn({'v': 'ACDC10JSON00014c_'})

body = {'acdc': {'v': 'ACDC10JSON00014c_', 'd': 'EPXTb9qRHquoEey-QsF-8Sks8nDoXBK6kdlP1G6WynJ3', 'i': 'a_prefix',
'ri': 'a_regk', 's': 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao',
sad = {'v': 'ACDC10JSON00014c_', 'd': '',
'i': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose',
'ri': 'a_regk', 's': 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao',
'a': {'d': 'EHpwssa6tmD2U5W7-aogym-r1NobKBNXydP4MmaebA4O',
'i': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose',
'dt': '2023-09-27T16:27:14.376928+00:00', 'LEI': 'ABC1234567890AD4456'}}

_, sad = coring.Saider.saidify(sad)

body = {'acdc': {'v': 'ACDC10JSON000196_', 'd': 'EK2xYrVkfJJHvlGhP79sfEPvQGmkFPPNAj-bjI5oHy7m',
'i': 'EHpwssa6tmD2U5W7-aogym-r1NobKBNXydP4MmaebA4O',
'ri': 'EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF',
's': 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao',
'a': {'d': 'EHpwssa6tmD2U5W7-aogym-r1NobKBNXydP4MmaebA4O',
'i': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose',
'dt': '2023-09-27T16:27:14.376928+00:00', 'LEI': 'ABC1234567890AD4456'}},
'iss': {'v': 'KERI10JSON0000c7_', 't': 'iss', 'd': 'EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF',
'i': 'EPXTb9qRHquoEey-QsF-8Sks8nDoXBK6kdlP1G6WynJ3', 's': '0', 'ri': 'a_regk',
'dt': '2023-09-27T16:27:14.376928+00:00'},
'ixn': {'v': 'KERI10JSON0000f1_', 't': 'ixn', 'd': 'EJM1yhn99LOgCPRsEqpg8nKXQjkSE4-Q4dfvF3wm1Waz',
'i': 'a_prefix', 's': '2', 'p': 'ABCDEFG', 'a': [
{'i': 'EPXTb9qRHquoEey-QsF-8Sks8nDoXBK6kdlP1G6WynJ3', 's': '0',
'd': 'EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF'}]}, 'sigs': ['a signature'],
'iss': {'v': 'KERI10JSON0000ed_', 't': 'iss', 'd': 'EE8yncw1LCyBVtZPtozAFi7qvGn9dRPwTbuq--ulOAtB',
'i': 'EK2xYrVkfJJHvlGhP79sfEPvQGmkFPPNAj-bjI5oHy7m', 's': '0',
'ri': 'EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF', 'dt': '2023-09-27T16:27:14.376928+00:00'},
'ixn': {'v': 'KERI10JSON000115_', 't': 'ixn', 'd': 'EC5KxyucpxnOpIpHe2QUPs9YeH1yGvkALg8NcWLYFe6a',
'i': 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose', 's': '2', 'p': 'ABCDEFG', 'a': [
{'i': 'EK2xYrVkfJJHvlGhP79sfEPvQGmkFPPNAj-bjI5oHy7m', 's': '0',
'd': 'EE8yncw1LCyBVtZPtozAFi7qvGn9dRPwTbuq--ulOAtB'}]}, 'sigs': ['a signature'],
'salty': {'keeper': 'params'}}

expect(mock_client, times=1).post(f"/identifiers/aid1/credentials", json=body).thenReturn(mock_response)

from signify.app.credentialing import Credentials
creder, iss, ixn, sigs, op = Credentials(client=mock_client).create(mock_hab, mock_registry, data, schema, recp)

assert creder.said == "EPXTb9qRHquoEey-QsF-8Sks8nDoXBK6kdlP1G6WynJ3"
assert iss.said == "EKRg7i8jS4O6BYUYiQG7X8YiMYdDXdw28tJRhFndCdGF"
assert ixn.said == "EJM1yhn99LOgCPRsEqpg8nKXQjkSE4-Q4dfvF3wm1Waz"
assert creder.said == "EK2xYrVkfJJHvlGhP79sfEPvQGmkFPPNAj-bjI5oHy7m"
assert iss.said == "EE8yncw1LCyBVtZPtozAFi7qvGn9dRPwTbuq--ulOAtB"
assert ixn.said == "EC5KxyucpxnOpIpHe2QUPs9YeH1yGvkALg8NcWLYFe6a"
assert op == {'v': 'ACDC10JSON00014c_'}

verifyNoUnwantedInteractions()
Expand Down
35 changes: 29 additions & 6 deletions tests/core/test_authing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# -*- encoding: utf-8 -*-
"""
SIGNIFY
signify.app.test_authing module

Testing authing with unit tests
"""

from keri import kering
from keri.core import serdering
from keri.core.coring import Tiers
from mockito import mock, unstub, expect, verifyNoUnwantedInteractions
import pytest

Expand Down Expand Up @@ -122,19 +132,32 @@ def test_controller_derive():

from keri.core import coring
e1 = dict(v=coring.Vstrings.json,
t="rot",
d="",
i="ABCDEFG",
s="0001",
t="rot")
i="EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV",
s="1",
p="EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV",
kt="1",
k=["DMZy6qbgnKzvCE594tQ4SPs6pIECXTYQBH7BkC4hNY3E"],
nt="1",
n=["EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV"],
bt="0",
br=[],
ba=[],
a=[]
)

_, e1 = coring.Saider.saidify(sad=e1)

from signify.signifying import State
state = State(controller={"ee": e1})
serder = ctrl.derive(state=state)

assert serder.raw == (b'{"v":"KERI10JSON00006f_","d":"EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F",'
b'"i":"ABCDEFG","s":"0001","t":"rot"}')
assert serder.raw == (b'{"v":"KERI10JSON000160_","t":"rot","d":"ENvjVqUoq2SGDrFSzqI5AI37ZE4IAlKLdFGw'
b'Uzf7Ir7I","i":"EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV","s":"1","p":"EM'
b'PYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV","kt":"1","k":["DMZy6qbgnKzvCE594'
b'tQ4SPs6pIECXTYQBH7BkC4hNY3E"],"nt":"1","n":["EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8'
b'A3jjXxqYawLcV"],"bt":"0","br":[],"ba":[],"a":[]}')


def test_approve_delegation():
Expand All @@ -160,7 +183,7 @@ def test_approve_delegation():
pre="EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV",
dig="EMPYj-h2OoCyPGQoUUd1tLUYe62YD_8A3jjXxqYawLcV",
sn=1,
data=[{'i': 'pre', 's': '1', 'd': 'said'}]).thenReturn(coring.Serder(ked=e1))
data=[{'i': 'pre', 's': '1', 'd': 'said'}]).thenReturn(serdering.SerderKERI(sad=e1))

serder, sig = ctrl.approveDelegation(agent=mock_agent)

Expand Down
Loading