Merge branch 'develop' into sg721-updatable-integration

This commit is contained in:
Serkan Reis
2023-03-07 19:07:59 +03:00
committed by GitHub
27 changed files with 1261 additions and 298 deletions
+19
View File
@@ -1,5 +1,6 @@
/* eslint-disable eslint-comments/disable-enable-pair */
import * as crypto from 'crypto'
import { Word32Array } from 'jscrypto'
import { SHA256 } from 'jscrypto/SHA256'
import * as secp256k1 from 'secp256k1'
@@ -23,3 +24,21 @@ export function generateSignature(id: number, owner: string, privateKey: string)
return ''
}
}
export function generateKeyPairs(amount: number) {
const keyPairs: { publicKey: string; privateKey: string }[] = []
for (let i = 0; i < amount; i++) {
let privKey: Buffer
do {
privKey = crypto.randomBytes(32)
} while (!secp256k1.privateKeyVerify(privKey))
const privateKey = privKey.toString('hex')
const publicKey = Buffer.from(secp256k1.publicKeyCreate(privKey)).toString('hex')
keyPairs.push({
publicKey,
privateKey,
})
}
return keyPairs
}