docs(identity): add export import identity to the docs (#887)

re #872
This commit is contained in:
Vivian Plasencia
2024-10-28 13:29:35 +01:00
committed by GitHub
parent 58132a9478
commit 376cd11808

View File

@@ -109,3 +109,33 @@ After a message is signed, anyone can verify the signature using the message its
// Static method.
Identity.verifySignature(message, signature, identity1.publicKey)
```
## Export and import an identity
A Semaphore Identity can be exported and then imported later for reuse.
### Export an identity
Returns the private key encoded as a base64 string.
```ts
import { Identity } from "@semaphore-protocol/identity"
const identity = new Identity()
const privateKey = identity.export()
```
### Import an identity
Returns a Semaphore identity based on a private key encoded as a base64 string.
```ts
import { Identity } from "@semaphore-protocol/identity"
const identity = new Identity()
const privateKey = identity.export()
const identity2 = Identity.import(privateKey)
```