Quick start
Our quick start guide will help you to get started with our product quickly.
You can use Hooks
and async functions
to make it easy to use our product application.
Note: The all MPCs functions(key-generation, sign-generation) are calls
WS
requests to the cloud node, and to secure the communication, all functions needs auserToken
andpartyKey(ECDSAP1PartyKeys)
to authenticate the user.
The
partyKey
acts as a user phone identity and for all the library exposed functions requiresECDSAP1PartyKeys
class's instance from@silencelaboratories/react-native-two-party-ecdsa
.The
userToken
is a unique JWT for each user, and it is used to authenticate the user. This token needs to be generated in the backend side which usesCloud Node
an admin token to create one. For theNode.JS
environment, you can use sigpair-admin-v2 package.
User Identity
Our SDK has a two-user identity user_id
and partyKey
. The user_id
is a unique ID for each user in the cloud node and needs to be generated on the application backend for each new user. This partyKey
is a unique identity for mobile device's run time. The partyKey
is generated by the ECDSAP1PartyKeys
or restored from old one.
JWT structure
{
"user_id": "USER_ID",
"exp": "EXPIRATION_TIME",
"iat": "ISSUED_AT_TIME",
"public_key": "PARTY_KEY's_PUBLIC_KEY"
}
The secret is base64 encoded `Cloud Node` admin token.
Important: The
userToken
'spublic_key
andpartyKey
should be the same fromECDSAP1PartyKeys
's class instance.
Using the Hooks
import { DuoProvider, useECDSAKeyGen } from '@silencelaboratories/react-native-duo-sdk';
import { ECDSAP1PartyKeys } from '@silencelaboratories/react-native-two-party-ecdsa';
import { Button, Text, View } from 'react-native';
const cloudNodeUrl = 'CLOUD_NODE_URL';
function App() {
return (
<DuoProvider
cloudNodeUrl={cloudNodeUrl}
>
<KeygenTest />
</DuoProvider>
);
}
function KeygenTest() {
const { isLoading, keyshare, error, asyncKeygen } = useECDSAKeyGen();
const handleKeygen = async () => {
const partyKey = await ECDSAP1PartyKeys.create();
const userToken = 'USER_TOKEN';
const localKeyshare = await asyncKeygen({
userToken,
partyKey
});
console.log('localKeyshare', localKeyshare);
};
if (isLoading) {
return (
<View>
<Text>Loading...</Text>
</View>
);
}
if (error) {
return (
<View>
<Text>Error: {error.message}</Text>
</View>
);
}
if (keyshare) {
return (
<View>
<Text>Keyshare: {keyshare}</Text>
<Button onPress={handleKeygen} title="Generate new key keyshare"/>
</View>
);
}
return (
<Button onPress={handleKeygen} title="Generate key keyshare"/>
);
}
Using async functions
import { DuoProvider, useECDSAKeyGen } from '@silencelaboratories/react-native-duo-sdk';
import { ECDSAP1PartyKeys } from '@silencelaboratories/react-native-two-party-ecdsa';
import { Button } from 'react-native';
const cloudNodeUrl = 'CLOUD_NODE_URL';
function App() {
const handleKeygen = async () => {
const partyKey = await ECDSAP1PartyKeys.create();
const userToken = 'USER_TOKEN';
const localKeyshare = await keyGenECDSA({
url: cloudNodeUrl,
partyKey,
userToken,
});
console.log('localKeyshare', localKeyshare);
};
return (
<Button onPress={handleKeygen} title="Generate key keyshare"/>
);
}
Last updated