Offshift Pilot Client-Side Guide

cover.png

The following documentation serves as a guide for interacting with the Offshift Pilot from the client side.

How to Launch and Interact With Offshift v1 from the Client Side

The docker image of the project is available on DockerHub here .

To start working with the docker image it is necessary to perform the following steps:

1. Install Docker:

2. Download the image

The following command can be used to download the docker image:

docker pull offshiftxft/offshift:v1

Commands for working with the docker image:

docker images

shows a list of all uploaded images

docker ps

displays a list of running docker containers

docker run -p 10000:10000 offshiftxft/offshift:v1

run Offshift docker container

docker stop 0dc3dd70ee34

stop docker container with the following ID: “0dc3dd70ee34”

docker ps -a

list of all available docker containers

docker start 0dc3dd70ee34

command to restart the container with the following ID: “0dc3dd70ee34”


After launching the Offshift container, you can interact with it through the address bar of the browser or in the command line of the terminal.

To import the input parameters from the external file, you need to:

1. Create a text file with the inputs for the needed command. For example, for command /calculateR the file should be named calculateR.json

2. Save in a text file the input parameters in JSON structure format. For example, for /calculateR:

{
    "riSet":[
        {
        "X": 32138742690242662502241199693237900335204239496008641016955400178363039706333,
        "Y": 98206281677669063585309234705818540728303839018966295776521001268753556134537
    },
    {
        "X": 72664875838982340636391200513545812992442341844955961733021880193736610927495,
        "Y": 72911874978211977551112918690838955657286613708826885971426767283825381825555
    }
    ]
}

3. Using the terminal, go to the folder where the file “calculateR.json” is placed.

4. To run the functions that the client side supports use the command:

curl -i -X POST -H "Content-Type: application/json" -d "@calculateR.json" localhost:10000/calculateR

Commands for launching the functions:

curl -i -X POST -H "Content-Type: application/json" -d "@calculateR.json" localhost:10000/calculateR
curl -i -X POST -H "Content-Type: application/json" -d "@aggregatedPubKey.json" localhost:10000/aggregatedPubKey
curl -i -X POST -H "Content-Type: application/json" -d "@deposit.json" localhost:10000/deposit
curl -i -X POST -H "Content-Type: application/json" -d "@calculateR.json" localhost:10000/calculateR

Available functions

1. Generation of public and private keys

GET request

localhost:10000/keys

Input structure:

{
    "PublicKey": {
        "X": 42819040757234794584093116854165396038282133597267920781144937243512001014926,
        "Y": 16613036104697039678886172991403554573723255145849724300409746814594793225130
    },
    "PrivateKey": "54157417345273714740058805884274764565572769750057293434269112943657356706138"
}
2. Schnorr signature (for 1 user)

POST request

localhost:10000/singleSig

Input structure:

{
    "Message":"message",
    "PubKey": {
        "X": 42819040757234794584093116854165396038282133597267920781144937243512001014926,
        "Y": 16613036104697039678886172991403554573723255145849724300409746814594793225130
    },
    "PrivateKey":54157417345273714740058805884274764565572769750057293434269112943657356706138
}

where:

“Message” - message for signing

“PubKey” - public key

“PrivateKey” - private key

Input structure:

{
    "R": {
        "X": 26619072936970554793633308674556768341722133251180443441300007231460603320286,
        "Y": 17797583446333289396642296322720088426699648732141596014797534923278170021222
    },
    "S": "39273007503788457903883229402146682860498221642303828769312405490858972955250"
}
3. Schnorr signature (MuSig)

1) Keys aggregation

POST request

localhost:10000/aggregatedPubKey

Input structure:

{
    "publicKeySet":[
        {
        "X": 42819040757234794584093116854165396038282133597267920781144937243512001014926,
        "Y": 16613036104697039678886172991403554573723255145849724300409746814594793225130
    },
    {
        "X": 30321070545248488399817466362260044602937803709853919585846660296849009833522,
        "Y": 584349551486137423528370505680565301008648566037903166922050018102495266109
    }
    ]
}

where:

“publicKeySet” - array of public keys

Output

{
    "L": "10044379105078759254068858172401465623303715744628901774287844183625279572755",
    "aggregatedPublicKey": {
        "X": 47888315361302638903367170609134468073239076049676029663996381866167888048452,
        "Y": 33200710740928124072887427442985608165696834167521834699664649186021155932435
    }
}

2) Generation of new R pair for each participant

GET request

localhost:10000/singleRPair

Input structure:

{
    "R": {
        "X": 17529266385671245595536407394531335745706339870644603504895059274074937732906,
        "Y": 102540959697668743130910375595945245890854860109723215999926370604784619961945
    },
    "Valr": 54360372087333951267848278312006320762551551356108342357325534895569593873995
}

3) Generation of common R

POST request

localhost:10000/calculateR

Input structure:

