forked from WebOfTrust/keripy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'wot/main'
- Loading branch information
Showing
70 changed files
with
338 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
keri.kli.commands module | ||
""" | ||
import argparse | ||
|
||
from hio.base import doing | ||
|
||
from keri import kering | ||
from keri.app.cli.common import existing | ||
from keri.core import indexing, coring, MtrDex | ||
|
||
parser = argparse.ArgumentParser(description='Decrypt arbitrary data for AIDs with Ed25519 public keys only') | ||
parser.set_defaults(handler=lambda args: handler(args)) | ||
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True) | ||
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore', | ||
required=False, default="") | ||
parser.add_argument('--alias', '-a', help='human readable alias for the new identifier prefix', required=True) | ||
parser.add_argument('--passcode', '-p', help='22 character encryption passcode for keystore (is not saved)', | ||
dest="bran", default=None) # passcode => bran | ||
parser.add_argument('--data', '-d', help='Encrypted data or file (starts with "@")', required=True) | ||
|
||
|
||
def handler(args): | ||
""" | ||
Verify signatures on arbitrary data | ||
Args: | ||
args(Namespace): arguments object from command line | ||
""" | ||
kwa = dict(args=args) | ||
return [doing.doify(decrypt, **kwa)] | ||
|
||
|
||
def decrypt(tymth, tock=0.0, **opts): | ||
""" Command line status handler | ||
""" | ||
_ = (yield tock) | ||
args = opts["args"] | ||
|
||
name = args.name | ||
alias = args.alias | ||
base = args.base | ||
bran = args.bran | ||
|
||
try: | ||
with existing.existingHab(name=name, alias=alias, base=base, bran=bran) as (_, hab): | ||
|
||
data = args.data | ||
if data.startswith("@"): | ||
f = open(data[1:], "r") | ||
data = f.read() | ||
else: | ||
data = data | ||
|
||
m = coring.Matter(qb64=data) | ||
d = coring.Matter(qb64=hab.decrypt(m.raw)) | ||
print(d.raw) | ||
|
||
except kering.ConfigurationError: | ||
print(f"prefix for {name} does not exist, incept must be run first", ) | ||
except FileNotFoundError: | ||
print("unable to open file", args.text[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.