Skip to content

RPC API

haijuncai edited this page May 6, 2022 · 10 revisions

1. smpc_getReqAddrNonce(account string) string

account is the account that initiated the request of generating public key.

The return value is the nonce value of the account.

2. smpc_reqSmpcAddr(raw string) string

raw is a signed special transaction for the request of generating public key. The nonce of the transaction is obtained through the rpc smpc_getReqAddrNonce. The data format is:

{
"TxType":"REQSMPCADDR",
"GroupId":"XXX",
"ThresHold":"XXX",
"Mode":"XXX",
"TimeStamp":"XXX",
"Sigs":"Sig1 | Sig2 | ... | SigN"
}

model = “0” co-management mode

model = “1” non-co-management mode

threshold is the threshold value, such as 3/3 or 2/3.

timestamp:The time when the user initiates this request.

Sig1 ---- SigN is empty when mode = 1

Sig1 = enodeID1@IP1:PORT1 + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeID1), privateKey1))

Sig2 = enodeID2@IP2:PORT2 + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeID2), privateKey2))

....

SigN = enodeIDN@IPN:PORTN + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeIDN), privateKeyN))

The return value is the key of the unique ID of this request .

3. smpc_getCurNodeReqAddrInfo(geteracc string) string

geteracc is the login user account corresponding to the node calling the rpc.

The return value is the unprocessed request of generating public key in the current node, the format is:

{
"jsonrpc":"2.0",
"id":67,
"result":
{
"Data":
[
{"Key":"xxxxx","Account":"xxxxx","Cointype":"xxxx","GroupId":"xxxx","Nonce":"xxxx","ThresHold":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"},
{"Key":"xxxxx","Account":"xxxxx","Cointype":"xxxx","GroupId":"xxxx","Nonce":"xxxx","ThresHold":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"}
],
"Error":"",
"Status":"Success",
"Tip":""
}
}

4. smpc_acceptReqAddr(raw string) string

raw is a special transaction that agrees to the request of generating public key, the data format is:

{
"TxType":"ACCEPTREQADDR",
"Key":"XXX",
"Accept":"XXX",
"TimeStamp":"XXX"
}

key is the unique ID of the request to be agreed

accept is AGREE or DISAGREE

The return value is the status such as success or failure.

5. smpc_getAccounts(geteracc,mode string) string

geteracc is the login user account corresponding to the node calling the rpc

The return value is the set of all public keys generated by special account and mode. the data format is:

{
"groupid1":[ {"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"...":"..."}{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"} ],
"groupid2":[ {"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"...":"..."}{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"} ],
"groupidn":[ {"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"},{"...":"..."}{"PubKey":"xxx","ThresHold":"xxx","TimeStamp":"xxxx"} ]
}

6. smpc_getAccountsBalance(pubkey string,geteracc string) string

pubkey is the public key.

geteracc is the login user account corresponding to the node calling the rpc.

The return value is the balance of each currency under the public key.

7. smpc_getReqAddrStatus(key string) string

key is the unique ID of the request of generating public key.

The returned data format is: { "Status":"xxx","PubKey":"xxx","Tip":"xxx","Error":"xxx","AllReply":"xxx","TimeStamp":"xxx" }

where AllReply is the answer to whether all nodes in the group agree with the request of generating public key or not,its value is {} or {"Enode": "xxx1","Status": "Agree","Timestamp": "xxxx","Initiator":"0"}

8. smpc_getBalance(account string,cointype string,smpcaddr string) string

account is the account of the initiator, empty if not exists.

smpcaddr is the mpc address.

The return value is the balance of the mpc address.

9. smpc_sign(raw string) string

raw is a special transaction of the request of signing . The nonce of the transaction is obtained through the smpc_getSignNonce. The data format is:

{
"TxType":"SIGN",
"PubKey":"XXX",
"MsgHash":"XXX",
"MsgContext":"XXX",
"Keytype":"XXX",
"GroupId":"XXX",
"ThresHold":"XXX",
"Mode":"XXX",
"TimeStamp":"XXX"
}

pubkey is the public key.

Assuming that the byte array to be signed is MSG, msghash = '0x' + hex Encodetostring (MSG), MsgHash is the array of msghash.

MsgContext is the corresponding unsigned transaction context information.

The value of keytype is "EC256K1" or "ED25519".

threshold is the threshold value, such as 3/3 or 2/3.

timestamp: The time when the user initiated this request.

The return value is the sign result(rsv).

10. smpc_acceptSign(raw string) string

raw is a special transaction that agrees to the request of signing, the data format is:

{
"TxType":"ACCEPTSIGN",
"Key":"XXX",
"Accept":"XXX",
"TimeStamp":"XXX"
}

key is the unique ID of the request of signing to be agreed

accept is AGREE/DISAGREE

The return value is the status such as success or failure.

11. smpc_getSignNonce(account string) string

account is the account that initiated the request of signing.

The return value is the nonce value of the account.

12. smpc_getCurNodeSignInfo(geteracc string) string

geteracc is the login user account corresponding to the node calling the rpc.

The return value is the unprocessed request of signing in the current node, the format is:

{
"jsonrpc":"2.0",
"id":67,
"result":
{
"Data":
[
{"Raw":"xxxxxx","Key":"xxxxx","Account":"xxxxx","PubKey":"xxxx","MsgHash":"xxxx","MsgContext":"xxxx","KeyType":"xxxx","GroupId":"xxxx","Nonce":"xxxxx","ThresHold":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"},{"Raw":"xxxxxx","Key":"xxxxx","Account":"xxxxx","PubKey":"xxxx","MsgHash":"xxxx","MsgContext":"xxxx","KeyType":"xxxx","GroupId":"xxxx","Nonce":"xxxxx","ThresHold":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"}
],
"Error":"",
"Status":"Success",
"Tip":""
}
}

13. smpc_getSignStatus(key string) string

key is the unique ID of the request of signing.

The returned data format is:

{"Status":"xxx","Rsv":"xxx","Tip":"xxx","Error":"xxx","AllReply":"xxx","TimeStamp":"xxx"}

where AllReply is the answer to whether all nodes in the group agree to sign or not,its value is {} or {"Enode": "xxx1","Status": "Agree","Timestamp": "xxxx","Initiator":"0"}

14. smpc_reShare(raw string) string

raw is a special transaction of the request of resharing, the data format is:

{
"TxType":"RESHARE",
"PubKey":"XXX",
"GroupId":"XXX",
"TSGroupId":"XXX",
"ThresHold":"XXX",
"Account":"XXX",
"Mode":"XXX",
"Sigs":"Sig1 | Sig2 | ... | SigN"  
"TimeStamp":"XXX"
}

pubkey is the public key.

groupid is the id of the group contain all nodes.

tsgroupid is the id of subgroup which node is involved to perform the reshare procedure. The number of its members must be greater than or equal to the threshold and cannot be a node that has lost private key.

threshold is the threshold value, such as 3/3 or 2/3.

model = “0” co-management mode

model = “1” non-co-management mode

account is the account that initiated the request of generating this public key.

Sig1 ---- SigN is empty when mode = 1

Sig1 = enodeID1@IP1:PORT1 + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeID1), privateKey1))

