mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 14:48:12 -05:00
@@ -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)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user