-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
310 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ["../../.eslintrc.js"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as Vorpal from "vorpal"; | ||
import { createBlsKeyPair as coreCreateBlsKeyPair } from "@xai-vanguard-node/core"; | ||
|
||
export function createBlsKeyPair(cli: Vorpal) { | ||
cli | ||
.command('create-bls-key-pair', 'Creates a BLS key pair. If a secret key is provided, it will return the corresponding public key. If no secret key is provided, it will generate a new key pair and return both the secret and public keys. Note: The secret key will be lost when the application closes, so please secure it safely.') | ||
.action(async function (this: Vorpal.CommandInstance) { | ||
const secretKeyPrompt: Vorpal.PromptObject = { | ||
type: 'password', | ||
name: 'secretKey', | ||
message: 'Enter your secret key (optional):', | ||
mask: '*', | ||
optional: true | ||
}; | ||
const {secretKey} = await this.prompt(secretKeyPrompt); | ||
const { secretKeyHex, publicKeyHex } = await coreCreateBlsKeyPair(secretKey); | ||
if (secretKey) { | ||
this.log(`Public Key: ${publicKeyHex}`); | ||
} else { | ||
this.log(`Secret Key: ${secretKeyHex}\nPublic Key: ${publicKeyHex}\nPlease secure your secret key safely. It will be lost when the application closes.`); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import {createBlsKeyPair} from "@xai-vanguard-node/core"; | ||
import * as Vorpal from 'vorpal'; | ||
import { createBlsKeyPair } from './commands/create-bls-key-pair'; | ||
|
||
const cli = new Vorpal(); | ||
|
||
console.log("Stealing all your info and sending to the Shadow Government"); | ||
// entrypoints to each of the commands | ||
createBlsKeyPair(cli); | ||
|
||
setInterval(() => { | ||
console.log("Lol why did you run this, idiot!"); | ||
}, 1000) | ||
cli | ||
.delimiter('vanguard-node$') | ||
.show() | ||
.log('\nType "help" to display a list of actions.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import bls from "@chainsafe/bls"; | ||
import { bls12_381 as bls } from '@noble/curves/bls12-381'; | ||
|
||
/** | ||
* Creates a BLS Key Pair and returns the secret and public key in hexadecimal format. | ||
* @param secretKeyString - An optional string representing the secret key. If not provided, a new secret key is generated. | ||
* @returns An object containing the secret key and public key in hexadecimal format. | ||
* @example | ||
* const { secretKeyHex, publicKeyHex } = await createBlsKeyPair(); | ||
* const { secretKeyHex, publicKeyHex } = await createBlsKeyPair('yourSecretKeyString'); | ||
*/ | ||
export async function createBlsKeyPair(): Promise<{ secretKeyHex: string, publicKeyHex: string }> { | ||
const secretKey = bls.SecretKey.fromKeygen(); | ||
const publicKey = secretKey.toPublicKey(); | ||
|
||
const secretKeyBytes = secretKey.toBytes(); | ||
const publicKeyBytes = publicKey.toBytes(); | ||
|
||
const secretKeyHex = Buffer.from(secretKeyBytes).toString('hex'); | ||
const publicKeyHex = Buffer.from(publicKeyBytes).toString('hex'); | ||
export async function createBlsKeyPair(secretKeyString?: string): Promise<{ secretKeyHex: string, publicKeyHex: string }> { | ||
const secretKey = secretKeyString ? Buffer.from(secretKeyString, 'hex') : bls.utils.randomPrivateKey(); | ||
const secretKeyHex = Buffer.from(secretKey).toString('hex'); | ||
const publicKey = bls.getPublicKey(secretKey); | ||
const publicKeyHex = Buffer.from(publicKey).toString('hex'); | ||
|
||
return { secretKeyHex, publicKeyHex }; | ||
} |
Oops, something went wrong.