Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = require('@railgun-reloaded/eslint-config')()
import railgunEslintConfig from '@railgun-reloaded/eslint-config'

export default railgunEslintConfig()
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@railgun-reloaded/wallet-node",
"version": "0.0.0",
"description": "TODO",
"type": "module",
"scripts": {
"build": "tsc --build",
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -34,9 +35,9 @@
"@msgpack/msgpack": "^3.1.3",
"@noble/ed25519": "^2.3.0",
"@noble/hashes": "^1.8.0",
"@railgun-reloaded/0zk-addresses": "https://github.com/railgun-reloaded/0zk-addresses",
"@railgun-reloaded/0zk-addresses": "https://github.com/railgun-reloaded/0zk-addresses#dev",
"@railgun-reloaded/bytes": "git+https://github.com/railgun-reloaded/bytes.git#dev",
"@railgun-reloaded/cryptography": "git+https://github.com/railgun-reloaded/cryptography.git#main",
"@railgun-reloaded/cryptography": "git+https://github.com/railgun-reloaded/cryptography.git#dev",
"@railgun-reloaded/eslint-config": "^1.1.0",
"@railgun-reloaded/scanner": "https://github.com/railgun-reloaded/scanner#dev",
"@railgun-reloaded/tsconfig": "^1.2.0",
Expand Down
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export * from './notes'
export * from './keys'
export * from './encoding'
export * from './notes/index.js'
export * from './keys.js'
export * from './encoding.js'

export * from './wallet/derivation'
export * from './wallet/bip32'
export type * from './wallet/types'
export type * from './wallet/wallet-node'
export { WalletNode } from './wallet/wallet-node'
export { RailgunWallet } from './wallet/railgun-wallet'
export * from './wallet/derivation.js'
export * from './wallet/bip32.js'
export type * from './wallet/types.js'
export type * from './wallet/wallet-node.js'
export { WalletNode } from './wallet/wallet-node.js'
export { RailgunWallet } from './wallet/railgun-wallet.js'

export { Mnemonic } from './mnemonic'
export { Mnemonic } from './mnemonic/index.js'
2 changes: 1 addition & 1 deletion src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { randomBytes } from '@noble/hashes/utils'
import { bigIntToBytes, bytesToBigInt } from '@railgun-reloaded/bytes'
import { eddsa, initCircomlib, initializeEddsa, poseidon } from '@railgun-reloaded/cryptography'

import { xorBytesInPlace } from './encoding'
import { xorBytesInPlace } from './encoding.js'

type Ed25519Module = typeof Ed25519

Expand Down
2 changes: 1 addition & 1 deletion src/mnemonic/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './mnemonic'
export * from './mnemonic.js'
6 changes: 3 additions & 3 deletions src/notes/commitment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { bytesToBigInt, bytesToHex } from '@railgun-reloaded/bytes'
import { AES } from '@railgun-reloaded/cryptography'

import { getSharedSymmetricKey } from '../keys'
import { getSharedSymmetricKey } from '../keys.js'

import type { Chain, Ciphertext, TokenData, TokenDataGetter } from './definitions'
import { TXIDVersion } from './definitions'
import type { Chain, Ciphertext, TokenData, TokenDataGetter } from './definitions.js'
import { TXIDVersion } from './definitions.js'

interface DecryptedCommitmentData {
random: string
Expand Down
26 changes: 13 additions & 13 deletions src/notes/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export * from './commitment'
export * from './definitions'
export * from './token-utils'
export * from './commitment.js'
export * from './definitions.js'
export * from './token-utils.js'

export { WalletInfo } from './wallet-info'
export { Memo } from './memo'
export type { NoteParams } from './note'
export { Note } from './note'
export type { ShieldNoteParams } from './shield-note'
export { ShieldNote } from './shield-note'
export type { UnshieldNoteParams } from './unshield-note'
export { UnshieldNote } from './unshield-note'
export type { TransactNoteParams } from './transact-note'
export { TransactNote } from './transact-note'
export { WalletInfo } from './wallet-info.js'
export { Memo } from './memo.js'
export type { NoteParams } from './note.js'
export { Note } from './note.js'
export type { ShieldNoteParams } from './shield-note.js'
export { ShieldNote } from './shield-note.js'
export type { UnshieldNoteParams } from './unshield-note.js'
export { UnshieldNote } from './unshield-note.js'
export type { TransactNoteParams } from './transact-note.js'
export { TransactNote } from './transact-note.js'
6 changes: 3 additions & 3 deletions src/notes/memo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { bytesToHex, hexToBytes, stripHexPrefix } from '@railgun-reloaded/bytes'
import type { CiphertextCTR } from '@railgun-reloaded/cryptography'
import { AES } from '@railgun-reloaded/cryptography'

import type { NoteAnnotationData } from './definitions'
import { MEMO_SENDER_RANDOM_NULL, OutputType } from './definitions'
import { WalletInfo } from './wallet-info'
import type { NoteAnnotationData } from './definitions.js'
import { MEMO_SENDER_RANDOM_NULL, OutputType } from './definitions.js'
import { WalletInfo } from './wallet-info.js'

/**
* Memo encoding, decoding, and V2 annotation data encryption/decryption.
Expand Down
6 changes: 3 additions & 3 deletions src/notes/note.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { bigIntToBytes, stripHexPrefix } from '@railgun-reloaded/bytes'
import { poseidon } from '@railgun-reloaded/cryptography'

import { assertCryptoInitialized } from '../keys'
import { assertCryptoInitialized } from '../keys.js'

import type { TokenData } from './definitions'
import { assertValidNoteToken, computeTokenHash } from './token-utils'
import type { TokenData } from './definitions.js'
import { assertValidNoteToken, computeTokenHash } from './token-utils.js'

/**
* Base parameters shared by all note types.
Expand Down
12 changes: 6 additions & 6 deletions src/notes/shield-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { decode, encode } from '@msgpack/msgpack'
import { bytesToHex, hexToBytes } from '@railgun-reloaded/bytes'
import { AES } from '@railgun-reloaded/cryptography'

import { getSharedSymmetricKey } from '../keys'
import { getSharedSymmetricKey } from '../keys.js'

import type { GeneratedCommitment, ShieldCommitment } from './definitions'
import { TokenType } from './definitions'
import type { NoteParams } from './note'
import { Note } from './note'
import { deserializeTokenData, serializeTokenData } from './token-utils'
import type { GeneratedCommitment, ShieldCommitment } from './definitions.js'
import { TokenType } from './definitions.js'
import type { NoteParams } from './note.js'
import { Note } from './note.js'
import { deserializeTokenData, serializeTokenData } from './token-utils.js'

/**
* Parameters for constructing a ShieldNote.
Expand Down
4 changes: 2 additions & 2 deletions src/notes/token-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { keccak_256 as keccak256 } from '@noble/hashes/sha3'
import { bigIntToBytes, bytesToBigInt, bytesToHex, hexToBytes, padBytesLeft } from '@railgun-reloaded/bytes'

import type { TokenData } from './definitions'
import { SNARK_PRIME, TokenType } from './definitions'
import type { TokenData } from './definitions.js'
import { SNARK_PRIME, TokenType } from './definitions.js'

/**
* Computes the token hash for ERC20 tokens.
Expand Down
8 changes: 4 additions & 4 deletions src/notes/transact-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { parse as parse0zkAddress, stringify as stringify0zkAddress } from '@rai
import { bytesToBigInt, bytesToHex, hexToBytes } from '@railgun-reloaded/bytes'
import { AES } from '@railgun-reloaded/cryptography'

import type { AddressData, Chain, Ciphertext, EncryptedData, LegacyCiphertext, TXIDVersion, TokenData, TokenDataGetter } from './definitions'
import type { NoteParams } from './note'
import { Note } from './note'
import { computeTokenHash, getTokenDataERC20 } from './token-utils'
import type { AddressData, Chain, Ciphertext, EncryptedData, LegacyCiphertext, TXIDVersion, TokenData, TokenDataGetter } from './definitions.js'
import type { NoteParams } from './note.js'
import { Note } from './note.js'
import { computeTokenHash, getTokenDataERC20 } from './token-utils.js'

/**
* Parameters for constructing a TransactNote.
Expand Down
10 changes: 5 additions & 5 deletions src/notes/unshield-note.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { decode, encode } from '@msgpack/msgpack'
import { bytesToBigInt, bytesToHex, hexToBytes } from '@railgun-reloaded/bytes'

import type { Unshield } from './definitions'
import { TokenType } from './definitions'
import type { NoteParams } from './note'
import { Note } from './note'
import { computeTokenHash, deserializeTokenData, serializeTokenData } from './token-utils'
import type { Unshield } from './definitions.js'
import { TokenType } from './definitions.js'
import type { NoteParams } from './note.js'
import { Note } from './note.js'
import { computeTokenHash, deserializeTokenData, serializeTokenData } from './token-utils.js'

/**
* Parameters for constructing an UnshieldNote.
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/bip32.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sha512HMAC } from '../encoding'
import { sha512HMAC } from '../encoding.js'

import type { KeyNode } from './types'
import type { KeyNode } from './types.js'

const CURVE_SEED = new TextEncoder().encode('babyjubjub seed')

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/derivation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WalletNodes } from './wallet-node'
import { WalletNode } from './wallet-node'
import type { WalletNodes } from './wallet-node.js'
import { WalletNode } from './wallet-node.js'

/**
* A collection of derivation path prefixes used for generating hierarchical deterministic (HD) wallet keys.
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './railgun-wallet'
export * from './wallet-node'
export * from './railgun-wallet.js'
export * from './wallet-node.js'
8 changes: 4 additions & 4 deletions src/wallet/railgun-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { deriveNodes } from './derivation'
import { deriveNodes } from './derivation.js'
import type {
SpendingKeyPair,
SpendingPublicKey,
ViewingKeyPair,
} from './types'
import type { WalletNodes } from './wallet-node'
import { WalletNode } from './wallet-node'
} from './types.js'
import type { WalletNodes } from './wallet-node.js'
import { WalletNode } from './wallet-node.js'

type RailgunKeystore = {
spendingKeyPair: SpendingKeyPair;
Expand Down
8 changes: 4 additions & 4 deletions src/wallet/wallet-node.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { poseidon } from '@railgun-reloaded/cryptography'

import { assertCryptoInitialized, getPublicSpendingKey, getPublicViewingKey } from '../keys'
import { Mnemonic } from '../mnemonic'
import { assertCryptoInitialized, getPublicSpendingKey, getPublicViewingKey } from '../keys.js'
import { Mnemonic } from '../mnemonic/index.js'

import { childKeyDerivationHardened, getMasterKeyFromSeed, getPathSegments } from './bip32'
import type { KeyNode, SpendingKeyPair, ViewingKeyPair } from './types'
import { childKeyDerivationHardened, getMasterKeyFromSeed, getPathSegments } from './bip32.js'
import type { KeyNode, SpendingKeyPair, ViewingKeyPair } from './types.js'

const HARDENED_OFFSET = 0x80000000 as const
type WalletNodes = { spending: WalletNode; viewing: WalletNode }
Expand Down
8 changes: 4 additions & 4 deletions test/commitment-memo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
getPublicViewingKey,
getSharedSymmetricKey,
initializeCryptographyLibs,
} from '../src/keys'
import { decryptCommitment } from '../src/notes/commitment'
import type { TokenDataGetter } from '../src/notes/definitions'
import { ChainType, TXIDVersion } from '../src/notes/definitions'
} from '../src/keys.js'
import { decryptCommitment } from '../src/notes/commitment.js'
import type { TokenDataGetter } from '../src/notes/definitions.js'
import { ChainType, TXIDVersion } from '../src/notes/definitions.js'

const TEST_CHAIN = { type: ChainType.EVM, id: 11155111 }
const EMPTY_MEMO = new Uint8Array(0)
Expand Down
10 changes: 5 additions & 5 deletions test/commitment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
getPublicViewingKey,
getSharedSymmetricKey,
initializeCryptographyLibs,
} from '../src/keys'
} from '../src/keys.js'
import {
decryptCommitment,
decryptCommitmentAsReceiverOrSender,
} from '../src/notes/commitment'
import type { TokenDataGetter } from '../src/notes/definitions'
import { ChainType, TXIDVersion } from '../src/notes/definitions'
import { computeTokenHash } from '../src/notes/token-utils'
} from '../src/notes/commitment.js'
import type { TokenDataGetter } from '../src/notes/definitions.js'
import { ChainType, TXIDVersion } from '../src/notes/definitions.js'
import { computeTokenHash } from '../src/notes/token-utils.js'

const TEST_CHAIN = { type: ChainType.EVM, id: 1 }
const TEST_VALUE = 1000000000000000000n // 1 ETH
Expand Down
4 changes: 2 additions & 2 deletions test/derivation.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'node:assert/strict'
import { before, test } from 'node:test'

import { initializeCryptographyLibs } from '../src/keys'
import { DERIVATION_PATH_PREFIXES, deriveNodes, derivePathsForIndex } from '../src/wallet/derivation'
import { initializeCryptographyLibs } from '../src/keys.js'
import { DERIVATION_PATH_PREFIXES, deriveNodes, derivePathsForIndex } from '../src/wallet/derivation.js'

const TEST_MNEMONIC = 'test test test test test test test test test test test junk'

Expand Down
2 changes: 1 addition & 1 deletion test/encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { bytesToHex } from '@railgun-reloaded/bytes'
import {
sha512HMAC,
xorBytesInPlace,
} from '../src/encoding'
} from '../src/encoding.js'

test('encoding - sha512HMAC', () => {
const key = new Uint8Array([1, 2, 3, 4])
Expand Down
2 changes: 1 addition & 1 deletion test/keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
initializeCryptographyLibs,
seedToScalar,
unblindNoteKey,
} from '../src/keys'
} from '../src/keys.js'

before(async () => {
await initializeCryptographyLibs()
Expand Down
6 changes: 3 additions & 3 deletions test/memo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { before, test } from 'node:test'

import { randomBytes } from '@noble/hashes/utils'

import { initializeCryptographyLibs } from '../src/keys'
import { MEMO_SENDER_RANDOM_NULL, OutputType } from '../src/notes/definitions'
import { Memo } from '../src/notes/memo'
import { initializeCryptographyLibs } from '../src/keys.js'
import { MEMO_SENDER_RANDOM_NULL, OutputType } from '../src/notes/definitions.js'
import { Memo } from '../src/notes/memo.js'

before(async () => {
await initializeCryptographyLibs()
Expand Down
4 changes: 2 additions & 2 deletions test/mnemonic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { test } from 'node:test'

import { bytesToHex, hexToBytes } from '@railgun-reloaded/bytes'

import { Mnemonic } from '../src/mnemonic'
import { childKeyDerivationHardened, getMasterKeyFromSeed, getPathSegments } from '../src/wallet/bip32'
import { Mnemonic } from '../src/mnemonic/index.js'
import { childKeyDerivationHardened, getMasterKeyFromSeed, getPathSegments } from '../src/wallet/bip32.js'

const TEST_MNEMONIC = 'test test test test test test test test test test test junk'
const MNEMONIC_ABANDON = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
Expand Down
6 changes: 3 additions & 3 deletions test/note.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { before, test } from 'node:test'

import { bytesToBigInt, bytesToHex, hexToBytes } from '@railgun-reloaded/bytes'

import { initializeCryptographyLibs } from '../src/keys'
import { Note } from '../src/notes/note'
import { computeTokenHash } from '../src/notes/token-utils'
import { initializeCryptographyLibs } from '../src/keys.js'
import { Note } from '../src/notes/note.js'
import { computeTokenHash } from '../src/notes/token-utils.js'

const TEST_TOKEN_ADDRESS = hexToBytes('0x1234567890123456789012345678901234567890')
const TEST_NPK =
Expand Down
Loading
Loading