Skip to content
Snippets Groups Projects
Commit c6cd81ea authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Completed E2e implementation, E2eAdapter

parent fb2c6d34
No related branches found
No related tags found
No related merge requests found
Showing
with 166 additions and 52 deletions
package io.elixxir.dapp.bindings.data
import io.elixxir.dapp.bindings.model.*
import io.elixxir.dapp.bindings.model.E2eParams
import io.elixxir.dapp.bindings.model.ReceptionIdentity
import io.elixxir.dapp.user.model.UserId
internal interface E2e {
val payloadSize: Long
fun getReceptionId(): ReceptionIdentity
fun getContact()
fun getContact(): Contact
fun callAllReceivedRequests()
fun confirmRequest()
fun confirmRequest(userId: UserId)
fun deleteAllRequests()
fun deleteRequest()
fun deleteSendRequests()
fun getAllPartnerIds()
fun hasAuthenticatedChannel()
fun registerListener()
fun reset()
fun sendRequest()
fun verifyOwnership()
fun sendE2e()
fun deleteRequest(request: Request)
fun deleteSentRequests()
fun getAllPartnerIds(): PartnersList
fun hasAuthenticatedChannel(contact: Contact): Boolean
fun registerListener(
senderId: UserId,
messageType: MessageType,
e2eListener: E2eListener
)
fun reset(contact: Contact): RoundId
fun sendRequest(
contact: Contact,
myFactsList: FactsList
): RoundId
fun verifyOwnership(
receivedUserId: UserId,
verifiedContact: Contact,
e2eHandler: E2eHandler
): Boolean
fun sendE2e(
messageType: MessageType,
receiverId: UserId,
payload: Payload,
params: E2eParams
): SendReport
}
package io.elixxir.dapp.bindings.data
import bindings.E2e as CoreE2e
import io.elixxir.dapp.bindings.model.*
import io.elixxir.dapp.bindings.model.E2eParams
import io.elixxir.dapp.bindings.model.ReceptionIdentity
import bindings.E2e as CoreE2e
import io.elixxir.dapp.user.model.UserId
@JvmInline
internal value class E2eAdapter(private val e2e: CoreE2e) : E2e {
override val payloadSize: Long
get() = e2e.payloadSize()
fun confirm(userId: ByteArray) {
e2e.confirm(userId)
}
override fun deleteAllRequests() {
e2e.deleteAllRequests()
}
override fun deleteRequest() {
TODO("Not yet implemented")
override fun getReceptionId(): ReceptionIdentity {
return ReceptionIdentity(e2e.receptionID)
}
override fun deleteSendRequests() {
TODO("Not yet implemented")
override fun getContact(): Contact {
return Contact(e2e.contact)
}
override fun getAllPartnerIds() {
TODO("Not yet implemented")
override fun callAllReceivedRequests() {
e2e.callAllReceivedRequests()
}
override fun hasAuthenticatedChannel() {
TODO("Not yet implemented")
override fun confirmRequest(userId: UserId) {
e2e.confirm(userId.value)
}
override fun registerListener() {
TODO("Not yet implemented")
override fun deleteAllRequests() {
e2e.deleteAllRequests()
}
override fun reset() {
TODO("Not yet implemented")
override fun deleteRequest(request: Request) {
e2e.deleteRequest(request.value)
}
override fun sendRequest() {
TODO("Not yet implemented")
override fun deleteSentRequests() {
e2e.deleteSentRequests()
}
override fun verifyOwnership() {
TODO("Not yet implemented")
override fun getAllPartnerIds(): PartnersList {
return PartnersList(e2e.allPartnerIDs)
}
override fun sendE2e() {
TODO("Not yet implemented")
override fun hasAuthenticatedChannel(contact: Contact): Boolean {
return e2e.hasAuthenticatedChannel(contact.value)
}
fun deleteReceivedRequests() {
e2e.deleteReceiveRequests()
override fun registerListener(
senderId: UserId,
messageType: MessageType,
e2eListener: E2eListener
) {
e2e.registerListener(
senderId.value,
messageType.code,
e2eListener
)
}
override val payloadSize: Long
get() = TODO("Not yet implemented")
override fun getReceptionId(): ReceptionIdentity {
return ReceptionIdentity(e2e.receptionID)
override fun reset(contact: Contact): RoundId {
return RoundId(
e2e.reset(contact.value)
)
}
override fun getContact() {
TODO("Not yet implemented")
override fun sendRequest(
contact: Contact,
myFactsList: FactsList
): RoundId {
return RoundId(
e2e.request(contact.value, myFactsList.value)
)
}
override fun callAllReceivedRequests() {
TODO("Not yet implemented")
override fun verifyOwnership(
receivedUserId: UserId,
verifiedContact: Contact,
e2eHandler: E2eHandler
): Boolean {
return e2e.verifyOwnership(
receivedUserId.value,
verifiedContact.value,
e2eHandler.value
)
}
override fun confirmRequest() {
TODO("Not yet implemented")
override fun sendE2e(
messageType: MessageType,
receiverId: UserId,
payload: Payload,
params: E2eParams
): SendReport {
return SendReport(
e2e.sendE2E(
messageType.code,
receiverId.value,
payload.value,
params.value
)
)
}
}
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class Contact(val value: ByteArray)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class E2eHandler(val value: Long)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
import bindings.Listener
internal interface E2eListener : Listener
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class FactsList(val value: ByteArray)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
internal enum class MessageType(val code: Long) {
NoType(0),
XxMessage(2),
KeyExchangeTrigger(30),
KeyExchangeConfirm(31),
KeyExchangeTriggerEphemeral(32),
KeyExchangeConfirmEphemeral(33),
E2eClose(34),
GroupCreationRequest(40),
NewFileTransfer(50),
EndFileTransfer(51),
ConnectionAuthenticationRequest(60);
companion object {
fun from(code: Long): MessageType {
return values().firstOrNull {
it.code == code
} ?: throw(IllegalArgumentException("Invalid code"))
}
}
}
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class PartnersList(val value: ByteArray)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class Payload(val value: ByteArray)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class Request(val value: ByteArray)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
value class RoundId(val value: Long)
\ No newline at end of file
package io.elixxir.dapp.bindings.model
@JvmInline
internal value class SendReport(val value: ByteArray)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment