## Indy SDK and Indy VDR How do we handle changes? - nym_request_v2 - Breaking API change? - Adding additional parameters at the end of the signature and setting to None if not delivered? ### New NYM Operation and new build_nym_request ### New Get Nym ### New API? Should indy-vdr and indy-sdk directly return a did doc? ## Indy Node and Indy Plenum ### Write NYM We need to adapt the schema of a write nym operation to include the optional `diddoccontent` attribute. The schema definition is part of [Plenum](https://github.com/hyperledger/indy-plenum/blob/5960118788c1a580cd271c50b920ac15b1497495/plenum/common/messages/client_request.py#L55) Should we adapt the existing class? ``` class ClientNYMOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(NYM)), (ALIAS, LimitedLengthStringField(max_length=ALIAS_FIELD_LIMIT, optional=True)), (VERKEY, VerkeyField(optional=True, nullable=True)), (TARGET_NYM, DestNymField()), (ROLE, RoleField(optional=True)), (DIDDOC_CONTENT, JsonField(max_length=JSON_FIELD_LIMIT(optional=True)), ) ``` or add another class? ``` class ClientNYMOperationV2(MessageValidator): ``` `JSON_FIELD_LIMIT` is used for the raw content of an ATTRIB tx and is set [here](https://github.com/hyperledger/indy-plenum/blob/f812a72197bc0740d4c6b75b796beff8f88c73f9/plenum/config.py#L316) to 5*1024 It seems that we don't need to adapt the [`update_state` function](https://github.com/hyperledger/indy-node/blob/master/indy_node/server/request_handlers/domain_req_handlers/nym_handler.py) An open question would be if store the diddoccontent directly or use dedicated store as is done in the attrib case. #### Validation ##### Self-certifying identifier in `_validate_new_nym` function add additional check ``` if config.ENABLE_DID_INDY and not self._is_self_certifying( request.operation.get(TARGET_NYM), request.operation.get(VERKEY) ): raise InvalidClientRequest( identifier, req_id, "DID must be self-certifying." ) ``` where ``` def _is_self_certifying(self, did, verkey): if self._is_abbrev_verkey(verkey): return True ## Full verkey return did == base58.b58encode(base58.b58decode(verkey)[:15]) ``` #### DID Document validation ##### Base DID Document ``` class BaseDIDDoc: def __init__(self, namespace: str, dest: str, verkey: str): self._id = f"did:indy:{namespace}:{dest}" self._did_doc = { "id": self._id, "verificationMethod": [ { "id": self._id + "#verkey", "type": "Ed25519VerificationKey2018", "publicKeyBase58": verkey, "controller": self._id, } ], "authentication": [self._id + "#verkey"], } @property def did_doc(self) -> dict: """Getter for did document""" return self._did_doc ``` ### Get NYM No changes required? Do we need new type/schemas of new version? ### GET DIDdoc by timestamp We can roughly follow the process outlined in RevocRegEntry 1. Define get nym request and handler with additional timestamp [New schema](https://github.com/hyperledger/indy-node/blob/78bb325121be212f4dc729998d713dbbcde78bee/indy_common/types.py#L67) with ` (TIMESTAMP, IntegerField(optional=True))`and [enhanced logic](https://github.com/hyperledger/indy-node/blob/78bb325121be212f4dc729998d713dbbcde78bee/indy_node/server/request_handlers/read_req_handlers/get_nym_handler.py#L17) to do the following 3. Use `NymHandler.make_state_path_for_nym(nym)` as defined [here](https://github.com/hyperledger/indy-node/blob/78bb325121be212f4dc729998d713dbbcde78bee/indy_common/state/domain.py#L33) 4. Implement `get_nym_by_timestamp(timestamp, path_to_nym_entry)` similar to [_get_reg_entry_by_timestamp(self, timestamp, path_to_reg_entry)](https://github.com/hyperledger/indy-node/blob/78bb325121be212f4dc729998d713dbbcde78bee/indy_node/server/request_handlers/read_req_handlers/get_revoc_reg_delta_handler.py#L128). More about timestamp storage can be found [here](https://hyperledger-indy.readthedocs.io/projects/plenum/en/latest/storage.html#timestamp-storage) ### Get DIDdoc by version (==seqNo) There seems to be no direct mapping between seqNo and state. Hence, I see the following options: 1. Introduce a new mapping `seqNo -> state` and add an optional seqNo attribute to the get nym request. 2. Use `GET_TXN(seqId)` internally, use `state_root_hash` which is part of the `state_proof` block to `get_value_from_state`. (Not sure if this the correct state root ([More info](https://github.com/hyperledger/indy-plenum/blob/5960118788c1a580cd271c50b920ac15b1497495/plenum/server/request_handlers/get_txn_handler.py#L43))) 2. Use `GET_TXN(seqId)` internally, get the timestamp from this TX and use `get_nym_by_timestamp` ### Issues #### Testing Can't run tests because indy-sdk/pyton-indy dependency indy_node/test/nym_txn