Sig2 = enodeID2@IP2:PORT2 + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeID2), privateKey2))

....

SigN = enodeIDN@IPN:PORTN + hex.EncodeToString(crypto.Sign(crypto.Keccak256(enodeIDN), privateKeyN))

timestamp: time when the user initiate this request.

The return value is the key of the unique ID of this request .

15. smpc_acceptReShare(raw string) string

raw is a special transaction that agrees to the request of resharing, and the data format is:

{
"TxType":"ACCEPTRESHARE",
"Key":"XXX",
"Accept":"XXX",
"TimeStamp":"XXX"
}

key is the unique ID of this request to be agreed

accept is AGREE/DISAGREE

The return value is the status such as success or failure.

16. smpc_getCurNodeReShareInfo() string

The return value is the unprocessed request of resharing in the current node, the format is:

{
"jsonrpc":"2.0",
"id":67,
"result":
{
"Data":
[
{"Key":"xxxxx","Pubkey":"xxxx","GroupId":"xxxx","TSGroupId":"xxxx","ThresHold":"xxxx","Account":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"},
{"Key":"xxxxx","Pubkey":"xxxx","GroupId":"xxxx","TSGroupId":"xxxx","ThresHold":"xxxx","Account":"xxxx","Mode":"xxxx","TimeStamp":"xxxxx"}
],
"Error":"",
"Status":"Success",
"Tip":""
}
}

17. smpc_getReShareStatus(key string) string

key is the unique ID of the request of resharing.

The returned data is:

{"Status":"xxx","Pubkey":"xxx","Tip":"xxx","Error":"xxx","AllReply":"xxx","TimeStamp":"xxx"}

where, AllReply is the answer of whether all nodes in the group agree to reshare or not, its value is {} or {"Enode": "xxx1","Status": "Agree","Timestamp": "xxxx","Initiator":"0"}