Skip to content

Commit

Permalink
Updates to multisig interaction and rotation protocols to enable full…
Browse files Browse the repository at this point in the history
… interop with KERIA agents for creating, interacting and rotating multisig AIDs across client types. (#569)
  • Loading branch information
pfeairheller authored Sep 6, 2023
1 parent 405b26b commit c1d5c89
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 4,122 deletions.
8 changes: 4 additions & 4 deletions scripts/demo/basic/multisig-signify-rotation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ read -n 1 -r -p "Press any key after agent0 has rotated:"

kli rotate --name multisig1 --alias multisig1
kli query --name multisig2 --alias multisig2 --prefix EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4
kli query --name multisig2 --alias multisig2 --prefix ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK
kli query --name multisig2 --alias multisig2 --prefix EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv
kli rotate --name multisig2 --alias multisig2
kli query --name multisig1 --alias multisig1 --prefix EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1
kli query --name multisig1 --alias multisig1 --prefix ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK
kli query --name multisig1 --alias multisig1 --prefix EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv

kli multisig rotate --name multisig1 --alias multisig --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4:1 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1:1 --smids ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK:1 --isith '["1/3", "1/3", "1/3"]' --nsith '["1/3", "1/3", "1/3"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --rmids ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK &
kli multisig rotate --name multisig1 --alias multisig --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4:1 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1:1 --smids EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv:1 --isith '["1/3", "1/3", "1/3"]' --nsith '["1/3", "1/3", "1/3"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --rmids EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv &
pid=$!
PID_LIST+=" $pid"
kli multisig rotate --name multisig2 --alias multisig --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4:1 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1:1 --smids ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK:1 --isith '["1/3", "1/3", "1/3"]' --nsith '["1/3", "1/3", "1/3"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --rmids ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK &
kli multisig rotate --name multisig2 --alias multisig --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4:1 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1:1 --smids EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv:1 --isith '["1/3", "1/3", "1/3"]' --nsith '["1/3", "1/3", "1/3"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --rmids EOGvmhJDBbJP4zeXaRun5vSz0O3_1zB10DwNMyjXlJEv &
pid=$!
PID_LIST+=" $pid"

Expand Down
14 changes: 9 additions & 5 deletions src/keri/app/cli/commands/multisig/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from keri import kering
from keri.app import grouping, indirecting, habbing, forwarding
from keri.app.cli.common import existing, displaying, config
from keri.app.notifying import Notifier
from keri.core import coring
from keri.peer import exchanging

logger = help.ogler.getLogger()

Expand Down Expand Up @@ -75,10 +77,15 @@ def __init__(self, name, alias, aids, base, bran, data):
self.hbyDoer = habbing.HaberyDoer(habery=self.hby) # setup doer
self.postman = forwarding.Poster(hby=self.hby)

mbd = indirecting.MailboxDirector(hby=self.hby, topics=['/receipt', '/multisig'])
notifier = Notifier(self.hby)
mux = grouping.Multiplexor(self.hby, notifier=notifier)
exc = exchanging.Exchanger(hby=self.hby, handlers=[])
grouping.loadHandlers(self.hby, exc, mux)

mbd = indirecting.MailboxDirector(hby=self.hby, topics=['/receipt', '/multisig'], exc=exc)
self.counselor = grouping.Counselor(hby=self.hby)

doers = [self.hbyDoer, self.postman, mbd, self.counselor]
doers = [self.hbyDoer, self.postman, mbd, self.counselor, exc]
self.toRemove = list(doers)

doers.extend([doing.doify(self.interactDo)])
Expand Down Expand Up @@ -107,15 +114,12 @@ def interactDo(self, tymth, tock=0.0):

ixn = ghab.interact(data=self.data)
serder = coring.Serder(raw=ixn)
atc = bytes(ixn[serder.size:])

exn, ims = grouping.multisigInteractExn(ghab=ghab, aids=aids, ixn=ixn)
others = list(oset(ghab.smids + (ghab.rmids or [])))
others.remove(ghab.mhab.pre)

for recpt in others: # send notification to other participants as a signalling mechanism
self.postman.send(src=ghab.mhab.pre, dest=recpt, topic="multisig", serder=serder,
attachment=bytearray(atc))
self.postman.send(src=ghab.mhab.pre, dest=recpt, topic="multisig", serder=exn, attachment=ims)

prefixer = coring.Prefixer(qb64=ghab.pre)
Expand Down
13 changes: 8 additions & 5 deletions src/keri/app/cli/commands/multisig/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
from keri import kering
from keri.app import grouping, indirecting, habbing, forwarding
from keri.app.cli.common import rotating, existing, displaying, config
from keri.app.notifying import Notifier
from keri.core import coring
from keri.db import dbing
from keri.peer import exchanging

logger = help.ogler.getLogger()

Expand Down Expand Up @@ -85,12 +87,16 @@ def __init__(self, name, base, bran, alias, smids=None, rmids=None, isith=None,

self.hby = existing.setupHby(name=name, base=base, bran=bran)
self.hbyDoer = habbing.HaberyDoer(habery=self.hby) # setup doer
notifier = Notifier(self.hby)
mux = grouping.Multiplexor(self.hby, notifier=notifier)
exc = exchanging.Exchanger(hby=self.hby, handlers=[])
grouping.loadHandlers(self.hby, exc, mux)

mbd = indirecting.MailboxDirector(hby=self.hby, topics=['/receipt', '/multisig'])
mbd = indirecting.MailboxDirector(hby=self.hby, topics=['/receipt', '/multisig'], exc=exc)
self.counselor = grouping.Counselor(hby=self.hby)
self.postman = forwarding.Poster(hby=self.hby)

doers = [mbd, self.hbyDoer, self.counselor, self.postman]
doers = [mbd, self.hbyDoer, self.counselor, self.postman, exc]
self.toRemove = list(doers)

doers.extend([doing.doify(self.rotateDo)])
Expand Down Expand Up @@ -212,9 +218,6 @@ def rotateDo(self, tymth, tock=0.0, **opts):
others.remove(ghab.mhab.pre)

for recpt in others: # Send event AND notification message to others
self.postman.send(src=ghab.mhab.pre, dest=recpt, topic="multisig", serder=rserder,
attachment=bytearray(rot))

self.postman.send(src=ghab.mhab.pre,
dest=recpt,
topic="multisig",
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def multisigInteractExn(ghab, aids, ixn):

exn, end = exchanging.exchange(route="/multisig/ixn", modifiers=dict(),
payload=dict(gid=ghab.pre,
aids=aids), sender=ghab.mhab.pre,
smids=aids), sender=ghab.mhab.pre,
embeds=embeds)
ims = ghab.mhab.endorse(serder=exn, last=False, pipelined=False)
atc = bytearray(ims[exn.size:])
Expand Down
Loading

0 comments on commit c1d5c89

Please sign in to comment.