/Legal/SignData
Allows the client to sign binary data.
JSON
- Request
- { "keyId": Required(Str(PKeyId)), "legalId": Required(Str(PLegalId)), "dataBase64": Required(Str(PDataBase64)), "keySignature": Required(Str(PKeySignature)), "requestSignature": Required(Str(PRequestSignature)) }
- Response (if successful)
- { "Signature": Required(Str(PSignature)) }
XML
- Request
- <SignData xmlns="https://waher.se/Schema/BrokerAgent.xsd" keyId=(Required(Str(PKeyId))) legalId=(Required(Str(PLegalId))) dataBase64=(Required(Str(PDataBase64))) keySignature=(Required(Str(PKeySignature))) requestSignature=(Required(Str(PRequestSignature))) />
- Response (if successful)
- <SignatureResponse xmlns="https://waher.se/Schema/BrokerAgent.xsd" Signature=Required(Str(PSignature)) />
Input Parameters
| Parameter | Description | 
|---|---|
| PKeyId | Identity of key to use for signing the contract. It must correspond to the key used when signing the Legal Identity application that will be used to sign the contract. | 
| PLegalId | Identity of the Legal Identity that will be used to sign the smart contract. | 
| PDataBase64 | Binary data, base64-encoded, that will be signed. | 
| PKeySignature | Cryptographic signature of the key ID, using the key password. | 
| PRequestSignature | Cryptographic signature of the requesut, using the account password. | 
Response Parameters
| Parameter | Description | 
|---|---|
| PSignature | Base64-encoded signature. | 
Calculating the Key Signature
The signature in PKeySignature is calculated as follows.
- Concatenate the strings - PUserName ":" Host ":" PLocalName ":" PNamespace ":" PKeyIdand call it- s1, where- Hostis the host/domain name of the server. It is taken from the HTTP- Hostrequest header, so it must be the same as is used in the URL of the request.- PUserNameis the name of the account, used when creating the current account or logging in to the current account.- PLocalNameand- PNamespaceare the local name and namespace corresponding to the algorithm used for the key.
- UTF-8 encode the secret corresponding to the key, and call it - Key1.
- UTF-8 encode the string - s1, and call it- Data1.
- Calculate the HMAC-SHA256 signature using - Key1and- Data1, and call it- H1.
- Base64-encode - H1. The result is the key signature of the request.
Calculating the Request Signature
The signature in PRequestSignature is calculated as follows.
- Concatenate the strings - s1 ":" PKeySignature ":" PDataBase64 ":" PLegalId, and call it- s2.- s1is the intermediate result of computing the key signature in the previous step.
- UTF-8 encode the secret corresponding to the account, and call it - Key2.
- UTF-8 encode the string - s2, and call it- Data2.
- Calculate the HMAC-SHA256 signature using - Key2and- Data2, and call it- H2.
- Base64-encode - H2. The result is the signature of the request.
Javascript Library
Use the following asynchronous method in the Javascript Library, to call this resource. It computes the signatures according to the above specification.
var Response = await AgentAPI.Legal.SignData(LocalName,Namespace,KeyId,KeyPassword,AccountPassword,LegalId,DataBase64);