Renamed InputStreams from in and is to input, so it doesn't look strange in kotlin
				
					
				
			This commit is contained in:
		@@ -81,16 +81,16 @@ class CryptoCustomMessage<T : Streamable> : CustomMessage {
 | 
			
		||||
 | 
			
		||||
    @Throws(DecryptionFailedException::class)
 | 
			
		||||
    fun decrypt(privateKey: ByteArray): T {
 | 
			
		||||
        val `in` = SignatureCheckingInputStream(container?.decrypt(privateKey) ?: throw IllegalStateException("no encrypted data available"))
 | 
			
		||||
        val input = SignatureCheckingInputStream(container?.decrypt(privateKey) ?: throw IllegalStateException("no encrypted data available"))
 | 
			
		||||
        if (dataReader == null) throw IllegalStateException("no data reader available")
 | 
			
		||||
 | 
			
		||||
        val addressVersion = varInt(`in`)
 | 
			
		||||
        val stream = varInt(`in`)
 | 
			
		||||
        val behaviorBitfield = int32(`in`)
 | 
			
		||||
        val publicSigningKey = bytes(`in`, 64)
 | 
			
		||||
        val publicEncryptionKey = bytes(`in`, 64)
 | 
			
		||||
        val nonceTrialsPerByte = if (addressVersion >= 3) varInt(`in`) else 0
 | 
			
		||||
        val extraBytes = if (addressVersion >= 3) varInt(`in`) else 0
 | 
			
		||||
        val addressVersion = varInt(input)
 | 
			
		||||
        val stream = varInt(input)
 | 
			
		||||
        val behaviorBitfield = int32(input)
 | 
			
		||||
        val publicSigningKey = bytes(input, 64)
 | 
			
		||||
        val publicEncryptionKey = bytes(input, 64)
 | 
			
		||||
        val nonceTrialsPerByte = if (addressVersion >= 3) varInt(input) else 0
 | 
			
		||||
        val extraBytes = if (addressVersion >= 3) varInt(input) else 0
 | 
			
		||||
 | 
			
		||||
        val sender = BitmessageAddress(Factory.createPubkey(
 | 
			
		||||
            addressVersion,
 | 
			
		||||
@@ -103,9 +103,9 @@ class CryptoCustomMessage<T : Streamable> : CustomMessage {
 | 
			
		||||
        ))
 | 
			
		||||
        this.sender = sender
 | 
			
		||||
 | 
			
		||||
        data = dataReader.read(sender, `in`)
 | 
			
		||||
        data = dataReader.read(sender, input)
 | 
			
		||||
 | 
			
		||||
        `in`.checkSignature(sender.pubkey!!)
 | 
			
		||||
        input.checkSignature(sender.pubkey!!)
 | 
			
		||||
 | 
			
		||||
        return data!!
 | 
			
		||||
    }
 | 
			
		||||
@@ -124,7 +124,7 @@ class CryptoCustomMessage<T : Streamable> : CustomMessage {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    interface Reader<out T> {
 | 
			
		||||
        fun read(sender: BitmessageAddress, `in`: InputStream): T
 | 
			
		||||
        fun read(sender: BitmessageAddress, input: InputStream): T
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private inner class SignatureCheckingInputStream internal constructor(private val wrapped: InputStream) : InputStream() {
 | 
			
		||||
 
 | 
			
		||||
@@ -56,8 +56,8 @@ data class ProofOfWorkRequest @JvmOverloads constructor(val sender: BitmessageAd
 | 
			
		||||
 | 
			
		||||
    class Reader(private val identity: BitmessageAddress) : CryptoCustomMessage.Reader<ProofOfWorkRequest> {
 | 
			
		||||
 | 
			
		||||
        override fun read(sender: BitmessageAddress, `in`: InputStream): ProofOfWorkRequest {
 | 
			
		||||
            return ProofOfWorkRequest.read(identity, `in`)
 | 
			
		||||
        override fun read(sender: BitmessageAddress, input: InputStream): ProofOfWorkRequest {
 | 
			
		||||
            return ProofOfWorkRequest.read(identity, input)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -87,12 +87,12 @@ data class ProofOfWorkRequest @JvmOverloads constructor(val sender: BitmessageAd
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        @JvmStatic
 | 
			
		||||
        fun read(client: BitmessageAddress, `in`: InputStream): ProofOfWorkRequest {
 | 
			
		||||
        fun read(client: BitmessageAddress, input: InputStream): ProofOfWorkRequest {
 | 
			
		||||
            return ProofOfWorkRequest(
 | 
			
		||||
                client,
 | 
			
		||||
                bytes(`in`, 64),
 | 
			
		||||
                Request.valueOf(varString(`in`)),
 | 
			
		||||
                varBytes(`in`)
 | 
			
		||||
                bytes(input, 64),
 | 
			
		||||
                Request.valueOf(varString(input)),
 | 
			
		||||
                varBytes(input)
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -44,14 +44,13 @@ class CryptoCustomMessageTest : TestBase() {
 | 
			
		||||
 | 
			
		||||
        val out = ByteArrayOutputStream()
 | 
			
		||||
        messageBefore.writer().write(out)
 | 
			
		||||
        val `in` = ByteArrayInputStream(out.toByteArray())
 | 
			
		||||
        val input = ByteArrayInputStream(out.toByteArray())
 | 
			
		||||
 | 
			
		||||
        val customMessage = CustomMessage.read(`in`, out.size())
 | 
			
		||||
        val customMessage = CustomMessage.read(input, out.size())
 | 
			
		||||
        val messageAfter = CryptoCustomMessage.read(customMessage,
 | 
			
		||||
                object : CryptoCustomMessage.Reader<GenericPayload> {
 | 
			
		||||
                    override fun read(sender: BitmessageAddress, `in`: InputStream): GenericPayload {
 | 
			
		||||
                        return GenericPayload.read(0, 1, `in`, 100)
 | 
			
		||||
                    }
 | 
			
		||||
                    override fun read(sender: BitmessageAddress, input: InputStream) =
 | 
			
		||||
                        GenericPayload.read(0, 1, input, 100)
 | 
			
		||||
                })
 | 
			
		||||
        val payloadAfter = messageAfter.decrypt(sendingIdentity.publicDecryptionKey)
 | 
			
		||||
 | 
			
		||||
@@ -72,9 +71,9 @@ class CryptoCustomMessageTest : TestBase() {
 | 
			
		||||
 | 
			
		||||
        val out = ByteArrayOutputStream()
 | 
			
		||||
        messageBefore.writer().write(out)
 | 
			
		||||
        val `in` = ByteArrayInputStream(out.toByteArray())
 | 
			
		||||
        val input = ByteArrayInputStream(out.toByteArray())
 | 
			
		||||
 | 
			
		||||
        val customMessage = CustomMessage.read(`in`, out.size())
 | 
			
		||||
        val customMessage = CustomMessage.read(input, out.size())
 | 
			
		||||
        val messageAfter = CryptoCustomMessage.read(customMessage,
 | 
			
		||||
                ProofOfWorkRequest.Reader(sendingIdentity))
 | 
			
		||||
        val requestAfter = messageAfter.decrypt(sendingIdentity.publicDecryptionKey)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user