From 6d5350d997f385657c0945418d4491a98f68f6e0 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 1 May 2024 07:43:19 -0600 Subject: [PATCH] fixed typo in new count code table and fixed related code and tests. wrong code for list. --- src/keri/core/counting.py | 4 +- src/keri/core/streaming.py | 20 ++-- tests/core/test_counting.py | 4 +- tests/core/test_serdering.py | 121 ++++++++++--------- tests/core/test_streaming.py | 224 ++++++++++++++++++++++------------- 5 files changed, 217 insertions(+), 156 deletions(-) diff --git a/src/keri/core/counting.py b/src/keri/core/counting.py index 9dee9fe14..cd14e01cd 100644 --- a/src/keri/core/counting.py +++ b/src/keri/core/counting.py @@ -102,8 +102,8 @@ class CounterCodex_2_0(MapDom): BigMapMessageBodyGroup: str = '-0G' # Big Field Map Message Body Group (Universal). GenericMapGroup: str = '-H' # Generic Field Map Group (Universal). BigGenericMapGroup: str = '-0H' # Big Generic Field Map Group (Universal). - GenericListGroup: str = '-L' # Generic List Group (Universal). - BigGenericListGroup: str = '-0L' # Big Generic List Group (Universal). + GenericListGroup: str = '-I' # Generic List Group (Universal). + BigGenericListGroup: str = '-0I' # Big Generic List Group (Universal). ControllerIdxSigs: str = '-J' # Controller Indexed Signature(s) of qb64. BigControllerIdxSigs: str = '-0J' # Big Controller Indexed Signature(s) of qb64. WitnessIdxSigs: str = '-K' # Witness Indexed Signature(s) of qb64. diff --git a/src/keri/core/streaming.py b/src/keri/core/streaming.py index 878a76ecc..617a74d21 100644 --- a/src/keri/core/streaming.py +++ b/src/keri/core/streaming.py @@ -304,19 +304,21 @@ def denot(ams): """De-annotate CESR stream Returns: - deannotation (bytes): deannotation of input annotated CESR stream + dms (bytes): deannotation of input annotated CESR message stream Parameters: ams (str): CESR annotated message stream text """ - - oms = bytearray() - - - - - return bytes(oms) - + dms = bytearray() # deannotated message stream + lines = ams.splitlines() + for line in lines: + line = line.strip() + front, sep, back = line.partition('#') # finde comment if any + front = front.strip() # non-commented portion strip white space + if front: + dms.extend(front.encode()) + + return bytes(dms) class Streamer: diff --git a/tests/core/test_counting.py b/tests/core/test_counting.py index bec518824..7887a610f 100644 --- a/tests/core/test_counting.py +++ b/tests/core/test_counting.py @@ -98,8 +98,8 @@ def test_codexes_tags(): 'BigMapMessageBodyGroup': '-0G', 'GenericMapGroup': '-H', 'BigGenericMapGroup': '-0H', - 'GenericListGroup': '-L', - 'BigGenericListGroup': '-0L', + 'GenericListGroup': '-I', + 'BigGenericListGroup': '-0I', 'ControllerIdxSigs': '-J', 'BigControllerIdxSigs': '-0J', 'WitnessIdxSigs': '-K', diff --git a/tests/core/test_serdering.py b/tests/core/test_serdering.py index 6cdddfc31..5ca21c30c 100644 --- a/tests/core/test_serdering.py +++ b/tests/core/test_serdering.py @@ -2698,7 +2698,7 @@ def test_cesr_native_dumps(): { 'v': 'KERICAACESRAAAA.', 't': 'icp', - 'd': 'EO6lMLcTbUhdpbQVXCh78MShuT_69th6tiZhEbAfPCj4', + 'd': 'EEx4oxGYbNrd6nZsdGu2KdN4MSDGD5IWS7hXjST7r8ew', 'i': 'DG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQ', 's': '0', 'kt': '1', @@ -2711,9 +2711,10 @@ def test_cesr_native_dumps(): 'a': [] } - assert serder.raw == (b'-FAtYKERICAAXicpEO6lMLcTbUhdpbQVXCh78MShuT_69th6tiZhEbAfPCj4DG9X' - b'hvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAAMAAB-LALDG9XhvcVryHj' - b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAA-LAAMAAA-LAA-LAA-LAA') + + assert serder.raw == (b'-FAtYKERICAAXicpEEx4oxGYbNrd6nZsdGu2KdN4MSDGD5IWS7hXjST7r8ewDG9X' + b'hvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAAMAAB-IALDG9XhvcVryHj' + b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAA-IAAMAAA-IAA-IAA-IAA') assert len(serder.raw) == serder.size == 184 sizeh = serder.raw[2:4] assert sizeh == b"At" @@ -2779,7 +2780,7 @@ def test_cesr_native_dumps(): kind=kering.Serials.cesr) pre = serder.pre - assert pre == 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6' + assert pre == 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi' said = serder.said assert said == pre @@ -2787,8 +2788,8 @@ def test_cesr_native_dumps(): { 'v': 'KERICAACESRAAAA.', 't': 'icp', - 'd': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6', - 'i': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6', + 'd': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi', + 'i': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi', 's': '0', 'kt': '2', 'k': @@ -2831,15 +2832,15 @@ def test_cesr_native_dumps(): ] } - assert serder.raw == (b'-FDCYKERICAAXicpEMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6EMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAAAMAAC-LAhDG9XhvcVryHj' + assert serder.raw == (b'-FDCYKERICAAXicpEKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiEKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAAAMAAC-IAhDG9XhvcVryHj' b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQDK58m521o6nwgcluK8Mu2ULvScXM9kB1' - b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-LAh' + b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-IAh' b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_EMrowWRk6u1imR32ZNHn' b'TPUtc7uSAvrchIPN3I8S6vUGEEbufBpvagqe9kijKISOoQPYFEOpy22CZJGJqQZp' - b'ZEyPMAAD-LAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' + b'ZEyPMAAD-IAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' b'o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnBMOmBoddcrRHShSajb4d60S6RK34' - b'gXZ2WYbr3AiPY1M0-LABXDND-LA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' + b'gXZ2WYbr3AiPY1M0-IABXDND-IA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' b'4fBJre3NGwTQMAAAEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAABEMrowWRk6u1imR32ZNHn' b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMAAPEEbufBpvagqe9kijKISOoQPYFEOpy22C' @@ -2852,21 +2853,22 @@ def test_cesr_native_dumps(): rawqb64 = serder._dumps() # default is it dumps self.sad assert rawqb64 == serder.raw - assert rawqb64 == (b'-FDCYKERICAAXicpEMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6EMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAAAMAAC-LAhDG9XhvcVryHj' + assert rawqb64 == (b'-FDCYKERICAAXicpEKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiEKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAAAMAAC-IAhDG9XhvcVryHj' b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQDK58m521o6nwgcluK8Mu2ULvScXM9kB1' - b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-LAh' + b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-IAh' b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_EMrowWRk6u1imR32ZNHn' b'TPUtc7uSAvrchIPN3I8S6vUGEEbufBpvagqe9kijKISOoQPYFEOpy22CZJGJqQZp' - b'ZEyPMAAD-LAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' + b'ZEyPMAAD-IAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' b'o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnBMOmBoddcrRHShSajb4d60S6RK34' - b'gXZ2WYbr3AiPY1M0-LABXDND-LA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' + b'gXZ2WYbr3AiPY1M0-IABXDND-IA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' b'4fBJre3NGwTQMAAAEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAABEMrowWRk6u1imR32ZNHn' b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMAAPEEbufBpvagqe9kijKISOoQPYFEOpy22C' b'ZJGJqQZpZEyP') + assert len(rawqb64) == 780 rawqb2 = decodeB64(rawqb64) @@ -2931,16 +2933,16 @@ def test_cesr_native_dumps(): kind=kering.Serials.cesr) said = serder.said - assert said == 'EHeLJVa4LLNRRYVkLQsXHIDvllcmhDaahe5a_oMvXKeP' + assert said == 'EHXLwMJsZLyG643VW8Do1cqqiMxD_E65Mc3Z1we6vTaR' assert serder.sad == \ { 'v': 'KERICAACESRAAAA.', 't': 'ixn', - 'd': 'EHeLJVa4LLNRRYVkLQsXHIDvllcmhDaahe5a_oMvXKeP', - 'i': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6', + 'd': 'EHXLwMJsZLyG643VW8Do1cqqiMxD_E65Mc3Z1we6vTaR', + 'i': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi', 's': '1', - 'p': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6', + 'p': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi', 'a': [ { @@ -2965,9 +2967,9 @@ def test_cesr_native_dumps(): ] } - assert serder.raw == (b'-FB6YKERICAAXixnEHeLJVa4LLNRRYVkLQsXHIDvllcmhDaahe5a_oMvXKePEMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAABEMEvSn0o6Iv2-3gInTDM' - b'MDTV0qQEfooM-yTzkj6Kynn6-LBU-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' + assert serder.raw == (b'-FB6YKERICAAXixnEHXLwMJsZLyG643VW8Do1cqqiMxD_E65Mc3Z1we6vTaREKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAABEKIuA20I5q6IrgAHrX-g' + b'kAt4Og17Ebu5CDBrRvh8RToi-IBU-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' b'4fBJre3NGwTQMAACEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAAiEMrowWRk6u1imR32ZNHn' b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMABDEEbufBpvagqe9kijKISOoQPYFEOpy22C' @@ -3025,20 +3027,23 @@ def test_cesr_native_dumps(): kind=kering.Serials.cesr) said = serder.said - assert said == 'EDtBwgOB0uGrSMBJhOmnkRoCupjg-4sJApvOx04ujhKs' + assert said == 'EDHlTlOcSXZInbTE4iXzb1iFjZcxJZn3C3UXhckb3uQm' assert serder.sad == \ { 'v': 'KERICAACESRAAAA.', 't': 'rot', - 'd': 'EDtBwgOB0uGrSMBJhOmnkRoCupjg-4sJApvOx04ujhKs', - 'i': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6', + 'd': 'EDHlTlOcSXZInbTE4iXzb1iFjZcxJZn3C3UXhckb3uQm', + 'i': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi', 's': '2', - 'p': 'EHeLJVa4LLNRRYVkLQsXHIDvllcmhDaahe5a_oMvXKeP', + 'p': 'EHXLwMJsZLyG643VW8Do1cqqiMxD_E65Mc3Z1we6vTaR', 'kt': '2', - 'k': ['DH7p14xo09rob5cEupmo8jSDi35ZOGt1k4t2nm1C1A68', - 'DIAdqJzLWEwQbhXEMOFjvFVZ7oMCJP4XXDP_ILaTEBAQ', - 'DKhYdMBeP6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMER'], + 'k': + [ + 'DH7p14xo09rob5cEupmo8jSDi35ZOGt1k4t2nm1C1A68', + 'DIAdqJzLWEwQbhXEMOFjvFVZ7oMCJP4XXDP_ILaTEBAQ', + 'DKhYdMBeP6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMER' + ], 'nt': '2', 'n': [ @@ -3054,15 +3059,15 @@ def test_cesr_native_dumps(): } - assert serder.raw == (b'-FCGYKERICAAXrotEDtBwgOB0uGrSMBJhOmnkRoCupjg-4sJApvOx04ujhKsEMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAACEHeLJVa4LLNRRYVkLQsX' - b'HIDvllcmhDaahe5a_oMvXKePMAAC-LAhDH7p14xo09rob5cEupmo8jSDi35ZOGt1' + assert serder.raw == (b'-FCGYKERICAAXrotEDHlTlOcSXZInbTE4iXzb1iFjZcxJZn3C3UXhckb3uQmEKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAACEHXLwMJsZLyG643VW8Do' + b'1cqqiMxD_E65Mc3Z1we6vTaRMAAC-IAhDH7p14xo09rob5cEupmo8jSDi35ZOGt1' b'k4t2nm1C1A68DIAdqJzLWEwQbhXEMOFjvFVZ7oMCJP4XXDP_ILaTEBAQDKhYdMBe' - b'P6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMERMAAC-LAhEBvDSpcj3y0y9W2-1GzY' + b'P6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMERMAAC-IAhEBvDSpcj3y0y9W2-1GzY' b'J85KEkDIPxu4y_TxAK49k7ciEEb97lh2oOd_yM3meBaRX5xSs8mIeBoPdhOTgVkd' - b'31jbECQTrhKHgrOXJS4kdvifvOqoJ7RjfJSsN3nshclYStgaMAAD-LALBG9XhvcV' - b'ryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQ-LALBH7p14xo09rob5cEupmo8jSD' - b'i35ZOGt1k4t2nm1C1A68-LAA-LAA') + b'31jbECQTrhKHgrOXJS4kdvifvOqoJ7RjfJSsN3nshclYStgaMAAD-IALBG9XhvcV' + b'ryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQ-IALBH7p14xo09rob5cEupmo8jSD' + b'i35ZOGt1k4t2nm1C1A68-IAA-IAA') assert len(serder.raw) == serder.size == 540 sizeh = serder.raw[2:4] @@ -3138,7 +3143,7 @@ def test_cesr_native_dumps(): kind=kering.Serials.cesr) pre = serder.pre - assert pre == 'ECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8T' + assert pre == 'EKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjC' said = serder.said assert said == pre @@ -3146,8 +3151,8 @@ def test_cesr_native_dumps(): { 'v': 'KERICAACESRAAAA.', 't': 'dip', - 'd': 'ECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8T', - 'i': 'ECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8T', + 'd': 'EKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjC', + 'i': 'EKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjC', 's': '0', 'kt': ['1/2', '1/2', '1/2'], 'k': @@ -3192,24 +3197,24 @@ def test_cesr_native_dumps(): 'd': 'EKFoJ9Conb37zSn8zHLKP3YwHbeQiD1D9Qx0MagJ44DS' } ], - 'di': 'EMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6' + 'di': 'EKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi' } - assert serder.raw == (b'-FDeYKERICAAXdipECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TECQs' - b'0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TMAAA4AADA1s2c1s2c1s2-LAh' + assert serder.raw == (b'-FDeYKERICAAXdipEKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCEKCF' + b'Mk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCMAAA4AADA1s2c1s2c1s2-IAh' b'DIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uVDN7WiKyjLLBTK92xayCu' b'ddZsBuwPmD2BKrl83h1xEUtiDOE5jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl' - b'5nfY4AADA1s2c1s2c1s2-LAhEKFoJ9Conb37zSn8zHLKP3YwHbeQiD1D9Qx0MagJ' + b'5nfY4AADA1s2c1s2c1s2-IAhEKFoJ9Conb37zSn8zHLKP3YwHbeQiD1D9Qx0MagJ' b'44DSEC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZEHgewy_ymPxtSFwu' - b'X2KaI_mPmoIUkxClviX3f-M38kCDMAAD-LAhBIR8GACw4z2GC5_XoReU4DMKbqi6' + b'X2KaI_mPmoIUkxClviX3f-M38kCDMAAD-IAhBIR8GACw4z2GC5_XoReU4DMKbqi6' b'-EdbgDZUAobRb8uVBN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiBOE5' - b'jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl5nfY-LAA-LBI-RAuDIR8GACw4z2G' + b'jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl5nfY-IAA-IBI-RAuDIR8GACw4z2G' b'C5_XoReU4DMKbqi6-EdbgDZUAobRb8uVMAADEKFoJ9Conb37zSn8zHLKP3YwHbeQ' b'iD1D9Qx0MagJ44DSDN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiMAAE' b'EC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZ-QAYMAAVEHgewy_ymPxt' b'SFwuX2KaI_mPmoIUkxClviX3f-M38kCDMD4SEKFoJ9Conb37zSn8zHLKP3YwHbeQ' - b'iD1D9Qx0MagJ44DSEMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6') + b'iD1D9Qx0MagJ44DSEKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi') assert len(serder.raw) == serder.size == 892 sizeh = serder.raw[2:4] @@ -3264,16 +3269,16 @@ def test_cesr_native_dumps(): kind=kering.Serials.cesr) said = serder.said - assert said == 'EKwDKG0L9pAMbzV2e31-I5ObiEfkptfs8VqXYiHGCL1v' + assert said == 'EKfRY6YrpqUU0HyKWMGvNtzuZCaeMcIBrdKzHAqpmtTA' assert serder.sad == \ { 'v': 'KERICAACESRAAAA.', 't': 'drt', - 'd': 'EKwDKG0L9pAMbzV2e31-I5ObiEfkptfs8VqXYiHGCL1v', - 'i': 'ECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8T', + 'd': 'EKfRY6YrpqUU0HyKWMGvNtzuZCaeMcIBrdKzHAqpmtTA', + 'i': 'EKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjC', 's': '1', - 'p': 'ECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8T', + 'p': 'EKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjC', 'kt': '1', 'k': ['DJ0pLe3f2zGus0Va1dqWAnukWdZHGNWlK9NciJop9N4f'], 'nt': '1', @@ -3285,13 +3290,13 @@ def test_cesr_native_dumps(): 'a': {} } + assert serder.raw == (b'-FBaYKERICAAXdrtEKfRY6YrpqUU0HyKWMGvNtzuZCaeMcIBrdKzHAqpmtTAEKCF' + b'Mk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCMAABEKCFMk4nmn3t8jdC1pB_' + b'-Qmp7w8EROvdYaxgru7vHOjCMAAB-IALDJ0pLe3f2zGus0Va1dqWAnukWdZHGNWl' + b'K9NciJop9N4fMAAB-IALENX_LTL97uOSOkA1PEzam9vtmCLPprnbcpi71wXpmhFF' + b'MAAD-IALBIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uV-IALBJ0pLe3f' + b'2zGus0Va1dqWAnukWdZHGNWlK9NciJop9N4f-IAA-IAA') - assert serder.raw == (b'-FBaYKERICAAXdrtEKwDKG0L9pAMbzV2e31-I5ObiEfkptfs8VqXYiHGCL1vECQs' - b'0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TMAABECQs0t3_GL7-B3q4kMU-' - b'qLeRCugTFjrxR15mxUwYWp8TMAAB-LALDJ0pLe3f2zGus0Va1dqWAnukWdZHGNWl' - b'K9NciJop9N4fMAAB-LALENX_LTL97uOSOkA1PEzam9vtmCLPprnbcpi71wXpmhFF' - b'MAAD-LALBIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uV-LALBJ0pLe3f' - b'2zGus0Va1dqWAnukWdZHGNWlK9NciJop9N4f-LAA-LAA') assert len(serder.raw) == serder.size == 364 sizeh = serder.raw[2:4] diff --git a/tests/core/test_streaming.py b/tests/core/test_streaming.py index 21e7d12aa..60b3ecc47 100644 --- a/tests/core/test_streaming.py +++ b/tests/core/test_streaming.py @@ -3,7 +3,7 @@ tests.core.test_streaming module """ - +from binascii import unhexlify import pytest @@ -12,7 +12,8 @@ from keri.help import helping -from keri.core import (Matter, ) +from keri.core import (Matter,) +from keri.core.coring import dumps from keri.core import streaming @@ -30,107 +31,160 @@ def test_annot(): """Test annot function Annotate""" # simple Inception - ims = bytearray( - b'-FAtYKERICAAXicpEO6lMLcTbUhdpbQVXCh78MShuT_69th6tiZhEbAfPCj4DG9X' - b'hvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAAMAAB-LALDG9XhvcVryHj' - b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAA-LAAMAAA-LAA-LAA-LAA') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FAtYKERICAAXicpEEx4oxGYbNrd6nZsdGu2KdN4MSDGD5IWS7hXjST7r8ewDG9X' + b'hvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAAMAAB-IALDG9XhvcVryHj' + b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQMAAA-IAAMAAA-IAA-IAA-IAA') + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims # complex inception - ims = bytearray( - b'-FDCYKERICAAXicpEMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6EMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAAAMAAC-LAhDG9XhvcVryHj' - b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQDK58m521o6nwgcluK8Mu2ULvScXM9kB1' - b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-LAh' - b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_EMrowWRk6u1imR32ZNHn' - b'TPUtc7uSAvrchIPN3I8S6vUGEEbufBpvagqe9kijKISOoQPYFEOpy22CZJGJqQZp' - b'ZEyPMAAD-LAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' - b'o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnBMOmBoddcrRHShSajb4d60S6RK34' - b'gXZ2WYbr3AiPY1M0-LABXDND-LA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' - b'4fBJre3NGwTQMAAAEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' - b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAABEMrowWRk6u1imR32ZNHn' - b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMAAPEEbufBpvagqe9kijKISOoQPYFEOpy22C' - b'ZJGJqQZpZEyP') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FDCYKERICAAXicpEKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiEKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAAAMAAC-IAhDG9XhvcVryHj' + b'oIGcj5nK4sAE3oslQHWi4fBJre3NGwTQDK58m521o6nwgcluK8Mu2ULvScXM9kB1' + b'bSORrxNSS9cnDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MAAC-IAh' + b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_EMrowWRk6u1imR32ZNHn' + b'TPUtc7uSAvrchIPN3I8S6vUGEEbufBpvagqe9kijKISOoQPYFEOpy22CZJGJqQZp' + b'ZEyPMAAD-IAhBG9XhvcVryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQBK58m521' + b'o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnBMOmBoddcrRHShSajb4d60S6RK34' + b'gXZ2WYbr3AiPY1M0-IABXDND-IA8-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' + b'4fBJre3NGwTQMAAAEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' + b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAABEMrowWRk6u1imR32ZNHn' + b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMAAPEEbufBpvagqe9kijKISOoQPYFEOpy22C' + b'ZJGJqQZpZEyP') + + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims # interaction - ims = bytearray( - b'-FB6YKERICAAXixnEHeLJVa4LLNRRYVkLQsXHIDvllcmhDaahe5a_oMvXKePEMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAABEMEvSn0o6Iv2-3gInTDM' - b'MDTV0qQEfooM-yTzkj6Kynn6-LBU-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' - b'4fBJre3NGwTQMAACEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' - b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAAiEMrowWRk6u1imR32ZNHn' - b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMABDEEbufBpvagqe9kijKISOoQPYFEOpy22C' - b'ZJGJqQZpZEyP-RAXDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MACA' - b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FB6YKERICAAXixnEHXLwMJsZLyG643VW8Do1cqqiMxD_E65Mc3Z1we6vTaREKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAABEKIuA20I5q6IrgAHrX-g' + b'kAt4Og17Ebu5CDBrRvh8RToi-IBU-RAuDG9XhvcVryHjoIGcj5nK4sAE3oslQHWi' + b'4fBJre3NGwTQMAACEB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_DK58' + b'm521o6nwgcluK8Mu2ULvScXM9kB1bSORrxNSS9cnMAAiEMrowWRk6u1imR32ZNHn' + b'TPUtc7uSAvrchIPN3I8S6vUG-QAMMABDEEbufBpvagqe9kijKISOoQPYFEOpy22C' + b'ZJGJqQZpZEyP-RAXDMOmBoddcrRHShSajb4d60S6RK34gXZ2WYbr3AiPY1M0MACA' + b'EB9O4V-zUteZJJFubu1h0xMtzt0wuGpLMVj1sKVsElA_') + + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims # Rotation - ims = bytearray( - b'-FCGYKERICAAXrotEDtBwgOB0uGrSMBJhOmnkRoCupjg-4sJApvOx04ujhKsEMEv' - b'Sn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6MAACEHeLJVa4LLNRRYVkLQsX' - b'HIDvllcmhDaahe5a_oMvXKePMAAC-LAhDH7p14xo09rob5cEupmo8jSDi35ZOGt1' - b'k4t2nm1C1A68DIAdqJzLWEwQbhXEMOFjvFVZ7oMCJP4XXDP_ILaTEBAQDKhYdMBe' - b'P6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMERMAAC-LAhEBvDSpcj3y0y9W2-1GzY' - b'J85KEkDIPxu4y_TxAK49k7ciEEb97lh2oOd_yM3meBaRX5xSs8mIeBoPdhOTgVkd' - b'31jbECQTrhKHgrOXJS4kdvifvOqoJ7RjfJSsN3nshclYStgaMAAD-LALBG9XhvcV' - b'ryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQ-LALBH7p14xo09rob5cEupmo8jSD' - b'i35ZOGt1k4t2nm1C1A68-LAA-LAA') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FCGYKERICAAXrotEDHlTlOcSXZInbTE4iXzb1iFjZcxJZn3C3UXhckb3uQmEKIu' + b'A20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToiMAACEHXLwMJsZLyG643VW8Do' + b'1cqqiMxD_E65Mc3Z1we6vTaRMAAC-IAhDH7p14xo09rob5cEupmo8jSDi35ZOGt1' + b'k4t2nm1C1A68DIAdqJzLWEwQbhXEMOFjvFVZ7oMCJP4XXDP_ILaTEBAQDKhYdMBe' + b'P6FoH3ajGJTf_4fH229rm_lTZXfYkfwGTMERMAAC-IAhEBvDSpcj3y0y9W2-1GzY' + b'J85KEkDIPxu4y_TxAK49k7ciEEb97lh2oOd_yM3meBaRX5xSs8mIeBoPdhOTgVkd' + b'31jbECQTrhKHgrOXJS4kdvifvOqoJ7RjfJSsN3nshclYStgaMAAD-IALBG9XhvcV' + b'ryHjoIGcj5nK4sAE3oslQHWi4fBJre3NGwTQ-IALBH7p14xo09rob5cEupmo8jSD' + b'i35ZOGt1k4t2nm1C1A68-IAA-IAA') + + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims + # Delegated Inception - ims = bytearray( - b'-FDeYKERICAAXdipECQs0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TECQs' - b'0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TMAAA4AADA1s2c1s2c1s2-LAh' - b'DIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uVDN7WiKyjLLBTK92xayCu' - b'ddZsBuwPmD2BKrl83h1xEUtiDOE5jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl' - b'5nfY4AADA1s2c1s2c1s2-LAhEKFoJ9Conb37zSn8zHLKP3YwHbeQiD1D9Qx0MagJ' - b'44DSEC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZEHgewy_ymPxtSFwu' - b'X2KaI_mPmoIUkxClviX3f-M38kCDMAAD-LAhBIR8GACw4z2GC5_XoReU4DMKbqi6' - b'-EdbgDZUAobRb8uVBN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiBOE5' - b'jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl5nfY-LAA-LBI-RAuDIR8GACw4z2G' - b'C5_XoReU4DMKbqi6-EdbgDZUAobRb8uVMAADEKFoJ9Conb37zSn8zHLKP3YwHbeQ' - b'iD1D9Qx0MagJ44DSDN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiMAAE' - b'EC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZ-QAYMAAVEHgewy_ymPxt' - b'SFwuX2KaI_mPmoIUkxClviX3f-M38kCDMD4SEKFoJ9Conb37zSn8zHLKP3YwHbeQ' - b'iD1D9Qx0MagJ44DSEMEvSn0o6Iv2-3gInTDMMDTV0qQEfooM-yTzkj6Kynn6') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FDeYKERICAAXdipEKCFMk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCEKCF' + b'Mk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCMAAA4AADA1s2c1s2c1s2-IAh' + b'DIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uVDN7WiKyjLLBTK92xayCu' + b'ddZsBuwPmD2BKrl83h1xEUtiDOE5jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl' + b'5nfY4AADA1s2c1s2c1s2-IAhEKFoJ9Conb37zSn8zHLKP3YwHbeQiD1D9Qx0MagJ' + b'44DSEC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZEHgewy_ymPxtSFwu' + b'X2KaI_mPmoIUkxClviX3f-M38kCDMAAD-IAhBIR8GACw4z2GC5_XoReU4DMKbqi6' + b'-EdbgDZUAobRb8uVBN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiBOE5' + b'jmI9ktNSAddEke1rH2cGMDq4uYmyagDkAzHl5nfY-IAA-IBI-RAuDIR8GACw4z2G' + b'C5_XoReU4DMKbqi6-EdbgDZUAobRb8uVMAADEKFoJ9Conb37zSn8zHLKP3YwHbeQ' + b'iD1D9Qx0MagJ44DSDN7WiKyjLLBTK92xayCuddZsBuwPmD2BKrl83h1xEUtiMAAE' + b'EC7sCVf_rYJ_khIj7UdlzrtemP31TuHTPUsGjvWni8GZ-QAYMAAVEHgewy_ymPxt' + b'SFwuX2KaI_mPmoIUkxClviX3f-M38kCDMD4SEKFoJ9Conb37zSn8zHLKP3YwHbeQ' + b'iD1D9Qx0MagJ44DSEKIuA20I5q6IrgAHrX-gkAt4Og17Ebu5CDBrRvh8RToi') + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims + # Delegated Rotatation - ims = bytearray( - b'-FBaYKERICAAXdrtEKwDKG0L9pAMbzV2e31-I5ObiEfkptfs8VqXYiHGCL1vECQs' - b'0t3_GL7-B3q4kMU-qLeRCugTFjrxR15mxUwYWp8TMAABECQs0t3_GL7-B3q4kMU-' - b'qLeRCugTFjrxR15mxUwYWp8TMAAB-LALDJ0pLe3f2zGus0Va1dqWAnukWdZHGNWl' - b'K9NciJop9N4fMAAB-LALENX_LTL97uOSOkA1PEzam9vtmCLPprnbcpi71wXpmhFF' - b'MAAD-LALBIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uV-LALBJ0pLe3f' - b'2zGus0Va1dqWAnukWdZHGNWlK9NciJop9N4f-LAA-LAA') - - print(f"incoming = \n{bytes(ims)}\n") - ams = annot(ims) # annotated message dream - assert not ims + ims = (b'-FBaYKERICAAXdrtEKfRY6YrpqUU0HyKWMGvNtzuZCaeMcIBrdKzHAqpmtTAEKCF' + b'Mk4nmn3t8jdC1pB_-Qmp7w8EROvdYaxgru7vHOjCMAABEKCFMk4nmn3t8jdC1pB_' + b'-Qmp7w8EROvdYaxgru7vHOjCMAAB-IALDJ0pLe3f2zGus0Va1dqWAnukWdZHGNWl' + b'K9NciJop9N4fMAAB-IALENX_LTL97uOSOkA1PEzam9vtmCLPprnbcpi71wXpmhFF' + b'MAAD-IALBIR8GACw4z2GC5_XoReU4DMKbqi6-EdbgDZUAobRb8uV-IALBJ0pLe3f' + b'2zGus0Va1dqWAnukWdZHGNWlK9NciJop9N4f-IAA-IAA') + + + bms = bytearray(ims) # make copy + print(f"incoming = \n{ims}\n") + ams = annot(bms) # annotated message dream + assert not bms print(f"annotated = \n{ams}\n") + dms = denot(ams) + assert dms == ims + + # JWK https://connect2id.com/products/nimbus-jose-jwt/examples/jwk-generation#okp + # ED25519 EDDSA + djwk = { + "kty" : "OKP", + "crv" : "Ed25519", + "x" : "11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo", + "d" : "nWGxne_9WmC6hEr0kuwsxERJxWl7MmkZcDusAxyuf2A", + "use" : "sig", + "kid" : "FdFYFzERwC2uCBB46pZQi4GG85LujR8obt-KWRBICVQ" + } + + jwk = dumps(djwk, kering.Serials.json) + assert jwk == (b'{"kty":"OKP","crv":"Ed25519","x":"11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHUR' + b'o","d":"nWGxne_9WmC6hEr0kuwsxERJxWl7MmkZcDusAxyuf2A","use":"sig","kid":"FdFY' + b'FzERwC2uCBB46pZQi4GG85LujR8obt-KWRBICVQ"}') + + assert len(jwk) == 193 + assert 193 - 44 == 149 + + # ECDSA Example + # https://pycose.readthedocs.io/en/latest/pycose/keys/ec2.html + + ckat = { + 'KTY': 'EC2', + 'CURVE': 'P_256', + 'ALG': 'ES256', + 'D': unhexlify(b'57c92077664146e876760c9520d054aa93c3afb04e306705db6090308507b4d3') + } + + + ck = (b'\xa6\x01\x02\x03&\x01!X\xba\xc5\xb1\x1c\xad\x8f\x99\xf9\xc7+\x05\xcfK\x9e&\xd2D\xdc\x18\x9ftR(%Z!\x9a\x86\xd6\xa0\x9e\xffX\x13\x8b\xf8-\xc1\xb6\xd5b\xbe\x0f\xa5J\xb7\x80J:d\xb6\xd7,\xcf\xedko\xb6\xed(\xbb\xfc\x11~#XW\xc9 wfAF\xe8vv\x0c\x95\xd0T\xaa\x93\xc3\xaf\xb0N0g\x05\xdb`\x900\x85\x07\xb4\xd3') + assert len(ck) == 105 + assert 105 - 36 == 69 +