refactor sign VCs
This commit is contained in:
parent
e91eaf1652
commit
a9cca75323
9
did.py
9
did.py
|
@ -57,7 +57,7 @@ def generate_keys():
|
||||||
# Generate an Ed25519 key pair
|
# Generate an Ed25519 key pair
|
||||||
key = jwk.JWK.generate(kty='OKP', crv='Ed25519')
|
key = jwk.JWK.generate(kty='OKP', crv='Ed25519')
|
||||||
key['kid'] = 'Generated'
|
key['kid'] = 'Generated'
|
||||||
return key.export()
|
return key.export_private(True)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -67,7 +67,8 @@ def main():
|
||||||
args=parser.parse_args()
|
args=parser.parse_args()
|
||||||
|
|
||||||
if args.new == 'keys':
|
if args.new == 'keys':
|
||||||
print(generate_keys())
|
keyspair = generate_keys()
|
||||||
|
print(json.dumps(keyspair))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not args.key_path and args.new == 'did':
|
if not args.key_path and args.new == 'did':
|
||||||
|
@ -76,8 +77,8 @@ def main():
|
||||||
|
|
||||||
if args.new == 'did':
|
if args.new == 'did':
|
||||||
key = key_read(args.key_path)
|
key = key_read(args.key_path)
|
||||||
keyspair = generate_did(key)
|
did = generate_did(key)
|
||||||
print(json.dumps(keyspair))
|
print(json.dumps(did))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
12
sign_vc.py
12
sign_vc.py
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
import argparse
|
||||||
from utils import now
|
from utils import now
|
||||||
from did import generate_keys, generate_did, get_signing_key
|
from did import generate_did, get_signing_key, key_read
|
||||||
from templates import credential_tmpl, proof_tmpl
|
from templates import credential_tmpl, proof_tmpl
|
||||||
from sign import sign_proof
|
from sign import sign_proof
|
||||||
|
|
||||||
|
@ -21,7 +22,12 @@ def sign(credential, key, issuer_did):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
key = generate_keys()
|
parser=argparse.ArgumentParser(description='Generates a new credential')
|
||||||
|
parser.add_argument("-k", "--key-path", required=True)
|
||||||
|
args=parser.parse_args()
|
||||||
|
|
||||||
|
if args.key_path:
|
||||||
|
key = key_read(args.key_path)
|
||||||
did = generate_did(key)
|
did = generate_did(key)
|
||||||
signing_key = get_signing_key(key)
|
signing_key = get_signing_key(key)
|
||||||
|
|
||||||
|
@ -34,6 +40,8 @@ def main():
|
||||||
|
|
||||||
print(json.dumps(vc, separators=(',', ':')))
|
print(json.dumps(vc, separators=(',', ':')))
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue