Split Secret
Splits a secret into multiple pieces using either standard secret sharing or Shamwari QKP (key pair) sharing. Provide either secret/secretPhrase or a Shamwari QKP key pair, but not both. Requires POST.
Request
POST /nxt?requestType=splitSecret&secret=<secret>&totalPieces=<n>&minimumPieces=<k>&primeFieldSize=<p>
OR
POST /nxt?requestType=splitSecret&secretPhrase=<secretPhrase>&totalPieces=<n>&minimumPieces=<k>
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
secret | string | Conditional | Secret string to split. Required if no Shamwari QKP is provided. |
secretPhrase | string | Conditional | Secret passphrase to split (account-based). Required if no Shamwari QKP is provided. |
totalPieces | integer | Conditional | Total number of pieces to create. Required if no Shamwari QKP. Range: 2-9. |
minimumPieces | integer | Conditional | Minimum pieces needed to reconstruct. Required if no Shamwari QKP. Range: 1-9. |
primeFieldSize | BigInteger | No | Prime field size for splitting. Required only if secret is provided. |
Response
Normal Secret
{
"pieces": ["piece1", "piece2"],
"totalPieces": 2,
"minimumPieces": 2,
"actualPrimeFieldSize": "123456789"
}
Shamwari QKP
{
"pieces": [
{
"index": 1,
"privateShare": "share1",
"publicShare": "share2"
},
{
"index": 2,
"privateShare": "share3",
"publicShare": "share4"
}
],
"totalPieces": 2,
"minimumPieces": 1
}
Error Responses
| Condition | Response |
|---|---|
| Both secret and Shamwari QKP provided | {"error": "either secret or secretPhrase"} |
| Neither secret nor Shamwari QKP provided | {"error": "missing secret or secretPhrase"} |
| Splitting failed | {"error": "Failed to split secret"} |
Notes
- This endpoint does not require the blockchain to be running (
requireBlockchain = false). - Not chain-specific.
- Requires POST method (
requirePost = true). - Does not require admin password authentication (
requirePassword = false). - Uses
SecretSharingGenerator.split()for normal secrets andSecretSharingGenerator.splitShamwariQKP()for QKP shares. - If Shamwari QKP is provided, the combined public key is verified against the associated account (if specified).
Source: SplitSecret.java.
Example
curl -X POST "http://localhost:22024/nxt" \
-d "requestType=splitSecret" \
-d "secret=mySecret" \
-d "totalPieces=2" \
-d "minimumPieces=2"