diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 1d5f40d010..38fa546783 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -101,7 +101,7 @@ ## AuthenticationRequest -**Kind**: global class +**Kind**: global class * [AuthenticationRequest](#AuthenticationRequest) * _instance_ @@ -112,20 +112,20 @@ ### authenticationRequest.toJSON() ⇒ any -**Kind**: instance method of [AuthenticationRequest](#AuthenticationRequest) +**Kind**: instance method of [AuthenticationRequest](#AuthenticationRequest) ### AuthenticationRequest.fromJSON(value) ⇒ [AuthenticationRequest](#AuthenticationRequest) -**Kind**: static method of [AuthenticationRequest](#AuthenticationRequest) +**Kind**: static method of [AuthenticationRequest](#AuthenticationRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## AuthenticationResponse -**Kind**: global class +**Kind**: global class * [AuthenticationResponse](#AuthenticationResponse) * _instance_ @@ -136,20 +136,20 @@ ### authenticationResponse.toJSON() ⇒ any -**Kind**: instance method of [AuthenticationResponse](#AuthenticationResponse) +**Kind**: instance method of [AuthenticationResponse](#AuthenticationResponse) ### AuthenticationResponse.fromJSON(value) ⇒ [AuthenticationResponse](#AuthenticationResponse) -**Kind**: static method of [AuthenticationResponse](#AuthenticationResponse) +**Kind**: static method of [AuthenticationResponse](#AuthenticationResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## Client -**Kind**: global class +**Kind**: global class * [Client](#Client) * [new Client()](#new_Client_new) @@ -177,61 +177,61 @@ Creates a new `Client` with default settings. ### client.network() ⇒ [Network](#Network) Returns the `Client` Tangle network. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) ### client.publishDocument(document) ⇒ Promise.<any> Publishes an `IotaDocument` to the Tangle. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| document | any | +| document | any | ### client.publishDiff(message_id, diff) ⇒ Promise.<any> Publishes a `DocumentDiff` to the Tangle. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| message_id | string | -| diff | [DocumentDiff](#DocumentDiff) | +| message_id | string | +| diff | [DocumentDiff](#DocumentDiff) | ### client.publishJSON(index, data) ⇒ Promise.<any> Publishes arbitrary JSON data to the specified index on the Tangle. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| index | string | -| data | any | +| index | string | +| data | any | ### client.resolve(did) ⇒ Promise.<any> -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| did | string | +| did | string | ### client.resolveHistory(did) ⇒ Promise.<any> Returns the message history of the given DID. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| did | string | +| did | string | @@ -242,60 +242,60 @@ integration chain. NOTE: the document must have been published to the tangle and have a valid message id and authentication method. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| document | [Document](#Document) | +| document | [Document](#Document) | ### client.checkCredential(data) ⇒ Promise.<any> Validates a credential with the DID Document from the Tangle. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| data | string | +| data | string | ### client.checkPresentation(data) ⇒ Promise.<any> Validates a presentation with the DID Document from the Tangle. -**Kind**: instance method of [Client](#Client) +**Kind**: instance method of [Client](#Client) | Param | Type | | --- | --- | -| data | string | +| data | string | ### Client.fromConfig(config) ⇒ [Client](#Client) Creates a new `Client` with settings from the given `Config`. -**Kind**: static method of [Client](#Client) +**Kind**: static method of [Client](#Client) | Param | Type | | --- | --- | -| config | [Config](#Config) | +| config | [Config](#Config) | ### Client.fromNetwork(network) ⇒ [Client](#Client) Creates a new `Client` with default settings for the given `Network`. -**Kind**: static method of [Client](#Client) +**Kind**: static method of [Client](#Client) | Param | Type | | --- | --- | -| network | [Network](#Network) | +| network | [Network](#Network) | ## Config -**Kind**: global class +**Kind**: global class * [Config](#Config) * _instance_ @@ -319,149 +319,149 @@ Creates a new `Client` with default settings for the given `Network`. ### config.setNetwork(network) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| network | [Network](#Network) | +| network | [Network](#Network) | ### config.setNode(url) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| url | string | +| url | string | ### config.setPrimaryNode(url, jwt, username, password) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| url | string | -| jwt | string \| undefined | -| username | string \| undefined | -| password | string \| undefined | +| url | string | +| jwt | string \| undefined | +| username | string \| undefined | +| password | string \| undefined | ### config.setPrimaryPoWNode(url, jwt, username, password) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| url | string | -| jwt | string \| undefined | -| username | string \| undefined | -| password | string \| undefined | +| url | string | +| jwt | string \| undefined | +| username | string \| undefined | +| password | string \| undefined | ### config.setPermanode(url, jwt, username, password) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| url | string | -| jwt | string \| undefined | -| username | string \| undefined | -| password | string \| undefined | +| url | string | +| jwt | string \| undefined | +| username | string \| undefined | +| password | string \| undefined | ### config.setNodeAuth(url, jwt, username, password) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| url | string | -| jwt | string \| undefined | -| username | string \| undefined | -| password | string \| undefined | +| url | string | +| jwt | string \| undefined | +| username | string \| undefined | +| password | string \| undefined | ### config.setNodeSyncInterval(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | number | +| value | number | ### config.setNodeSyncDisabled() -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) ### config.setQuorum(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | boolean | +| value | boolean | ### config.setQuorumSize(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | number | +| value | number | ### config.setQuorumThreshold(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | number | +| value | number | ### config.setLocalPoW(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | boolean | +| value | boolean | ### config.setTipsInterval(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | number | +| value | number | ### config.setRequestTimeout(value) -**Kind**: instance method of [Config](#Config) +**Kind**: instance method of [Config](#Config) | Param | Type | | --- | --- | -| value | number | +| value | number | ### Config.fromNetwork(network) ⇒ [Config](#Config) -**Kind**: static method of [Config](#Config) +**Kind**: static method of [Config](#Config) | Param | Type | | --- | --- | -| network | [Network](#Network) | +| network | [Network](#Network) | ## CredentialIssuance -**Kind**: global class +**Kind**: global class * [CredentialIssuance](#CredentialIssuance) * _instance_ @@ -472,20 +472,20 @@ Creates a new `Client` with default settings for the given `Network`. ### credentialIssuance.toJSON() ⇒ any -**Kind**: instance method of [CredentialIssuance](#CredentialIssuance) +**Kind**: instance method of [CredentialIssuance](#CredentialIssuance) ### CredentialIssuance.fromJSON(value) ⇒ [CredentialIssuance](#CredentialIssuance) -**Kind**: static method of [CredentialIssuance](#CredentialIssuance) +**Kind**: static method of [CredentialIssuance](#CredentialIssuance) | Param | Type | | --- | --- | -| value | any | +| value | any | ## CredentialOptionRequest -**Kind**: global class +**Kind**: global class * [CredentialOptionRequest](#CredentialOptionRequest) * _instance_ @@ -496,20 +496,20 @@ Creates a new `Client` with default settings for the given `Network`. ### credentialOptionRequest.toJSON() ⇒ any -**Kind**: instance method of [CredentialOptionRequest](#CredentialOptionRequest) +**Kind**: instance method of [CredentialOptionRequest](#CredentialOptionRequest) ### CredentialOptionRequest.fromJSON(value) ⇒ [CredentialOptionRequest](#CredentialOptionRequest) -**Kind**: static method of [CredentialOptionRequest](#CredentialOptionRequest) +**Kind**: static method of [CredentialOptionRequest](#CredentialOptionRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## CredentialOptionResponse -**Kind**: global class +**Kind**: global class * [CredentialOptionResponse](#CredentialOptionResponse) * _instance_ @@ -520,20 +520,20 @@ Creates a new `Client` with default settings for the given `Network`. ### credentialOptionResponse.toJSON() ⇒ any -**Kind**: instance method of [CredentialOptionResponse](#CredentialOptionResponse) +**Kind**: instance method of [CredentialOptionResponse](#CredentialOptionResponse) ### CredentialOptionResponse.fromJSON(value) ⇒ [CredentialOptionResponse](#CredentialOptionResponse) -**Kind**: static method of [CredentialOptionResponse](#CredentialOptionResponse) +**Kind**: static method of [CredentialOptionResponse](#CredentialOptionResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## CredentialRevocation -**Kind**: global class +**Kind**: global class * [CredentialRevocation](#CredentialRevocation) * _instance_ @@ -544,20 +544,20 @@ Creates a new `Client` with default settings for the given `Network`. ### credentialRevocation.toJSON() ⇒ any -**Kind**: instance method of [CredentialRevocation](#CredentialRevocation) +**Kind**: instance method of [CredentialRevocation](#CredentialRevocation) ### CredentialRevocation.fromJSON(value) ⇒ [CredentialRevocation](#CredentialRevocation) -**Kind**: static method of [CredentialRevocation](#CredentialRevocation) +**Kind**: static method of [CredentialRevocation](#CredentialRevocation) | Param | Type | | --- | --- | -| value | any | +| value | any | ## CredentialSelection -**Kind**: global class +**Kind**: global class * [CredentialSelection](#CredentialSelection) * _instance_ @@ -568,20 +568,20 @@ Creates a new `Client` with default settings for the given `Network`. ### credentialSelection.toJSON() ⇒ any -**Kind**: instance method of [CredentialSelection](#CredentialSelection) +**Kind**: instance method of [CredentialSelection](#CredentialSelection) ### CredentialSelection.fromJSON(value) ⇒ [CredentialSelection](#CredentialSelection) -**Kind**: static method of [CredentialSelection](#CredentialSelection) +**Kind**: static method of [CredentialSelection](#CredentialSelection) | Param | Type | | --- | --- | -| value | any | +| value | any | ## DID -**Kind**: global class +**Kind**: global class * [DID](#DID) * [new DID(key, network)](#new_DID_new) @@ -602,60 +602,60 @@ Creates a new `DID` from a `KeyPair` object. | Param | Type | | --- | --- | -| key | [KeyPair](#KeyPair) | -| network | string \| undefined | +| key | [KeyPair](#KeyPair) | +| network | string \| undefined | ### did.network ⇒ [Network](#Network) Returns the IOTA tangle network of the `DID`. -**Kind**: instance property of [DID](#DID) +**Kind**: instance property of [DID](#DID) ### did.networkName ⇒ string Returns the IOTA tangle network of the `DID`. -**Kind**: instance property of [DID](#DID) +**Kind**: instance property of [DID](#DID) ### did.tag ⇒ string Returns the unique tag of the `DID`. -**Kind**: instance property of [DID](#DID) +**Kind**: instance property of [DID](#DID) ### did.toString() ⇒ string Returns the `DID` object as a string. -**Kind**: instance method of [DID](#DID) +**Kind**: instance method of [DID](#DID) ### DID.fromBase58(key, network) ⇒ [DID](#DID) Creates a new `DID` from a base58-encoded public key. -**Kind**: static method of [DID](#DID) +**Kind**: static method of [DID](#DID) | Param | Type | | --- | --- | -| key | string | -| network | string \| undefined | +| key | string | +| network | string \| undefined | ### DID.parse(input) ⇒ [DID](#DID) Parses a `DID` from the input string. -**Kind**: static method of [DID](#DID) +**Kind**: static method of [DID](#DID) | Param | Type | | --- | --- | -| input | string | +| input | string | ## DidRequest -**Kind**: global class +**Kind**: global class * [DidRequest](#DidRequest) * _instance_ @@ -666,20 +666,20 @@ Parses a `DID` from the input string. ### didRequest.toJSON() ⇒ any -**Kind**: instance method of [DidRequest](#DidRequest) +**Kind**: instance method of [DidRequest](#DidRequest) ### DidRequest.fromJSON(value) ⇒ [DidRequest](#DidRequest) -**Kind**: static method of [DidRequest](#DidRequest) +**Kind**: static method of [DidRequest](#DidRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## DidResponse -**Kind**: global class +**Kind**: global class * [DidResponse](#DidResponse) * _instance_ @@ -690,20 +690,20 @@ Parses a `DID` from the input string. ### didResponse.toJSON() ⇒ any -**Kind**: instance method of [DidResponse](#DidResponse) +**Kind**: instance method of [DidResponse](#DidResponse) ### DidResponse.fromJSON(value) ⇒ [DidResponse](#DidResponse) -**Kind**: static method of [DidResponse](#DidResponse) +**Kind**: static method of [DidResponse](#DidResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## DiffChainHistory -**Kind**: global class +**Kind**: global class * [DiffChainHistory](#DiffChainHistory) * _instance_ @@ -720,7 +720,7 @@ Returns a [`js_sys::Array`] of `$wasm_ty` as strings. NOTE: this clones the field. -**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) +**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) ### diffChainHistory.spam() ⇒ Array.<any> @@ -728,28 +728,28 @@ Returns a [`js_sys::Array`] of [`MessageIds`][MessageId] as strings. NOTE: this clones the field. -**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) +**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) ### diffChainHistory.toJSON() ⇒ any Serializes a `$ident` object as a JSON object. -**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) +**Kind**: instance method of [DiffChainHistory](#DiffChainHistory) ### DiffChainHistory.fromJSON(json) ⇒ [DiffChainHistory](#DiffChainHistory) Deserializes a `$ident` object from a JSON object. -**Kind**: static method of [DiffChainHistory](#DiffChainHistory) +**Kind**: static method of [DiffChainHistory](#DiffChainHistory) | Param | Type | | --- | --- | -| json | any | +| json | any | ## Document -**Kind**: global class +**Kind**: global class * [Document](#Document) * [new Document(type_, network, tag)](#new_Document_new) @@ -795,165 +795,165 @@ Creates a new DID Document from the given KeyPair. | Param | Type | | --- | --- | -| type_ | number | -| network | string \| undefined | -| tag | string \| undefined | +| type_ | number | +| network | string \| undefined | +| tag | string \| undefined | ### document.id ⇒ [DID](#DID) Returns the DID Document `id`. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.created ⇒ [Timestamp](#Timestamp) Returns the timestamp of when the DID document was created. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.created Sets the timestamp of when the DID document was created. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) | Param | Type | | --- | --- | -| timestamp | [Timestamp](#Timestamp) | +| timestamp | [Timestamp](#Timestamp) | ### document.updated ⇒ [Timestamp](#Timestamp) Returns the timestamp of the last DID document update. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.updated Sets the timestamp of the last DID document update. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) | Param | Type | | --- | --- | -| timestamp | [Timestamp](#Timestamp) | +| timestamp | [Timestamp](#Timestamp) | ### document.proof ⇒ any Returns the DID Document `proof` object. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.messageId ⇒ string Get the message_id of the DID Document. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.messageId Set the message_id of the DID Document. -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) | Param | Type | | --- | --- | -| message_id | string | +| message_id | string | ### document.previousMessageId ⇒ string -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) ### document.previousMessageId -**Kind**: instance property of [Document](#Document) +**Kind**: instance property of [Document](#Document) | Param | Type | | --- | --- | -| value | string | +| value | string | ### document.authentication() ⇒ [VerificationMethod](#VerificationMethod) Returns the default Verification Method of the DID Document. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) ### document.insertMethod(method, scope) ⇒ boolean -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| method | [VerificationMethod](#VerificationMethod) | -| scope | string \| undefined | +| method | [VerificationMethod](#VerificationMethod) | +| scope | string \| undefined | ### document.removeMethod(did) -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| did | [DID](#DID) | +| did | [DID](#DID) | ### document.insertService(service) ⇒ boolean -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| service | [Service](#Service) | +| service | [Service](#Service) | ### document.removeService(did) -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| did | [DID](#DID) | +| did | [DID](#DID) | ### document.sign(key) Signs the DID Document with the default authentication method. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| key | [KeyPair](#KeyPair) | +| key | [KeyPair](#KeyPair) | ### document.verify() ⇒ boolean Verify the signature with the authentication_key -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) ### document.signCredential(data, args) ⇒ [VerifiableCredential](#VerifiableCredential) -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| data | any | -| args | any | +| data | any | +| args | any | ### document.signPresentation(data, args) ⇒ [VerifiablePresentation](#VerifiablePresentation) -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| data | any | -| args | any | +| data | any | +| args | any | @@ -964,66 +964,66 @@ Verification Method. An additional `proof` property is required if using a Merkle Key Collection verification Method. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| data | any | -| args | any | +| data | any | +| args | any | ### document.verifyData(data) ⇒ boolean Verifies the authenticity of `data` using the target verification method. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| data | any | +| data | any | ### document.resolveKey(query) ⇒ [VerificationMethod](#VerificationMethod) -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| query | string | +| query | string | ### document.revokeMerkleKey(query, index) ⇒ boolean -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| query | string | -| index | number | +| query | string | +| index | number | ### document.diff(other, message, key) ⇒ [DocumentDiff](#DocumentDiff) Generate the difference between two DID Documents and sign it -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| other | [Document](#Document) | -| message | string | -| key | [KeyPair](#KeyPair) | +| other | [Document](#Document) | +| message | string | +| key | [KeyPair](#KeyPair) | ### document.merge(diff) Verifies a `DocumentDiff` signature and merges the changes into `self`. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) | Param | Type | | --- | --- | -| diff | [DocumentDiff](#DocumentDiff) | +| diff | [DocumentDiff](#DocumentDiff) | @@ -1035,13 +1035,13 @@ E.g. For an [`IotaDocument`] `doc` with DID: did:iota:1234567890abcdefghijklmnopqrstuvxyzABCDEFGHI, `doc.integration_index()` == "1234567890abcdefghijklmnopqrstuvxyzABCDEFGHI" -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) ### document.toJSON() ⇒ any Serializes a `Document` object as a JSON object. -**Kind**: instance method of [Document](#Document) +**Kind**: instance method of [Document](#Document) ### Document.fromKeyPair(key, network) ⇒ [Document](#Document) @@ -1049,23 +1049,23 @@ Creates a new DID Document from the given KeyPair and optional network. If unspecified, network defaults to the mainnet. -**Kind**: static method of [Document](#Document) +**Kind**: static method of [Document](#Document) | Param | Type | | --- | --- | -| key | [KeyPair](#KeyPair) | -| network | string \| undefined | +| key | [KeyPair](#KeyPair) | +| network | string \| undefined | ### Document.fromAuthentication(method) ⇒ [Document](#Document) Creates a new DID Document from the given verification [`method`][`Method`]. -**Kind**: static method of [Document](#Document) +**Kind**: static method of [Document](#Document) | Param | Type | | --- | --- | -| method | [VerificationMethod](#VerificationMethod) | +| method | [VerificationMethod](#VerificationMethod) | @@ -1075,29 +1075,29 @@ published on the integration chain. This is the Base58-btc encoded SHA-256 digest of the hex-encoded message id. -**Kind**: static method of [Document](#Document) +**Kind**: static method of [Document](#Document) | Param | Type | | --- | --- | -| message_id | string | +| message_id | string | ### Document.fromJSON(json) ⇒ [Document](#Document) Deserializes a `Document` object from a JSON object. -**Kind**: static method of [Document](#Document) +**Kind**: static method of [Document](#Document) | Param | Type | | --- | --- | -| json | any | +| json | any | ## DocumentDiff Defines the difference between two DID [`Document`]s' JSON representations. -**Kind**: global class +**Kind**: global class * [DocumentDiff](#DocumentDiff) * [.did](#DocumentDiff+did) ⇒ [DID](#DID) @@ -1114,7 +1114,7 @@ Defines the difference between two DID [`Document`]s' JSON representations. ### documentDiff.did ⇒ [DID](#DID) Returns the DID of the associated DID Document. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) ### documentDiff.diff ⇒ string @@ -1122,40 +1122,40 @@ Returns the raw contents of the DID Document diff. NOTE: clones the data. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) ### documentDiff.messageId ⇒ string Returns the message_id of the DID Document diff. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) ### documentDiff.messageId Sets the message_id of the DID Document diff. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) | Param | Type | | --- | --- | -| message_id | string | +| message_id | string | ### documentDiff.previousMessageId ⇒ string Returns the Tangle message id of the previous DID Document diff. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) ### documentDiff.previousMessageId Sets the Tangle message id of the previous DID Document diff. -**Kind**: instance property of [DocumentDiff](#DocumentDiff) +**Kind**: instance property of [DocumentDiff](#DocumentDiff) | Param | Type | | --- | --- | -| message_id | string | +| message_id | string | @@ -1164,25 +1164,25 @@ Returns the DID of the associated DID Document. NOTE: clones the data. -**Kind**: instance method of [DocumentDiff](#DocumentDiff) +**Kind**: instance method of [DocumentDiff](#DocumentDiff) ### documentDiff.merge(document) ⇒ [Document](#Document) Returns a new DID Document which is the result of merging `self` with the given Document. -**Kind**: instance method of [DocumentDiff](#DocumentDiff) +**Kind**: instance method of [DocumentDiff](#DocumentDiff) | Param | Type | | --- | --- | -| document | [Document](#Document) | +| document | [Document](#Document) | ## DocumentHistory A DID Document's history and current state. -**Kind**: global class +**Kind**: global class * [DocumentHistory](#DocumentHistory) * _instance_ @@ -1201,7 +1201,7 @@ Returns a [`js_sys::Array`] of integration chain [`WasmDocuments`](WasmDocument) NOTE: clones the data. -**Kind**: instance method of [DocumentHistory](#DocumentHistory) +**Kind**: instance method of [DocumentHistory](#DocumentHistory) ### documentHistory.integrationChainSpam() ⇒ Array.<any> @@ -1210,7 +1210,7 @@ as the integration chain. NOTE: clones the data. -**Kind**: instance method of [DocumentHistory](#DocumentHistory) +**Kind**: instance method of [DocumentHistory](#DocumentHistory) ### documentHistory.diffChainData() ⇒ Array.<any> @@ -1218,7 +1218,7 @@ Returns a [`js_sys::Array`] of diff chain [`WasmDocumentDiffs`](WasmDocumentDiff NOTE: clones the data. -**Kind**: instance method of [DocumentHistory](#DocumentHistory) +**Kind**: instance method of [DocumentHistory](#DocumentHistory) ### documentHistory.diffChainSpam() ⇒ Array.<any> @@ -1227,28 +1227,28 @@ as the diff chain. NOTE: clones the data. -**Kind**: instance method of [DocumentHistory](#DocumentHistory) +**Kind**: instance method of [DocumentHistory](#DocumentHistory) ### documentHistory.toJSON() ⇒ any Serializes a [`WasmDocumentHistory`] object as a JSON object. -**Kind**: instance method of [DocumentHistory](#DocumentHistory) +**Kind**: instance method of [DocumentHistory](#DocumentHistory) ### DocumentHistory.fromJSON(json) ⇒ [DocumentHistory](#DocumentHistory) Deserializes a [`WasmDocumentHistory`] object from a JSON object. -**Kind**: static method of [DocumentHistory](#DocumentHistory) +**Kind**: static method of [DocumentHistory](#DocumentHistory) | Param | Type | | --- | --- | -| json | any | +| json | any | ## FeaturesRequest -**Kind**: global class +**Kind**: global class * [FeaturesRequest](#FeaturesRequest) * _instance_ @@ -1259,20 +1259,20 @@ Deserializes a [`WasmDocumentHistory`] object from a JSON object. ### featuresRequest.toJSON() ⇒ any -**Kind**: instance method of [FeaturesRequest](#FeaturesRequest) +**Kind**: instance method of [FeaturesRequest](#FeaturesRequest) ### FeaturesRequest.fromJSON(value) ⇒ [FeaturesRequest](#FeaturesRequest) -**Kind**: static method of [FeaturesRequest](#FeaturesRequest) +**Kind**: static method of [FeaturesRequest](#FeaturesRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## FeaturesResponse -**Kind**: global class +**Kind**: global class * [FeaturesResponse](#FeaturesResponse) * _instance_ @@ -1283,20 +1283,20 @@ Deserializes a [`WasmDocumentHistory`] object from a JSON object. ### featuresResponse.toJSON() ⇒ any -**Kind**: instance method of [FeaturesResponse](#FeaturesResponse) +**Kind**: instance method of [FeaturesResponse](#FeaturesResponse) ### FeaturesResponse.fromJSON(value) ⇒ [FeaturesResponse](#FeaturesResponse) -**Kind**: static method of [FeaturesResponse](#FeaturesResponse) +**Kind**: static method of [FeaturesResponse](#FeaturesResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## IntegrationChainHistory -**Kind**: global class +**Kind**: global class * [IntegrationChainHistory](#IntegrationChainHistory) * _instance_ @@ -1313,7 +1313,7 @@ Returns a [`js_sys::Array`] of `$wasm_ty` as strings. NOTE: this clones the field. -**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) +**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) ### integrationChainHistory.spam() ⇒ Array.<any> @@ -1321,28 +1321,28 @@ Returns a [`js_sys::Array`] of [`MessageIds`][MessageId] as strings. NOTE: this clones the field. -**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) +**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) ### integrationChainHistory.toJSON() ⇒ any Serializes a `$ident` object as a JSON object. -**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) +**Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) ### IntegrationChainHistory.fromJSON(json) ⇒ [IntegrationChainHistory](#IntegrationChainHistory) Deserializes a `$ident` object from a JSON object. -**Kind**: static method of [IntegrationChainHistory](#IntegrationChainHistory) +**Kind**: static method of [IntegrationChainHistory](#IntegrationChainHistory) | Param | Type | | --- | --- | -| json | any | +| json | any | ## Introduction -**Kind**: global class +**Kind**: global class * [Introduction](#Introduction) * _instance_ @@ -1353,20 +1353,20 @@ Deserializes a `$ident` object from a JSON object. ### introduction.toJSON() ⇒ any -**Kind**: instance method of [Introduction](#Introduction) +**Kind**: instance method of [Introduction](#Introduction) ### Introduction.fromJSON(value) ⇒ [Introduction](#Introduction) -**Kind**: static method of [Introduction](#Introduction) +**Kind**: static method of [Introduction](#Introduction) | Param | Type | | --- | --- | -| value | any | +| value | any | ## IntroductionProposal -**Kind**: global class +**Kind**: global class * [IntroductionProposal](#IntroductionProposal) * _instance_ @@ -1377,20 +1377,20 @@ Deserializes a `$ident` object from a JSON object. ### introductionProposal.toJSON() ⇒ any -**Kind**: instance method of [IntroductionProposal](#IntroductionProposal) +**Kind**: instance method of [IntroductionProposal](#IntroductionProposal) ### IntroductionProposal.fromJSON(value) ⇒ [IntroductionProposal](#IntroductionProposal) -**Kind**: static method of [IntroductionProposal](#IntroductionProposal) +**Kind**: static method of [IntroductionProposal](#IntroductionProposal) | Param | Type | | --- | --- | -| value | any | +| value | any | ## IntroductionResponse -**Kind**: global class +**Kind**: global class * [IntroductionResponse](#IntroductionResponse) * _instance_ @@ -1401,20 +1401,20 @@ Deserializes a `$ident` object from a JSON object. ### introductionResponse.toJSON() ⇒ any -**Kind**: instance method of [IntroductionResponse](#IntroductionResponse) +**Kind**: instance method of [IntroductionResponse](#IntroductionResponse) ### IntroductionResponse.fromJSON(value) ⇒ [IntroductionResponse](#IntroductionResponse) -**Kind**: static method of [IntroductionResponse](#IntroductionResponse) +**Kind**: static method of [IntroductionResponse](#IntroductionResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## KeyCollection -**Kind**: global class +**Kind**: global class * [KeyCollection](#KeyCollection) * [new KeyCollection(type_, count)](#new_KeyCollection_new) @@ -1423,7 +1423,7 @@ Deserializes a `$ident` object from a JSON object. * [.isEmpty()](#KeyCollection+isEmpty) ⇒ boolean * [.keypair(index)](#KeyCollection+keypair) ⇒ [KeyPair](#KeyPair) \| undefined * [.public(index)](#KeyCollection+public) ⇒ string \| undefined - * [.secret(index)](#KeyCollection+secret) ⇒ string \| undefined + * [.private(index)](#KeyCollection+private) ⇒ string \| undefined * [.merkleRoot(digest)](#KeyCollection+merkleRoot) ⇒ string * [.merkleProof(digest, index)](#KeyCollection+merkleProof) ⇒ string \| undefined * [.toJSON()](#KeyCollection+toJSON) ⇒ any @@ -1438,103 +1438,103 @@ Creates a new `KeyCollection` with the specified key type. | Param | Type | | --- | --- | -| type_ | number | -| count | number | +| type_ | number | +| count | number | ### keyCollection.length ⇒ number Returns the number of keys in the collection. -**Kind**: instance property of [KeyCollection](#KeyCollection) +**Kind**: instance property of [KeyCollection](#KeyCollection) ### keyCollection.isEmpty() ⇒ boolean Returns `true` if the collection contains no keys. -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) ### keyCollection.keypair(index) ⇒ [KeyPair](#KeyPair) \| undefined Returns the keypair at the specified `index`. -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| index | number | +| index | number | ### keyCollection.public(index) ⇒ string \| undefined Returns the public key at the specified `index` as a base58-encoded string. -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| index | number | +| index | number | - + -### keyCollection.secret(index) ⇒ string \| undefined -Returns the secret key at the specified `index` as a base58-encoded string. +### keyCollection.private(index) ⇒ string \| undefined +Returns the private key at the specified `index` as a base58-encoded string. -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| index | number | +| index | number | ### keyCollection.merkleRoot(digest) ⇒ string -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| digest | number | +| digest | number | ### keyCollection.merkleProof(digest, index) ⇒ string \| undefined -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| digest | number | -| index | number | +| digest | number | +| index | number | ### keyCollection.toJSON() ⇒ any Serializes a `KeyCollection` object as a JSON object. -**Kind**: instance method of [KeyCollection](#KeyCollection) +**Kind**: instance method of [KeyCollection](#KeyCollection) ### KeyCollection.fromJSON(json) ⇒ [KeyCollection](#KeyCollection) Deserializes a `KeyCollection` object from a JSON object. -**Kind**: static method of [KeyCollection](#KeyCollection) +**Kind**: static method of [KeyCollection](#KeyCollection) | Param | Type | | --- | --- | -| json | any | +| json | any | ## KeyPair -**Kind**: global class +**Kind**: global class * [KeyPair](#KeyPair) * [new KeyPair(type_)](#new_KeyPair_new) * _instance_ * [.public](#KeyPair+public) ⇒ string - * [.secret](#KeyPair+secret) ⇒ string + * [.private](#KeyPair+private) ⇒ string * [.toJSON()](#KeyPair+toJSON) ⇒ any * _static_ - * [.fromBase58(type_, public_key, secret_key)](#KeyPair.fromBase58) ⇒ [KeyPair](#KeyPair) + * [.fromBase58(type_, public_key, private_key)](#KeyPair.fromBase58) ⇒ [KeyPair](#KeyPair) * [.fromJSON(json)](#KeyPair.fromJSON) ⇒ [KeyPair](#KeyPair) @@ -1545,54 +1545,54 @@ Generates a new `KeyPair` object. | Param | Type | | --- | --- | -| type_ | number | +| type_ | number | ### keyPair.public ⇒ string Returns the public key as a base58-encoded string. -**Kind**: instance property of [KeyPair](#KeyPair) - +**Kind**: instance property of [KeyPair](#KeyPair) + -### keyPair.secret ⇒ string -Returns the secret key as a base58-encoded string. +### keyPair.private ⇒ string +Returns the private key as a base58-encoded string. -**Kind**: instance property of [KeyPair](#KeyPair) +**Kind**: instance property of [KeyPair](#KeyPair) ### keyPair.toJSON() ⇒ any Serializes a `KeyPair` object as a JSON object. -**Kind**: instance method of [KeyPair](#KeyPair) +**Kind**: instance method of [KeyPair](#KeyPair) -### KeyPair.fromBase58(type_, public_key, secret_key) ⇒ [KeyPair](#KeyPair) -Parses a `KeyPair` object from base58-encoded public/secret keys. +### KeyPair.fromBase58(type_, public_key, private_key) ⇒ [KeyPair](#KeyPair) +Parses a `KeyPair` object from base58-encoded public/private keys. -**Kind**: static method of [KeyPair](#KeyPair) +**Kind**: static method of [KeyPair](#KeyPair) | Param | Type | | --- | --- | -| type_ | number | -| public_key | string | -| secret_key | string | +| type_ | number | +| public_key | string | +| private_key | string | ### KeyPair.fromJSON(json) ⇒ [KeyPair](#KeyPair) Deserializes a `KeyPair` object from a JSON object. -**Kind**: static method of [KeyPair](#KeyPair) +**Kind**: static method of [KeyPair](#KeyPair) | Param | Type | | --- | --- | -| json | any | +| json | any | ## Network -**Kind**: global class +**Kind**: global class * [Network](#Network) * _instance_ @@ -1610,51 +1610,51 @@ Deserializes a `KeyPair` object from a JSON object. ### network.defaultNodeURL ⇒ string \| undefined Returns the node URL of the Tangle network. -**Kind**: instance property of [Network](#Network) +**Kind**: instance property of [Network](#Network) ### network.explorerURL ⇒ string \| undefined Returns the web explorer URL of the Tangle network. -**Kind**: instance property of [Network](#Network) +**Kind**: instance property of [Network](#Network) ### network.messageURL(message_id) ⇒ string Returns the web explorer URL of the given `message`. -**Kind**: instance method of [Network](#Network) +**Kind**: instance method of [Network](#Network) | Param | Type | | --- | --- | -| message_id | string | +| message_id | string | ### network.toString() ⇒ string -**Kind**: instance method of [Network](#Network) +**Kind**: instance method of [Network](#Network) ### Network.try\_from\_name(name) ⇒ [Network](#Network) Parses the provided string to a [`WasmNetwork`]. -**Kind**: static method of [Network](#Network) +**Kind**: static method of [Network](#Network) | Param | Type | | --- | --- | -| name | string | +| name | string | ### Network.mainnet() ⇒ [Network](#Network) -**Kind**: static method of [Network](#Network) +**Kind**: static method of [Network](#Network) ### Network.devnet() ⇒ [Network](#Network) -**Kind**: static method of [Network](#Network) +**Kind**: static method of [Network](#Network) ## NewDocument -**Kind**: global class +**Kind**: global class * [NewDocument](#NewDocument) * [.key](#NewDocument+key) ⇒ [KeyPair](#KeyPair) @@ -1663,15 +1663,15 @@ Parses the provided string to a [`WasmNetwork`]. ### newDocument.key ⇒ [KeyPair](#KeyPair) -**Kind**: instance property of [NewDocument](#NewDocument) +**Kind**: instance property of [NewDocument](#NewDocument) ### newDocument.doc ⇒ [Document](#Document) -**Kind**: instance property of [NewDocument](#NewDocument) +**Kind**: instance property of [NewDocument](#NewDocument) ## PresentationRequest -**Kind**: global class +**Kind**: global class * [PresentationRequest](#PresentationRequest) * _instance_ @@ -1682,20 +1682,20 @@ Parses the provided string to a [`WasmNetwork`]. ### presentationRequest.toJSON() ⇒ any -**Kind**: instance method of [PresentationRequest](#PresentationRequest) +**Kind**: instance method of [PresentationRequest](#PresentationRequest) ### PresentationRequest.fromJSON(value) ⇒ [PresentationRequest](#PresentationRequest) -**Kind**: static method of [PresentationRequest](#PresentationRequest) +**Kind**: static method of [PresentationRequest](#PresentationRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## PresentationResponse -**Kind**: global class +**Kind**: global class * [PresentationResponse](#PresentationResponse) * _instance_ @@ -1706,20 +1706,20 @@ Parses the provided string to a [`WasmNetwork`]. ### presentationResponse.toJSON() ⇒ any -**Kind**: instance method of [PresentationResponse](#PresentationResponse) +**Kind**: instance method of [PresentationResponse](#PresentationResponse) ### PresentationResponse.fromJSON(value) ⇒ [PresentationResponse](#PresentationResponse) -**Kind**: static method of [PresentationResponse](#PresentationResponse) +**Kind**: static method of [PresentationResponse](#PresentationResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## ResolutionRequest -**Kind**: global class +**Kind**: global class * [ResolutionRequest](#ResolutionRequest) * _instance_ @@ -1730,20 +1730,20 @@ Parses the provided string to a [`WasmNetwork`]. ### resolutionRequest.toJSON() ⇒ any -**Kind**: instance method of [ResolutionRequest](#ResolutionRequest) +**Kind**: instance method of [ResolutionRequest](#ResolutionRequest) ### ResolutionRequest.fromJSON(value) ⇒ [ResolutionRequest](#ResolutionRequest) -**Kind**: static method of [ResolutionRequest](#ResolutionRequest) +**Kind**: static method of [ResolutionRequest](#ResolutionRequest) | Param | Type | | --- | --- | -| value | any | +| value | any | ## ResolutionResponse -**Kind**: global class +**Kind**: global class * [ResolutionResponse](#ResolutionResponse) * _instance_ @@ -1754,20 +1754,20 @@ Parses the provided string to a [`WasmNetwork`]. ### resolutionResponse.toJSON() ⇒ any -**Kind**: instance method of [ResolutionResponse](#ResolutionResponse) +**Kind**: instance method of [ResolutionResponse](#ResolutionResponse) ### ResolutionResponse.fromJSON(value) ⇒ [ResolutionResponse](#ResolutionResponse) -**Kind**: static method of [ResolutionResponse](#ResolutionResponse) +**Kind**: static method of [ResolutionResponse](#ResolutionResponse) | Param | Type | | --- | --- | -| value | any | +| value | any | ## Service -**Kind**: global class +**Kind**: global class * [Service](#Service) * _instance_ @@ -1780,22 +1780,22 @@ Parses the provided string to a [`WasmNetwork`]. ### service.toJSON() ⇒ any Serializes a `Service` object as a JSON object. -**Kind**: instance method of [Service](#Service) +**Kind**: instance method of [Service](#Service) ### Service.fromJSON(value) ⇒ [Service](#Service) Deserializes a `Service` object from a JSON object. -**Kind**: static method of [Service](#Service) +**Kind**: static method of [Service](#Service) | Param | Type | | --- | --- | -| value | any | +| value | any | ## Timestamp -**Kind**: global class +**Kind**: global class * [Timestamp](#Timestamp) * _instance_ @@ -1809,28 +1809,28 @@ Deserializes a `Service` object from a JSON object. ### timestamp.toRFC3339() ⇒ string Returns the `Timestamp` as an RFC 3339 `String`. -**Kind**: instance method of [Timestamp](#Timestamp) +**Kind**: instance method of [Timestamp](#Timestamp) ### Timestamp.parse(input) ⇒ [Timestamp](#Timestamp) Parses a `Timestamp` from the provided input string. -**Kind**: static method of [Timestamp](#Timestamp) +**Kind**: static method of [Timestamp](#Timestamp) | Param | Type | | --- | --- | -| input | string | +| input | string | ### Timestamp.nowUTC() ⇒ [Timestamp](#Timestamp) Creates a new `Timestamp` with the current date and time. -**Kind**: static method of [Timestamp](#Timestamp) +**Kind**: static method of [Timestamp](#Timestamp) ## Timing -**Kind**: global class +**Kind**: global class * [Timing](#Timing) * _instance_ @@ -1853,98 +1853,98 @@ Creates a new `Timestamp` with the current date and time. ### timing.outTime ⇒ string \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.outTime -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | string | +| value | string | ### timing.inTime ⇒ string \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.inTime -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | string | +| value | string | ### timing.staleTime ⇒ string \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.staleTime -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | string | +| value | string | ### timing.expiresTime ⇒ string \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.expiresTime -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | string | +| value | string | ### timing.waitUntilTime ⇒ string \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.waitUntilTime -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | string | +| value | string | ### timing.delayMilli ⇒ number \| undefined -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) ### timing.delayMilli -**Kind**: instance property of [Timing](#Timing) +**Kind**: instance property of [Timing](#Timing) | Param | Type | | --- | --- | -| value | number | +| value | number | ### timing.toJSON() ⇒ any -**Kind**: instance method of [Timing](#Timing) +**Kind**: instance method of [Timing](#Timing) ### Timing.fromJSON(value) ⇒ [Timing](#Timing) -**Kind**: static method of [Timing](#Timing) +**Kind**: static method of [Timing](#Timing) | Param | Type | | --- | --- | -| value | any | +| value | any | ## TrustPing -**Kind**: global class +**Kind**: global class * [TrustPing](#TrustPing) * _instance_ @@ -1955,20 +1955,20 @@ Creates a new `Timestamp` with the current date and time. ### trustPing.toJSON() ⇒ any -**Kind**: instance method of [TrustPing](#TrustPing) +**Kind**: instance method of [TrustPing](#TrustPing) ### TrustPing.fromJSON(value) ⇒ [TrustPing](#TrustPing) -**Kind**: static method of [TrustPing](#TrustPing) +**Kind**: static method of [TrustPing](#TrustPing) | Param | Type | | --- | --- | -| value | any | +| value | any | ## TrustedIssuer -**Kind**: global class +**Kind**: global class * [TrustedIssuer](#TrustedIssuer) * _instance_ @@ -1979,20 +1979,20 @@ Creates a new `Timestamp` with the current date and time. ### trustedIssuer.toJSON() ⇒ any -**Kind**: instance method of [TrustedIssuer](#TrustedIssuer) +**Kind**: instance method of [TrustedIssuer](#TrustedIssuer) ### TrustedIssuer.fromJSON(value) ⇒ [TrustedIssuer](#TrustedIssuer) -**Kind**: static method of [TrustedIssuer](#TrustedIssuer) +**Kind**: static method of [TrustedIssuer](#TrustedIssuer) | Param | Type | | --- | --- | -| value | any | +| value | any | ## VerifiableCredential -**Kind**: global class +**Kind**: global class * [VerifiableCredential](#VerifiableCredential) * _instance_ @@ -2007,43 +2007,43 @@ Creates a new `Timestamp` with the current date and time. ### verifiableCredential.toJSON() ⇒ any Serializes a `VerifiableCredential` object as a JSON object. -**Kind**: instance method of [VerifiableCredential](#VerifiableCredential) +**Kind**: instance method of [VerifiableCredential](#VerifiableCredential) ### VerifiableCredential.extend(value) ⇒ [VerifiableCredential](#VerifiableCredential) -**Kind**: static method of [VerifiableCredential](#VerifiableCredential) +**Kind**: static method of [VerifiableCredential](#VerifiableCredential) | Param | Type | | --- | --- | -| value | any | +| value | any | ### VerifiableCredential.issue(issuer_doc, subject_data, credential_type, credential_id) ⇒ [VerifiableCredential](#VerifiableCredential) -**Kind**: static method of [VerifiableCredential](#VerifiableCredential) +**Kind**: static method of [VerifiableCredential](#VerifiableCredential) | Param | Type | | --- | --- | -| issuer_doc | [Document](#Document) | -| subject_data | any | -| credential_type | string \| undefined | -| credential_id | string \| undefined | +| issuer_doc | [Document](#Document) | +| subject_data | any | +| credential_type | string \| undefined | +| credential_id | string \| undefined | ### VerifiableCredential.fromJSON(json) ⇒ [VerifiableCredential](#VerifiableCredential) Deserializes a `VerifiableCredential` object from a JSON object. -**Kind**: static method of [VerifiableCredential](#VerifiableCredential) +**Kind**: static method of [VerifiableCredential](#VerifiableCredential) | Param | Type | | --- | --- | -| json | any | +| json | any | ## VerifiablePresentation -**Kind**: global class +**Kind**: global class * [VerifiablePresentation](#VerifiablePresentation) * [new VerifiablePresentation(holder_doc, credential_data, presentation_type, presentation_id)](#new_VerifiablePresentation_new) @@ -2058,32 +2058,32 @@ Deserializes a `VerifiableCredential` object from a JSON object. | Param | Type | | --- | --- | -| holder_doc | [Document](#Document) | -| credential_data | any | -| presentation_type | string \| undefined | -| presentation_id | string \| undefined | +| holder_doc | [Document](#Document) | +| credential_data | any | +| presentation_type | string \| undefined | +| presentation_id | string \| undefined | ### verifiablePresentation.toJSON() ⇒ any Serializes a `VerifiablePresentation` object as a JSON object. -**Kind**: instance method of [VerifiablePresentation](#VerifiablePresentation) +**Kind**: instance method of [VerifiablePresentation](#VerifiablePresentation) ### VerifiablePresentation.fromJSON(json) ⇒ [VerifiablePresentation](#VerifiablePresentation) Deserializes a `VerifiablePresentation` object from a JSON object. -**Kind**: static method of [VerifiablePresentation](#VerifiablePresentation) +**Kind**: static method of [VerifiablePresentation](#VerifiablePresentation) | Param | Type | | --- | --- | -| json | any | +| json | any | ## VerificationMethod -**Kind**: global class +**Kind**: global class * [VerificationMethod](#VerificationMethod) * [new VerificationMethod(key, tag)](#new_VerificationMethod_new) @@ -2106,88 +2106,88 @@ Creates a new `VerificationMethod` object from the given `key`. | Param | Type | | --- | --- | -| key | [KeyPair](#KeyPair) | -| tag | string \| undefined | +| key | [KeyPair](#KeyPair) | +| tag | string \| undefined | ### verificationMethod.id ⇒ [DID](#DID) Returns the `id` DID of the `VerificationMethod` object. -**Kind**: instance property of [VerificationMethod](#VerificationMethod) +**Kind**: instance property of [VerificationMethod](#VerificationMethod) ### verificationMethod.controller ⇒ [DID](#DID) Returns the `controller` DID of the `VerificationMethod` object. -**Kind**: instance property of [VerificationMethod](#VerificationMethod) +**Kind**: instance property of [VerificationMethod](#VerificationMethod) ### verificationMethod.type ⇒ string Returns the `VerificationMethod` type. -**Kind**: instance property of [VerificationMethod](#VerificationMethod) +**Kind**: instance property of [VerificationMethod](#VerificationMethod) ### verificationMethod.data ⇒ any Returns the `VerificationMethod` public key data. -**Kind**: instance property of [VerificationMethod](#VerificationMethod) +**Kind**: instance property of [VerificationMethod](#VerificationMethod) ### verificationMethod.toJSON() ⇒ any Serializes a `VerificationMethod` object as a JSON object. -**Kind**: instance method of [VerificationMethod](#VerificationMethod) +**Kind**: instance method of [VerificationMethod](#VerificationMethod) ### VerificationMethod.fromDID(did, key, tag) ⇒ [VerificationMethod](#VerificationMethod) Creates a new `VerificationMethod` object from the given `did` and `key`. -**Kind**: static method of [VerificationMethod](#VerificationMethod) +**Kind**: static method of [VerificationMethod](#VerificationMethod) | Param | Type | | --- | --- | -| did | [DID](#DID) | -| key | [KeyPair](#KeyPair) | -| tag | string \| undefined | +| did | [DID](#DID) | +| key | [KeyPair](#KeyPair) | +| tag | string \| undefined | ### VerificationMethod.createMerkleKey(digest, did, keys, tag) ⇒ [VerificationMethod](#VerificationMethod) Creates a new Merkle Key Collection Method from the given key collection. -**Kind**: static method of [VerificationMethod](#VerificationMethod) +**Kind**: static method of [VerificationMethod](#VerificationMethod) | Param | Type | | --- | --- | -| digest | number | -| did | [DID](#DID) | -| keys | [KeyCollection](#KeyCollection) | -| tag | string \| undefined | +| digest | number | +| did | [DID](#DID) | +| keys | [KeyCollection](#KeyCollection) | +| tag | string \| undefined | ### VerificationMethod.fromJSON(value) ⇒ [VerificationMethod](#VerificationMethod) Deserializes a `VerificationMethod` object from a JSON object. -**Kind**: static method of [VerificationMethod](#VerificationMethod) +**Kind**: static method of [VerificationMethod](#VerificationMethod) | Param | Type | | --- | --- | -| value | any | +| value | any | ## Digest -**Kind**: global variable +**Kind**: global variable ## KeyType -**Kind**: global variable +**Kind**: global variable ## start() Initializes the console error panic hook for better error messages -**Kind**: global function +**Kind**: global function diff --git a/bindings/wasm/examples/src/create_vc.js b/bindings/wasm/examples/src/create_vc.js index 5769ea7fa5..63167e5054 100644 --- a/bindings/wasm/examples/src/create_vc.js +++ b/bindings/wasm/examples/src/create_vc.js @@ -45,7 +45,7 @@ async function createVC(clientConfig) { const signedVc = issuer.doc.signCredential(unsignedVc, { method: issuer.doc.id.toString() + "#newKey", public: issuer.newKey.public, - secret: issuer.newKey.secret, + private: issuer.newKey.private, }); // Check if the credential is verifiable. diff --git a/bindings/wasm/examples/src/create_vp.js b/bindings/wasm/examples/src/create_vp.js index 3b815523c4..41bbd8b246 100644 --- a/bindings/wasm/examples/src/create_vp.js +++ b/bindings/wasm/examples/src/create_vp.js @@ -27,7 +27,7 @@ async function createVP(clientConfig) { const signedVp = alice.doc.signPresentation(unsignedVp, { method: "#key", - secret: alice.key.secret, + private: alice.key.private, }) // Check the validation status of the Verifiable Presentation diff --git a/bindings/wasm/examples/src/merkle_key.js b/bindings/wasm/examples/src/merkle_key.js index cf251308dc..376d9e8e8c 100644 --- a/bindings/wasm/examples/src/merkle_key.js +++ b/bindings/wasm/examples/src/merkle_key.js @@ -70,7 +70,7 @@ async function merkleKey(clientConfig) { const signedVc = issuer.doc.signCredential(unsignedVc, { method: method.id.toString(), public: keys.public(0), - secret: keys.secret(0), + private: keys.private(0), proof: keys.merkleProof(Digest.Sha256, 0) }); diff --git a/bindings/wasm/src/crypto/key_collection.rs b/bindings/wasm/src/crypto/key_collection.rs index ab675806ae..08ce0821ea 100644 --- a/bindings/wasm/src/crypto/key_collection.rs +++ b/bindings/wasm/src/crypto/key_collection.rs @@ -7,8 +7,8 @@ use identity::crypto::merkle_key::Blake2b256; use identity::crypto::merkle_key::Sha256; use identity::crypto::merkle_tree::Proof; use identity::crypto::KeyCollection as KeyCollection_; +use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::crypto::SecretKey; use wasm_bindgen::prelude::*; use crate::crypto::Digest; @@ -26,7 +26,7 @@ struct JsonData { #[derive(Deserialize, Serialize)] struct KeyData { public: String, - secret: String, + private: String, } // ============================================================================= @@ -68,10 +68,10 @@ impl KeyCollection { self.0.public(index).map(encode_b58) } - /// Returns the secret key at the specified `index` as a base58-encoded string. + /// Returns the private key at the specified `index` as a base58-encoded string. #[wasm_bindgen] - pub fn secret(&self, index: usize) -> Option { - self.0.secret(index).map(encode_b58) + pub fn private(&self, index: usize) -> Option { + self.0.private(index).map(encode_b58) } #[wasm_bindgen(js_name = merkleRoot)] @@ -108,13 +108,13 @@ impl KeyCollection { #[wasm_bindgen(js_name = toJSON)] pub fn to_json(&self) -> Result { let public: _ = self.0.iter_public(); - let secret: _ = self.0.iter_secret(); + let private: _ = self.0.iter_private(); let keys: Vec = public - .zip(secret) - .map(|(public, secret)| KeyData { + .zip(private) + .map(|(public, private)| KeyData { public: encode_b58(public), - secret: encode_b58(secret), + private: encode_b58(private), }) .collect(); @@ -133,7 +133,7 @@ impl KeyCollection { let iter: _ = data.keys.iter().flat_map(|data| { let pk: PublicKey = decode_b58(&data.public).ok()?.into(); - let sk: SecretKey = decode_b58(&data.secret).ok()?.into(); + let sk: PrivateKey = decode_b58(&data.private).ok()?.into(); Some((pk, sk)) }); diff --git a/bindings/wasm/src/crypto/key_pair.rs b/bindings/wasm/src/crypto/key_pair.rs index d28b78ee39..2f5f41da62 100644 --- a/bindings/wasm/src/crypto/key_pair.rs +++ b/bindings/wasm/src/crypto/key_pair.rs @@ -4,8 +4,8 @@ use identity::core::decode_b58; use identity::core::encode_b58; use identity::crypto::KeyPair as KeyPair_; +use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::crypto::SecretKey; use wasm_bindgen::prelude::*; use crate::crypto::KeyType; @@ -16,7 +16,7 @@ struct JsonData { #[serde(rename = "type")] type_: KeyType, public: String, - secret: String, + private: String, } // ============================================================================= @@ -34,13 +34,13 @@ impl KeyPair { KeyPair_::new(type_.into()).map_err(wasm_error).map(Self) } - /// Parses a `KeyPair` object from base58-encoded public/secret keys. + /// Parses a `KeyPair` object from base58-encoded public/private keys. #[wasm_bindgen(js_name = fromBase58)] - pub fn from_base58(type_: KeyType, public_key: &str, secret_key: &str) -> Result { + pub fn from_base58(type_: KeyType, public_key: &str, private_key: &str) -> Result { let public: PublicKey = decode_b58(public_key).map_err(wasm_error)?.into(); - let secret: SecretKey = decode_b58(secret_key).map_err(wasm_error)?.into(); + let private: PrivateKey = decode_b58(private_key).map_err(wasm_error)?.into(); - Ok(Self((type_.into(), public, secret).into())) + Ok(Self((type_.into(), public, private).into())) } /// Returns the public key as a base58-encoded string. @@ -49,10 +49,10 @@ impl KeyPair { encode_b58(self.0.public()) } - /// Returns the secret key as a base58-encoded string. + /// Returns the private key as a base58-encoded string. #[wasm_bindgen(getter)] - pub fn secret(&self) -> String { - encode_b58(self.0.secret()) + pub fn private(&self) -> String { + encode_b58(self.0.private()) } /// Serializes a `KeyPair` object as a JSON object. @@ -61,7 +61,7 @@ impl KeyPair { let data: JsonData = JsonData { type_: self.0.type_().into(), public: self.public(), - secret: self.secret(), + private: self.private(), }; JsValue::from_serde(&data).map_err(wasm_error) @@ -72,6 +72,6 @@ impl KeyPair { pub fn from_json(json: &JsValue) -> Result { let data: JsonData = json.into_serde().map_err(wasm_error)?; - Self::from_base58(data.type_, &data.public, &data.secret) + Self::from_base58(data.type_, &data.public, &data.private) } } diff --git a/bindings/wasm/src/did/wasm_document.rs b/bindings/wasm/src/did/wasm_document.rs index 27e74478ab..f6ec4446c8 100644 --- a/bindings/wasm/src/did/wasm_document.rs +++ b/bindings/wasm/src/did/wasm_document.rs @@ -8,8 +8,8 @@ use identity::crypto::merkle_key::MerkleDigestTag; use identity::crypto::merkle_key::MerkleKey; use identity::crypto::merkle_key::Sha256; use identity::crypto::merkle_tree::Proof; +use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::crypto::SecretKey; use identity::did::verifiable; use identity::did::MethodScope; use identity::iota::Error; @@ -209,7 +209,7 @@ impl WasmDocument { /// Signs the DID Document with the default authentication method. #[wasm_bindgen] pub fn sign(&mut self, key: &KeyPair) -> Result<()> { - self.0.sign(key.0.secret()).wasm_result() + self.0.sign(key.0.private()).wasm_result() } /// Verify the signature with the authentication_key @@ -247,12 +247,12 @@ impl WasmDocument { MerkleKey { method: String, public: String, - secret: String, + private: String, proof: String, }, Default { method: String, - secret: String, + private: String, }, } @@ -263,7 +263,7 @@ impl WasmDocument { Args::MerkleKey { method, public, - secret, + private, proof, } => { let merkle_key: Vec = self @@ -273,12 +273,12 @@ impl WasmDocument { .wasm_result()?; let public: PublicKey = decode_b58(&public).map(Into::into).wasm_result()?; - let secret: SecretKey = decode_b58(&secret).map(Into::into).wasm_result()?; + let private: PrivateKey = decode_b58(&private).map(Into::into).wasm_result()?; let digest: MerkleDigestTag = MerkleKey::extract_tags(&merkle_key).wasm_result()?.1; let proof: Vec = decode_b58(&proof).wasm_result()?; - let signer: _ = self.0.signer(&secret).method(&method); + let signer: _ = self.0.signer(&private).method(&method); match digest { MerkleDigestTag::SHA256 => match Proof::::decode(&proof) { @@ -288,10 +288,10 @@ impl WasmDocument { _ => return Err("Invalid Merkle Key Digest".into()), } } - Args::Default { method, secret } => { - let secret: SecretKey = decode_b58(&secret).wasm_result().map(Into::into)?; + Args::Default { method, private } => { + let private: PrivateKey = decode_b58(&private).wasm_result().map(Into::into)?; - self.0.signer(&secret).method(&method).sign(&mut data).wasm_result()?; + self.0.signer(&private).method(&method).sign(&mut data).wasm_result()?; } } @@ -332,7 +332,7 @@ impl WasmDocument { pub fn diff(&self, other: &WasmDocument, message: &str, key: &KeyPair) -> Result { self .0 - .diff(&other.0, MessageId::from_str(message).wasm_result()?, key.0.secret()) + .diff(&other.0, MessageId::from_str(message).wasm_result()?, key.0.private()) .map(WasmDocumentDiff::from) .wasm_result() } diff --git a/bindings/wasm/tests/wasm.rs b/bindings/wasm/tests/wasm.rs index 2967d3c1ab..c76975077b 100644 --- a/bindings/wasm/tests/wasm.rs +++ b/bindings/wasm/tests/wasm.rs @@ -15,9 +15,9 @@ use std::borrow::Cow; #[wasm_bindgen_test] fn test_keypair() { let key1 = KeyPair::new(KeyType::Ed25519).unwrap(); - let pk = key1.public(); - let sk = key1.secret(); - let key2 = KeyPair::from_base58(KeyType::Ed25519, &pk, &sk).unwrap(); + let public_key = key1.public(); + let private_key = key1.private(); + let key2 = KeyPair::from_base58(KeyType::Ed25519, &public_key, &private_key).unwrap(); let json1 = key1.to_json().unwrap(); let json2 = key2.to_json().unwrap(); @@ -26,10 +26,10 @@ fn test_keypair() { let from2 = KeyPair::from_json(&json2).unwrap(); assert_eq!(from1.public(), key1.public()); - assert_eq!(from1.secret(), key1.secret()); + assert_eq!(from1.private(), key1.private()); assert_eq!(from2.public(), key2.public()); - assert_eq!(from2.secret(), key2.secret()); + assert_eq!(from2.private(), key2.private()); } #[wasm_bindgen_test] @@ -44,7 +44,7 @@ fn test_key_collection() { let key = keys.keypair(index).unwrap(); assert_eq!(key.public(), keys.public(index).unwrap()); - assert_eq!(key.secret(), keys.secret(index).unwrap()); + assert_eq!(key.private(), keys.private(index).unwrap()); assert!(keys.merkle_proof(Digest::Sha256, index).is_some()); } @@ -57,7 +57,7 @@ fn test_key_collection() { for index in 0..keys.length() { assert_eq!(keys.public(index).unwrap(), from.public(index).unwrap()); - assert_eq!(keys.secret(index).unwrap(), from.secret(index).unwrap()); + assert_eq!(keys.private(index).unwrap(), from.private(index).unwrap()); } } diff --git a/examples/low-level-api/common.rs b/examples/low-level-api/common.rs index 1b40ef7eae..68bc365564 100644 --- a/examples/low-level-api/common.rs +++ b/examples/low-level-api/common.rs @@ -76,7 +76,7 @@ pub async fn add_new_key( // Prepare the update updated_doc.set_previous_message_id(*receipt.message_id()); updated_doc.set_updated(Timestamp::now_utc()); - updated_doc.sign(key.secret())?; + updated_doc.sign(key.private())?; // Publish the update to the Tangle let update_receipt: Receipt = client.publish_document(&updated_doc).await?; diff --git a/examples/low-level-api/create_did.rs b/examples/low-level-api/create_did.rs index 6b1fb075df..e21bfe2693 100644 --- a/examples/low-level-api/create_did.rs +++ b/examples/low-level-api/create_did.rs @@ -21,7 +21,7 @@ pub async fn run() -> Result<(IotaDocument, KeyPair, Receipt)> { let mut document: IotaDocument = IotaDocument::from_keypair(&keypair)?; // Sign the DID Document with the default authentication key. - document.sign(keypair.secret())?; + document.sign(keypair.private())?; println!("DID Document JSON > {:#}", document); diff --git a/examples/low-level-api/create_vc.rs b/examples/low-level-api/create_vc.rs index f5972c75d1..e30761742a 100644 --- a/examples/low-level-api/create_vc.rs +++ b/examples/low-level-api/create_vc.rs @@ -29,8 +29,8 @@ pub async fn create_vc() -> Result<()> { // Create an unsigned Credential with claims about `subject` specified by `issuer`. let mut credential: Credential = common::issue_degree(&issuer_doc, &subject_doc)?; - // Sign the Credential with the issuer's secret key - issuer_doc.sign_data(&mut credential, issuer_key.secret())?; + // Sign the Credential with the issuer's private key. + issuer_doc.sign_data(&mut credential, issuer_key.private())?; println!("Credential JSON > {:#}", credential); diff --git a/examples/low-level-api/create_vp.rs b/examples/low-level-api/create_vp.rs index b5503c416b..be862fbe6e 100644 --- a/examples/low-level-api/create_vp.rs +++ b/examples/low-level-api/create_vp.rs @@ -30,8 +30,8 @@ pub async fn create_vp() -> Result { // Create an unsigned Credential with claims about `subject` specified by `issuer`. let mut credential: Credential = common::issue_degree(&doc_iss, &doc_sub)?; - // Sign the Credential with the issuers secret key - doc_iss.sign_data(&mut credential, key_iss.secret())?; + // Sign the Credential with the issuers private key. + doc_iss.sign_data(&mut credential, key_iss.private())?; // Create an unsigned Presentation from the previously issued Verifiable Credential. let mut presentation: Presentation = PresentationBuilder::default() @@ -40,8 +40,8 @@ pub async fn create_vp() -> Result { .credential(credential) .build()?; - // Sign the presentation with the holders secret key - doc_sub.sign_data(&mut presentation, key_sub.secret())?; + // Sign the presentation with the holders private key. + doc_sub.sign_data(&mut presentation, key_sub.private())?; Ok(presentation) } diff --git a/examples/low-level-api/diff_chain.rs b/examples/low-level-api/diff_chain.rs index 8214c1a502..59f460ebae 100644 --- a/examples/low-level-api/diff_chain.rs +++ b/examples/low-level-api/diff_chain.rs @@ -38,7 +38,7 @@ async fn main() -> Result<()> { }; // Generate a signed diff object. - let diff: DocumentDiff = document.diff(&updated_document, *receipt.message_id(), keypair.secret())?; + let diff: DocumentDiff = document.diff(&updated_document, *receipt.message_id(), keypair.private())?; println!("Diff > {:#?}", diff); diff --git a/examples/low-level-api/manipulate_did.rs b/examples/low-level-api/manipulate_did.rs index be6603131c..ee0364fef3 100644 --- a/examples/low-level-api/manipulate_did.rs +++ b/examples/low-level-api/manipulate_did.rs @@ -44,7 +44,7 @@ pub async fn run() -> Result<(IotaDocument, KeyPair, KeyPair, Receipt, Receipt)> document.set_updated(Timestamp::now_utc()); // Sign the DID Document with the original private key. - document.sign(keypair.secret())?; + document.sign(keypair.private())?; // Publish the updated DID Document to the Tangle. let update_receipt: Receipt = client.publish_document(&document).await?; diff --git a/examples/low-level-api/merkle_key.rs b/examples/low-level-api/merkle_key.rs index dae2699bfd..75e03f8846 100644 --- a/examples/low-level-api/merkle_key.rs +++ b/examples/low-level-api/merkle_key.rs @@ -13,8 +13,8 @@ use identity::credential::Credential; use identity::crypto::merkle_key::Sha256; use identity::crypto::merkle_tree::Proof; use identity::crypto::KeyCollection; +use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::crypto::SecretKey; use identity::did::MethodScope; use identity::iota::ClientMap; use identity::iota::CredentialValidation; @@ -46,7 +46,7 @@ async fn main() -> Result<()> { // Add to the DID Document as a general-purpose verification method issuer_doc.insert_method(MethodScope::VerificationMethod, method); issuer_doc.set_previous_message_id(*issuer_receipt.message_id()); - issuer_doc.sign(issuer_key.secret())?; + issuer_doc.sign(issuer_key.private())?; // Publish the Identity to the IOTA Network and log the results. // This may take a few seconds to complete proof-of-work. @@ -60,14 +60,14 @@ async fn main() -> Result<()> { let index: usize = OsRng.gen_range(0..keys.len()); let public: &PublicKey = keys.public(index).unwrap(); - let secret: &SecretKey = keys.secret(index).unwrap(); + let private: &PrivateKey = keys.private(index).unwrap(); // Generate an inclusion proof for the selected key let proof: Proof = keys.merkle_proof(index).unwrap(); - // Sign the Credential with the issuers secret key + // Sign the Credential with the issuers private key issuer_doc - .signer(secret) + .signer(private) .method("merkle-key") .merkle_key((public, &proof)) .sign(&mut credential)?; @@ -89,7 +89,7 @@ async fn main() -> Result<()> { .and_then(IotaVerificationMethod::try_from_mut)? .revoke_merkle_key(index)?; issuer_doc.set_previous_message_id(*receipt.message_id()); - issuer_doc.sign(issuer_key.secret())?; + issuer_doc.sign(issuer_key.private())?; let receipt: Receipt = client.publish_document(&issuer_doc).await?; diff --git a/examples/low-level-api/private_tangle.rs b/examples/low-level-api/private_tangle.rs index 0aee4816b3..148f255ef8 100644 --- a/examples/low-level-api/private_tangle.rs +++ b/examples/low-level-api/private_tangle.rs @@ -39,7 +39,7 @@ pub async fn main() -> Result<()> { let mut document: IotaDocument = IotaDocument::from_keypair_with_network(&keypair, network_name)?; // Sign the DID Document with the default authentication key. - document.sign(keypair.secret())?; + document.sign(keypair.private())?; println!("DID Document JSON > {:#}", document); diff --git a/examples/low-level-api/resolve_history.rs b/examples/low-level-api/resolve_history.rs index 4e273e17de..682688bc22 100644 --- a/examples/low-level-api/resolve_history.rs +++ b/examples/low-level-api/resolve_history.rs @@ -66,7 +66,7 @@ async fn main() -> Result<()> { int_doc_1.set_updated(Timestamp::now_utc()); // Sign the DID Document with the original private key. - int_doc_1.sign(keypair.secret())?; + int_doc_1.sign(keypair.private())?; int_doc_1 }; @@ -98,7 +98,7 @@ async fn main() -> Result<()> { // // This is the first diff therefore the `previous_message_id` property is // set to the last DID document published. - let diff_1: DocumentDiff = int_doc_1.diff(&diff_doc_1, *int_receipt_1.message_id(), keypair.secret())?; + let diff_1: DocumentDiff = int_doc_1.diff(&diff_doc_1, *int_receipt_1.message_id(), keypair.private())?; // Publish the diff to the Tangle, starting a diff chain. let diff_receipt_1: Receipt = client.publish_diff(int_receipt_1.message_id(), &diff_1).await?; @@ -124,7 +124,7 @@ async fn main() -> Result<()> { // This is the second diff therefore its `previous_message_id` property is // set to the first published diff to extend the diff chain. - let diff_2: DocumentDiff = diff_doc_1.diff(&diff_doc_2, *diff_receipt_1.message_id(), keypair.secret())?; + let diff_2: DocumentDiff = diff_doc_1.diff(&diff_doc_2, *diff_receipt_1.message_id(), keypair.private())?; // Publish the diff to the Tangle. // Note that we still use the `message_id` from the last integration chain message here to link @@ -176,7 +176,7 @@ async fn main() -> Result<()> { // update, NOT the last diff chain message. int_doc_2.set_previous_message_id(*int_receipt_1.message_id()); int_doc_2.set_updated(Timestamp::now_utc()); - int_doc_2.sign(keypair.secret())?; + int_doc_2.sign(keypair.private())?; int_doc_2 }; diff --git a/examples/low-level-api/revoke_vc.rs b/examples/low-level-api/revoke_vc.rs index 5ed5e9ee0a..d1223aa030 100644 --- a/examples/low-level-api/revoke_vc.rs +++ b/examples/low-level-api/revoke_vc.rs @@ -36,7 +36,7 @@ async fn main() -> Result<()> { issuer_doc.remove_method(&issuer_doc.id().join("#newKey")?)?; issuer_doc.set_previous_message_id(*issuer_receipt.message_id()); issuer_doc.set_updated(Timestamp::now_utc()); - issuer_doc.sign(issuer_key.secret())?; + issuer_doc.sign(issuer_key.private())?; // This is an integration chain update, so we publish the full document. let update_receipt = client.publish_document(&issuer_doc).await?; @@ -74,8 +74,8 @@ async fn create_vc_helper( // Create an unsigned Credential with claims about `subject` specified by `issuer`. let mut credential: Credential = common::issue_degree(&issuer_doc, &subject_doc)?; - // Sign the Credential with the issuer's #newKey secret key, so we can later revoke it - issuer_doc.sign_data(&mut credential, issuer_new_key.secret())?; + // Sign the Credential with the issuer's #newKey private key, so we can later revoke it + issuer_doc.sign_data(&mut credential, issuer_new_key.private())?; let issuer = (issuer_doc, issuer_key, issuer_updated_receipt); Ok((issuer, credential)) @@ -101,7 +101,7 @@ pub async fn add_new_key( // Prepare the update updated_doc.set_previous_message_id(*receipt.message_id()); updated_doc.set_updated(Timestamp::now_utc()); - updated_doc.sign(key.secret())?; + updated_doc.sign(key.private())?; // Publish the update to the Tangle let update_receipt: Receipt = client.publish_document(&updated_doc).await?; diff --git a/identity-account/src/crypto/remote.rs b/identity-account/src/crypto/remote.rs index c60de98050..034c68f1dc 100644 --- a/identity-account/src/crypto/remote.rs +++ b/identity-account/src/crypto/remote.rs @@ -42,10 +42,10 @@ impl<'a, T> Sign for RemoteSign<'a, T> where T: Storage, { - type Secret = RemoteKey<'a, T>; + type Private = RemoteKey<'a, T>; type Output = Vec; - fn sign(message: &[u8], key: &Self::Secret) -> Result { + fn sign(message: &[u8], key: &Self::Private) -> Result { let future: _ = key.store.key_sign(key.id, key.location, message.to_vec()); executor::block_on(future) diff --git a/identity-account/src/error.rs b/identity-account/src/error.rs index cabd863626..fb48374a6d 100644 --- a/identity-account/src/error.rs +++ b/identity-account/src/error.rs @@ -91,8 +91,8 @@ pub enum Error { /// Caused by attempting to perform an upate in an invalid context. #[error("Update Error: {0}")] UpdateError(#[from] crate::events::UpdateError), - #[error("Invalid Secret Key: {0}")] - InvalidSecretKey(String), + #[error("Invalid Private Key: {0}")] + InvalidPrivateKey(String), } #[doc(hidden)] diff --git a/identity-account/src/events/command.rs b/identity-account/src/events/command.rs index 439b8cca6f..8b43e68357 100644 --- a/identity-account/src/events/command.rs +++ b/identity-account/src/events/command.rs @@ -99,8 +99,8 @@ impl Command { UpdateError::DuplicateKeyLocation(location) ); - let public: PublicKey = if let Some(method_secret_key) = method_secret { - insert_method_secret(store, state.id(), &location, authentication, method_secret_key).await + let public: PublicKey = if let Some(method_private_key) = method_secret { + insert_method_secret(store, state.id(), &location, authentication, method_private_key).await } else { store.key_new(state.id(), &location).await }?; @@ -148,8 +148,8 @@ impl Command { UpdateError::DuplicateKeyFragment(location.fragment.clone()), ); - let public: PublicKey = if let Some(method_secret_key) = method_secret { - insert_method_secret(store, state.id(), &location, type_, method_secret_key).await + let public: PublicKey = if let Some(method_private_key) = method_secret { + insert_method_secret(store, state.id(), &location, type_, method_private_key).await } else { store.key_new(state.id(), &location).await }?; @@ -252,13 +252,13 @@ async fn insert_method_secret( method_secret: MethodSecret, ) -> Result { match method_secret { - MethodSecret::Ed25519(secret_key) => { + MethodSecret::Ed25519(private_key) => { ensure!( - secret_key.as_ref().len() == ed25519::SECRET_KEY_LENGTH, + private_key.as_ref().len() == ed25519::SECRET_KEY_LENGTH, UpdateError::InvalidMethodSecret(format!( "an ed25519 secret key requires {} bytes, found {}", ed25519::SECRET_KEY_LENGTH, - secret_key.as_ref().len() + private_key.as_ref().len() )) ); @@ -269,7 +269,7 @@ async fn insert_method_secret( ) ); - store.key_insert(identity_id, location, secret_key).await + store.key_insert(identity_id, location, private_key).await } MethodSecret::MerkleKeyCollection(_) => { ensure!( diff --git a/identity-account/src/identity/identity_state.rs b/identity-account/src/identity/identity_state.rs index 97ebb66772..cf34c8be40 100644 --- a/identity-account/src/identity/identity_state.rs +++ b/identity-account/src/identity/identity_state.rs @@ -327,8 +327,8 @@ impl IdentityState { T: Storage, U: Serialize + SetSignature, { - // Create a secret key suitable for identity_core::crypto - let secret: RemoteKey<'_, T> = RemoteKey::new(self.id, location, store); + // Create a private key suitable for identity_core::crypto + let private: RemoteKey<'_, T> = RemoteKey::new(self.id, location, store); // Create the Verification Method identifier let fragment: &str = location.fragment.identifier(); @@ -336,7 +336,7 @@ impl IdentityState { match location.method() { MethodType::Ed25519VerificationKey2018 => { - RemoteEd25519::create_signature(target, method.as_str(), &secret)?; + RemoteEd25519::create_signature(target, method.as_str(), &private)?; } MethodType::MerkleKeyCollection2021 => { todo!("Handle MerkleKeyCollection2021") diff --git a/identity-account/src/storage/memstore.rs b/identity-account/src/storage/memstore.rs index 4cd277f71c..aacb09c9de 100644 --- a/identity-account/src/storage/memstore.rs +++ b/identity-account/src/storage/memstore.rs @@ -12,8 +12,8 @@ use hashbrown::HashMap; use identity_core::crypto::Ed25519; use identity_core::crypto::KeyPair; use identity_core::crypto::KeyType; +use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; use identity_core::crypto::Sign; use identity_did::verification::MethodType; use std::convert::TryFrom; @@ -116,23 +116,23 @@ impl Storage for MemStore { } } - async fn key_insert(&self, id: IdentityId, location: &KeyLocation, secret_key: SecretKey) -> Result { + async fn key_insert(&self, id: IdentityId, location: &KeyLocation, private_key: PrivateKey) -> Result { let mut vaults: RwLockWriteGuard<'_, _> = self.vaults.write()?; let vault: &mut MemVault = vaults.entry(id).or_default(); match location.method() { MethodType::Ed25519VerificationKey2018 => { - let mut secret_key_bytes: [u8; 32] = <[u8; 32]>::try_from(secret_key.as_ref()) - .map_err(|err| Error::InvalidSecretKey(format!("expected a slice of 32 bytes - {}", err)))?; + let mut private_key_bytes: [u8; 32] = <[u8; 32]>::try_from(private_key.as_ref()) + .map_err(|err| Error::InvalidPrivateKey(format!("expected a slice of 32 bytes - {}", err)))?; - let secret: ed25519::SecretKey = ed25519::SecretKey::from_bytes(secret_key_bytes); - secret_key_bytes.zeroize(); + let secret: ed25519::SecretKey = ed25519::SecretKey::from_bytes(private_key_bytes); + private_key_bytes.zeroize(); let public: ed25519::PublicKey = secret.public_key(); let public_key: PublicKey = public.to_bytes().to_vec().into(); - let keypair: KeyPair = KeyPair::from((KeyType::Ed25519, public_key.clone(), secret_key)); + let keypair: KeyPair = KeyPair::from((KeyType::Ed25519, public_key.clone(), private_key)); vault.insert(location.clone(), keypair); @@ -181,7 +181,7 @@ impl Storage for MemStore { assert_eq!(keypair.type_(), KeyType::Ed25519); let public: PublicKey = keypair.public().clone(); - let signature: [u8; 64] = Ed25519::sign(&data, keypair.secret())?; + let signature: [u8; 64] = Ed25519::sign(&data, keypair.private())?; let signature: Signature = Signature::new(public, signature.to_vec()); Ok(signature) diff --git a/identity-account/src/storage/stronghold.rs b/identity-account/src/storage/stronghold.rs index 2c1a5abdc1..df17123d68 100644 --- a/identity-account/src/storage/stronghold.rs +++ b/identity-account/src/storage/stronghold.rs @@ -12,7 +12,7 @@ use hashbrown::HashSet; use identity_core::convert::FromJson; use identity_core::convert::ToJson; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; +use identity_core::crypto::PrivateKey; use identity_did::verification::MethodType; use iota_stronghold::Location; use iota_stronghold::SLIP10DeriveInput; @@ -101,11 +101,11 @@ impl Storage for Stronghold { Ok(public) } - async fn key_insert(&self, id: IdentityId, location: &KeyLocation, secret_key: SecretKey) -> Result { + async fn key_insert(&self, id: IdentityId, location: &KeyLocation, private_key: PrivateKey) -> Result { let vault = self.vault(id); vault - .insert(location_skey(location), secret_key.as_ref(), default_hint(), &[]) + .insert(location_skey(location), private_key.as_ref(), default_hint(), &[]) .await?; match location.method() { diff --git a/identity-account/src/storage/traits.rs b/identity-account/src/storage/traits.rs index 0b95cc9a2c..ffceb76340 100644 --- a/identity-account/src/storage/traits.rs +++ b/identity-account/src/storage/traits.rs @@ -4,8 +4,8 @@ use core::fmt::Debug; use futures::stream::BoxStream; use futures::TryStreamExt; +use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; use crate::error::Result; use crate::events::Commit; @@ -31,8 +31,8 @@ pub trait Storage: Debug + Send + Sync + 'static { /// Creates a new keypair at the specified `location` async fn key_new(&self, id: IdentityId, location: &KeyLocation) -> Result; - /// Inserts a secret key at the specified `location`. - async fn key_insert(&self, id: IdentityId, location: &KeyLocation, secret_key: SecretKey) -> Result; + /// Inserts a private key at the specified `location`. + async fn key_insert(&self, id: IdentityId, location: &KeyLocation, private_key: PrivateKey) -> Result; /// Retrieves the public key at the specified `location`. async fn key_get(&self, id: IdentityId, location: &KeyLocation) -> Result; @@ -97,8 +97,8 @@ impl Storage for Box { (**self).key_new(id, location).await } - async fn key_insert(&self, id: IdentityId, location: &KeyLocation, secret_key: SecretKey) -> Result { - (**self).key_insert(id, location, secret_key).await + async fn key_insert(&self, id: IdentityId, location: &KeyLocation, private_key: PrivateKey) -> Result { + (**self).key_insert(id, location, private_key).await } async fn key_get(&self, id: IdentityId, location: &KeyLocation) -> Result { diff --git a/identity-account/src/stronghold/tests.rs b/identity-account/src/stronghold/tests.rs index 0e7e36728a..279dca76fe 100644 --- a/identity-account/src/stronghold/tests.rs +++ b/identity-account/src/stronghold/tests.rs @@ -275,7 +275,7 @@ rusty_fork_test! { #[test] - fn test_store_secret_key() { + fn test_store_private_key() { block_on(async { let password: EncryptionKey = derive_encryption_key("my-password:test_vault_persistence"); let filename: PathBuf = generate_filename(); @@ -286,7 +286,7 @@ rusty_fork_test! { let snapshot: Snapshot = open_snapshot(&filename, password).await; let vault = snapshot.vault(b"persistence", &[]); - vault.insert(location("A"), keypair.secret().as_ref(), default_hint(), &[]).await.unwrap(); + vault.insert(location("A"), keypair.private().as_ref(), default_hint(), &[]).await.unwrap(); snapshot.unload(true).await.unwrap(); } diff --git a/identity-account/src/tests/commands.rs b/identity-account/src/tests/commands.rs index 290e2c1b24..496ad2c2db 100644 --- a/identity-account/src/tests/commands.rs +++ b/identity-account/src/tests/commands.rs @@ -18,7 +18,7 @@ use identity_core::common::UnixTimestamp; use identity_core::crypto::KeyCollection; use identity_core::crypto::KeyPair; use identity_core::crypto::KeyType; -use identity_core::crypto::SecretKey; +use identity_core::crypto::PrivateKey; use identity_did::verification::MethodScope; use identity_did::verification::MethodType; @@ -166,17 +166,17 @@ async fn test_create_identity_already_exists() -> Result<()> { } #[tokio::test] -async fn test_create_identity_from_secret_key() -> Result<()> { +async fn test_create_identity_from_private_key() -> Result<()> { let account: Account = new_account().await?; let account2: Account = new_account().await?; let identity: IdentityId = IdentityId::from_u32(1); - let secret_key = KeyPair::new_ed25519()?.secret().clone(); + let private_key = KeyPair::new_ed25519()?.private().clone(); let id_create = IdentityCreate::new() .key_type(KeyType::Ed25519) - .method_secret(MethodSecret::Ed25519(secret_key)); + .method_secret(MethodSecret::Ed25519(private_key)); account.create_identity(id_create.clone()).await?; account2.create_identity(id_create).await?; @@ -184,7 +184,7 @@ async fn test_create_identity_from_secret_key() -> Result<()> { let ident = account.find_identity(identity).await.unwrap().unwrap(); let ident2 = account.find_identity(identity).await.unwrap().unwrap(); - // The same secret key should result in the same did + // The same private key should result in the same did assert_eq!(ident.identity().did(), ident2.identity().did()); assert_eq!(ident.identity().authentication()?, ident2.identity().authentication()?); @@ -192,15 +192,15 @@ async fn test_create_identity_from_secret_key() -> Result<()> { } #[tokio::test] -async fn test_create_identity_from_invalid_secret_key() -> Result<()> { +async fn test_create_identity_from_invalid_private_key() -> Result<()> { let account: Account = new_account().await?; - let secret_bytes: Box<[u8]> = Box::new([0; 33]); - let secret_key: SecretKey = SecretKey::from(secret_bytes); + let private_bytes: Box<[u8]> = Box::new([0; 33]); + let private_key: PrivateKey = PrivateKey::from(private_bytes); let id_create = IdentityCreate::new() .key_type(KeyType::Ed25519) - .method_secret(MethodSecret::Ed25519(secret_key)); + .method_secret(MethodSecret::Ed25519(private_key)); let err = account.create_identity(id_create).await.unwrap_err(); @@ -330,7 +330,7 @@ async fn test_create_method_duplicate_fragment() -> Result<()> { } #[tokio::test] -async fn test_create_method_from_secret_key() -> Result<()> { +async fn test_create_method_from_private_key() -> Result<()> { let account: Account = new_account().await?; let identity: IdentityId = IdentityId::from_u32(1); @@ -346,7 +346,7 @@ async fn test_create_method_from_secret_key() -> Result<()> { let command: Command = Command::CreateMethod { scope: MethodScope::default(), - method_secret: Some(MethodSecret::Ed25519(keypair.secret().clone())), + method_secret: Some(MethodSecret::Ed25519(keypair.private().clone())), type_: MethodType::Ed25519VerificationKey2018, fragment: "key-1".to_owned(), }; @@ -365,7 +365,7 @@ async fn test_create_method_from_secret_key() -> Result<()> { } #[tokio::test] -async fn test_create_method_from_invalid_secret_key() -> Result<()> { +async fn test_create_method_from_invalid_private_key() -> Result<()> { let account: Account = new_account().await?; let identity: IdentityId = IdentityId::from_u32(1); @@ -377,12 +377,12 @@ async fn test_create_method_from_invalid_secret_key() -> Result<()> { account.process(identity, command, false).await?; - let secret_bytes: Box<[u8]> = Box::new([0; 33]); - let secret_key = SecretKey::from(secret_bytes); + let private_bytes: Box<[u8]> = Box::new([0; 33]); + let private_key = PrivateKey::from(private_bytes); let command: Command = Command::CreateMethod { scope: MethodScope::default(), - method_secret: Some(MethodSecret::Ed25519(secret_key)), + method_secret: Some(MethodSecret::Ed25519(private_key)), type_: MethodType::Ed25519VerificationKey2018, fragment: "key-1".to_owned(), }; @@ -407,12 +407,12 @@ async fn test_create_method_with_type_secret_mismatch() -> Result<()> { account.process(identity, command, false).await?; - let secret_bytes: Box<[u8]> = Box::new([0; 32]); - let secret_key = SecretKey::from(secret_bytes); + let private_bytes: Box<[u8]> = Box::new([0; 32]); + let private_key = PrivateKey::from(private_bytes); let command: Command = Command::CreateMethod { scope: MethodScope::default(), - method_secret: Some(MethodSecret::Ed25519(secret_key)), + method_secret: Some(MethodSecret::Ed25519(private_key)), type_: MethodType::MerkleKeyCollection2021, fragment: "key-1".to_owned(), }; diff --git a/identity-account/src/types/method_secret.rs b/identity-account/src/types/method_secret.rs index fbc9ed453c..1b2845ec38 100644 --- a/identity-account/src/types/method_secret.rs +++ b/identity-account/src/types/method_secret.rs @@ -1,10 +1,10 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use identity_core::crypto::{KeyCollection, SecretKey}; +use identity_core::crypto::{KeyCollection, PrivateKey}; #[derive(Clone, Debug)] pub enum MethodSecret { - Ed25519(SecretKey), + Ed25519(PrivateKey), MerkleKeyCollection(KeyCollection), } diff --git a/identity-comm/src/envelope/encrypted.rs b/identity-comm/src/envelope/encrypted.rs index 32582c1ddb..48b819ab83 100644 --- a/identity-comm/src/envelope/encrypted.rs +++ b/identity-comm/src/envelope/encrypted.rs @@ -6,8 +6,8 @@ use identity_core::convert::FromJson; use identity_core::convert::ToJson; use identity_core::crypto::KeyPair; +use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; use libjose::jwe::Decoder; use libjose::jwe::Encoder; use libjose::jwe::JweAlgorithm; @@ -70,7 +70,7 @@ impl Encrypted { let encoder: Encoder<'_> = Encoder::new() .format(JweFormat::General) .protected(&header) - .secret(sender.secret()); + .secret(sender.private()); recipients .iter() @@ -83,7 +83,7 @@ impl Encrypted { pub fn unpack( &self, algorithm: EncryptionAlgorithm, - recipient: &SecretKey, + recipient: &PrivateKey, sender: &PublicKey, ) -> Result { let token: Token = Decoder::new(recipient) diff --git a/identity-comm/src/envelope/signed.rs b/identity-comm/src/envelope/signed.rs index 3fd7a1beb8..cdfa81dddf 100644 --- a/identity-comm/src/envelope/signed.rs +++ b/identity-comm/src/envelope/signed.rs @@ -38,7 +38,7 @@ impl Signed { Encoder::new() .format(JwsFormat::Compact) - .recipient((keypair.secret(), &header)) + .recipient((keypair.private(), &header)) .encode(message.as_bytes()) .map_err(Into::into) .map(Self) diff --git a/identity-comm/tests/message_authentication.rs b/identity-comm/tests/message_authentication.rs index 5413e67cad..3242ebf96f 100644 --- a/identity-comm/tests/message_authentication.rs +++ b/identity-comm/tests/message_authentication.rs @@ -4,7 +4,7 @@ // use core::slice; // use identity_core::crypto::KeyPair; // use identity_core::crypto::PublicKey; -// use identity_core::crypto::SecretKey; +// use identity_core::crypto::PrivateKey; // use libjose::utils::ed25519_to_x25519_public; // use libjose::utils::ed25519_to_x25519_secret; @@ -49,7 +49,7 @@ // assert_eq!(format!("{:?}", request), format!("{:?}", authentication_request)); // } -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, SecretKey)> { +// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { // Ok(( // ed25519_to_x25519_public(keypair.public())?.to_vec().into(), // ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), diff --git a/identity-comm/tests/message_did_resolution.rs b/identity-comm/tests/message_did_resolution.rs index 78d79bddeb..9d4f56317d 100644 --- a/identity-comm/tests/message_did_resolution.rs +++ b/identity-comm/tests/message_did_resolution.rs @@ -4,7 +4,7 @@ // use core::slice; // use identity_core::crypto::KeyPair; // use identity_core::crypto::PublicKey; -// use identity_core::crypto::SecretKey; +// use identity_core::crypto::PrivateKey; // use libjose::utils::ed25519_to_x25519_public; // use libjose::utils::ed25519_to_x25519_secret; @@ -72,7 +72,7 @@ // assert_eq!(format!("{:?}", response), format!("{:?}", resolotion_respone)); // } -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, SecretKey)> { +// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { // Ok(( // ed25519_to_x25519_public(keypair.public())?.to_vec().into(), // ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), diff --git a/identity-comm/tests/message_features_discovery.rs b/identity-comm/tests/message_features_discovery.rs index 0fb20ba11a..ab85802ba0 100644 --- a/identity-comm/tests/message_features_discovery.rs +++ b/identity-comm/tests/message_features_discovery.rs @@ -4,7 +4,7 @@ // use core::slice; // use identity_core::crypto::KeyPair; // use identity_core::crypto::PublicKey; -// use identity_core::crypto::SecretKey; +// use identity_core::crypto::PrivateKey; // use libjose::utils::ed25519_to_x25519_public; // use libjose::utils::ed25519_to_x25519_secret; @@ -72,7 +72,7 @@ // assert_eq!(format!("{:?}", response), format!("{:?}", did_response)); // } -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, SecretKey)> { +// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { // Ok(( // ed25519_to_x25519_public(keypair.public())?.to_vec().into(), // ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), diff --git a/identity-comm/tests/message_trust_ping.rs b/identity-comm/tests/message_trust_ping.rs index 8a47e02fd5..c308937561 100644 --- a/identity-comm/tests/message_trust_ping.rs +++ b/identity-comm/tests/message_trust_ping.rs @@ -4,7 +4,7 @@ // use core::slice; // use identity_core::crypto::KeyPair; // use identity_core::crypto::PublicKey; -// use identity_core::crypto::SecretKey; +// use identity_core::crypto::PrivateKey; // use libjose::utils::ed25519_to_x25519_public; // use libjose::utils::ed25519_to_x25519_secret; @@ -41,7 +41,7 @@ // assert_eq!(format!("{:?}", tp), format!("{:?}", ping)); // } -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, SecretKey)> { +// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { // Ok(( // ed25519_to_x25519_public(keypair.public())?.to_vec().into(), // ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), diff --git a/identity-core/src/crypto/key/collection.rs b/identity-core/src/crypto/key/collection.rs index 26678f438d..56bf9494e9 100644 --- a/identity-core/src/crypto/key/collection.rs +++ b/identity-core/src/crypto/key/collection.rs @@ -18,8 +18,8 @@ use crate::crypto::merkle_tree::Proof; use crate::crypto::KeyPair; use crate::crypto::KeyRef; use crate::crypto::KeyType; +use crate::crypto::PrivateKey; use crate::crypto::PublicKey; -use crate::crypto::SecretKey; use crate::error::Error; use crate::error::Result; use crate::utils::generate_ed25519_keypairs; @@ -29,30 +29,30 @@ use crate::utils::generate_ed25519_keypairs; pub struct KeyCollection { type_: KeyType, public: Box<[PublicKey]>, - secret: Box<[SecretKey]>, + private: Box<[PrivateKey]>, } impl KeyCollection { /// Creates a new [`KeyCollection`] from an iterator of - /// [`PublicKey`]/[`SecretKey`] pairs. + /// [`PublicKey`]/[`PrivateKey`] pairs. pub fn from_iterator(type_: KeyType, iter: I) -> Result where - I: IntoIterator, + I: IntoIterator, { - let (public, secret): (Vec<_>, Vec<_>) = iter.into_iter().unzip(); + let (public, private): (Vec<_>, Vec<_>) = iter.into_iter().unzip(); if public.is_empty() { return Err(Error::InvalidKeyCollectionSize(public.len())); } - if secret.is_empty() { - return Err(Error::InvalidKeyCollectionSize(secret.len())); + if private.is_empty() { + return Err(Error::InvalidKeyCollectionSize(private.len())); } Ok(Self { type_, public: public.into_boxed_slice(), - secret: secret.into_boxed_slice(), + private: private.into_boxed_slice(), }) } @@ -63,7 +63,7 @@ impl KeyCollection { /// Creates a new [`KeyCollection`] with the given [`key type`][`KeyType`]. pub fn new(type_: KeyType, count: usize) -> Result { - let keys: Vec<(PublicKey, SecretKey)> = match type_ { + let keys: Vec<(PublicKey, PrivateKey)> = match type_ { KeyType::Ed25519 => generate_ed25519_keypairs(count)?, }; @@ -95,28 +95,28 @@ impl KeyCollection { self.public.get(index).map(|key| KeyRef::new(self.type_, key.as_ref())) } - /// Returns a reference to the secret key at the specified `index`. - pub fn secret(&self, index: usize) -> Option<&SecretKey> { - self.secret.get(index) + /// Returns a reference to the private key at the specified `index`. + pub fn private(&self, index: usize) -> Option<&PrivateKey> { + self.private.get(index) } - /// Returns a [`KeyRef`] object referencing the secret key at the specified `index`. - pub fn secret_ref(&self, index: usize) -> Option> { - self.secret.get(index).map(|key| KeyRef::new(self.type_, key.as_ref())) + /// Returns a [`KeyRef`] object referencing the private key at the specified `index`. + pub fn private_ref(&self, index: usize) -> Option> { + self.private.get(index).map(|key| KeyRef::new(self.type_, key.as_ref())) } /// Returns a [`KeyPair`] object for the keys at the specified `index`. pub fn keypair(&self, index: usize) -> Option { - if let (Some(public), Some(secret)) = (self.public.get(index), self.secret.get(index)) { - Some((self.type_, public.clone(), secret.clone()).into()) + if let (Some(public), Some(private)) = (self.public.get(index), self.private.get(index)) { + Some((self.type_, public.clone(), private.clone()).into()) } else { None } } /// Returns an iterator over the key pairs in the collection. - pub fn iter(&self) -> impl Iterator { - self.public.iter().zip(self.secret.iter()) + pub fn iter(&self) -> impl Iterator { + self.public.iter().zip(self.private.iter()) } /// Returns an iterator over the public keys in the collection. @@ -124,9 +124,9 @@ impl KeyCollection { self.public.iter() } - /// Returns an iterator over the secret keys in the collection. - pub fn iter_secret(&self) -> Iter<'_, SecretKey> { - self.secret.iter() + /// Returns an iterator over the private keys in the collection. + pub fn iter_private(&self) -> Iter<'_, PrivateKey> { + self.private.iter() } /// Returns the Merkle root hash of the public keys in the collection. @@ -153,9 +153,9 @@ impl KeyCollection { { let proof: Proof = self.merkle_proof(index)?; let public: &PublicKey = self.public(index)?; - let secret: &SecretKey = self.secret(index)?; + let private: &PrivateKey = self.private(index)?; - Some(SigningKey::from_owned(public, secret, proof)) + Some(SigningKey::from_owned(public, private, proof)) } /// Creates a DID Document public key value for the Merkle root of @@ -189,11 +189,11 @@ where } impl IntoIterator for KeyCollection { - type Item = (PublicKey, SecretKey); - type IntoIter = Zip, IntoIter>; + type Item = (PublicKey, PrivateKey); + type IntoIter = Zip, IntoIter>; fn into_iter(self) -> Self::IntoIter { - self.public.to_vec().into_iter().zip(self.secret.to_vec().into_iter()) + self.public.to_vec().into_iter().zip(self.private.to_vec().into_iter()) } } @@ -209,27 +209,27 @@ mod tests { assert!(!keys.is_empty()); let public: Vec<_> = keys.iter_public().cloned().collect(); - let secret: Vec<_> = keys.iter_secret().cloned().collect(); + let private: Vec<_> = keys.iter_private().cloned().collect(); assert_eq!(public.len(), keys.len()); - assert_eq!(secret.len(), keys.len()); + assert_eq!(private.len(), keys.len()); - for (index, (public, secret)) in public.iter().zip(secret.iter()).enumerate() { + for (index, (public, private)) in public.iter().zip(private.iter()).enumerate() { assert_eq!(public.as_ref(), keys.public(index).unwrap().as_ref()); - assert_eq!(secret.as_ref(), keys.secret(index).unwrap().as_ref()); + assert_eq!(private.as_ref(), keys.private(index).unwrap().as_ref()); } - let iter: _ = public.into_iter().zip(secret.into_iter()); + let iter: _ = public.into_iter().zip(private.into_iter()); let next: KeyCollection = KeyCollection::from_iterator(keys.type_(), iter).unwrap(); assert_eq!(next.len(), keys.len()); let public: Vec<_> = next.iter_public().cloned().collect(); - let secret: Vec<_> = next.iter_secret().cloned().collect(); + let private: Vec<_> = next.iter_private().cloned().collect(); - for (index, (public, secret)) in public.iter().zip(secret.iter()).enumerate() { + for (index, (public, private)) in public.iter().zip(private.iter()).enumerate() { assert_eq!(public.as_ref(), keys.public(index).unwrap().as_ref()); - assert_eq!(secret.as_ref(), keys.secret(index).unwrap().as_ref()); + assert_eq!(private.as_ref(), keys.private(index).unwrap().as_ref()); } } } diff --git a/identity-core/src/crypto/key/key.rs b/identity-core/src/crypto/key/key.rs index 0eaf46e1ec..d771977d36 100644 --- a/identity-core/src/crypto/key/key.rs +++ b/identity-core/src/crypto/key/key.rs @@ -11,8 +11,8 @@ use zeroize::Zeroize; /// A cryptographic key with `Public` components. pub type PublicKey = Key; -/// A cryptographic key with `Secret` components. -pub type SecretKey = Key; +/// A cryptographic key with `Private` components. +pub type PrivateKey = Key; // ============================================================================= // ============================================================================= @@ -21,17 +21,17 @@ mod private { pub trait Sealed {} } -// A marker type for the `Public` components of a cryptographic key. +// A marker type for the `Public` components of an asymmetric cryptographic key. #[derive(Clone, Copy, Debug)] pub enum Public {} -// A marker type for the `Secret` components of a cryptographic key. +// A marker type for the `Private` components of an asymmetric cryptographic key. #[derive(Clone, Copy, Debug)] -pub enum Secret {} +pub enum Private {} impl private::Sealed for Public {} -impl private::Sealed for Secret {} +impl private::Sealed for Private {} // ============================================================================= // ============================================================================= diff --git a/identity-core/src/crypto/key/mod.rs b/identity-core/src/crypto/key/mod.rs index 58c317b249..bc57a0927d 100644 --- a/identity-core/src/crypto/key/mod.rs +++ b/identity-core/src/crypto/key/mod.rs @@ -11,7 +11,7 @@ mod type_; pub use self::collection::KeyCollection; pub use self::key::PublicKey; -pub use self::key::SecretKey; +pub use self::key::PrivateKey; pub use self::pair::KeyPair; pub use self::reference::KeyRef; pub use self::type_::KeyType; diff --git a/identity-core/src/crypto/key/pair.rs b/identity-core/src/crypto/key/pair.rs index c7ecf16752..c5283a6446 100644 --- a/identity-core/src/crypto/key/pair.rs +++ b/identity-core/src/crypto/key/pair.rs @@ -5,8 +5,8 @@ use zeroize::Zeroize; use crate::crypto::KeyRef; use crate::crypto::KeyType; +use crate::crypto::PrivateKey; use crate::crypto::PublicKey; -use crate::crypto::SecretKey; use crate::error::Result; use crate::utils::generate_ed25519_keypair; @@ -15,7 +15,7 @@ use crate::utils::generate_ed25519_keypair; pub struct KeyPair { type_: KeyType, public: PublicKey, - secret: SecretKey, + private: PrivateKey, } impl KeyPair { @@ -26,11 +26,11 @@ impl KeyPair { /// Creates a new [`KeyPair`] with the given [`key type`][`KeyType`]. pub fn new(type_: KeyType) -> Result { - let (public, secret): (PublicKey, SecretKey) = match type_ { + let (public, private): (PublicKey, PrivateKey) = match type_ { KeyType::Ed25519 => generate_ed25519_keypair()?, }; - Ok(Self { type_, public, secret }) + Ok(Self { type_, public, private }) } /// Returns the [`type`][`KeyType`] of the `KeyPair` object. @@ -48,37 +48,37 @@ impl KeyPair { KeyRef::new(self.type_, self.public.as_ref()) } - /// Returns a reference to the [`SecretKey`] object. - pub const fn secret(&self) -> &SecretKey { - &self.secret + /// Returns a reference to the [`PrivateKey`] object. + pub const fn private(&self) -> &PrivateKey { + &self.private } - /// Returns the secret key as a [`KeyRef`] object. - pub fn secret_ref(&self) -> KeyRef<'_> { - KeyRef::new(self.type_, self.secret.as_ref()) + /// Returns the private key as a [`KeyRef`] object. + pub fn private_ref(&self) -> KeyRef<'_> { + KeyRef::new(self.type_, self.private.as_ref()) } } impl Drop for KeyPair { fn drop(&mut self) { self.public.zeroize(); - self.secret.zeroize(); + self.private.zeroize(); } } impl Zeroize for KeyPair { fn zeroize(&mut self) { self.public.zeroize(); - self.secret.zeroize(); + self.private.zeroize(); } } -impl From<(KeyType, PublicKey, SecretKey)> for KeyPair { - fn from(other: (KeyType, PublicKey, SecretKey)) -> Self { +impl From<(KeyType, PublicKey, PrivateKey)> for KeyPair { + fn from(other: (KeyType, PublicKey, PrivateKey)) -> Self { Self { type_: other.0, public: other.1, - secret: other.2, + private: other.2, } } } @@ -92,6 +92,6 @@ mod tests { let keypair: KeyPair = KeyPair::new_ed25519().unwrap(); assert_eq!(keypair.type_(), KeyType::Ed25519); assert_eq!(keypair.public().as_ref().len(), 32); - assert_eq!(keypair.secret().as_ref().len(), 32); + assert_eq!(keypair.private().as_ref().len(), 32); } } diff --git a/identity-core/src/crypto/key/type_.rs b/identity-core/src/crypto/key/type_.rs index 687f162dc5..02f36667da 100644 --- a/identity-core/src/crypto/key/type_.rs +++ b/identity-core/src/crypto/key/type_.rs @@ -13,7 +13,7 @@ use crate::error::Result; /// Supported cryptographic key types. #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)] pub enum KeyType { - /// Identifies an `Ed25519` public/secret key. + /// Identifies an `Ed25519` public/private key. #[serde(rename = "ed25519")] Ed25519, } diff --git a/identity-core/src/crypto/merkle_key/signer.rs b/identity-core/src/crypto/merkle_key/signer.rs index 7e1876803a..91f0771f7a 100644 --- a/identity-core/src/crypto/merkle_key/signer.rs +++ b/identity-core/src/crypto/merkle_key/signer.rs @@ -11,8 +11,8 @@ use crate::crypto::merkle_key::MerkleKey; use crate::crypto::merkle_key::MerkleSignature; use crate::crypto::merkle_tree::Proof; use crate::crypto::Named; +use crate::crypto::PrivateKey; use crate::crypto::PublicKey; -use crate::crypto::SecretKey; use crate::crypto::Sign; use crate::crypto::SignatureValue; use crate::crypto::Signer; @@ -26,7 +26,7 @@ where D: MerkleDigest, { public: &'key PublicKey, - secret: &'key SecretKey, + private: &'key PrivateKey, proof: Cow<'key, Proof>, } @@ -35,18 +35,18 @@ where D: MerkleDigest, { /// Creates a new [`SigningKey`] instance. - pub fn new(public: &'key PublicKey, secret: &'key SecretKey, proof: Cow<'key, Proof>) -> Self { - Self { public, secret, proof } + pub fn new(public: &'key PublicKey, private: &'key PrivateKey, proof: Cow<'key, Proof>) -> Self { + Self { public, private, proof } } /// Creates a new [`SigningKey`] from a borrowed [`proof`][`Proof`]. - pub fn from_borrowed(public: &'key PublicKey, secret: &'key SecretKey, proof: &'key Proof) -> Self { - Self::new(public, secret, Cow::Borrowed(proof)) + pub fn from_borrowed(public: &'key PublicKey, private: &'key PrivateKey, proof: &'key Proof) -> Self { + Self::new(public, private, Cow::Borrowed(proof)) } /// Creates a new [`SigningKey`] from an owned [`proof`][`Proof`]. - pub fn from_owned(public: &'key PublicKey, secret: &'key SecretKey, proof: Proof) -> Self { - Self::new(public, secret, Cow::Owned(proof)) + pub fn from_owned(public: &'key PublicKey, private: &'key PrivateKey, proof: Proof) -> Self { + Self::new(public, private, Cow::Owned(proof)) } } @@ -54,7 +54,7 @@ impl<'key, D, S> MerkleSigningKey for SigningKey<'key, D> where D: MerkleDigest, S: Sign, - SecretKey: AsRef, + PrivateKey: AsRef, { fn proof(&self) -> String { encode_b58(&self.proof.encode()) @@ -64,8 +64,8 @@ where encode_b58(self.public.as_ref()) } - fn secret(&self) -> &S::Secret { - self.secret.as_ref() + fn private(&self) -> &S::Private { + self.private.as_ref() } } @@ -84,9 +84,9 @@ where /// Returns the target public key as a base58-encoded string. fn public(&self) -> String; - /// Returns a reference to the secret key of the underlying + /// Returns a reference to the private key of the underlying /// [`signature`][`Sign`] implementation. - fn secret(&self) -> &S::Secret; + fn private(&self) -> &S::Private; } // ============================================================================= @@ -121,14 +121,14 @@ where K: MerkleSigningKey, S::Output: AsRef<[u8]>, { - fn sign(data: &X, secret: &K) -> Result + fn sign(data: &X, private: &K) -> Result where X: Serialize, { let message: Vec = data.to_jcs()?; - let signature: S::Output = S::sign(&message, secret.secret())?; + let signature: S::Output = S::sign(&message, private.private())?; let signature: String = encode_b58(signature.as_ref()); - let formatted: String = format!("{}.{}.{}", secret.public(), secret.proof(), signature); + let formatted: String = format!("{}.{}.{}", private.public(), private.proof(), signature); Ok(SignatureValue::Signature(formatted)) } diff --git a/identity-core/src/crypto/merkle_key/tests.rs b/identity-core/src/crypto/merkle_key/tests.rs index 542405b5de..83c9b16b0e 100644 --- a/identity-core/src/crypto/merkle_key/tests.rs +++ b/identity-core/src/crypto/merkle_key/tests.rs @@ -40,7 +40,7 @@ fn inject_key(signature: &SignatureValue, key: &PublicKey) -> SignatureValue { fn __test_sign_verify() where D: MerkleDigest, - S: MerkleSignature + Sign + Verify, + S: MerkleSignature + Sign + Verify, S::Output: AsRef<[u8]>, { assert_eq!(S::TAG, MerkleSignatureTag::ED25519); diff --git a/identity-core/src/crypto/mod.rs b/identity-core/src/crypto/mod.rs index 820ec52d96..fa8cd592cb 100644 --- a/identity-core/src/crypto/mod.rs +++ b/identity-core/src/crypto/mod.rs @@ -14,8 +14,8 @@ pub use self::key::KeyCollection; pub use self::key::KeyPair; pub use self::key::KeyRef; pub use self::key::KeyType; +pub use self::key::PrivateKey; pub use self::key::PublicKey; -pub use self::key::SecretKey; pub use self::proof::JcsEd25519; pub use self::signature::Ed25519; pub use self::signature::Named; diff --git a/identity-core/src/crypto/proof/jcs_ed25519.rs b/identity-core/src/crypto/proof/jcs_ed25519.rs index 431e636e6f..fe6b631e16 100644 --- a/identity-core/src/crypto/proof/jcs_ed25519.rs +++ b/identity-core/src/crypto/proof/jcs_ed25519.rs @@ -33,17 +33,17 @@ impl Named for JcsEd25519 { const NAME: &'static str = "JcsEd25519Signature2020"; } -impl Signer for JcsEd25519 +impl Signer for JcsEd25519 where T: Sign, T::Output: AsRef<[u8]>, { - fn sign(data: &X, secret: &T::Secret) -> Result + fn sign(data: &X, private: &T::Private) -> Result where X: Serialize, { let message: Vec = data.to_jcs()?; - let signature: T::Output = T::sign(&message, secret)?; + let signature: T::Output = T::sign(&message, private)?; let signature: String = encode_b58(signature.as_ref()); Ok(SignatureValue::Signature(signature)) @@ -79,21 +79,21 @@ mod tests { use crate::crypto::Ed25519; use crate::crypto::JcsEd25519; use crate::crypto::KeyPair; + use crate::crypto::PrivateKey; use crate::crypto::PublicKey; - use crate::crypto::SecretKey; use crate::crypto::SignatureValue; use crate::crypto::Signer as _; use crate::crypto::Verifier as _; use crate::json; use crate::utils::decode_b58; - type Signer = JcsEd25519>; + type Signer = JcsEd25519>; type Verifier = JcsEd25519>; struct TestVector { public: &'static str, - secret: &'static str, + private: &'static str, input: &'static str, output: &'static str, } @@ -104,13 +104,13 @@ mod tests { fn test_tvs() { for tv in TVS { let public: PublicKey = decode_b58(tv.public).unwrap().into(); - let secret: SecretKey = decode_b58(tv.secret).unwrap().into(); + let private: PrivateKey = decode_b58(tv.private).unwrap().into(); let badkey: PublicKey = b"IOTA".to_vec().into(); let input: Object = Object::from_json(tv.input).unwrap(); let output: Object = Object::from_json(tv.output).unwrap(); - let signature: SignatureValue = Signer::sign(&input, &secret).unwrap(); + let signature: SignatureValue = Signer::sign(&input, &private).unwrap(); assert_eq!(output["proof"]["signatureValue"], signature.as_str()); @@ -134,9 +134,9 @@ mod tests { const MSG: &[u8] = b"hello"; let public: PublicKey = decode_b58(PUBLIC).unwrap().into(); - let secret: SecretKey = decode_b58(SECRET).unwrap().into(); + let private: PrivateKey = decode_b58(SECRET).unwrap().into(); - let signature: SignatureValue = Signer::sign(&MSG, &secret).unwrap(); + let signature: SignatureValue = Signer::sign(&MSG, &private).unwrap(); assert_eq!(signature.as_str().as_bytes(), SIG); assert!(Verifier::verify(&MSG, &signature, &public).is_ok()); @@ -150,7 +150,7 @@ mod tests { let data1: Value = json!({ "msg": "IOTA Identity" }); let data2: Value = json!({ "msg": "IOTA Identity 2" }); - let signature: _ = Signer::sign(&data1, key1.secret()).unwrap(); + let signature: _ = Signer::sign(&data1, key1.private()).unwrap(); // The signature should be valid assert!(Verifier::verify(&data1, &signature, key1.public()).is_ok()); diff --git a/identity-core/src/crypto/signature/ed25519.rs b/identity-core/src/crypto/signature/ed25519.rs index 6f5e9c01e9..98f9ed2655 100644 --- a/identity-core/src/crypto/signature/ed25519.rs +++ b/identity-core/src/crypto/signature/ed25519.rs @@ -21,10 +21,10 @@ impl Sign for Ed25519 where T: AsRef<[u8]> + ?Sized, { - type Secret = T; + type Private = T; type Output = [u8; SIGNATURE_LENGTH]; - fn sign(message: &[u8], key: &Self::Secret) -> Result { + fn sign(message: &[u8], key: &Self::Private) -> Result { parse_secret(key.as_ref()).map(|key| key.sign(message).to_bytes()) } } @@ -93,9 +93,9 @@ mod tests { #[test] fn test_ed25519_can_sign_and_verify() { let public: Vec = decode_b58(PUBLIC_B58).unwrap(); - let secret: Vec = decode_b58(SECRET_B58).unwrap(); + let private: Vec = decode_b58(SECRET_B58).unwrap(); - let signature: _ = Ed25519::sign(b"hello", &secret).unwrap(); + let signature: _ = Ed25519::sign(b"hello", &private).unwrap(); let combined: _ = [&signature[..], b"hello"].concat(); assert_eq!(&combined, SIGNATURE_HELLO); diff --git a/identity-core/src/crypto/signature/traits/core.rs b/identity-core/src/crypto/signature/traits/core.rs index ff5ec492b8..d182d725db 100644 --- a/identity-core/src/crypto/signature/traits/core.rs +++ b/identity-core/src/crypto/signature/traits/core.rs @@ -13,13 +13,13 @@ use crate::error::Result; /// A common interface for digital signature creation. pub trait Sign { /// The secret key type of this signature implementation. - type Secret: ?Sized; + type Private: ?Sized; /// The output type of this signature implementation. type Output; /// Signs the given `message` with `key` and returns a digital signature. - fn sign(message: &[u8], key: &Self::Secret) -> Result; + fn sign(message: &[u8], key: &Self::Private) -> Result; } // ============================================================================= diff --git a/identity-core/src/utils/ed25519.rs b/identity-core/src/utils/ed25519.rs index 8c552ef09a..83c4644c75 100644 --- a/identity-core/src/utils/ed25519.rs +++ b/identity-core/src/utils/ed25519.rs @@ -3,22 +3,22 @@ use crypto::signatures::ed25519; +use crate::crypto::PrivateKey; use crate::crypto::PublicKey; -use crate::crypto::SecretKey; use crate::error::Result; -/// Generates a new pair of public/secret ed25519 keys. -pub fn generate_ed25519_keypair() -> Result<(PublicKey, SecretKey)> { +/// Generates a new pair of public/private ed25519 keys. +pub fn generate_ed25519_keypair() -> Result<(PublicKey, PrivateKey)> { let secret: ed25519::SecretKey = ed25519::SecretKey::generate()?; let public: ed25519::PublicKey = secret.public_key(); - let secret: SecretKey = secret.to_bytes().to_vec().into(); + let private: PrivateKey = secret.to_bytes().to_vec().into(); let public: PublicKey = public.to_bytes().to_vec().into(); - Ok((public, secret)) + Ok((public, private)) } -/// Generates a list of public/secret ed25519 keys. -pub fn generate_ed25519_keypairs(count: usize) -> Result> { +/// Generates a list of public/private ed25519 keys. +pub fn generate_ed25519_keypairs(count: usize) -> Result> { (0..count).map(|_| generate_ed25519_keypair()).collect() } diff --git a/identity-core/tests/fixtures/jcs_ed25519.rs b/identity-core/tests/fixtures/jcs_ed25519.rs index ba2c967573..fe0045fe1b 100644 --- a/identity-core/tests/fixtures/jcs_ed25519.rs +++ b/identity-core/tests/fixtures/jcs_ed25519.rs @@ -1,7 +1,7 @@ [ TestVector { public: "4CcKDtU1JNGi8U4D8Rv9CHzfmF7xzaxEAPFA54eQjRHF", - secret: "z3nisqMdwW7nZdWomCfUyRaezHzKEBfwRbvaMcJAqaMSbmjxuRfS5qz4ff3QAf1A5sZT4ZMcxYoGjN4K1VsDV7b", + private: "z3nisqMdwW7nZdWomCfUyRaezHzKEBfwRbvaMcJAqaMSbmjxuRfS5qz4ff3QAf1A5sZT4ZMcxYoGjN4K1VsDV7b", input: r#" { "id": "did:example:abcd", @@ -54,7 +54,7 @@ }, TestVector { public: "4CcKDtU1JNGi8U4D8Rv9CHzfmF7xzaxEAPFA54eQjRHF", - secret: "z3nisqMdwW7nZdWomCfUyRaezHzKEBfwRbvaMcJAqaMSbmjxuRfS5qz4ff3QAf1A5sZT4ZMcxYoGjN4K1VsDV7b", + private: "z3nisqMdwW7nZdWomCfUyRaezHzKEBfwRbvaMcJAqaMSbmjxuRfS5qz4ff3QAf1A5sZT4ZMcxYoGjN4K1VsDV7b", input: r#" { "foo": "bar", diff --git a/identity-credential/src/presentation/builder.rs b/identity-credential/src/presentation/builder.rs index 35a5cf67f8..824768b3ff 100644 --- a/identity-credential/src/presentation/builder.rs +++ b/identity-credential/src/presentation/builder.rs @@ -197,7 +197,7 @@ mod tests { .unwrap(); document - .signer(keypair.secret()) + .signer(keypair.private()) .method("#key-1") .sign(&mut credential) .unwrap(); diff --git a/identity-did/src/verifiable/document.rs b/identity-did/src/verifiable/document.rs index 552d8ce480..89b1cccfe7 100644 --- a/identity-did/src/verifiable/document.rs +++ b/identity-did/src/verifiable/document.rs @@ -17,8 +17,8 @@ use identity_core::crypto::merkle_key::VerificationKey; use identity_core::crypto::merkle_tree::Proof; use identity_core::crypto::Ed25519; use identity_core::crypto::JcsEd25519; +use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; use identity_core::crypto::SetSignature; use identity_core::crypto::Sign; use identity_core::crypto::Signature; @@ -101,7 +101,7 @@ where U: Serialize, V: Serialize, { - pub fn sign_this<'query, Q>(&mut self, query: Q, secret: &SecretKey) -> Result<()> + pub fn sign_this<'query, Q>(&mut self, query: Q, private: &PrivateKey) -> Result<()> where Q: Into>, { @@ -110,7 +110,7 @@ where match method.key_type() { MethodType::Ed25519VerificationKey2018 => { - JcsEd25519::::create_signature(self, &fragment, secret.as_ref())?; + JcsEd25519::::create_signature(self, &fragment, private.as_ref())?; } MethodType::MerkleKeyCollection2021 => { // CoreDocuments can't be signed with Merkle Key Collections @@ -143,8 +143,8 @@ where impl CoreDocument { /// Creates a new [`DocumentSigner`] that can be used to create digital /// signatures from verification methods in this DID Document. - pub fn signer<'base>(&'base self, secret: &'base SecretKey) -> DocumentSigner<'base, '_, '_, T, U, V> { - DocumentSigner::new(self, secret) + pub fn signer<'base>(&'base self, private: &'base PrivateKey) -> DocumentSigner<'base, '_, '_, T, U, V> { + DocumentSigner::new(self, private) } /// Creates a new [`DocumentVerifier`] that can be used to verify signatures @@ -160,16 +160,16 @@ impl CoreDocument { pub struct DocumentSigner<'base, 'query, 'proof, T, U, V> { document: &'base CoreDocument, - secret: &'base SecretKey, + private: &'base PrivateKey, method: Option>, merkle_key: Option<(&'proof PublicKey, &'proof dyn Any)>, } impl<'base, T, U, V> DocumentSigner<'base, '_, '_, T, U, V> { - pub fn new(document: &'base CoreDocument, secret: &'base SecretKey) -> Self { + pub fn new(document: &'base CoreDocument, private: &'base PrivateKey) -> Self { Self { document, - secret, + private, method: None, merkle_key: None, } @@ -213,7 +213,7 @@ impl DocumentSigner<'_, '_, '_, T, U, V> { match method.key_type() { MethodType::Ed25519VerificationKey2018 => { - JcsEd25519::::create_signature(that, &method_uri, self.secret.as_ref())?; + JcsEd25519::::create_signature(that, &method_uri, self.private.as_ref())?; } MethodType::MerkleKeyCollection2021 => { let data: Vec = method.key_data().try_decode()?; @@ -239,7 +239,7 @@ impl DocumentSigner<'_, '_, '_, T, U, V> { where X: Serialize + SetSignature, D: MerkleDigest, - S: MerkleSignature + Sign, + S: MerkleSignature + Sign, S::Output: AsRef<[u8]>, { match self.merkle_key { @@ -248,7 +248,7 @@ impl DocumentSigner<'_, '_, '_, T, U, V> { .downcast_ref() .ok_or(Error::CoreError(CoreError::InvalidKeyFormat))?; - let skey: SigningKey<'_, D> = SigningKey::from_borrowed(public, self.secret, proof); + let skey: SigningKey<'_, D> = SigningKey::from_borrowed(public, self.private, proof); MerkleSigner::::create_signature(that, &method, &skey)?; diff --git a/identity-did/src/verifiable/tests.rs b/identity-did/src/verifiable/tests.rs index be6372b112..e47f578629 100644 --- a/identity-did/src/verifiable/tests.rs +++ b/identity-did/src/verifiable/tests.rs @@ -8,8 +8,8 @@ use identity_core::crypto::merkle_tree::Proof; use identity_core::crypto::Ed25519; use identity_core::crypto::KeyCollection; use identity_core::crypto::KeyPair; +use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; -use identity_core::crypto::SecretKey; use identity_core::crypto::SetSignature; use identity_core::crypto::Signature; use identity_core::crypto::TrySignature; @@ -85,7 +85,7 @@ fn test_sign_verify_this_ed25519() { assert!(document.verify_this().is_err()); - document.sign_this("#key-1", key.secret()).unwrap(); + document.sign_this("#key-1", key.private()).unwrap(); assert!(document.verify_this().is_ok()); } @@ -119,14 +119,14 @@ fn test_sign_verify_that_merkle_key_ed25519_sha256() { .unwrap(); let public: &PublicKey = keys.public(index).unwrap(); - let secret: &SecretKey = keys.secret(index).unwrap(); + let private: &PrivateKey = keys.private(index).unwrap(); let mut that: That = That::new(123); assert!(document.verifier().verify(&that).is_err()); document - .signer(secret) + .signer(private) .method("#key-collection") .merkle_key((public, &proof)) .sign(&mut that) diff --git a/identity-iota/src/chain/diff_chain.rs b/identity-iota/src/chain/diff_chain.rs index 09a8ba2bfa..26d8871ae5 100644 --- a/identity-iota/src/chain/diff_chain.rs +++ b/identity-iota/src/chain/diff_chain.rs @@ -233,7 +233,7 @@ mod test { { let keypair: KeyPair = KeyPair::new_ed25519().unwrap(); let mut document: IotaDocument = IotaDocument::from_keypair(&keypair).unwrap(); - document.sign(keypair.secret()).unwrap(); + document.sign(keypair.private()).unwrap(); document.set_message_id(MessageId::new([8; 32])); chain = DocumentChain::new(IntegrationChain::new(document).unwrap()); keys.push(keypair); @@ -268,7 +268,7 @@ mod test { new.set_updated(Timestamp::now_utc()); new.set_previous_message_id(*chain.integration_message_id()); - assert!(chain.current().sign_data(&mut new, keys[0].secret()).is_ok()); + assert!(chain.current().sign_data(&mut new, keys[0].private()).is_ok()); assert_eq!( chain.current().proof().unwrap().verification_method(), "#authentication" @@ -291,7 +291,7 @@ mod test { }; let message_id = *chain.diff_message_id(); - let mut diff: DocumentDiff = chain.current().diff(&new, message_id, keys[1].secret()).unwrap(); + let mut diff: DocumentDiff = chain.current().diff(&new, message_id, keys[1].private()).unwrap(); diff.set_message_id(message_id); assert!(chain.try_push_diff(diff).is_ok()); } diff --git a/identity-iota/src/did/doc/iota_document.rs b/identity-iota/src/did/doc/iota_document.rs index 1d807266c0..01a12e6109 100644 --- a/identity-iota/src/did/doc/iota_document.rs +++ b/identity-iota/src/did/doc/iota_document.rs @@ -15,7 +15,7 @@ use identity_core::common::Timestamp; use identity_core::common::Url; use identity_core::convert::SerdeInto; use identity_core::crypto::KeyPair; -use identity_core::crypto::SecretKey; +use identity_core::crypto::PrivateKey; use identity_core::crypto::SetSignature; use identity_core::crypto::Signature; use identity_core::crypto::TrySignature; @@ -420,16 +420,16 @@ impl IotaDocument { /// /// Fails if an unsupported verification method is used, document /// serialization fails, or the signature operation fails. - pub fn sign(&mut self, secret: &SecretKey) -> Result<()> { + pub fn sign(&mut self, private_key: &PrivateKey) -> Result<()> { let key: String = self.authentication_id().to_string(); - self.document.sign_this(&key, secret).map_err(Into::into) + self.document.sign_this(&key, private_key).map_err(Into::into) } /// Creates a new [`DocumentSigner`] that can be used to create digital /// signatures from verification methods in this DID Document. - pub fn signer<'base>(&'base self, secret: &'base SecretKey) -> Signer<'base, 'base, 'base> { - self.document.signer(secret) + pub fn signer<'base>(&'base self, private_key: &'base PrivateKey) -> Signer<'base, 'base, 'base> { + self.document.signer(private_key) } /// Verifies the signature of the DID document. @@ -454,13 +454,13 @@ impl IotaDocument { /// /// Fails if an unsupported verification method is used, document /// serialization fails, or the signature operation fails. - pub fn sign_data(&self, data: &mut X, secret: &SecretKey) -> Result<()> + pub fn sign_data(&self, data: &mut X, private_key: &PrivateKey) -> Result<()> where X: Serialize + SetSignature + TryMethod, { self .document - .signer(secret) + .signer(private_key) .method(self.authentication_id()) .sign(data) .map_err(Into::into) @@ -489,15 +489,15 @@ impl IotaDocument { /// Creates a `DocumentDiff` representing the changes between `self` and `other`. /// /// The returned `DocumentDiff` will have a digital signature created using the - /// default authentication method and `secret`. + /// default authentication method and `private_key`. /// /// # Errors /// /// Fails if the diff operation or signature operation fails. - pub fn diff(&self, other: &Self, message_id: MessageId, secret: &SecretKey) -> Result { + pub fn diff(&self, other: &Self, message_id: MessageId, private_key: &PrivateKey) -> Result { let mut diff: DocumentDiff = DocumentDiff::new(self, other, message_id)?; - self.sign_data(&mut diff, secret)?; + self.sign_data(&mut diff, private_key)?; Ok(diff) } @@ -631,8 +631,8 @@ mod tests { use identity_core::convert::SerdeInto; use identity_core::crypto::KeyPair; use identity_core::crypto::KeyType; + use identity_core::crypto::PrivateKey; use identity_core::crypto::PublicKey; - use identity_core::crypto::SecretKey; use identity_did::did::DID; use identity_did::document::CoreDocument; use identity_did::service::Service; @@ -707,7 +707,7 @@ mod tests { } fn generate_testkey() -> KeyPair { - let secret_key: Vec = vec![ + let private_key: Vec = vec![ 40, 185, 109, 70, 134, 119, 123, 37, 190, 254, 232, 186, 106, 48, 213, 63, 133, 223, 167, 126, 159, 43, 178, 4, 190, 217, 52, 66, 92, 63, 69, 84, ]; @@ -718,7 +718,7 @@ mod tests { KeyPair::from(( KeyType::Ed25519, PublicKey::from(public_key), - SecretKey::from(secret_key), + PrivateKey::from(private_key), )) } @@ -1004,7 +1004,7 @@ mod tests { let document2: IotaDocument = IotaDocument::from_json(&json_doc).unwrap(); assert_eq!(document, document2); - assert!(document.sign(keypair.secret()).is_ok()); + assert!(document.sign(keypair.private()).is_ok()); let json_doc: String = document.to_string(); let document2: IotaDocument = IotaDocument::from_json(&json_doc).unwrap(); @@ -1049,7 +1049,7 @@ mod tests { let mut document: IotaDocument = IotaDocument::from_keypair(&keypair).unwrap(); assert!(document.proof().is_none()); - assert!(document.sign(keypair.secret()).is_ok()); + assert!(document.sign(keypair.private()).is_ok()); assert_eq!(document.proof().unwrap().verification_method(), "#authentication"); } diff --git a/identity/benches/benchmark.rs b/identity/benches/benchmark.rs index 04a0f8a818..a29e858a2b 100644 --- a/identity/benches/benchmark.rs +++ b/identity/benches/benchmark.rs @@ -21,7 +21,7 @@ use self::diff_chain::update_integration_chain; fn generate_signed_document(keypair: &KeyPair) { let mut document: IotaDocument = IotaDocument::from_keypair(keypair).unwrap(); - document.sign(keypair.secret()).unwrap(); + document.sign(keypair.private()).unwrap(); } fn generate_did(keypair: &KeyPair) { diff --git a/identity/benches/diff_chain.rs b/identity/benches/diff_chain.rs index 5331aa8772..be06deef64 100644 --- a/identity/benches/diff_chain.rs +++ b/identity/benches/diff_chain.rs @@ -18,7 +18,7 @@ pub fn setup_diff_chain_bench() -> (IotaDocument, KeyPair) { let keypair: KeyPair = KeyPair::new_ed25519().unwrap(); let mut document: IotaDocument = IotaDocument::from_keypair(&keypair).unwrap(); - document.sign(keypair.secret()).unwrap(); + document.sign(keypair.private()).unwrap(); document.set_message_id(MessageId::new([8; 32])); (document, keypair) @@ -41,7 +41,7 @@ pub fn update_diff_chain(n: usize, chain: &mut DocumentChain, keypair: &KeyPair) }; let message_id = *chain.diff_message_id(); - let mut diff: DocumentDiff = chain.current().diff(&new, message_id, keypair.secret()).unwrap(); + let mut diff: DocumentDiff = chain.current().diff(&new, message_id, keypair.private()).unwrap(); diff.set_message_id(message_id); assert!(chain.try_push_diff(diff).is_ok()); @@ -72,7 +72,7 @@ pub fn update_integration_chain(n: usize, chain: &mut DocumentChain, keypair: &K new.set_updated(Timestamp::now_utc()); new.set_previous_message_id(*chain.integration_message_id()); - chain.current().sign_data(&mut new, keypair.secret()).unwrap(); + chain.current().sign_data(&mut new, keypair.private()).unwrap(); chain.try_push_integration(new).unwrap(); } }