mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-04-09 12:37:22 +03:00
update secret generation
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ethers } from 'ethers';
|
||||
class XorShift128Plus {
|
||||
private x: number;
|
||||
private y: number;
|
||||
@@ -42,11 +41,13 @@ function isomorphicCryptoRandomBytes(size: number): Uint8Array {
|
||||
return generateRandomBytes(size, rng);
|
||||
}
|
||||
|
||||
const generateSecret = () => {
|
||||
function decodeToString(uint8Array: Uint8Array): string {
|
||||
return new TextDecoder('utf-8').decode(uint8Array);
|
||||
}
|
||||
|
||||
const generateSecret = (): string => {
|
||||
const RANDOM_BITS = 256;
|
||||
const rand = isomorphicCryptoRandomBytes(RANDOM_BITS);
|
||||
const secret = ethers.keccak256(rand);
|
||||
return secret;
|
||||
return decodeToString(isomorphicCryptoRandomBytes(RANDOM_BITS));
|
||||
};
|
||||
|
||||
export default generateSecret;
|
||||
|
||||
Reference in New Issue
Block a user