@@ -3265,126 +3265,30 @@ def _sha2_256(ser, raw):
3265
3265
3266
3266
class Prefixer (Matter ):
3267
3267
"""
3268
- Prefixer is Matter subclass for autonomic identifier prefix using
3269
- derivation as determined by code from ked
3268
+ Prefixer is Matter subclass for autonomic identifier AID prefix
3270
3269
3271
3270
Attributes:
3272
3271
3273
3272
Inherited Properties: (see Matter)
3274
- .pad is int number of pad chars given raw
3275
- .code is str derivation code to indicate cypher suite
3276
- .raw is bytes crypto material only without code
3277
- .index is int count of attached crypto material by context (receipts)
3278
- .qb64 is str in Base64 fully qualified with derivation code + crypto mat
3279
- .qb64b is bytes in Base64 fully qualified with derivation code + crypto mat
3280
- .qb2 is bytes in binary with derivation code + crypto material
3281
- .transferable is Boolean, True when transferable derivation code False otherwise
3282
3273
3283
3274
Properties:
3284
3275
3285
3276
Methods:
3286
- verify(): Verifies derivation of aid prefix from a ked
3287
3277
3288
3278
Hidden:
3289
- ._pad is method to compute .pad property
3290
- ._code is str value for .code property
3291
- ._raw is bytes value for .raw property
3292
- ._index is int value for .index property
3293
- ._infil is method to compute fully qualified Base64 from .raw and .code
3294
- ._exfil is method to extract .code and .raw from fully qualified Base64
3295
- """
3296
- Dummy = "#" # dummy spaceholder char for pre. Must not be a valid Base64 char
3297
-
3298
- def __init__ (self , raw = None , code = None , ked = None , allows = None , ** kwa ):
3299
- """
3300
- assign ._derive to derive aid prefix from ked
3301
- assign ._verify to verify derivation of aid prefix from ked
3302
3279
3303
- Default code is None to force EmptyMaterialError when only raw provided but
3304
- not code.
3280
+ """
3305
3281
3282
+ def __init__ (self , ** kwa ):
3283
+ """Checks for .code in PreDex so valid prefixive code
3306
3284
Inherited Parameters:
3307
- raw is bytes of unqualified crypto material usable for crypto operations
3308
- qb64b is bytes of fully qualified crypto material
3309
- qb64 is str or bytes of fully qualified crypto material
3310
- qb2 is bytes of fully qualified crypto material
3311
- code is str of derivation code
3312
- index is int of count of attached receipts for CryCntDex codes
3313
-
3314
- Parameters:
3315
- allows (list): allowed codes for prefix. When None then all supported
3316
- codes are allowed. This enables a particular use case to restrict
3317
- the codes allowed to a subset of all supported.
3285
+ See Matter
3318
3286
3319
3287
"""
3320
- super (Prefixer , self ).__init__ (raw = raw , code = code , ** kwa )
3288
+ super (Prefixer , self ).__init__ (** kwa )
3321
3289
if self .code not in PreDex :
3322
3290
raise InvalidCodeError (f"Invalid prefixer code = { self .code } ." )
3323
3291
3324
- #if self.code in [MtrDex.Ed25519N, MtrDex.ECDSA_256r1N, MtrDex.ECDSA_256k1N]:
3325
- #self._verify = self._verify_non_transferable
3326
- #elif self.code in [MtrDex.Ed25519, MtrDex.ECDSA_256r1, MtrDex.ECDSA_256k1]:
3327
- #self._verify = self._verify_transferable
3328
-
3329
-
3330
- def _verify_non_transferable (self , ked , pre , prefixed = False ):
3331
- """
3332
- Returns True if verified False otherwise
3333
- Verify derivation of fully qualified Base64 pre from inception iked dict
3334
-
3335
- Parameters:
3336
- ked is inception key event dict
3337
- pre is Base64 fully qualified prefix default to .qb64
3338
- """
3339
- try :
3340
- keys = ked ["k" ]
3341
- if len (keys ) != 1 :
3342
- return False
3343
-
3344
- if keys [0 ] != pre :
3345
- return False
3346
-
3347
- if prefixed and ked ["i" ] != pre :
3348
- return False
3349
-
3350
- if ked ["n" ]: # must be empty
3351
- return False
3352
-
3353
- except Exception as ex :
3354
- return False
3355
-
3356
- return True
3357
-
3358
-
3359
-
3360
- def _verify_transferable (self , ked , pre , prefixed = False ):
3361
- """
3362
- Returns True if verified False otherwise
3363
- Verify derivation of fully qualified Base64 prefix from
3364
- inception key event dict (ked)
3365
-
3366
- Parameters:
3367
- ked is inception key event dict
3368
- pre is Base64 fully qualified prefix default to .qb64
3369
- """
3370
- try :
3371
- keys = ked ["k" ]
3372
- if len (keys ) != 1 :
3373
- return False
3374
-
3375
- if keys [0 ] != pre :
3376
- return False
3377
-
3378
- if prefixed and ked ["i" ] != pre :
3379
- return False
3380
-
3381
- except Exception as ex :
3382
- return False
3383
-
3384
- return True
3385
-
3386
-
3387
-
3388
3292
3389
3293
3390
3294
# digest algorithm klas, digest size (not default), digest length
0 commit comments