RAILGUN Reloaded
    Preparing search index...

    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. Extends Note with a masterPublicKey that identifies the receiving wallet.

    Can be created directly, deserialized from msgpack-encoded bytes, or reconstructed from on-chain commitment data (GeneratedCommitment or ShieldCommitment).

    Hierarchy (View Summary)

    Index
    • Validates that random value is the correct length (16 bytes).

      Parameters

      • random: string

        The random value to validate (hex string)

      Returns void

      If validation fails

    • Validates the caller input of an outbound note factory.

      Parameters

      • params: NoteCreateParams

        The value, token data, optional random, and optional master public key

      • tokenTypes: TokenType[]

        The token types the factory accepts

      Returns void

      If a parameter is invalid

    • Computes the note hash from npk, token hash, and value.

      Parameters

      • npk: Uint8Array

        The note public key as a Uint8Array

      • tokenHash: Uint8Array

        The token hash as a Uint8Array

      • value: bigint

        The note value as a bigint

      Returns Uint8Array

      The note hash as a Uint8Array

      If initializeCryptographyLibs() has not been called.

    • Computes the note public key (NPK) from a master public key and random value. NPK = poseidon(masterPublicKey, random)

      Parameters

      • masterPublicKey: Uint8Array

        The receiver's master public key as a Uint8Array

      • random: Uint8Array

        The note random value as a Uint8Array (16 bytes)

      Returns Uint8Array

      The note public key as a Uint8Array

      If initializeCryptographyLibs() has not been called.

    • Computes the nullifier for a note at a given leaf index. The nullifier uniquely identifies a note when it is spent.

      Parameters

      • nullifyingKey: Uint8Array

        The wallet's nullifying key as a Uint8Array

      • leafIndex: bigint

        The note's position in the merkle tree

      Returns Uint8Array

      The nullifier as a Uint8Array

      If initializeCryptographyLibs() has not been called.

    • Creates a new ShieldNote for a recipient identified by their master public key. Supports ERC20 and ERC721 token data. Derives the note public key from the master public key and the note random, generating a fresh 16-byte random when one is not supplied. The note carries the full pre-fee shield value; the shield fee is deducted on-chain.

      Parameters

      Returns ShieldNote

      A new ShieldNote instance

      If a parameter is invalid or initializeCryptographyLibs() has not been called.

    • Creates a ShieldNote from a GeneratedCommitment (V1). The random is encrypted in encryptedRandom using AES-GCM with the viewing private key. encryptedRandom layout: [0] = ivTag (32 bytes: iv 16 + tag 16) [1] = encrypted random data (16 bytes)

      Parameters

      • commitment: GeneratedCommitment

        The GeneratedCommitment object

      • viewingPrivateKey: Uint8Array

        The wallet's viewing private key for decryption

      • masterPublicKey: Uint8Array

        The master public key

      Returns ShieldNote | null

      A new ShieldNote instance, or null if decryption fails (wrong viewing key) or the preimage does not hash to the commitment

      If the decrypted preimage has an unknown tokenType

    • Creates a ShieldNote from a ShieldCommitment (V2+). The random is encrypted in encryptedBundle and must be decrypted using ECDH(viewingPrivateKey, shieldKey). NOTE: shieldKey is the shielder's public viewing key (used only for ECDH), NOT the master public key. NOTE: Requires cryptography libraries to be initialized first via initializeCryptographyLibs()

      Parameters

      • commitment: ShieldCommitment

        The ShieldCommitment object

      • viewingPrivateKey: Uint8Array

        The wallet's viewing private key for ECDH decryption

      • masterPublicKey: Uint8Array

        The wallet's master public key

      Returns Promise<ShieldNote | null>

      A new ShieldNote instance, or null if decryption fails (not addressed to this wallet) or the preimage does not hash to the commitment

      If the decrypted preimage has an unknown tokenType

    notePublicKey: string

    The note public key (npk) as a hex string

    value: bigint

    The note value as a bigint

    tokenData: TokenData

    The token data containing address, type, and subID

    tokenHash: string

    The token hash as a hex string

    random: string

    Random value (16 bytes hex string)

    masterPublicKey: Uint8Array

    The master public key as a Uint8Array (32 bytes)

    shieldFee: bigint | undefined

    Optional shield fee

    blockNumber: number | undefined

    Optional block number