Skip to content

Commit

Permalink
Updates to match the changes in KERIpy for tracking multisig particip…
Browse files Browse the repository at this point in the history
…ants. (WebOfTrust#224)

* Updated to match the new database for Habs and names from KERIpy as well as the new method for tracking signing and rotation members of a multisig AID.

Signed-off-by: pfeairheller <pfeairheller@gmail.com>

* Update event cloning.

Signed-off-by: pfeairheller <pfeairheller@gmail.com>

* Updates to match latest changes from KERIpy and fixing reference to NoBackers that should remain in this version

Signed-off-by: pfeairheller <pfeairheller@gmail.com>

* Upgrade python and hio versions

Signed-off-by: pfeairheller <pfeairheller@gmail.com>

---------

Signed-off-by: pfeairheller <pfeairheller@gmail.com>
  • Loading branch information
pfeairheller authored Apr 4, 2024
1 parent 2a0c19f commit 664cfee
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-app-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12.1
- name: Set up Python 3.12.2
uses: actions/setup-python@v2
with:
python-version: 3.12.1
python-version: 3.12.2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -44,10 +44,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12.1
- name: Set up Python 3.12.2
uses: actions/setup-python@v2
with:
python-version: 3.12.1
python-version: 3.12.2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"resolver",
# eg: 'keyword1', 'keyword2', 'keyword3',
],
python_requires='>=3.12.1',
python_requires='>=3.12.2',
install_requires=[
'hio>=0.6.9',
'hio>=0.6.12',
'keri @ git+https://git@github.com/weboftrust/keripy.git@development',
'mnemonic>=0.20',
'multicommand>=1.0.0',
Expand Down
6 changes: 3 additions & 3 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,12 +972,12 @@ def on_get(req, rep):
preb = pre.encode("utf-8")
events = []
for fn, dig in agent.hby.db.getFelItemPreIter(preb, fn=0):
dgkey = dbing.dgKey(preb, dig) # get message
if not (raw := agent.hby.db.getEvt(key=dgkey)):
if not (raw := agent.hby.db.cloneEvtMsg(pre=preb, fn=fn, dig=dig)):
raise falcon.HTTPInternalServerError(f"Missing event for dig={dig}.")

serder = serdering.SerderKERI(raw=bytes(raw))
events.append(serder.ked)
atc = raw[serder.size:]
events.append(dict(ked=serder.ked, atc=atc.decode("utf-8")))

rep.status = falcon.HTTP_200
rep.content_type = "application/json"
Expand Down
34 changes: 23 additions & 11 deletions src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ def on_get(self, _, rep, caid):
if agent.caid not in agent.hby.kevers:
raise falcon.HTTPBadRequest(description=f"invalid controller configuration, {agent.caid} not found")

pidx = agent.hby.db.habs.cntAll()
pidx = 0
for name, _ in agent.hby.db.names.getItemIter():
if name[0] != "agent":
pidx += 1

# pidx = agent.hby.db.habs.cntAll()

state = asdict(agent.hby.kevers[agent.caid].state())
key = dbing.dgKey(state['i'], state['ee']['d']) # digest key
Expand Down Expand Up @@ -269,17 +274,18 @@ def on_get(req, rep):
start, end = httping.parseRangeHeader(rng, "aids")

count = agent.hby.db.habs.cntAll()
it = agent.hby.db.habs.getItemIter()
it = agent.hby.db.names.getItemIter()
for _ in range(start):
try:
next(it)
except StopIteration:
break

for name, habord in it:
name = ".".join(name) # detupleize the database key name
for (ns, name), pre in it:
if ns == "agent":
continue

hab = agent.hby.habByName(name)
hab = agent.hby.habs[pre]
data = info(hab, agent.mgr)
res.append(data)

Expand All @@ -288,7 +294,7 @@ def on_get(req, rep):

end = start + (len(res) - 1) if len(res) > 0 else 0
rep.set_header("Accept-Ranges", "aids")
rep.set_header("Content-Range", f"aids {start}-{end}/{count}")
rep.set_header("Content-Range", f"aids {start}-{end}/{count-1}")
rep.content_type = "application/json"
rep.data = json.dumps(res).encode("utf-8")

Expand Down Expand Up @@ -350,18 +356,20 @@ def on_post(req, rep):
ndigs = group["ndigs"]
digers = [coring.Diger(qb64=ndig) for ndig in ndigs]

smids = httping.getRequiredParam(body, "smids")
rmids = httping.getRequiredParam(body, "rmids")

hab = agent.hby.makeSignifyGroupHab(name, mhab=mhab, serder=serder, sigers=sigers)
states = httping.getRequiredParam(body, "smids")
rstates = httping.getRequiredParam(body, "rmids")
smids = [state['i'] for state in states]
rmids = [rstate['i'] for rstate in rstates]
hab = agent.hby.makeSignifyGroupHab(name, mhab=mhab, smids=smids, rmids=rmids, serder=serder,
sigers=sigers)
try:
agent.inceptGroup(pre=serder.pre, mpre=mhab.pre, verfers=verfers, digers=digers)
except ValueError as e:
agent.hby.deleteHab(name=name)
raise falcon.HTTPInternalServerError(description=f"{e.args[0]}")

# Generate response, a long running operaton indicator for the type
agent.groups.append(dict(pre=hab.pre, serder=serder, sigers=sigers, smids=smids, rmids=rmids))
agent.groups.append(dict(pre=hab.pre, serder=serder, sigers=sigers, smids=states, rmids=rstates))
op = agent.monitor.submit(serder.pre, longrunning.OpTypes.group, metadata=dict(sn=0))

rep.content_type = "application/json"
Expand Down Expand Up @@ -1145,6 +1153,10 @@ def on_get(self, req, rep):
def authn(agent, contacts):
for contact in contacts:
aid = contact['id']

ends = agent.agentHab.endsFor(aid)
contact['ends'] = ends

accepted = [saider.qb64 for saider in agent.hby.db.chas.get(keys=(aid,))]
received = [saider.qb64 for saider in agent.hby.db.reps.get(keys=(aid,))]

Expand Down
2 changes: 1 addition & 1 deletion src/keria/testing/testing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def createRegistry(client, agent, salt, doist, deeds):
baks=[],
toad="0",
nonce=nonce,
cnfg=[eventing.TraitCodex.NoRegistrarBackers],
cnfg=[eventing.TraitCodex.NoBackers],
code=coring.MtrDex.Blake3_256)
anchor = dict(i=regser.ked['i'], s=regser.ked["s"], d=regser.said)
serder, sigers = Helpers.interact(pre=pre, bran=salt, pidx=0, ridx=0, dig=aid['d'], sn='1', data=[anchor])
Expand Down
14 changes: 10 additions & 4 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,10 @@ def test_identifier_collection_end(helpers):
assert res.status_code == 200
assert "signing" in res.json
signing = res.json["signing"]
assert len(signing) == 5 # this number is a little janky because we reuse public keys above, leaving for now
assert len(signing) == 3
assert "rotation" in res.json
rotation = res.json["rotation"]
assert len(rotation) == 5 # this number is a little janky because we reuse rotation keys above, leaving for now
assert len(rotation) == 3

