(secret: Uint8Array)
| 163 | * Generate authentication challenge response |
| 164 | */ |
| 165 | export function authChallenge(secret: Uint8Array): { |
| 166 | challenge: Uint8Array |
| 167 | publicKey: Uint8Array |
| 168 | signature: Uint8Array |
| 169 | } { |
| 170 | const keypair = tweetnacl.sign.keyPair.fromSeed(secret); |
| 171 | const challenge = getRandomBytes(32); |
| 172 | const signature = tweetnacl.sign.detached(challenge, keypair.secretKey); |
| 173 | |
| 174 | return { |
| 175 | challenge, |
| 176 | publicKey: keypair.publicKey, |
| 177 | signature |
| 178 | }; |
| 179 | } |
no test coverage detected