RAILGUN Reloaded
    Preparing search index...

    Represents a Transact note for private-to-private transfers. These notes move value between wallets without ever exposing assets on-chain, carrying receiver/sender address data, a Poseidon hash, and optional metadata such as memoText, outputType, and shieldFee. Extends Note with transaction-specific fields.

    Supports both a modern msgpack serialization format and a legacy format that encrypts the random value with AES-GCM using the viewing private key directly (see TransactNote.serializeLegacy).

    Can be created directly, deserialized from either format, or reconstructed from on-chain commitment data (TransactCommitment or EncryptedCommitment).

    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 ERC20 outbound TransactNote addressed to the receiver. Derives the note public key from the receiver master public key and the note random, generating a fresh 16-byte random when one is not supplied. A hidden sender gets a fresh 15-byte sender random. A shown sender gets MEMO_SENDER_RANDOM_NULL.

      Parameters

      Returns TransactNote

      A new TransactNote instance ready to encrypt

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

    • Creates a TransactNote from pre-decrypted commitment fields. Use decryptCommitment to obtain the fields from an encrypted commitment. NOTE: Requires cryptography libraries to be initialized first via initializeCryptographyLibs()

      Parameters

      • random: string

        Random value (16 bytes hex string)

      • npk: string

        Note public key (hex string)

      • value: bigint

        Note value (bigint)

      • tokenData: TokenData

        Token data

      • receiverAddressData: AddressData

        Receiver address data

      • OptionalsenderAddressData: AddressData

        Optional sender address data

      Returns TransactNote

      A new TransactNote instance

    • Serializes a transact note in legacy format (for backward compatibility). Legacy format uses encrypted random field instead of plain random. The random is encrypted directly with the viewing private key (no ECDH). Output shape matches LegacyTransactNoteSerialized.

      Parameters

      • viewingPrivateKey: Uint8Array

        Viewing private key for encryption (32 bytes)

      Returns Uint8Array

      The serialized legacy transact note

    • Deserializes a legacy transact note. The random is decrypted directly with the viewing private key (no ECDH). Legacy notes are always ERC20.

      Parameters

      • bytes: Uint8Array

        The serialized legacy note data

      • viewingPrivateKey: Uint8Array

        Viewing private key for decryption (32 bytes)

      Returns TransactNote | null

      A new TransactNote instance, or null if decryption fails (wrong viewing key)

    • Checks if a serialized note is in legacy format.

      Parameters

      • noteData: any

        The serialized note data

      Returns boolean

      True if legacy format, false otherwise

    • AES-256-GCM encrypts this outbound note for the V2 transact circuit, using the shared symmetric key derived between the sender and the receiver. The encrypted memo is split off the ciphertext data but stays under the same GCM tag, matching the contract's CommitmentCiphertext layout. The annotation data carries the output type, sender random, and wallet source, readable only by the sender's viewing key. Matches the community engine encryptV2.

      Parameters

      • sharedKey: Uint8Array

        32-byte shared symmetric key between sender and receiver

      • senderMasterPublicKey: bigint

        Sender master public key, used to encode the MPK when senderRandom is unset

      • viewingPrivateKey: Uint8Array

        Sender viewing private key, encrypts the annotation data

      Returns { noteCiphertext: Ciphertext; noteMemo: Uint8Array; annotationData: Uint8Array }

      The note ciphertext (3 data blocks), the encrypted memo bytes, and the annotation data

    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)

    hash: bigint

    The note hash as a bigint

    receiverAddressData: AddressData

    Receiver address data

    senderAddressData: AddressData | undefined

    Optional sender address data

    outputType: number | undefined

    Optional output type

    walletSource: string | undefined

    Optional wallet source

    senderRandom: string | undefined

    Optional sender random value

    memoText: string | undefined

    Optional memo text

    shieldFee: string | undefined

    Optional shield fee

    blockNumber: number | undefined

    Optional block number