-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add local test signer and log testing
Signed-off-by: pstlouis <[email protected]>
- Loading branch information
1 parent
92a7229
commit 2af5410
Showing
5 changed files
with
83 additions
and
41 deletions.
There are no files selected for viewing
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,29 @@ | ||
from hashlib import sha256 | ||
import canonicaljson | ||
from multiformats import multibase | ||
from aries_askar import Key, KeyAlg | ||
from aries_askar.bindings import LocalKeyHandle | ||
from tests.fixtures import TEST_SEED, TEST_PROOF_OPTIONS | ||
|
||
def sign(document, options=TEST_PROOF_OPTIONS): | ||
key = Key(LocalKeyHandle()).from_seed(KeyAlg.ED25519, TEST_SEED) | ||
pub_key_multi = multibase.encode( | ||
bytes.fromhex( | ||
f"ed01{key.get_public_bytes().hex()}" | ||
), | ||
"base58btc", | ||
) | ||
options['verificationMethod'] = f'did:key:{pub_key_multi}#{pub_key_multi}' | ||
|
||
hash_data = ( | ||
sha256(canonicaljson.encode_canonical_json(options)).digest() | ||
+ sha256(canonicaljson.encode_canonical_json(document)).digest() | ||
) | ||
|
||
proof = options.copy() | ||
proof["proofValue"] = multibase.encode( | ||
key.sign_message(hash_data), "base58btc" | ||
) | ||
|
||
return document | {'proof': proof} | ||
|
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