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
2 changes: 1 addition & 1 deletion src/notes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { Memo } from './memo.js'
export type { NoteParams } from './note.js'
export { Note } from './note.js'
export type { ShieldNoteCreateParams, ShieldNoteParams } from './shield-note.js'
export { ShieldNote } from './shield-note.js'
export { SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE, ShieldNote } from './shield-note.js'
export type { ShieldRequest } from './shield-request.js'
export { buildShieldRequest } from './shield-request.js'
export type { UnshieldNoteParams } from './unshield-note.js'
Expand Down
11 changes: 10 additions & 1 deletion src/notes/shield-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ type ShieldNoteCreateParams = {
/** Maximum note value representable in the contract's uint120 preimage field. */
const UINT_120_MAX = 2n ** 120n - 1n

/**
* Message a public wallet signs to derive a shield private key.
*
* DO NOT MODIFY. The shield private key is derived from a signature over this
* exact string, so any change yields a different key and shields created under
* the previous message can no longer be decrypted.
*/
const SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE = 'RAILGUN_SHIELD'

/**
* Represents a Shield note for converting public assets into private RAILGUN notes.
* This is the entry point for funds entering the privacy system via on-chain shield transactions.
Expand Down Expand Up @@ -282,4 +291,4 @@ class ShieldNote extends Note {
}

export type { ShieldNoteParams, ShieldNoteCreateParams }
export { ShieldNote }
export { SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE, ShieldNote }
10 changes: 0 additions & 10 deletions src/wallet/railgun-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ export class RailgunWallet {
this.initializeKeyPairs()
}

/**
* Retrieves the constant signature message used for shield private key operations.
* This message is a predefined string that should not be modified.
* @returns The constant signature message 'RAILGUN_SHIELD'.
*/
static getShieldPrivateKeySignatureMessage () {
// DO NOT MODIFY THIS CONSTANT.
return 'RAILGUN_SHIELD'
}

/**
* Initializes the key pairs and related cryptographic keys for the wallet node.
* This method retrieves the spending key pair, nullifying key, and viewing key pair
Expand Down
8 changes: 4 additions & 4 deletions test/wallet-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { stringify } from '@railgun-reloaded/0zk-addresses'
import { hexToBytes } from '@railgun-reloaded/bytes'

import { initializeCryptographyLibs } from '../src/keys.js'
import { SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE } from '../src/notes/shield-note.js'
import { RailgunWallet } from '../src/wallet/railgun-wallet.js'
import { WalletNode } from '../src/wallet/wallet-node.js'

Expand Down Expand Up @@ -205,10 +206,9 @@ test('railgun-wallet - deterministic key derivation', async () => {
'master public key should match expected value')
})

test('railgun-wallet - RailgunWallet.getShieldPrivateKeySignatureMessage', () => {
const message = RailgunWallet.getShieldPrivateKeySignatureMessage()

assert.equal(message, 'RAILGUN_SHIELD', 'should return correct constant message')
test('shield-note - SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE', () => {
assert.equal(SHIELD_PRIVATE_KEY_SIGNATURE_MESSAGE, 'RAILGUN_SHIELD',
'should return correct constant message')
})

test('railgun-wallet - Different mnemonics generate different wallets', async () => {
Expand Down
Loading