feat: remove outdated experiment
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
016fb34ee5
commit
b9d89c017a
|
|
@ -1,41 +0,0 @@
|
|||
package chat.revolt.internals
|
||||
|
||||
import java.security.MessageDigest
|
||||
|
||||
class CryptographicAgeVerification {
|
||||
fun getProofHash(
|
||||
seed: String,
|
||||
userAge: Int,
|
||||
minAllowedAge: Int
|
||||
): Pair<ByteArray, ByteArray> {
|
||||
var proof = MessageDigest.getInstance("SHA-256").digest(seed.toByteArray())
|
||||
|
||||
for (i in 1 until userAge - minAllowedAge) {
|
||||
proof = MessageDigest.getInstance("SHA-256").digest(proof)
|
||||
}
|
||||
|
||||
var ageHash =
|
||||
MessageDigest.getInstance("SHA-256").digest(seed.toByteArray())
|
||||
|
||||
for (i in 1 until userAge - 1) {
|
||||
ageHash = MessageDigest.getInstance("SHA-256").digest(ageHash)
|
||||
}
|
||||
|
||||
return ageHash to proof
|
||||
}
|
||||
|
||||
fun proveAge(
|
||||
minAllowedAge: Int,
|
||||
proofHash: ByteArray,
|
||||
ageHash: ByteArray,
|
||||
): Boolean {
|
||||
var verifyHash =
|
||||
MessageDigest.getInstance("SHA-256").digest(proofHash.toString().toByteArray())
|
||||
|
||||
for (i in 1 until minAllowedAge - 1) {
|
||||
verifyHash = MessageDigest.getInstance("SHA-256").digest(verifyHash)
|
||||
}
|
||||
|
||||
return verifyHash.contentEquals(ageHash)
|
||||
}
|
||||
}
|
||||
|
|
@ -157,15 +157,6 @@ fun LabsHomeScreen(navController: NavController) {
|
|||
Column(
|
||||
modifier = Modifier.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Text("Cryptographic Age Verification")
|
||||
},
|
||||
modifier = Modifier.clickable {
|
||||
navController.navigate("sandboxes/cryptoageverif")
|
||||
}
|
||||
)
|
||||
HorizontalDivider()
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Text("Settings DSL")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import androidx.navigation.compose.rememberNavController
|
|||
import chat.revolt.api.settings.FeatureFlags
|
||||
import chat.revolt.screens.labs.ui.mockups.CallScreenMockup
|
||||
import chat.revolt.screens.labs.ui.mockups.NewLoginExperienceMockup
|
||||
import chat.revolt.screens.labs.ui.sandbox.CryptographicAgeVerificationSandbox
|
||||
import chat.revolt.screens.labs.ui.sandbox.JBMSandbox
|
||||
import chat.revolt.screens.labs.ui.sandbox.SettingsDslSandbox
|
||||
|
||||
|
|
@ -70,9 +69,6 @@ fun LabsRootScreen(topNav: NavController) {
|
|||
NewLoginExperienceMockup(labsNav)
|
||||
}
|
||||
|
||||
composable("sandboxes/cryptoageverif") {
|
||||
CryptographicAgeVerificationSandbox(labsNav)
|
||||
}
|
||||
composable("sandboxes/settingsdsl") {
|
||||
SettingsDslSandbox(labsNav)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
package chat.revolt.screens.labs.ui.sandbox
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.navigation.NavController
|
||||
import chat.revolt.api.REVOLT_KJBOOK
|
||||
import chat.revolt.internals.CryptographicAgeVerification
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CryptographicAgeVerificationSandbox(navController: NavController) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
"Crypto Age Verify Sandbox",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(Icons.AutoMirrored.Default.ArrowBack, "Back")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) { pv ->
|
||||
Column(
|
||||
Modifier
|
||||
.padding(pv)
|
||||
.fillMaxSize()
|
||||
) {
|
||||
Button(onClick = {
|
||||
val cav = CryptographicAgeVerification()
|
||||
val (ageHash, verifyHash) = cav.getProofHash(
|
||||
seed = REVOLT_KJBOOK,
|
||||
userAge = 21,
|
||||
minAllowedAge = 18
|
||||
)
|
||||
|
||||
Log.d(
|
||||
"CryptographicAgeVerificationSandbox",
|
||||
"ageHash: ${ageHash.contentToString()}"
|
||||
)
|
||||
Log.d(
|
||||
"CryptographicAgeVerificationSandbox",
|
||||
"verifyHash: ${verifyHash.contentToString()}"
|
||||
)
|
||||
|
||||
val verification = cav.proveAge(
|
||||
minAllowedAge = 18,
|
||||
proofHash = verifyHash,
|
||||
ageHash = ageHash
|
||||
)
|
||||
|
||||
Log.d("CryptographicAgeVerificationSandbox", "Verification result: $verification")
|
||||
}) {
|
||||
Text("Run Cryptographic Age Verification")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue