@xmr-core/xmr-crypto-utils
Version:
Core crypto operations for Monero and implementations and interfaces of various hardware devices for creating Monero transactions securely
18 lines (14 loc) • 446 B
text/typescript
import { randomBytes } from "crypto";
import { sc_reduce32 } from "../crypto-ops/primitive_ops";
// Generate a 256-bit / 64-char / 32-byte crypto random
export function rand_32() {
return randomBytes(32).toString("hex");
}
// Generate a 64-bit / 16-char / 8-byte crypto random
export function rand_8() {
return randomBytes(8).toString("hex");
}
// Random 32-byte ec scalar
export function random_scalar() {
return sc_reduce32(rand_32());
}