public Pubkey(byte[] data, ref int pos, bool checkSign = false)
{
Status = Status.Invalid;
try
{
int timeStartPos = pos - 8;
if (pos == 12) timeStartPos = 8;// now, time have 4 bite length, but i wait 8
Version = data.ReadVarInt(ref pos);
Stream = data.ReadVarInt(ref pos);
BehaviorBitfield = data.ReadUInt32(ref pos);
SigningKey = ((byte)4).Concatenate(data.ReadBytes(ref pos, 64));
EncryptionKey = ((byte)4).Concatenate(data.ReadBytes(ref pos, 64));
if (Version < 3)
{
Status = Status.Valid;
return;
}
NonceTrialsPerByte = data.ReadVarInt(ref pos);
PayloadLengthExtraBytes = data.ReadVarInt(ref pos);
if (!checkSign)
{
Status = Status.Valid;
return;
}
if (timeStartPos >= 0)
{
var forCheck = new byte[pos - timeStartPos];
Buffer.BlockCopy(data, timeStartPos, forCheck, 0, forCheck.Length);
var signLen = (int)data.ReadVarInt(ref pos);
var sign = data.ReadBytes(ref pos, signLen);
if (forCheck.ECDSAVerify(SigningKey, sign))
Status = Status.Valid;
}
}
catch
{
Status = Status.Invalid;
}
}