Note class using the WebAssembly note backend.

The goal of this class is to provide a Note interface that works both in Node.js and in the browser.

Hierarchy

  • Note

Constructors

Properties

note: JsNote
CURRENT_VERSION: "v1" = 'v1'

Accessors

  • get wasm(): Promise<{
        ExtData: any;
        JsLeaf: any;
        JsNote: any;
        JsNoteBuilder: any;
        JsProofInput: any;
        JsProofInputBuilder: any;
        JsProofOutput: any;
        JsProvingKeys: any;
        JsUtxo: any;
        LeavesMapInput: any;
        MTBn254X5: any;
        MixerProof: any;
        OperationError: any;
        VAnchorProof: any;
        default: any;
        generate_proof_js: any;
        js_note_of_jsval: any;
        js_utxo_of_jsval: any;
        main: any;
        setupKeys: any;
        verify_js_proof: any;
    }>
  • Gets the WebAssembly module for the target environment. Supports the browser and Node.js.

    Returns Promise<{
        ExtData: any;
        JsLeaf: any;
        JsNote: any;
        JsNoteBuilder: any;
        JsProofInput: any;
        JsProofInputBuilder: any;
        JsProofOutput: any;
        JsProvingKeys: any;
        JsUtxo: any;
        LeavesMapInput: any;
        MTBn254X5: any;
        MixerProof: any;
        OperationError: any;
        VAnchorProof: any;
        default: any;
        generate_proof_js: any;
        js_note_of_jsval: any;
        js_utxo_of_jsval: any;
        main: any;
        setupKeys: any;
        verify_js_proof: any;
    }>

Methods

  • Generate a default JsUtxo which will have both index,amount = 0

    Returns

    A note class instance.

    Returns Promise<Note>

  • Gets the leaf commitment of the note depending on the protocol.

    Returns

    Returns the leaf commitment of the note.

    Returns Uint8Array

  • Calls the webassembly JsNote's mutate index to change the index.

    Returns

    void

    Parameters

    • index: string

    Returns void

  • Serializes the note to a string.

    Returns

    The serialized note.

    Returns string

  • Deserializes a note from a string.

    Returns

    A note class instance.

    Parameters

    • value: string

      A serialized note.

    Returns Promise<Note>

  • Generates a note using the relevant input data. Supports the protocols defined in the WebAssembly note backend.

    // Generate an anchor note
    const input: NoteGenInput = {
    protocol: 'vanchor',
    version: 'v1',
    targetChain: '1',
    targetIdentifyingData: '1',
    sourceChain: '1',
    sourceIdentifyingData: '1',
    backend: 'Circom',
    hashFunction: 'Poseidon',
    curve: 'Bn254',
    tokenSymbol: 'WEBB',
    amount: '1',
    denomination: '18',
    width: '4',
    exponentiation: '5',
    }

    const note = await Note.generateNote(input);

    Returns

    Parameters

    • noteGenInput: NoteGenInput

      The input data for generating a note.

    Returns Promise<Note>

Generated using TypeDoc