{
    "riSet":[
        {
        "X": 32138742690242662502241199693237900335204239496008641016955400178363039706333,
        "Y": 98206281677669063585309234705818540728303839018966295776521001268753556134537
    },
    {
        "X": 72664875838982340636391200513545812992442341844955961733021880193736610927495,
        "Y": 72911874978211977551112918690838955657286613708826885971426767283825381825555
    }
    ]
}

Output structure:

{
    "X": 21954240974367986768968703217224470574531668758188507420077336449714863251255,
    "Y": 59257226922668145037564841935192103580724138939404350391193921365000813716903
}

4) Signature generation by each participant

POST request

localhost:10000/signaturePart

Input structure:

{
    "message":"1234",
    "Ri": {
        "X": 72664875838982340636391200513545812992442341844955961733021880193736610927495,
        "Y": 72911874978211977551112918690838955657286613708826885971426767283825381825555
    },
    "ri": 110277077903500845345512394751386888471914029780409723985344654177239377126024,
    "L": 92111008636566153212032464762143563073542001160751363761712155655010845645112,
    "aggregatedPublicKey": {
        "X": 53273021753290677733958181036785342793909515636172542173452266111914559687918,
        "Y": 80438816962432312406855120871023622040514830899308207189257144571508235291798
    },
    "R": {
        "X": 39187551096853091697318624048264502756276174131861726900667247414843938291671,
        "Y": 104858173701843540448383142892396261186943819363060132734804369366770619715086
    },
    "pubKey":{
        "X": 30321070545248488399817466362260044602937803709853919585846660296849009833522,
        "Y": 584349551486137423528370505680565301008648566037903166922050018102495266109
    },
    "privateKey":105670716540001694424498454195915610571798257276411699105868739679738559251819
}

where:

“Message” - message for signing

“Ri” - public key that was generated in step 2

“ri” - private key that was generated in step 2

“L” - generated value in step 1

“aggregatedPublicKey” - aggregated public key

“R” - private key that was generated in step 3

“pubKey” - public key

“privateKey” - private key

Output structure:

74443022546988139061598211812603205866830863595660865133631292810888798763966

5) Signatures aggregation

POST request

localhost:10000/aggregatedSignature

Input structure:

{
    "L": 92111008636566153212032464762143563073542001160751363761712155655010845645112,
    "aggregatedPublicKey": {
        "X": 53273021753290677733958181036785342793909515636172542173452266111914559687918,
        "Y": 80438816962432312406855120871023622040514830899308207189257144571508235291798
    },
    "R": {
        "X": 39187551096853091697318624048264502756276174131861726900667247414843938291671,
        "Y": 104858173701843540448383142892396261186943819363060132734804369366770619715086
    },
    "sigList":[
        105689801978300580997942871504732446698008366627471895897196456699423211941014,
        74443022546988139061598211812603205866830863595660865133631292810888798763966
    ]
}

where:

“L” - value generated in step 1

“aggregatedPublicKey” - aggregated public key

“R” - private key that was generated in step 3

“sigList” - list of individual signatures

Output structure:

{
    "R": {
        "X": 39187551096853091697318624048264502756276174131861726900667247414843938291671,
        "Y": 104858173701843540448383142892396261186943819363060132734804369366770619715086
    },
    "S": "51451353949343670787600886700040163140835898335017047734382576772724312283694"
}
4. Deposit

1) Schnorr signature (for 1 user)

2) Commitment generation

POST request

localhost:10000/generateCommitment

Input structure:

{
    "amount": 10000,
    "recipientPubKey": {
        "X": 53273021753290677733958181036785342793909515636172542173452266111914559687918,
        "Y": 80438816962432312406855120871023622040514830899308207189257144571508235291798
    },
    "L": 92111008636566153212032464762143563073542001160751363761712155655010845645112
}

where:

“amount” - amount of deposit

“recipientPubKey” - user’s public key

“L” - value generated while key aggregation

Output structure:

{
    "X": 19795565013315582606940396496562298516408683722983819558981515122355401190744,
    "Y": 89338180409720623908550592962307435189775861369417461463063483974668277481313
}

3) Deposit

POST request

localhost:10000/deposit

Input structure:

{
    "sender": "0x1b17552bE3192810B80AE14B6CF8769D5dF9FF9e",
    "senderPrivateKey": "88893ec39cb7725a46ac5bc44ee6e9642c5518ff507df5ca6ce37e622ed86d92",
    "commitment": {
        "X": 80896827534506630690547520492020251026855161557744096096567524235125637166228,
        "Y": 35340021902447857874733116252574618597035402700515652153758858212804173617786
    },
    "amount": 10000,
    "message": "message",
    "publicKey": {
        "X": 105012878946854625478151668840096389084932252989398520013599206687016371737084,
        "Y": 109332001306514958330197135056171475144957829515243433050908948584468608042267
    },
    "R": {
        "X": 50076431034714051257113545201217887633355089690556915100431086728944568565495,
        "Y": 100534334696491181083477625115660637245645677532597488342701629369138874590038
    },
    "S":"45407579404865038949469822443889530360183727020693714560400763628627243928653"
}

