|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--webfunds.sox.Encodable
|
+--webfunds.sox.Token
This class represents a token (a.k.a. coin). Token objects are usually created by means of a Withdrawal protocol between client and mint-capable SOXServer. They might go through several phases, being potentially: proto signed blinded spent which may or may not be exclusive.
| Field Summary | |
protected long |
expiry
Tokens commonly come from a batch that is identified with a series label or an expiry date. |
protected int |
log
The quantity of the item that this token represents. |
protected byte[] |
series
|
protected byte[] |
sig
The signature on the token (generally made by the mint according to the protocol). |
protected int |
state
The state that the token is in (generally made by the mint according to the protocol). |
protected int |
subversion
The version of the subclass Token. |
static int |
TOK_PROTO
|
static int |
TOK_RAW
|
static int |
TOK_RECEIVED
|
static int |
TOK_SETTLED
|
static int |
TOK_SIGNED
|
static int |
TOK_SPENT
|
static int |
TOK_UNBLIND
|
static int |
TOK_VALID
|
protected int |
type
The type of token of this class See TokenFactory for current definitions. |
protected int |
version
|
static int |
VERSION
The version number for this structure: 0: current |
| Constructor Summary | |
Token(byte[] buf)
Construct a token object from a byte array that was previously returned from the encode() method of a token object. |
|
Token(java.io.InputStream is)
Construct a token object from data in an input stream, where the data was previously returned from the encode() method of a token object. |
|
Token(int type,
int subversion,
int log)
Create an uninitialised token. |
|
| Method Summary | |
void |
decode(java.io.InputStream is)
Update this token object with the values from a token encoded as a byte array (such as previously returned from the encode() method of a token object). |
void |
encode(java.io.OutputStream os)
Encode a token as a byte array, suitable for sending to third parties for depositing. |
boolean |
equals(java.lang.Object obj)
|
long |
getExpiry()
|
int |
getLog()
|
long |
getQty()
Note (1) that this may be derived information, the real token value may be encoded in the signature key or some other way. |
byte[] |
getSeries()
|
byte[] |
getSignature()
|
int |
getState()
|
int |
getSubVersion()
|
int |
getType()
|
abstract byte[] |
getUniqueId()
Get the unique identifier that is used for checking against double-spending. |
int |
getVersion()
|
boolean |
isProto()
|
boolean |
isRaw()
|
boolean |
isReceived()
|
boolean |
isSettled()
|
boolean |
isSigned()
|
boolean |
isSpent()
|
boolean |
isUnblinded()
|
void |
setState(int state)
|
abstract void |
sign(java.security.PrivateKey key,
byte[] series)
Sign a protocoin. |
java.lang.String |
toString()
|
abstract void |
unblind()
Unblind the signed coin, revealing the signed, private coin. |
abstract boolean |
verify(java.security.PublicKey key)
Sign a protocoin. |
java.lang.String |
vString()
|
| Methods inherited from class webfunds.sox.Encodable |
decode,
encode,
main,
readByteArray,
readCertificate,
readProperties,
readString,
writeByteArray,
writeCertificate,
writeProperties,
writeString |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
public static final int VERSION
protected int version
protected int type
protected int subversion
protected int state
public static final int TOK_RAW
public static final int TOK_PROTO
public static final int TOK_SIGNED
public static final int TOK_UNBLIND
public static final int TOK_RECEIVED
public static final int TOK_SPENT
public static final int TOK_SETTLED
public static final int TOK_VALID
protected int log
protected long expiry
protected byte[] series
protected byte[] sig
| Constructor Detail |
public Token(int type,
int subversion,
int log)
type - of token, being the blinding or coin schemesubversion - is the version of the parent coin classlog - the coin size, log base 2 of quantity
public Token(byte[] buf)
throws SOXPacketException
token - the previously encoded token
public Token(java.io.InputStream is)
throws SOXPacketException
is - the input stream from which to read the token data| Method Detail |
public final int getVersion()
public int getType()
public int getSubVersion()
public int getState()
public void setState(int state)
public boolean isRaw()
public boolean isProto()
public boolean isSigned()
public boolean isUnblinded()
public boolean isReceived()
public boolean isSpent()
public boolean isSettled()
public int getLog()
public long getQty()
public long getExpiry()
public byte[] getSeries()
public byte[] getSignature()
public abstract void sign(java.security.PrivateKey key,
byte[] series)
throws java.security.KeyException
series - is a string identifying batchkey - is the signing key of the mint
public abstract boolean verify(java.security.PublicKey key)
throws java.security.KeyException
key - is the signer's public key (of the mint)public abstract byte[] getUniqueId()
key - is the signer's public key (of the mint)public abstract void unblind()
public void decode(java.io.InputStream is)
throws java.io.IOException,
SOXPacketException
token - the previosly encoded token
public void encode(java.io.OutputStream os)
throws java.io.IOException
public java.lang.String toString()
public java.lang.String vString()
public boolean equals(java.lang.Object obj)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||