# Try unknown witness
serder, signers = helpers.incept(salt, "signify:aid", pidx=3,
Expand Down Expand Up @@ -733,7 +733,7 @@ def test_identifier_collection_end(helpers):
assert res.status_code == 200
events = res.json
assert len(events) == 2
assert events[1] == serder.ked
assert events[1]['ked'] == serder.ked

serder = eventing.interact(pre=pre, dig=serder.said, sn=len(events), data=[pre])
sigers = [signer.sign(ser=serder.raw, index=0).qb64 for signer in signers]
Expand All @@ -748,7 +748,7 @@ def test_identifier_collection_end(helpers):
assert res.status_code == 200
events = res.json
assert len(events) == 3
assert events[2] == serder.ked
assert events[2]['ked'] == serder.ked

# Bad interactions
res = client.simulate_put(path="/identifiers/badrandy?type=ixn", body=json.dumps(body))
Expand Down Expand Up @@ -1135,6 +1135,7 @@ def test_contact_ends(helpers):
assert response.status == falcon.HTTP_200
assert response.json == [{'challenges': [],
'company': 'GLEIF',
'ends': {},
'first': 'Ken3',
'id': 'EAjKmvW6flpWJfdYYZ2Lu4pllPWKFjCBz0dcX-S86Nvg',
'last': 'Burns3',
Expand All @@ -1146,30 +1147,35 @@ def test_contact_ends(helpers):
assert response.status == falcon.HTTP_200
assert response.json == [{'challenges': [],
'company': 'GLEIF',
'ends': {},
'first': 'Ken3',
'id': 'EAjKmvW6flpWJfdYYZ2Lu4pllPWKFjCBz0dcX-S86Nvg',
'last': 'Burns3',
'wellKnowns': []},
{'challenges': [],
'company': 'GLEIF',
'ends': {},
'first': 'Ken1',
'id': 'EER-n23rDM2RQB8Kw4KRrm8SFpoid4Jnelhauo6KxQpz',
'last': 'Burns1',
'wellKnowns': []},
{'challenges': [],
'company': 'ProSapien',
'ends': {},
'first': 'Ken4',
'id': 'EGwcSt3uvK5-oHI7hVU7dKMvWt0vRfMW2demzBBMDnBG',
'last': 'Burns4',
'wellKnowns': []},
{'challenges': [],
'company': 'ProSapien',
'ends': {},
'first': 'Ken2',
'id': 'ELTQ3tF3n7QS8LDpKMdJyCMhVyMdvNPTiisnqW5ZQP3C',
'last': 'Burns2',
'wellKnowns': []},
{'challenges': [],
'company': 'GLEIF',
'ends': {},
'first': 'Ken0',
'id': 'EPo8Wy1xpTa6ri25M4IlmWBBzs5y8v4Qn3Z8xP4kEjcK',
'last': 'Burns0',
Expand Down
2 changes: 1 addition & 1 deletion tests/app/test_credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_registry_end(helpers, seeder):
baks=[],
toad="0",
nonce=nonce,
cnfg=[TraitCodex.NoRegistrarBackers],
cnfg=[TraitCodex.NoBackers],
code=coring.MtrDex.Blake3_256)
anchor = dict(i=regser.ked['i'], s=regser.ked["s"], d=regser.said)
serder, sigers = helpers.interact(pre=pre, bran=salt, pidx=0, ridx=0, dig=aid['d'], sn='1', data=[anchor])
Expand Down
4 changes: 2 additions & 2 deletions tests/app/test_ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hio.base import doing
from hio.help import decking
from keri.app import habbing, signing
from keri.core import eventing, coring, parsing, serdering
from keri.core import eventing, coring, serdering
from keri.help import helping
from keri.kering import Roles
from keri.peer import exchanging
Expand Down Expand Up @@ -605,7 +605,7 @@ def test_multisig_grant_admit(seeder, helpers):
baks=[],
toad="0",
nonce=nonce,
cnfg=[eventing.TraitCodex.NoRegistrarBackers],
cnfg=[eventing.TraitCodex.NoBackers],
code=coring.MtrDex.Blake3_256)

anchor = dict(i=regser.ked['i'], s=regser.ked["s"], d=regser.said)
Expand Down

0 comments on commit 664cfee

Please sign in to comment.