Skip to content

Commit

Permalink
fix: generate nonce with correct curve
Browse files Browse the repository at this point in the history
  • Loading branch information
guru-web3 committed Jan 3, 2024
1 parent a94043e commit 01c2324
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/routes/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable security/detect-object-injection */
import { generatePrivate } from "@toruslabs/eccrypto";
import { celebrate, Joi, Segments } from "celebrate";
import { ec as EC } from "elliptic";
import express, { Request, Response } from "express";
Expand Down Expand Up @@ -432,11 +431,11 @@ router.post(
if (nonce) {
pubNonce = await getPubNonce(true);
} else {
// create new nonce
nonce = generatePrivate().toString("hex");

const ec = keyType === "ed25519" ? new EC("ed25519") : new EC("secp256k1");

// create new nonce
nonce = ec.genKeyPair().getPrivate().toString("hex", 64);

const unformattedPubNonce = ec.keyFromPrivate(nonce).getPublic();
pubNonce = {
x: unformattedPubNonce.getX().toString("hex"),
Expand Down

0 comments on commit 01c2324

Please sign in to comment.