Sidetreeコード・仕様照らし合わせ



## 関連リンク
DID Sidetree Protocol
https://identity.foundation/sidetree/spec/#hashing-process

[Github] Sidetree
https://github.com/decentralized-identity/sidetree

[Github] ION
https://github.com/decentralized-identity/ion



## 5. Default Parameters 
Protocol Parameterは以下のjsonファイルに設定されている。
[sidetree/lib/core/versions/latest/protocol-parameters.json](https://github.com/decentralized-identity/sidetree/blob/master/lib/core/versions/latest/protocol-parameters.json)

[sidetree/lib/core/versions/latest/ProtocolParameters.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/ProtocolParameters.ts)


### JSON_CANONICALIZATION_SCHEME
[Sidetree v1.0.0 - Default Parameters(JSON_CANONICALIZATION_SCHEME)](https://identity.foundation/sidetree/spec/#default-parameters)

[RFC:  JSON Canonicalization Scheme (JCS) draft-rundgren-json-canonicalization-scheme-17](https://datatracker.ietf.org/doc/html/draft-rundgren-json-canonicalization-scheme-17)

ソースコード：
- class JsonCanonicalizer: [sidetree/lib/core/versions/latest/util/JsonCanonicalizer.ts:6](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/JsonCanonicalizer.ts#L6)
- npm: [canonicalize](https://www.npmjs.com/package/canonicalize)




## 6.1 Multihash
[Sidetree v1.0.0 - 6.1 Hashing Process](https://identity.foundation/sidetree/spec/#hashing-process)
[Multiformats / Multihash](https://multiformats.io/multihash/)

ソースコード :
- class Multihash: [sidetree/lib/core/versions/latest/Multihash.ts:13](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/Multihash.ts#L13)

## 6.2 Commitment Schemes
[Sidetree v1.0.0 - 6.2 Commitment Schemes](https://identity.foundation/sidetree/spec/#commitment-schemes)

ソースコード :
- class Jwk: [sidetree/lib/core/versions/latest/util/Jwk.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/Jwk.ts#L9)

## 7. Network Topology
[Sidetree v1.0.0 - 7. Network Topology](https://identity.foundation/sidetree/spec/#network-topology)

#### Decentralized Ledger System


#### Sidetree Network


#### CAS Network


## 8. File Structures
[Sidetree v1.0.0 - 8. File Structures](https://identity.foundation/sidetree/spec/#file-structures)


### 8.1 Core Index File
[Sidetree v1.0.0 - 8.1 Core Index File](https://identity.foundation/sidetree/spec/#core-index-file)

ソースコード:
- class CoreIndexFile: [sidetree/lib/core/versions/latest/CoreIndexFile.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/CoreIndexFile.ts#L26)
- interface CoreIndexFileModel: [sidetree/lib/core/versions/latest/models/CoreIndexFileModel.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/CoreIndexFileModel.ts#L6)

### 8.2 Provisional Index File
[Sidetree v1.0.0 - 8.2 Provisional Index File](https://identity.foundation/sidetree/spec/#provisional-index-file)

ソースコード:
- class ProvisionalIndexFile: [sidetree/lib/core/versions/latest/ProvisionalIndexFile.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/ProvisionalIndexFile.ts#L15)
- interface ProvisionalIndexFileModel: [sidetree/lib/core/versions/latest/models/ProvisionalIndexFileModel.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/ProvisionalIndexFileModel.ts#L6)

### 8.3 Core Proof File
[Sidetree v1.0.0 - 8.3 Core Proof File](https://identity.foundation/sidetree/spec/#core-proof-file)

ソースコード:
- class CoreProofFile: [sidetree/lib/core/versions/latest/CoreProofFile.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/CoreProofFile.ts#L17)
- interface CoreProofFileModel: [sidetree/lib/core/versions/latest/models/CoreProofFileModel.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/CoreProofFileModel.ts#L4)

### 8.4 Provisional Proof File
[Sidetree v1.0.0 - 8.4 Provisional Proof File](https://identity.foundation/sidetree/spec/#provisional-proof-file)

ソースコード:
- class ProvisionalProofFile: [sidetree/lib/core/versions/latest/ProvisionalProofFile.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/ProvisionalProofFile.ts#L15)
- interface CoreProofFileModel: [sidetree/lib/core/versions/latest/models/CoreProofFileModel.t](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/CoreProofFileModel.ts#L4)


### 8.5 Chunk Files
[Sidetree v1.0.0 - 8.5 Chunk Files](https://identity.foundation/sidetree/spec/#chunk-files)

ソースコード:
- class ChunkFile: [sidetree/lib/core/versions/latest/ChunkFile.ts ](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/ChunkFile.ts#L17)
- interface ChunkFileModel: [sidetree/lib/core/versions/latest/models/ChunkFileModel.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/ChunkFileModel.ts#L5)

## 9. DID URI Composition
[Sidetree v1.0.0 - 9. DID URI Composition](https://identity.foundation/sidetree/spec/#did-uri-composition)

ソースコード: 
- class Did: [sidetree/lib/core/versions/latest/Did.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/Did.ts#L14)

### 9.1 Long-Form DID URIs
[9.1 Long-Form DID URIs](https://identity.foundation/sidetree/spec/#long-form-did-uris)

ソースコード: 
- resolveLongFormDid(): [sidetree/lib/core/versions/latest/RequestHandler.ts#L215](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/RequestHandler.ts#L215)

## 10. JSON Web Signatures
[Sidetree v1.0.0 - 10. JSON Web Signatures](https://identity.foundation/sidetree/spec/#json-web-signatures)

ソースコード:
- class Jws: [sidetree/lib/core/versions/latest/util/Jws.ts #L87](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/Jws.ts#L12)
- interface JwsModel: [sidetree/lib/core/versions/latest/models/JwsModel.ts ](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/JwsModel.ts#L4)

### 10.1 Signing
[Sidetree v1.0.0 - 10.1 Signing](https://identity.foundation/sidetree/spec/#signing)

ソースコード:
- sign(): [sidetree/lib/core/versions/latest/util/Jws.ts#L119](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/Jws.ts#L119)



### 10.2 Verifying
[Sidetree v1.0.0 - 10.2 Verifying](https://identity.foundation/sidetree/spec/#verifying)

ソースコード:
- verifySignature(): [sidetree/lib/core/versions/latest/util/Jws.t#L87](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/Jws.ts#L87)


## 11. DID Operations
[Sidetree v1.0.0 - 11. DID Operations](https://identity.foundation/sidetree/spec/#did-operations)

ソースコード:
- class Operation(): 
[sidetree/lib/core/versions/latest/Operation.ts#L15](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/Operation.ts#L15)
- class OperationProcessor(): 
[sidetree/lib/core/versions/latest/OperationProcessor.ts#L22](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/OperationProcessor.ts#L22)
- class RequestHandler():
[sidetree/lib/core/versions/latest/RequestHandler.ts#L22](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/RequestHandler.ts#L22)


### 11.1 Create
[Sidetree v1.0.0 - 11.1 Create](https://identity.foundation/sidetree/spec/#create)

ソースコード:
- applyCreateOperation(): [sidetree/lib/core/Resolver.ts#L87](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/Resolver.ts#L87)
- class CreateOperation: [sidetree/lib/core/versions/latest/CreateOperation.ts#L15](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/CreateOperation.ts#L15)


### 11.2 Update
[Sidetree v1.0.0 - 11.2 Update](https://identity.foundation/sidetree/spec/#update)

ソースコード: 
- applyUpdateOperations(): [sidetree/lib/core/Resolver.ts#L137](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/Resolver.ts#L137)
- class UpdateOperation: [sidetree/lib/core/versions/latest/UpdateOperation.ts ](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/UpdateOperation.ts#L18)


### 11.3 Recover
[Sidetree v1.0.0 - 11.2 Recover](https://identity.foundation/sidetree/spec/#recover)

ソースコード:
- applyRecoverAndDeactivateOperations(): [sidetree/lib/core/Resolver.ts#L105](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/Resolver.ts#L105) 
- class RecoverOperation: [sidetree/lib/core/versions/latest/RecoverOperation.ts](https://github.com/decentralized-identity/sidetree/blob/master/lib/core/versions/latest/RecoverOperation.ts)


### 11.4 Deactivate
[Sidetree v1.0.0 - 11.4 Deactivate](https://identity.foundation/sidetree/spec/#deactivate)

ソースコード:
- applyRecoverAndDeactivateOperations(): [sidetree/lib/core/Resolver.ts#L105](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/Resolver.ts#L105) 
- class DeactivateOperation: [sidetree/lib/core/versions/latest/DeactivateOperation.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/DeactivateOperation.ts#L16)


## 12. DID State Patches
[Sidetree v1.0.0 - 12. DID State Patches](https://identity.foundation/sidetree/spec/#did-state-patches)
ソースコード:
- enum: [sidetree/lib/core/versions/latest/PatchAction.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/PatchAction.ts#L4)
- DocumentComposer.ts: [sidetree/lib/core/versions/latest/DocumentComposer.ts](https://github.com/decentralized-identity/sidetree/blob/master/lib/core/versions/latest/DocumentComposer.ts)


### 12.1.1 add-public-keys
[Sidetree v1.0.0 - 12.1.1 add-public-keys](https://identity.foundation/sidetree/spec/#add-public-keys)
ソースコード: 
- addPublicKeys(): [sidetree/lib/core/versions/latest/DocumentComposer.ts#L415](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/DocumentComposer.ts#L415)

### 12.1.2 remove-public-keys
[Sidetree v1.0.0 - 12.1.2 remove-public-keys](https://identity.foundation/sidetree/spec/#remove-public-keys)
ソースコード:
- removePublicKeys(): [sidetree/lib/core/versions/latest/DocumentComposer.ts#L431](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/DocumentComposer.ts#L431)

### 12.1.3 add-services
[Sidetree v1.0.0 - 12.1.3 add-services](https://identity.foundation/sidetree/spec/#add-services)
ソースコード:
- addServices(): [sidetree/lib/core/versions/latest/DocumentComposer.ts#L442](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/DocumentComposer.ts#L442)


### 12.1.4 remove-services
[Sidetree v1.0.0 - 12.1.4 remove-services](https://identity.foundation/sidetree/spec/#remove-services)
ソースコード: 
- removeServices(): [sidetree/lib/core/versions/latest/DocumentComposer.ts#L466](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/DocumentComposer.ts#L466)


### 12.1.5 replace
[Sidetree v1.0.0 - 12.1.5 replace](https://identity.foundation/sidetree/spec/#replace)
ソースコード: 
- [idetree/lib/core/versions/latest/util/JsObject.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/util/JsObject.ts#L28)


### 12.1.6 ietf-json-patch
[Sidetree v1.0.0 - 12.1.6 ietf-json-patch](https://identity.foundation/sidetree/spec/#ietf-json-patch)

実装されていない?

## 13. Transaction & Operation Processing

### 13.1 Transaction Anchoring
[Sidetree v1.0.0 - 13.1 Transaction Anchoring](https://identity.foundation/sidetree/spec/#transaction-anchoring)
- write():[sidetree/lib/core/versions/latest/BatchWriter.ts#76](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/BatchWriter.ts#L36)
- AnchoredData{}: [sidetree/lib/core/versions/latest/models/AnchoredData.ts](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/models/AnchoredData.ts#L4)

### 13.2 CAS File Propagation
[Sidetree v1.0.0 - 13.2 CAS File Propagation]()

### 13.3 Transaction Processing
[Sidetree v1.0.0 - 13.3 Transaction Processing]()

ソースコード:
- processTransaction(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L38](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L38)

### 13.4 Core Index File Processing
[Sidetree v1.0.0 - 13.4 CAS File Propagation]()

ソースコード:
- downloadAndVerifyCoreIndexFile(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L138](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L138)
- parse(): [sidetree/lib/bitcoin/SidetreeTransactionParser.ts #L23](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/bitcoin/SidetreeTransactionParser.ts#L23)

### 13.5 Provisional Index File Processing
[Sidetree v1.0.0 - 13.5 Transaction Processing]()

ソースコード:
- downloadAndVerifyCoreProofFile(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L138](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L138)
- parse(): [sidetree/lib/bitcoin/SidetreeTransactionParser.ts #L23](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/bitcoin/SidetreeTransactionParser.ts#L23)

### 13.6 Core Proof File Processing
[Sidetree v1.0.0 - 13.6  Core Proof File Processing]()

ソースコード:
- downloadAndVerifyCoreProofFile(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L173](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L173)
- parse(): [sidetree/lib/bitcoin/SidetreeTransactionParser.ts#L23](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/bitcoin/SidetreeTransactionParser.ts#L23)

### 13.7 Provisional Proof File Processing
[Sidetree v1.0.0 - 13.7 Provisional Proof File Processing]()

ソースコード:
- downloadAndVerifyProvisionalProofFile(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L197](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L197)
- parse(): [sidetree/lib/core/versions/latest/ProvisionalProofFile.ts#L55](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/ProvisionalProofFile.ts#L55)

### 13.8 Chunk File Processing
[Sidetree v1.0.0 - 13.8 Chunk File Processing]()

ソースコード:
- downloadAndVerifyChunkFile(): [sidetree/lib/core/versions/latest/TransactionProcessor.ts#L263](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L263)
- parse(): [sidetree/lib/core/versions/latest/ProvisionalProofFile.ts#L55](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/TransactionProcessor.ts#L263)

## 14. Proof of Fee

### 14.1 Base Fee Variable
[Sidetree v1.0.0 - 14.1 Base Fee Variable](https://identity.foundation/sidetree/spec/#base-fee-variable)

ソースコード:
- computeMinimumTransactionFee(): [sidetree/lib/core/versions/latest/FeeManager.ts#L19](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/FeeManager.ts#L19)

### 14.2 Per-Operation Fee
[Sidetree v1.0.0 - 14.2 Per-Operation Fee](https://identity.foundation/sidetree/spec/#per-operation-fee)

ソースコード：
"normalizedFeeToPerOperationFeeMultiplier": [sidetree/lib/core/versions/latest/protocol-parameters.json#L14](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/versions/latest/protocol-parameters.json#L14)

### 14.3 Value Locking
[Sidetree v1.0.0 - 14.3 Value Locking](https://identity.foundation/sidetree/spec/#value-locking)

- ソースコード:
createLockTransaction(): [sidetree/lib/bitcoin/BitcoinClient.ts#L157](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/bitcoin/BitcoinClient.ts#L157)


## 15. Resolution
[Sidetree v1.0.0 - 15. Resolution](https://identity.foundation/sidetree/spec/#resolution)

ソースコード:
- resolve: [sidetree/lib/core/Resolver.ts#L22](https://github.com/decentralized-identity/sidetree/blob/54b4288a1f2cea1df22f89f803a88f34ecf9f76c/lib/core/Resolver.ts#L22)

## タスク
発見できなかったコードや疑問点等を以下に記録。