Introduction
Welcome to the SWIPE API (alpha version)! You can use our API to access SWIPE API endpoints for encryption and decryption utilities as well as data requests and re-encryption.
We have language bindings in Shell! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Utilities
Generate keypairs
curl "https://privacyapi.swipecrypto.com/util/gen-key"
The above command returns JSON structured like this:
{
"private_key": "fzpuSvNxWRxT3dPai4G7Qay1FQJGxVBVnWeyAqKKALA=",
"public_key": "AqisQZ9fIpesq+9p7xaFL75hKXdNi4XD5R16ch1esN0e",
"success": true
}
This endpoint generates the public and private key.
HTTP Request
GET https://privacyapi.swipecrypto.com/util/gen-key
Responses
Response | Description |
---|---|
private_key | Generated private key. Private key is required in order to decrypt and generate reencryption key. |
public_key | Generated public key. Public key is also used as user's identity. |
success | true or false. |
Encrypt
curl --header "Content-Type: application/json" \
--request POST \
--data '{"public_key":"A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE","payload":{"name":"Alex"}}' \
https://privacyapi.swipecrypto.com/util/encrypt
The above command returns JSON structured like this:
{
"capsule": "AqDohL6EUEDkjhoXZf7WBpEovGQZD7CljmnhEu2CZ9McAsfDGaRSlJPwi6sogcLGHtgOBNqJu8hcZ5DtYvk1yWKTPNH5tYBGHnZLPOwoP4pM7qCwcKPLdMum5dToa3zkRok=",
"ipfs_hash": "QmQ983q7sdUCDPNk5sJdUJuPs5Ut6vpfcNEqU4k8qdoEfs",
"success": true,
"ipfs_url": "https://ipfs.infura.io/ipfs/QmQ983q7sdUCDPNk5sJdUJuPs5Ut6vpfcNEqU4k8qdoEfs"
}
This endpoint encrypts payload based on public key parameter.
HTTP Request
POST https://privacyapi.swipecrypto.com/util/encrypt/
URL Parameters
Parameter | Description |
---|---|
public_key | Data owner's public key |
payload | User data to be encrypted in JSON format |
Responses
Response | Description |
---|---|
capsule | Key Encapsulation Mechanism (KEM) cyphertext. Capsule is required in order to decrypt and generate reencryption key. |
ipfs_hash | IPFS hash address of the encrypted data. |
success | true or false. |
ipfs_url | IPS URL of the encrypted data. |
Decrypt
curl --header "Content-Type: application/json" \
--request POST \
--data '{"capsule": "AizRcV4N6iwzQ+KUOK/S7UJkqzxXAkrvfcBTAdzIJ2dwA9dAXdaYCcSB7q6wl7o7Z7glO37DqINkZIaHCy3HX/ykTCUMem50PKyycxH8i5gsb7FNvdtu/w+fZpG6eGCcuZA=", "ipfs_hash": "QmUrUowtDnFz4TByhcZJKYkUrjww7uD8xG1oT4p2ffLhti", "private_key": "vrQDKUwH5rJIfXznVa1ujbjbi0ZkAbwqqZ1YSy5AiDs=", "public_key":"A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE"}' \
https://privacyapi.swipecrypto.com/util/decrypt
The above command returns JSON structured like this:
{
"payload": {
"name": "alex"
},
"success": true
}
This endpoint decrypts own encrypted data.
HTTP Request
POST https://privacyapi.swipecrypto.com/util/decrypt/
URL Parameters
Parameter | Description |
---|---|
capsule | Key Encapsulation Mechanism (KEM) cyphertext. Capsule is required in order to decrypt and generate reencryption key. |
ipfs_hash | IPFS hash address of the encrypted data. |
private_key | Data owner's private key |
public_key | Data owner's public key |
Responses
Response | Description |
---|---|
payload | Decrypted user data in JSON format. |
success | true or false. |
Generate Reencryption Key
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "owner_private_key":"vrQDKUwH5rJIfXznVa1ujbjbi0ZkAbwqqZ1YSy5AiDs=", "requestor_public_key":"ArZFkME4kLbjQOMqBzO3yM32qbq6rXhZMOmd84T/YdMX" }' \
https://privacyapi.swipecrypto.com/util/reencrypt
The above command returns JSON structured like this:
{
"kfrags": [
"gIrYjBAbhFg821uXx7BWSdx/dSAwaTIk35bxm6vkh1ZGy+RRIIIiEUMopBTjK+fC7V4r7SOcZwy+MORhoZi/uwPT/FuFx1sNPyRqx4XatFpgVf8jvJFsVT6EYyyHnN4baAOHMQ64SaY0F+iEk1ZbgGzwkONhGrvF1LQWL+EXFaLCSANstZbSGFIE48L9irZZG3uBC4znyWc27/2aTpmuS3CUWDE3qtR7EYx2qiZhVCSVbA8jSWEmmzdqa83l9G1HIXHVS4hNjBn73WOvWnUBEJa8MCaqZta2tsABOlZ1u/0wSYY="
],
"signing_pub_key": "Aj/ohmWXqpxpkDgnayl7HlBj4b+ifd/z8ybCGH9MDAFh",
"success": true
}
This endpoint generates reencryption keys.
HTTP Request
POST https://privacyapi.swipecrypto.com/util/reencrypt/
URL Parameters
Parameter | Description |
---|---|
owner_private_key | Data owner's private key. |
requestor_public_key | Data requestor's public key. |
Responses
Response | Description |
---|---|
kfrags | Re-encryption keys. |
signing_pub_key | Data Owner's signing key. |
success | true or false. |
Request
Create new data request
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "ipfs_hash": "QmQ983q7sdUCDPNk5sJdUJuPs5Ut6vpfcNEqU4k8qdoEfs", "owner_public_key": "A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE", "requestor_public_key": "ArZFkME4kLbjQOMqBzO3yM32qbq6rXhZMOmd84T/YdMX"}' \
https://privacyapi.swipecrypto.com/request/new
The above command returns JSON structured like this:
{
"contract_address": "0xdE7f4b6Cdc7fC362B633C470d9096380B683CFBa",
"request_id": "76dfa0f6-c9f0-406f-ac23-84cd49c1171c",
"success": true,
"tx_hash": "0xc476ddcabc9890a896bf1db3813eabd6054cb344d2121363a49ae58bfad13999"
}
This endpoint creates new data request. Created smart contract is accessible via https://kovan.etherscan.io/tx/{tx_hash}
HTTP Request
POST https://privacyapi.swipecrypto.com/request/new
Query Parameters
Parameter | Description |
---|---|
ipfs_hash | IPFS hash address of the encrypted data. |
owner_public_key | Data owner's public key. |
requestor_public_key | Data requestor's public key. |
Responses
Response | Description |
---|---|
contract_address | Smart contract address created to manage the data request. |
request_id | Identifier for the data request. |
success | true or false. |
tx_hash | Transaction hash of the smart contract creation. |
Check My Data Request
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "requestor_public_key" : "ArZFkME4kLbjQOMqBzO3yM32qbq6rXhZMOmd84T/YdMX" }' \
https://privacyapi.swipecrypto.com/request/status/<RequestID>
The above command returns JSON structured like this:
{
"data": {
"contract_address": "0xDB222D7Fed715C9328288bc457F51e54A3843e76",
"ipfs_hash": "QmUrUowtDnFz4TByhcZJKYkUrjww7uD8xG1oT4p2ffLhti",
"owner_public_key": "A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE",
"request_id": "94d7f94f-87a8-497e-b1b1-d9425bf6870b",
"requestor_public_key": "ArZFkME4kLbjQOMqBzO3yM32qbq6rXhZMOmd84T/YdMX",
"status": "PENDING"
},
"success": true
}
This endpoint checks the status of my data request.
HTTP Request
POST https://privacyapi.swipecrypto.com/request/status/<RequestID>
Query Parameters
Parameter | Description |
---|---|
requestor_public_key | Data requestor's public key. |
Responses
Response | Description |
---|---|
contract_address | Smart contract address created to manage the data request. |
ipfs_hash | IPFS hash address of the encrypted data. |
owner_public_key | Data owner's public key. |
request_id | Identifier for the data request. |
requestor_public_key | Data requestor's public key. |
status | PENDING or APPROVED or REJECTED |
success | true or false. |
Retrieve Data Requests to Myself
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "owner_public_key":"A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE" }' \
https://privacyapi.swipecrypto.com/request/list/all
The above command returns JSON structured like this:
{
"data": [
{
"contract_address": "0xDB222D7Fed715C9328288bc457F51e54A3843e76",
"ipfs_hash": "QmUrUowtDnFz4TByhcZJKYkUrjww7uD8xG1oT4p2ffLhti",
"owner_public_key": "A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE",
"request_id": "94d7f94f-87a8-497e-b1b1-d9425bf6870b",
"requestor_public_key": "ArZFkME4kLbjQOMqBzO3yM32qbq6rXhZMOmd84T/YdMX",
"status": "PENDING"
}
],
"success": true
}
This endpoint retrieves all data requests to myself.
HTTP Request
POST https://privacyapi.swipecrypto.com/request/list/<status> [all|pending|rejected|approved]
Query Parameters
Parameter | Description |
---|---|
owner_public_key | Data owner's public key. |
Responses
Response | Description |
---|---|
contract_address | Smart contract address created to manage the data request. |
ipfs_hash | IPFS hash address of the encrypted data. |
owner_public_key | Data owner's public key. |
request_id | Identifier for the data request. |
requestor_public_key | Data requestor's public key. |
status | PENDING or APPROVED or REJECTED |
success | true or false. |
Approve Data Request
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "owner_public_key":"A/bNEla4pTjOBVBfwsgKgZkhA9xSnTGUcbWQWmMPTTXE", "request_id":"94d7f94f-87a8-497e-b1b1-d9425bf6870b", "kfrags": [ "U4gT3nvUTuYrvakhizbTttXjrR2SRc2GmHVdpK/ojPCk5kcIGwIlEGxFIzCjFWfZpE7+f6r3TE3jYhonf9Dh8QL0Md/FMfsvsUfptKmqIamwsROxejlwlyTzgZK98+JNYwJ1/X05Vp+KLdR8AbW29ssCGI5MJ0b1FVzv6trPiX2PaQISw2ZGftsLpBdl2NwQcFFxYlWzCPCSzr1bnw7QLLqJslAq4JgLisXlPus5gm9XYpaiodMZf1zrrsbLcYMC81bDQYgOJn/csf3BRufftMyiZE5SZhs60/YoCV/06wQNpVg=" ], "signing_pub_key": "Aj/ohmWXqpxpkDgnayl7HlBj4b+ifd/z8ybCGH9MDAFh", "capsule":"AizRcV4N6iwzQ+KUOK/S7UJkqzxXAkrvfcBTAdzIJ2dwA9dAXdaYCcSB7q6wl7o7Z7glO37DqINkZIaHCy3HX/ykTCUMem50PKyycxH8i5gsb7FNvdtu/w+fZpG6eGCcuZA=" }' \
https://privacyapi.swipecrypto.com/request/approve
The above command returns JSON structured like this:
{
"request_id": "94d7f94f-87a8-497e-b1b1-d9425bf6870b",
"status": "APPROVED",
"success": true,
"tx_hash": "0xb7b66c80ddabd38cd6acd1170f35faa50a66bd06e176e2b1e2fd65d21e3a3e21"
}
This endpoint approves data request to myself.
HTTP Request
POST https://privacyapi.swipecrypto.com/request/approve
Query Parameters
Parameter | Description |
---|---|
owner_public_key | Data owner's public key. |
Responses
Response | Description |
---|---|
contract_address | Smart contract address created to manage the data request. |
ipfs_hash | IPFS hash address of the encrypted data. |
owner_public_key | Data owner's public key. |
request_id | Identifier for the data request. |
requestor_public_key | Data requestor's public key. |
status | PENDING or APPROVED or REJECTED |
success | true or false. |
Decrypt Data Request
curl --header "Content-Type: application/json" \
--request POST \
--data '{ "requestor_private_key":"9J4Boenuy35T903+CQfkqS+ZR+bp7DuZYkf7e7kxyXI=", "requestor_public_key":"Anfbq64i+SMnnz4S6AL62jFZdknCwP//NPfg/JX8wMll" }' \
https://privacyapi.swipecrypto.com/util/decrypt-request/<RequestID>
The above command returns JSON structured like this:
{
"payload": {
"name": "Alex"
},
"success": true
}
This endpoint decrypts approved data request.
HTTP Request
POST https://privacyapi.swipecrypto.com/util/decrypt-request/<RequestID>
Query Parameters
Parameter | Description |
---|---|
requestor_public_key | Data requestor's public key. |
requestor_private_key | Data requestor's private key. |
Responses
Response | Description |
---|---|
payload | User data decrypted in JSON format |
success | true or false. |