-
Notifications
You must be signed in to change notification settings - Fork 11
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
21 changed files
with
168 additions
and
75 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,5 @@ | ||
--- | ||
"niljs": patch | ||
--- | ||
|
||
Add commitlint config in typescript |
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,5 @@ | ||
--- | ||
"niljs": patch | ||
--- | ||
|
||
Add IReceipt and ILog interfaces |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
import type { UserConfig } from "@commitlint/types"; | ||
|
||
const config = { | ||
extends: ["@commitlint/config-conventional"], | ||
rules: { | ||
"body-max-line-length": [0, "always", 100], | ||
"footer-max-line-length": [0, "always", 100], | ||
"footer-leading-blank": [0, "always"], | ||
"references-empty": [2, "never"], | ||
"type-empty": [0, "never"], | ||
"subject-empty": [0, "never"], | ||
}, | ||
ignores: [(message) => message.includes("version packages")], | ||
defaultIgnores: false, | ||
} satisfies UserConfig; | ||
|
||
export default config; |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
export * from "./LocalKeySigner.js"; | ||
export * from "./verifySignature.js"; | ||
export * from "./getPublicKey.js"; | ||
export * from "./verifyMessage.js"; | ||
export * from "./publicKey.js"; | ||
export * from "./types/ILocalKeySignerConfig.js"; | ||
export * from "./types/IPrivateKey.js"; | ||
export * from "./types/ISigner.js"; | ||
export * from "./types/ISignature.js"; | ||
export * from "./generatePrivateKey.js"; |
2 changes: 1 addition & 1 deletion
2
src/signers/getPublicKey.test.ts → src/signers/publicKey.test.ts
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,34 @@ | ||
import { type Hex, bytesToHex } from "@noble/curves/abstract/utils"; | ||
import { secp256k1 } from "@noble/curves/secp256k1"; | ||
import { | ||
type ISignature, | ||
addHexPrefix, | ||
removeHexPrefix, | ||
toHex, | ||
} from "../index.js"; | ||
import type { IPrivateKey } from "./types/IPrivateKey.js"; | ||
|
||
/** | ||
* Returns the public key from the private key using the secp256k1 curve. | ||
*/ | ||
const getPublicKey = (privateKey: IPrivateKey): Hex => { | ||
const publicKey = secp256k1.getPublicKey(removeHexPrefix(privateKey), false); | ||
return addHexPrefix(bytesToHex(publicKey)); | ||
}; | ||
|
||
/** | ||
* Generate a new private key. | ||
* @returns Hex - Private key | ||
* @example | ||
* const privateKey = generatePrivateKey(); | ||
*/ | ||
const generatePrivateKey = (): Hex => toHex(secp256k1.utils.randomPrivateKey()); | ||
|
||
const recoverPublicKey = ( | ||
messageHash: Hex | Uint8Array, | ||
signature: ISignature, | ||
) => { | ||
// | ||
}; | ||
|
||
export { getPublicKey, generatePrivateKey, recoverPublicKey }; |
File renamed without changes.
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,10 @@ | ||
import type { Hex } from "@noble/curves/abstract/utils"; | ||
import type { ISignature } from "./index.js"; | ||
|
||
const verifyMessage = async ( | ||
signature: ISignature, | ||
messageHash: Uint8Array, | ||
fullPublicKey: Hex, | ||
) => { | ||
// | ||
}; |
Empty file.
Empty file.
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,11 @@ | ||
/** | ||
* Log interface. | ||
*/ | ||
type ILog = { | ||
address: string; | ||
topics: string[]; | ||
data: string; | ||
blockNumber: bigint; | ||
}; | ||
|
||
export type { ILog }; |
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,18 @@ | ||
import type { ILog } from "./ILog.js"; | ||
|
||
/** | ||
* Receipt interface. | ||
*/ | ||
type IReceipt = { | ||
success: boolean; | ||
gasUsed: number; | ||
bloom: string; | ||
logs: ILog[]; | ||
msgHash: string; | ||
contractAddress: string; | ||
blockHash: string; | ||
blockNumber: bigint; | ||
msgIndex: bigint; | ||
}; | ||
|
||
export type { IReceipt }; |
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,6 +1,3 @@ | ||
export * from "../clients/types/ClientConfigs.js"; | ||
export * from "./IMessage.js"; | ||
export * from "../signers/types/ISigner.js"; | ||
export * from "../signers/types/IPrivateKey.js"; | ||
export * from "./IBlock.js"; | ||
export * from "../signers/types/ILocalKeySignerConfig.js"; | ||
export * from "./ISignedMessage.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