/**
* Array indexes for raw package array
*/
- const INDEX_PACKAGE_SENDER = 0;
- const INDEX_PACKAGE_RECIPIENT = 1;
- const INDEX_PACKAGE_CONTENT = 2;
- const INDEX_PACKAGE_STATUS = 3;
- const INDEX_PACKAGE_HASH = 4;
+ const INDEX_PACKAGE_SENDER = 0;
+ const INDEX_PACKAGE_RECIPIENT = 1;
+ const INDEX_PACKAGE_CONTENT = 2;
+ const INDEX_PACKAGE_STATUS = 3;
+ const INDEX_PACKAGE_HASH = 4;
+ const INDEX_PACKAGE_PRIVATE_KEY_HASH = 5;
/**
* Size of the decoded data array
*/
- const DECODED_DATA_ARRAY_SIZE = 5;
+ const DECODED_DATA_ARRAY_SIZE = 6;
/**
* Named array elements for decoded package content
*/
- const PACKAGE_CONTENT_EXTENSION = 'compressor';
- const PACKAGE_CONTENT_MESSAGE = 'message';
- const PACKAGE_CONTENT_TAGS = 'tags';
- const PACKAGE_CONTENT_CHECKSUM = 'checksum';
- const PACKAGE_CONTENT_SENDER = 'sender';
- const PACKAGE_CONTENT_HASH = 'hash';
+ const PACKAGE_CONTENT_EXTENSION = 'compressor';
+ const PACKAGE_CONTENT_MESSAGE = 'message';
+ const PACKAGE_CONTENT_TAGS = 'tags';
+ const PACKAGE_CONTENT_CHECKSUM = 'checksum';
+ const PACKAGE_CONTENT_SENDER = 'sender';
+ const PACKAGE_CONTENT_HASH = 'hash';
+ const PACKAGE_CONTENT_PRIVATE_KEY_HASH = 'pkhash';
/**
* Named array elements for package data
*/
- const PACKAGE_DATA_SENDER = 'sender';
- const PACKAGE_DATA_RECIPIENT = 'recipient';
- const PACKAGE_DATA_CONTENT = 'content';
- const PACKAGE_DATA_STATUS = 'status';
- const PACKAGE_DATA_HASH = 'hash';
+ const PACKAGE_DATA_SENDER = 'sender';
+ const PACKAGE_DATA_RECIPIENT = 'recipient';
+ const PACKAGE_DATA_CONTENT = 'content';
+ const PACKAGE_DATA_STATUS = 'status';
+ const PACKAGE_DATA_HASH = 'hash';
+ const PACKAGE_DATA_PRIVATE_KEY_HASH = 'pkhash';
/**
* All package status
// Make sure the requested element is there
// @TODO Wrong hash!!!!
/* DEBUG-DIE */ die('decodedData=' . print_r($decodedData, TRUE));
- assert(isset($decodedData[self::PACKAGE_CONTENT_HASH]));
+ assert(isset($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH]));
// There is no DHT entry so, accept the hash from decoded data
- return $decodedData[self::PACKAGE_CONTENT_HASH];
+ return $decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH];
}
/**
private function generatePackageHash ($content, $senderId) {
// Fake array
$data = array(
- self::PACKAGE_CONTENT_SENDER => $senderId,
- self::PACKAGE_CONTENT_MESSAGE => $content,
- self::PACKAGE_CONTENT_HASH => ''
+ self::PACKAGE_CONTENT_SENDER => $senderId,
+ self::PACKAGE_CONTENT_MESSAGE => $content,
+ self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => ''
);
// Hash content and sender id together, use scrypt
// Now prepare the temporary array and push it on the 'undeclared' stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array(
- self::PACKAGE_DATA_SENDER => $this->getSessionId(),
- self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(),
- self::PACKAGE_DATA_CONTENT => $packageContent,
- self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW,
- self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId())
+ self::PACKAGE_DATA_SENDER => $this->getSessionId(),
+ self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(),
+ self::PACKAGE_DATA_CONTENT => $packageContent,
+ self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW,
+ self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId()),
+ self::PACKAGE_DATA_PRIVATE_KEY_HASH => $this->getPrivateKeyHash(),
));
// Debug message
* Create 'decodedData' array with all assoziative array elements.
*/
$decodedData = array(
- self::PACKAGE_DATA_SENDER => $decodedArray[self::INDEX_PACKAGE_SENDER],
- self::PACKAGE_DATA_RECIPIENT => $decodedArray[self::INDEX_PACKAGE_RECIPIENT],
- self::PACKAGE_DATA_CONTENT => $decodedArray[self::INDEX_PACKAGE_CONTENT],
- self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_DECODED,
- self::PACKAGE_DATA_HASH => $decodedArray[self::INDEX_PACKAGE_HASH]
+ self::PACKAGE_DATA_SENDER => $decodedArray[self::INDEX_PACKAGE_SENDER],
+ self::PACKAGE_DATA_RECIPIENT => $decodedArray[self::INDEX_PACKAGE_RECIPIENT],
+ self::PACKAGE_DATA_CONTENT => $decodedArray[self::INDEX_PACKAGE_CONTENT],
+ self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_DECODED,
+ self::PACKAGE_DATA_HASH => $decodedArray[self::INDEX_PACKAGE_HASH]
+ self::PACKAGE_DATA_PRIVATE_KEY_HASH => $decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]
);
// And return it
*/
$decodedContent = array(
// Compressor's extension used to compress the data
- self::PACKAGE_CONTENT_EXTENSION => $decodedContent[self::INDEX_COMPRESSOR_EXTENSION],
+ self::PACKAGE_CONTENT_EXTENSION => $decodedContent[self::INDEX_COMPRESSOR_EXTENSION],
// Package data (aka "message") in BASE64-decoded form but still compressed
- self::PACKAGE_CONTENT_MESSAGE => base64_decode($decodedContent[self::INDEX_PACKAGE_DATA]),
+ self::PACKAGE_CONTENT_MESSAGE => base64_decode($decodedContent[self::INDEX_PACKAGE_DATA]),
// Tags as an indexed array for "tagging" the message
- self::PACKAGE_CONTENT_TAGS => explode(self::PACKAGE_TAGS_SEPARATOR, $decodedContent[self::INDEX_TAGS]),
+ self::PACKAGE_CONTENT_TAGS => explode(self::PACKAGE_TAGS_SEPARATOR, $decodedContent[self::INDEX_TAGS]),
// Checksum of the _decoded_ data
- self::PACKAGE_CONTENT_CHECKSUM => $decodedContent[self::INDEX_CHECKSUM],
+ self::PACKAGE_CONTENT_CHECKSUM => $decodedContent[self::INDEX_CHECKSUM],
// Sender's id
- self::PACKAGE_CONTENT_SENDER => $decodedData[self::PACKAGE_DATA_SENDER],
+ self::PACKAGE_CONTENT_SENDER => $decodedData[self::PACKAGE_DATA_SENDER],
// Hash from decoded raw data
- self::PACKAGE_CONTENT_HASH => $decodedData[self::PACKAGE_DATA_HASH]
+ self::PACKAGE_CONTENT_HASH => $decodedData[self::PACKAGE_DATA_HASH],
+ // Hash of private key
+ self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $decodedData[self::PACKAGE_DATA_PRIVATE_KEY_HASH]
);
// Is the checksum valid?