where:

“sender” - user address (metamask)

“senderPrivateKey” - private key (metamask)

“commitment” - calculated commitment

“amount” - deposit amount

“message” - message that was signed

“publicKey” - public key

“R” - part of Schnorr signature

“S” - part of Schnorr signature

5. Transfer of hidden tokens

1) Schnorr signature (MuSig)

2) Transfer

POST request

localhost:10000/transfer

Input structure:

{
    "sender": "0x1b17552bE3192810B80AE14B6CF8769D5dF9FF9e",
    "senderPrivateKey": "88893ec39cb7725a46ac5bc44ee6e9642c5518ff507df5ca6ce37e622ed86d92",
    "recipient": "0xf58FAB89AFAC097AE8DB81A67a01aaF456A361A5",
    "amount": 10000,
    "senderPubKey": {
        "X": 71274971107086009423654472625397165911876163557104606609532095793867594051721,
        "Y": 98502168618575688520806502038862068970238071196776002104116306534168193007953
    },
    "recipientPubKey": {
        "X": 20400392980662004582987447932701697310381594492307122531911924466916881217178,
        "Y": 109842135426088964300149151521482980156991777499160788235495451760041101648489
    },
    "message": "message",
    "aggregatedPublicKey": {
        "X": 105012878946854625478151668840096389084932252989398520013599206687016371737084,
        "Y": 109332001306514958330197135056171475144957829515243433050908948584468608042267
    },
    "L": 90223355694085419087863670107616094985267487352052136056399093451244047138415,
    "R": {
        "X": 50076431034714051257113545201217887633355089690556915100431086728944568565495,
        "Y": 100534334696491181083477625115660637245645677532597488342701629369138874590038
    },
    "S":"45407579404865038949469822443889530360183727020693714560400763628627243928653"
}

where:

“sender” - user address (metamask)

“senderPrivateKey” - private key (metamask)

“recipient” - recipient address

“amount” - transferred amount

“senderPubKey” - sender public key

“recipientPubKey” - recipient public key

“message” - message that was signed

“aggregatedPublicKey” - aggregated public key

“L” - value generated while key aggregation

““R” - part of Schnorr signature

“S” - part of Schnorr signature

6. Withdrawal

1) Schnorr signature (for 1 user)

2) Change commitment generation

POST request

localhost:10000/generateCommitment

Input structure:

{
    "amount": 10000,
    "recipientPubKey": {
        "X": 53273021753290677733958181036785342793909515636172542173452266111914559687918,
        "Y": 80438816962432312406855120871023622040514830899308207189257144571508235291798
    },
    "L": 92111008636566153212032464762143563073542001160751363761712155655010845645112
}

where:

“amount” - amount that left on the balance

“recipientPubKey” - recipient public key

“L” - value generated while key aggregation

Output structure:

{
    "X": 19795565013315582606940396496562298516408683722983819558981515122355401190744,
    "Y": 89338180409720623908550592962307435189775861369417461463063483974668277481313
}

3) Withdrawal

POST request

localhost:10000/withdraw

Input structure:

{
    "sender": "0x1b17552bE3192810B80AE14B6CF8769D5dF9FF9e",
    "senderPrivateKey": "88893ec39cb7725a46ac5bc44ee6e9642c5518ff507df5ca6ce37e622ed86d92",
    "commitmentOldId": 1640100991,
    "commitment": {
        "X": 29581854941473273780983167316696779832306506083614655401787514381088218353587,
        "Y": 95742839520915075053972174008082682421116400817893831937435579328761440955019
    },
    "amount": 10000,
    "message": "message",
    "publicKey": {
        "X": 105012878946854625478151668840096389084932252989398520013599206687016371737084,
        "Y": 109332001306514958330197135056171475144957829515243433050908948584468608042267
    },
    "R": {
        "X": 50076431034714051257113545201217887633355089690556915100431086728944568565495,
        "Y": 100534334696491181083477625115660637245645677532597488342701629369138874590038
    },
    "S":"45407579404865038949469822443889530360183727020693714560400763628627243928653"
}

where:

“sender” - user address (metamask)

“senderPrivateKey” - private key (metamask)

“commitmentOldId” - commitment id that is withdrew

“commitment” - change commitment calculated on step 2

“amount” - withdrawal amount

“message” - message that was signed

“publicKey” - public key

““R” - part of Schnorr signature

“S” - part of Schnorr signature


About Offshift

Offshift is leading private decentralized finance (PriFi) with the world’s first Private Derivatives Platform. It leverages zero-knowledge (zk) proofs and sources reliable, real-time price feeds from Chainlink’s decentralized oracle network to enable users to mint zkAssets, an unprecedented line of fully private synthetics. Offshift’s mostly anonymous team has developed a trusted reputation for their thorough privacy research, development and execution.

To learn more and get involved, visit the links below:

Website | Telegram | Discord | Twitter | Instagram | YouTube | Buy XFT