Skip to content

Commit 376cd11

Browse files
authored
docs(identity): add export import identity to the docs (#887)
re #872
1 parent 58132a9 commit 376cd11

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

apps/docs/versioned_docs/version-V4/guides/identities.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,33 @@ After a message is signed, anyone can verify the signature using the message its
109109
// Static method.
110110
Identity.verifySignature(message, signature, identity1.publicKey)
111111
```
112+
113+
## Export and import an identity
114+
115+
A Semaphore Identity can be exported and then imported later for reuse.
116+
117+
### Export an identity
118+
119+
Returns the private key encoded as a base64 string.
120+
121+
```ts
122+
import { Identity } from "@semaphore-protocol/identity"
123+
124+
const identity = new Identity()
125+
126+
const privateKey = identity.export()
127+
```
128+
129+
### Import an identity
130+
131+
Returns a Semaphore identity based on a private key encoded as a base64 string.
132+
133+
```ts
134+
import { Identity } from "@semaphore-protocol/identity"
135+
136+
const identity = new Identity()
137+
138+
const privateKey = identity.export()
139+
140+
const identity2 = Identity.import(privateKey)
141+
```

0 commit comments

Comments
 (0)