Installation and usage of the platform

REST API: signing and validating messages in the blockchain

https://img.shields.io/badge/auth-required-orange.svg

The following methods of the addresses group are provided for signing and validating messages:

POST /addresses/sign/{address}

The method signs the string passed in the message field with the addressee {address} private key and then serializes it in base58 format.

Important

The addresses/sign method is not available when PKI is used, that is, when the node configuration file parameter node.crypto.pki.mode is set to ON. The method can be used in PKI test mode (node.crypto.pki.mode = TEST) or with PKI disabled (node.crypto.pki.mode = OFF).

The method returns the serialized string, the addressee’s public key and signature in the response.

Examples of a query and a response:

POST /addresses/sign/{address}:

Query:

{
 "message": "mytext"
}

Response:

{
  "message": "wWshKhJj",
  "publicKey": "C1ADP1tNGuSLTiQrfNRPhgXx59nCrwrZFRV4AHpfKBpZ",
  "signature": "62PFG855ThsEHUZ4N8VE8kMyHCK9GWnvtTZ3hq6JHYv12BhP1eRjegA6nSa3DAoTTMammhamadvizDUYZAZtKY9S"
}

POST /addresses/verify/{address}

The method checks the signature of the message made by the {address}.

Examples of a query and a response:

POST /addresses/verify/{address}:

Query:

{
  "message": "wWshKhJj",
  "publickey": "C1ADP1tNGuSLTiQrfNRPhgXx59nCrwrZFRV4AHpfKBpZ",
  "signature": "5kwwE9sDZzssoNaoBSJnb8RLqfYGt1NDGbTWWXUeX8b9amRRJN3hr5fhs9vHBq6VES5ng4hqbCUoDEsoQNauRRts"
}

Response:

{
  "valid": true
}

POST /addresses/signText/{address}

The method signs the string passed in the message field with the private key of an {address}. Unlike the POST /`addresses/sign/{address} method, the string is passed in the original format.

Important

The addresses/signText method is not available when PKI is used, that is, when the node configuration file parameter node.crypto.pki.mode is set to ON. The method can be used in PKI test mode (node.crypto.pki.mode = TEST) or with PKI disabled (node.crypto.pki.mode = OFF).

Examples of a query and a response:

POST /addresses/signText/{address}:

Query:

{
  "message": "mytext"
}

Response:

{
  "message": "mytext",
  "publicKey": "C1ADP1tNGuSLTiQrfNRPhgXx59nCrwrZFRV4AHpfKBpZ",
  "signature": "5kVZfWfFmoYn38cJfNhkdct5WCyksMgQ7kjwHK7Zjnrzs9QYRWo6HuJoGc8WRMozdYcAVJvojJnPpArqPvu2uc3u"
}

POST /addresses/verifyText/{address}

Checks the signature of the message made by the {address} via the POST method /addresses/signText/{address}.

Examples of a query and a response:

POST /addresses/verifyText/{address}:

Query:

{
  "message": "mytext",
  "publicKey": "C1ADP1tNGuSLTiQrfNRPhgXx59nCrwrZFRV4AHpfKBpZ",
  "signature": "5kVZfWfFmoYn38cJfNhkdct5WCyksMgQ7kjwHK7Zjnrzs9QYRWo6HuJoGc8WRMozdYcAVJvojJnPpArqPvu2uc3u"
}

Response:

{
  "valid": true
}
See also