ecash.kernel
Class UsedNotesList

java.lang.Object
  |
  +--ecash.kernel.UsedNotesList
All Implemented Interfaces:
java.io.Serializable

public class UsedNotesList
extends java.lang.Object
implements java.io.Serializable

A list of all the notes already returned to the bank. Every note is recorded in order to avoid that people re-use several times the same note. Each item of this list is a UsedNote object.

Author:
Michel Deriaz
See Also:
UsedNote, Serialized Form

Constructor Summary
UsedNotesList()
          Creates a new list of used notes.
UsedNotesList(java.lang.String value)
          Re-build the object from it's string representation.
UsedNotesList(java.util.Vector v)
          Creates a new list using the specified values.
 
Method Summary
 void add(java.math.BigInteger bigM, java.math.BigInteger[] x)
          Adds a new note to the list.
 int check(java.math.BigInteger bigM, java.math.BigInteger[] x)
          Checks if a note has already been used, and if so, identifies the cheater.
 UsedNotesList copy()
          Creates and returns a copy of this list.
static UsedNotesList load(java.lang.String filename)
          Re-build the object from it's file representation.
 void save(java.lang.String filename)
          Saves this object into it's file representation.
 java.lang.String toString()
          Returns a string representation of this UsedNotesList.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UsedNotesList

public UsedNotesList()
Creates a new list of used notes.


UsedNotesList

public UsedNotesList(java.util.Vector v)
Creates a new list using the specified values.

Parameters:
v - the values

UsedNotesList

public UsedNotesList(java.lang.String value)
Re-build the object from it's string representation.

Parameters:
value - the string representation of the object
Method Detail

add

public void add(java.math.BigInteger bigM,
                java.math.BigInteger[] x)
Adds a new note to the list.

Parameters:
bigM - the note
x - the revealed part of the RIS

check

public int check(java.math.BigInteger bigM,
                 java.math.BigInteger[] x)
Checks if a note has already been used, and if so, identifies the cheater. The returned value can be:
0, if nobody cheats (note seen for the first time)
-1, the seller cheats (same RIS)
n > 0, the buyer with account n cheats (differents valid RIS)

Parameters:
bigM - the note
x - the revealed part of the RIS
Returns:
0 if nobody cheats, -1 if the seller cheats, n if the buyer with account n cheats

copy

public UsedNotesList copy()
Creates and returns a copy of this list.

Returns:
a copy of this list

load

public static UsedNotesList load(java.lang.String filename)
Re-build the object from it's file representation.

Parameters:
filename - the filename

save

public void save(java.lang.String filename)
Saves this object into it's file representation.

Parameters:
filename - the filename

toString

public java.lang.String toString()
Returns a string representation of this UsedNotesList.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this UsedNotesList