Skip to content

Commit

Permalink
adds randy keeper tests (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
m00sey authored Aug 23, 2023
1 parent 1114174 commit 5c66777
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 26 deletions.
3 changes: 0 additions & 3 deletions integration/app/integration_clienting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
import requests
from keri.app.keeping import Algos
from keri.core import coring
from responses import _recorder

import pytest
from keri import kering
from keri.core.coring import Tiers, Serder, MtrDex

import keria.app.aiding as aiding

from signify.app.clienting import SignifyClient

TESTS_APP_DIR = "tests/app/"
Expand Down
39 changes: 20 additions & 19 deletions src/signify/core/keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import importlib

from keri import kering
from keri.app.keeping import SaltyCreator, Algos, RandyCreator
from keri.app import keeping
from keri.core import coring
from keri.core.coring import Tiers, MtrDex

Expand All @@ -32,16 +32,16 @@ def __init__(self, salter, extern_modules=None):

def new(self, algo, pidx, **kwargs):
match algo:
case Algos.salty:
case keeping.Algos.salty:
return SaltyKeeper(salter=self.salter, pidx=pidx, **kwargs)

case Algos.group:
case keeping.Algos.group:
return GroupKeeper(mgr=self, **kwargs)

case Algos.randy:
case keeping.Algos.randy:
return RandyKeeper(salter=self.salter, **kwargs)

case Algos.extern:
case keeping.Algos.extern:
typ = kwargs["extern_type"]
if typ not in self.modules:
raise kering.ConfigurationError(f"unsupported external module type {typ}")
Expand All @@ -52,16 +52,16 @@ def new(self, algo, pidx, **kwargs):

def get(self, aid):
pre = coring.Prefixer(qb64=aid["prefix"])
if Algos.salty in aid:
kwargs = aid[Algos.salty]
if keeping.Algos.salty in aid:
kwargs = aid[keeping.Algos.salty]
return SaltyKeeper(salter=self.salter, **kwargs)

elif Algos.randy in aid:
kwargs = aid[Algos.randy]
elif keeping.Algos.randy in aid:
kwargs = aid[keeping.Algos.randy]
return RandyKeeper(salter=self.salter, transferable=pre.transferable, **kwargs)

elif Algos.group in aid:
kwargs = aid[Algos.group]
elif keeping.Algos.group in aid:
kwargs = aid[keeping.Algos.group]
return GroupKeeper(mgr=self, **kwargs)


Expand All @@ -70,13 +70,13 @@ class BaseKeeper:
@property
def algo(self):
if isinstance(self, SaltyKeeper):
return Algos.salty
return keeping.Algos.salty
elif isinstance(self, RandyKeeper):
return Algos.randy
return keeping.Algos.randy
elif isinstance(self, GroupKeeper):
return Algos.group
return keeping.Algos.group
else:
return Algos.extern
return keeping.Algos.extern

@staticmethod
def __sign__(ser, signers, indexed=False, indices=None, ondices=None):
Expand Down Expand Up @@ -174,17 +174,17 @@ def __init__(self, salter, pidx, kidx=0, tier=Tiers.low, transferable=False, ste
# sxlt is encrypted salt for this AID or None if incepting
if bran is not None:
bran = coring.MtrDex.Salt_128 + 'A' + bran[:21]
self.creator = SaltyCreator(salt=bran, stem=stem, tier=tier)
self.creator = keeping.SaltyCreator(salt=bran, stem=stem, tier=tier)
self.sxlt = self.encrypter.encrypt(self.creator.salt).qb64

elif sxlt is None:
self.creator = SaltyCreator(stem=stem, tier=tier)
self.creator = keeping.SaltyCreator(stem=stem, tier=tier)
self.sxlt = self.encrypter.encrypt(self.creator.salt).qb64

else:
self.sxlt = sxlt
ciph = coring.Cipher(qb64=self.sxlt)
self.creator = SaltyCreator(self.decrypter.decrypt(cipher=ciph).qb64, stem=stem, tier=tier)
self.creator = keeping.SaltyCreator(self.decrypter.decrypt(cipher=ciph).qb64, stem=stem, tier=tier)

def params(self):
""" Get AID parameters to store externally """
Expand Down Expand Up @@ -290,7 +290,7 @@ def __init__(self, salter, code=MtrDex.Ed25519_Seed, count=1, icodes=None, trans
self.ncodes = ncodes
self.dcode = dcode

self.creator = RandyCreator()
self.creator = keeping.RandyCreator()

def params(self):
return dict(
Expand All @@ -310,6 +310,7 @@ def incept(self, transferable):
self.nxts = [self.encrypter.encrypt(matter=signer).qb64 for signer in nsigners]
digers = [coring.Diger(ser=nsigner.verfer.qb64b, code=self.dcode).qb64 for nsigner in nsigners]
return verfers, digers
return verfers, digers

def rotate(self, ncodes, transferable, **_):
self.transferable = transferable
Expand Down
Loading

0 comments on commit 5c66777

Please sign in to comment.